From: apo Date: Mon, 4 Dec 2006 08:56:41 +0000 (+0000) Subject: To implement more accurate memory size calculation X-Git-Tag: WP1_2_3_05-12-2006_cache_system~6 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=979fca65627bd13fe752a2b04ce13fff48ea3ace;p=modules%2Fvisu.git To implement more accurate memory size calculation --- diff --git a/src/CONVERTOR/VISU_Convertor_impl.cxx b/src/CONVERTOR/VISU_Convertor_impl.cxx index ac3462d5..c889ff2d 100644 --- a/src/CONVERTOR/VISU_Convertor_impl.cxx +++ b/src/CONVERTOR/VISU_Convertor_impl.cxx @@ -315,6 +315,17 @@ namespace VISU return ""; } + unsigned long int + TNamedPointCoords + ::GetMemorySize() + { + size_t aSize = TPointCoords::GetMemorySize(); + aSize += myObj2VTKID.size() * sizeof(vtkIdType) * 2; + aSize += myVectorID.size() * sizeof(vtkIdType); + return aSize; + } + + //--------------------------------------------------------------- TMeshImpl::TMeshImpl(): myPoints(vtkPoints::New()), @@ -2865,7 +2876,7 @@ VISU_Convertor_impl }else aSize += GetTimeStampSize(theMeshName, theEntity, theFieldName, theStampsNum); - cout<<"VISU_Convertor_impl::GetTimeStampOnMeshSize - "<myIsVTKDone)<myIsVTKDone)<myIsVTKDone)<myIsVTKDone)< TPointsDim; TPointsDim myPointsDim; //!< Keeps name of each dimension - TVectorID myVectorID; //!< Keeps object¶ numeration + TVectorID myVectorID; //!< Keeps objects numeration TObj2VTKID myObj2VTKID; //!< Keeps mapping from object number to VTK one public: @@ -285,6 +285,11 @@ namespace VISU virtual std::string GetNodeName(vtkIdType theObjID) const; + + //! Gets memory size used by the instance (bytes). + virtual + unsigned long int + GetMemorySize(); }; typedef SharedPtr PNamedPointCoords; diff --git a/src/CONVERTOR/VISU_MedConvertor.cxx b/src/CONVERTOR/VISU_MedConvertor.cxx index 77c4351b..f8fa135e 100644 --- a/src/CONVERTOR/VISU_MedConvertor.cxx +++ b/src/CONVERTOR/VISU_MedConvertor.cxx @@ -1001,14 +1001,16 @@ namespace TMEDNamedPointCoords ::Init(vtkIdType theNbPoints, vtkIdType theDim, - const MED::PNodeInfo& theNodeInfo) + const MED::PNodeInfo& theNodeInfo, + MED::EVersion theVersion) { + myVersion = theVersion; if(theNodeInfo->IsElemNum()) TNamedPointCoords::Init(theNbPoints,theDim,theNodeInfo->myElemNum); else TNamedPointCoords::Init(theNbPoints,theDim); if(theNodeInfo->IsElemNames()) - myNodeInfo = theNodeInfo; + myElemNames = theNodeInfo->myElemNames; } void @@ -1020,15 +1022,32 @@ namespace TNamedPointCoords::Init(theNbPoints,theDim); } + MED::TInt + GetPNOMLength(MED::EVersion theVersion) + { + if(theVersion == MED::eV2_1) + return MED::GetPNOMLength(); + return MED::GetPNOMLength(); + } + std::string TMEDNamedPointCoords ::GetNodeName(vtkIdType theObjID) const { - if(myNodeInfo) - return myNodeInfo->GetElemName(theObjID); + if(!myElemNames.empty()) + return GetString(theObjID, GetPNOMLength(myVersion), myElemNames); return TNamedPointCoords::GetNodeName(theObjID); } + unsigned long int + TMEDNamedPointCoords + ::GetMemorySize() + { + size_t aSize = TNamedPointCoords::GetMemorySize(); + aSize += myElemNames.size() * sizeof(char); + return aSize; + } + //--------------------------------------------------------------- vtkIdType @@ -1080,7 +1099,8 @@ namespace //--------------------------------------------------------------- void TMEDSubMesh - ::Init(const MED::PElemInfo& theElemInfo) + ::Init(const MED::PElemInfo& theElemInfo, + MED::EVersion theVersion) { myIsElemNum = theElemInfo->IsElemNum(); @@ -1088,7 +1108,7 @@ namespace myElemNum = theElemInfo->myElemNum; if(theElemInfo->IsElemNames()) - myElemInfo = theElemInfo; + myElemNames = theElemInfo->myElemNames; } @@ -1114,11 +1134,21 @@ namespace TMEDSubMesh ::GetElemName(vtkIdType theObjID) const { - if(myElemInfo) - return myElemInfo->GetElemName(theObjID); + if(!myElemNames.empty()) + return GetString(theObjID, GetPNOMLength(myVersion), myElemNames); return TSubMeshImpl::GetElemName(theObjID); } + unsigned long int + TMEDSubMesh + ::GetMemorySize() + { + size_t aSize = TSubMeshImpl::GetMemorySize(); + aSize += myElemNum.size() * sizeof(MED::TInt); + aSize += myElemNames.size() * sizeof(char); + return aSize; + } + struct TSetIsDone { bool& myIsDone; @@ -1766,7 +1796,7 @@ VISU_MedConvertor PMEDNamedPointCoords aNamedPointCoords = theMesh->myNamedPointCoords; TMEDNamedPointCoords& aCoords = aNamedPointCoords; - aCoords.Init(aNbElem,aDim,aNodeInfo); + aCoords.Init(aNbElem,aDim,aNodeInfo,theMed->GetVersion()); for(int iDim = 0; iDim < aDim; iDim++) aCoords.GetName(iDim) = aNodeInfo->GetCoordName(iDim); @@ -1781,7 +1811,7 @@ VISU_MedConvertor TGeom2SubMesh& aGeom2SubMesh = aMeshOnEntity->myGeom2SubMesh; PMEDSubMesh aSubMesh = aGeom2SubMesh[VISU::ePOINT1](new TMEDSubMesh()); - aSubMesh->Init(MED::PElemInfo(aNodeInfo)); + aSubMesh->Init(MED::PElemInfo(aNodeInfo),theMed->GetVersion()); aSubMesh->myNbCells = theMesh->myNbPoints; aSubMesh->myCellsSize = 2*theMesh->myNbPoints; @@ -2037,7 +2067,7 @@ VISU_MedConvertor if(aNbElem > 0){ PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new TMEDSubMesh()); - aSubMesh->Init(MED::PElemInfo(aPolygoneInfo)); + aSubMesh->Init(MED::PElemInfo(aPolygoneInfo),theMed->GetVersion()); aSubMesh->myNbCells = aNbElem; TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect; @@ -2062,7 +2092,7 @@ VISU_MedConvertor if(aNbElem > 0){ PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new TMEDSubMesh()); - aSubMesh->Init((MED::PElemInfo)aPolyedreInfo); + aSubMesh->Init(MED::PElemInfo(aPolyedreInfo),theMed->GetVersion()); aSubMesh->myNbCells = aNbElem; TCell2Connect& aCell2Connect = aSubMesh->myCell2Connect; @@ -2105,7 +2135,7 @@ VISU_MedConvertor if(aNbElem > 0){ PMEDSubMesh aSubMesh = aGeom2SubMesh[aEGeom](new TMEDSubMesh()); - aSubMesh->Init((MED::PElemInfo)aCellInfo); + aSubMesh->Init(MED::PElemInfo(aCellInfo), theMed->GetVersion()); aSubMesh->myNbCells = aNbElem; aSubMesh->myCellsSize = aNbElem*(aVNbNodes+1); diff --git a/src/CONVERTOR/VISU_MedConvertor.hxx b/src/CONVERTOR/VISU_MedConvertor.hxx index c467f0c1..15e31e9c 100644 --- a/src/CONVERTOR/VISU_MedConvertor.hxx +++ b/src/CONVERTOR/VISU_MedConvertor.hxx @@ -29,18 +29,17 @@ namespace VISU { - typedef TVector TNames; - //--------------------------------------------------------------- class TMEDNamedPointCoords: public virtual TNamedPointCoords { - MED::PNodeInfo myNodeInfo; - TNames myPointNames; + MED::EVersion myVersion; + MED::TString myElemNames; public: void Init(vtkIdType theNbPoints, vtkIdType theDim, - const MED::PNodeInfo& theNodeInfo); + const MED::PNodeInfo& theNodeInfo, + MED::EVersion theVersion); void Init(vtkIdType theNbPoints, @@ -50,6 +49,11 @@ namespace VISU virtual std::string GetNodeName(vtkIdType theObjID) const; + + //! Gets memory size used by the instance (bytes). + virtual + unsigned long int + GetMemorySize(); }; typedef SharedPtr PMEDNamedPointCoords; @@ -135,10 +139,13 @@ namespace VISU MED::EBooleen myIsElemNum; MED::TElemNum myElemNum; - MED::PElemInfo myElemInfo; + + MED::EVersion myVersion; + MED::TString myElemNames; void - Init(const MED::PElemInfo& theElemInfo); + Init(const MED::PElemInfo& theElemInfo, + MED::EVersion theVersion); void Init(const MED::PGrilleInfo& theGrilleInfo); @@ -150,6 +157,11 @@ namespace VISU virtual std::string GetElemName(vtkIdType theObjID) const; + + //! Gets memory size used by the instance (bytes). + virtual + unsigned long int + GetMemorySize(); }; typedef SharedPtr PMEDSubMesh; diff --git a/src/VISU_I/VISU_GaussPoints_i.cc b/src/VISU_I/VISU_GaussPoints_i.cc index 2341f209..d5e7cec9 100644 --- a/src/VISU_I/VISU_GaussPoints_i.cc +++ b/src/VISU_I/VISU_GaussPoints_i.cc @@ -61,28 +61,28 @@ VISU::GaussPoints_i CORBA::Long theTimeStampNumber, bool theIsMemoryCheck) { + size_t aResult = 0; + if(theEntity == VISU::NODE) + return aResult; try{ - if(theEntity == VISU::NODE) - return 0; - size_t aResult = VISU::ScalarMap_i::IsPossible(theResult,theMeshName,theEntity,theFieldName,theTimeStampNumber,false); - if(theIsMemoryCheck && aResult){ - VISU::Result_i::TInput* anInput = theResult->GetInput(); - size_t aSize = anInput->GetTimeStampOnGaussPtsSize(theMeshName, - (VISU::TEntity)theEntity, - theFieldName, - theTimeStampNumber); + VISU::Result_i::TInput* anInput = theResult->GetInput(); + size_t aSize = anInput->GetTimeStampOnGaussPtsSize(theMeshName, + (VISU::TEntity)theEntity, + theFieldName, + theTimeStampNumber); + aResult = 1; + if(theIsMemoryCheck){ aSize *= INCMEMORY; aResult = VISU_PipeLine::CheckAvailableMemory(aSize); if(MYDEBUG) MESSAGE("GaussPoints_i::IsPossible - CheckAvailableMemory = "<