#include "MED_GaussUtils.hxx"
#include "MED_Utilities.hxx"
+#include <boost/thread/thread.hpp>
+
#include <vtkCellType.h>
using namespace std;
#ifdef _DEBUG_
static int MYDEBUG = 0;
static int MYVALUEDEBUG = 0;
+static int MYTHREADDEBUG = 1;
static int MY_FAMILY_DEBUG = 0;
static int MY_GROUP_DEBUG = 0;
//#define _DEXCEPT_
#else
static int MYDEBUG = 0;
static int MYVALUEDEBUG = 0;
+static int MYTHREADDEBUG = 0;
static int MY_FAMILY_DEBUG = 0;
static int MY_GROUP_DEBUG = 0;
#endif
BuildMeshOnEntityMap(PMEDMesh theMesh,
TFamilyCounterMap& theFamilyID2CellsSize,
const MED::TEntityInfo& theEntityInfo,
- MED::PNodeInfo theNodeInfo,
- MED::PWrapper theMEDWrapper)
+ const MED::PNodeInfo& theNodeInfo,
+ const MED::PWrapper& theMEDWrapper)
{
INITMSG(MYDEBUG,"BuildMeshOnEntityMap"<<endl);
MED::PMeshInfo aMeshInfo = theMesh->myMeshInfo;
//---------------------------------------------------------------
+ struct TFieldMinMax;
+
void
- CalculateMinMax(MED::PTimeStampVal theTimeStampVal,
- PMEDField theField,
- PMEDValForTime theValForTime)
+ GetMinMax(TFieldMinMax* theFieldMinMax,
+ PMEDField theField,
+ const MED::PFieldInfo& theFieldInfo,
+ TInt theNbTimeStamps,
+ MED::EEntiteMaillage theMEntity,
+ const MED::TGeom2Size& theGeom2Size,
+ const MED::TMKey2Profile& theMKey2Profile,
+ const MED::TKey2Gauss& theKey2Gauss,
+ const MED::PWrapper& theMEDWrapper,
+ VISU_MedConvertor::TMutex& theMutex)
{
+ //boost::mutex::scoped_lock aLock(theMutex);
+ INITMSG(MYTHREADDEBUG,"GetMinMax: - "<<theFieldMinMax<<
+ "; aFieldName = '"<<theField->myName<<"'"<<
+ "; theNbTimeStamps = "<<theNbTimeStamps<<
+ endl);
+
TInt aNbComp = theField->myNbComp;
+ TValField& aValField = theField->myValField;
TMinMaxArr& aMinMaxArr = theField->myMinMaxArr;
- const MED::TTimeStampVal& aTimeStampValRef = theTimeStampVal;
+ for(TInt iTimeStamp = 1; iTimeStamp <= theNbTimeStamps; iTimeStamp++){
+ INITMSG(MYTHREADDEBUG,"- "<<theFieldMinMax<<"; iTimeStamp = "<<iTimeStamp<<endl);
- PMEDProfile aProfile = theValForTime->myProfile;
- TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
- TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin();
- for(; anIter != aGeom2SubProfile.end(); anIter++){
- vtkIdType aVGeom = anIter->first;
- PMEDSubProfile aSubProfile(anIter->second);
-
- TInt aNbElem = aSubProfile->myNbCells;
- TInt aNbGauss = theValForTime->GetNbGauss(aVGeom);
+ MED::PTimeStampInfo aTimeStampInfo = theMEDWrapper->GetPTimeStampInfo(theFieldInfo,
+ theMEntity,
+ theGeom2Size,
+ iTimeStamp);
+ MED::PTimeStampVal aTimeStampVal = theMEDWrapper->GetPTimeStampVal(aTimeStampInfo,
+ theMKey2Profile,
+ theKey2Gauss);
+ PMEDValForTime aValForTime = aValField[iTimeStamp];
+
+ const MED::TTimeStampVal& aTimeStampValRef = aTimeStampVal;
+
+ PMEDProfile aProfile = aValForTime->myProfile;
+ TGeom2SubProfile& aGeom2SubProfile = aProfile->myGeom2SubProfile;
+ TGeom2SubProfile::const_iterator anIter = aGeom2SubProfile.begin();
+ for(; anIter != aGeom2SubProfile.end(); anIter++){
+ vtkIdType aVGeom = anIter->first;
+ PMEDSubProfile aSubProfile(anIter->second);
- if(aSubProfile->myStatus != eRemoveAll){
- INITMSG(MYDEBUG,
- "- aVGeom = "<<aVGeom<<
- "; aNbElem = "<<aNbElem<<
- "; aNbGauss = "<<aNbGauss<<
- endl);
+ TInt aNbElem = aSubProfile->myNbCells;
+ TInt aNbGauss = aValForTime->GetNbGauss(aVGeom);
- MED::EGeometrieElement aMGeom = aSubProfile->myMGeom;
- const MED::TMeshValue& aMMeshValue = aTimeStampValRef.GetMeshValue(aMGeom);
- for(TInt iElem = 0; iElem < aNbElem; iElem++){
- MED::TCValueSliceArr aMValueSliceArr = aMMeshValue.GetCompValueSliceArr(iElem);
- ADDMSG(MYVALUEDEBUG,"{");
- for(TInt iComp = 0; iComp < aNbComp; iComp++){
- const MED::TCValueSlice& aMValueSlice = aMValueSliceArr[iComp];
- TMinMax& aMinMax = aMinMaxArr[iComp];
- float& aMin = aMinMax.first;
- float& aMax = aMinMax.second;
- for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
- const float& aVal = aMValueSlice[iGauss];
- ADDMSG(MYVALUEDEBUG,aVal<<" ");
- aMin = min(aMin,aVal);
- aMax = max(aMax,aVal);
+ if(aSubProfile->myStatus != eRemoveAll){
+ INITMSG(MYTHREADDEBUG,
+ "- "<<theFieldMinMax<<
+ "; aVGeom = "<<aVGeom<<
+ "; aNbElem = "<<aNbElem<<
+ "; aNbGauss = "<<aNbGauss<<
+ endl);
+
+ MED::EGeometrieElement aMGeom = aSubProfile->myMGeom;
+ const MED::TMeshValue& aMMeshValue = aTimeStampValRef.GetMeshValue(aMGeom);
+ for(TInt iElem = 0; iElem < aNbElem; iElem++){
+ MED::TCValueSliceArr aMValueSliceArr = aMMeshValue.GetCompValueSliceArr(iElem);
+ ADDMSG(MYVALUEDEBUG,"{");
+ for(TInt iComp = 0; iComp < aNbComp; iComp++){
+ const MED::TCValueSlice& aMValueSlice = aMValueSliceArr[iComp];
+ TMinMax& aMinMax = aMinMaxArr[iComp];
+ float& aMin = aMinMax.first;
+ float& aMax = aMinMax.second;
+ for(TInt iGauss = 0; iGauss < aNbGauss; iGauss++){
+ const float& aVal = aMValueSlice[iGauss];
+ ADDMSG(MYVALUEDEBUG,aVal<<" ");
+ aMin = min(aMin,aVal);
+ aMax = max(aMax,aVal);
+ }
+ ADDMSG(MYVALUEDEBUG,"| ");
}
- ADDMSG(MYVALUEDEBUG,"| ");
+ ADDMSG(MYVALUEDEBUG,"} ");
}
- ADDMSG(MYVALUEDEBUG,"} ");
+ ADDMSG(MYVALUEDEBUG,"\n");
}
- ADDMSG(MYDEBUG,"\n");
}
}
+ for(TInt iComp = 0; iComp < aNbComp; iComp++){
+ VISU::TMinMax aMinMax = theField->GetMinMax(iComp);
+ INITMSG(MYTHREADDEBUG,"- "<<theFieldMinMax<<"; "<<iComp<<": "<<aMinMax.first<<"; "<<aMinMax.second<<endl);
+ }
+ }
+
+
+ //---------------------------------------------------------------
+ struct TFieldMinMax
+ {
+ PMEDField myField;
+ MED::PFieldInfo myFieldInfo;
+ TInt myNbTimeStamps;
+ MED::EEntiteMaillage myMEntity;
+ MED::TGeom2Size myGeom2Size;
+ MED::TMKey2Profile myMKey2Profile;
+ MED::TKey2Gauss myKey2Gauss;
+ MED::PWrapper myMEDWrapper;
+ VISU_MedConvertor::TMutex& myMutex;
+
+ TFieldMinMax(const PMEDField& theField,
+ const MED::PFieldInfo& theFieldInfo,
+ TInt theNbTimeStamps,
+ MED::EEntiteMaillage theMEntity,
+ const MED::TGeom2Size& theGeom2Size,
+ const MED::TMKey2Profile& theMKey2Profile,
+ const MED::TKey2Gauss& theKey2Gauss,
+ const MED::PWrapper& theMEDWrapper,
+ VISU_MedConvertor::TMutex& theMutex):
+ myField(theField),
+ myFieldInfo(theFieldInfo),
+ myNbTimeStamps(theNbTimeStamps),
+ myMEntity(theMEntity),
+ myGeom2Size(theGeom2Size),
+ myMKey2Profile(theMKey2Profile),
+ myKey2Gauss(theKey2Gauss),
+ myMEDWrapper(theMEDWrapper),
+ myMutex(theMutex)
+ {}
+
+ void
+ operator()()
+ {
+ GetMinMax(this,
+ myField,
+ myFieldInfo,
+ myNbTimeStamps,
+ myMEntity,
+ myGeom2Size,
+ myMKey2Profile,
+ myKey2Gauss,
+ myMEDWrapper,
+ myMutex);
+ }
+ };
+
+ //---------------------------------------------------------------
+ void
+ MinMaxCalculation(PMEDMesh theMesh,
+ const MED::TEntityInfo& theEntityInfo,
+ const MED::TMKey2Profile& theMKey2Profile,
+ const MED::TKey2Gauss& theKey2Gauss,
+ const MED::PWrapper& theMEDWrapper,
+ VISU_MedConvertor::TMutex& theMutex)
+ {
+ TInt aNbFields = theMEDWrapper->GetNbFields();
+ MED::PMeshInfo aMeshInfo = theMesh->myMeshInfo;
+ const std::string& aMeshName = theMesh->myName;
+ INITMSG(MYDEBUG,"MinMaxCalculation: aNbFields = "<<aNbFields<<"\n");
+ for(TInt iField = 1; iField <= aNbFields; iField++){
+ MED::PFieldInfo aFieldInfo = theMEDWrapper->GetPFieldInfo(aMeshInfo,iField);
+ TInt aNbComp = aFieldInfo->GetNbComp();
+ std::string aFieldName = aFieldInfo->GetName();
+
+ MED::TGeom2Size aGeom2Size;
+ MED::EEntiteMaillage aMEntity;
+ TInt aNbTimeStamps = theMEDWrapper->GetNbTimeStamps(aFieldInfo,
+ theEntityInfo,
+ aMEntity,
+ aGeom2Size);
+ if(aNbTimeStamps < 1)
+ continue;
+
+ TEntity aVEntity = MEDEntityToVTK(aMEntity);
+ PMEDMeshOnEntity aMeshOnEntity = theMesh->myMeshOnEntityMap[aVEntity];
+ TFieldMap& aFieldMap = aMeshOnEntity->myFieldMap;
+ PMEDField aField = aFieldMap[aFieldName];
+
+ TFieldMinMax* aFieldMinMax = new TFieldMinMax(aField,
+ aFieldInfo,
+ aNbTimeStamps,
+ aMEntity,
+ aGeom2Size,
+ theMKey2Profile,
+ theKey2Gauss,
+ theMEDWrapper,
+ theMutex);
+ new boost::thread(*aFieldMinMax);
+ }
}
aMeshOnEntity,
aGeom2Size,
aValForTime);
-
- CalculateMinMax(aTimeStampVal,
- aField,
- aValForTime);
}
}
}
aFamilyInfoSet);
#endif
+ MinMaxCalculation(aMesh,
+ aEntityInfo,
+ aMKey2Profile,
+ aKey2Gauss,
+ aMed,
+ myMutex);
+
#ifndef _DEXCEPT_
}catch(std::exception& exc){
MSG(MYDEBUG,"Follow exception was occured in:\n"<<exc.what());
aName = aGaussInfo->GetName();
if(!aSubMeshID.empty()){
const std::string& aProfileName = aSubProfile->myName;
- MED::PProfileInfo aProfileInfo = MED::GetProfileInfo(*theMed,
+ MED::PProfileInfo aProfileInfo = MED::GetProfileInfo(theMed,
aProfileName);
if(aProfileInfo){
const MED::TElemNum& anElemNum = aProfileInfo->myElemNum;
}else{
if(!aSubMeshID.empty()){
const std::string& aProfileName = aSubProfile->myName;
- MED::PProfileInfo aProfileInfo = MED::GetProfileInfo(*theMed,
+ MED::PProfileInfo aProfileInfo = MED::GetProfileInfo(theMed,
aProfileName);
if(aProfileInfo){
const MED::TElemNum& anElemNum = aProfileInfo->myElemNum;
aGeom2Size,
theValForTime->myId);
- MED::TKey2Gauss aKey2Gauss = GetKey2Gauss(*theMed);
- MED::TMKey2Profile aMKey2Profile = GetMKey2Profile(*theMed);
+ MED::TKey2Gauss aKey2Gauss = GetKey2Gauss(theMed);
+ MED::TMKey2Profile aMKey2Profile = GetMKey2Profile(theMed);
MED::PTimeStampVal aTimeStampVal =
theMed->GetPTimeStampVal(aTimeStampInfo,