]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
0022875: memory leaks and wrong joints
authoreap <eap@opencascade.com>
Wed, 27 May 2015 19:22:02 +0000 (22:22 +0300)
committereap <eap@opencascade.com>
Wed, 27 May 2015 19:22:02 +0000 (22:22 +0300)
src/MEDPartitioner/MEDPARTITIONER_MeshCollection.cxx
src/MEDPartitioner/MEDPARTITIONER_MeshCollection.hxx
src/MEDPartitioner/MEDPARTITIONER_MeshCollectionDriver.cxx
src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedAsciiDriver.cxx
src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedXmlDriver.cxx

index 1dd9950c29351b26b20dff1be68c2d81f7bb9c7c..7643a53f006a9916515ffdd0b4c02251150e0d5f 100644 (file)
@@ -1117,6 +1117,7 @@ void MEDPARTITIONER::MeshCollection::buildConnectZones( const NodeMapping& nodeM
               cz->setName( "Nodal Connect Zone defined by MEDPARTITIONER" );
               cz->setLocalDomainNumber  ( idomain );
               cz->setDistantDomainNumber( idomainNear );
+              czVec.push_back(cz);
             }
 
           cz->setNodeCorresp( &corresp[0], corresp.size()/2 );
@@ -1882,19 +1883,22 @@ MEDPARTITIONER::Topology* MEDPARTITIONER::MeshCollection::getTopology() const
   return _topology;
 }
 
-void MEDPARTITIONER::MeshCollection::setTopology(Topology* topo)
+void MEDPARTITIONER::MeshCollection::setTopology(Topology* topo, bool takeOwneship)
 {
   if (_topology!=0)
     {
       throw INTERP_KERNEL::Exception("topology is already set");
     }
   else
-    _topology = topo;
+    {
+      _topology = topo;
+      _owns_topology = takeOwneship;
+    }
 }
 
-/*! Method creating the cell graph in serial mode 
- * 
- * \param array returns the pointer to the structure that contains the graph 
+/*! Method creating the cell graph in serial mode
+ *
+ * \param array returns the pointer to the structure that contains the graph
  * \param edgeweight returns the pointer to the table that contains the edgeweights
  *        (only used if indivisible regions are required)
  */
index 8a04e0117444d0445547c16455037d01dc3955d0..a4eec9a4cfe99342ba8315900189d0be97fbbf58 100644 (file)
@@ -124,7 +124,7 @@ namespace MEDPARTITIONER
     ParaDomainSelector* getParaDomainSelector() const { return _domain_selector; }
     void setParaDomainSelector(ParaDomainSelector* pds) { _domain_selector = pds; }
     //setting a new topology
-    void setTopology(Topology* topology);
+    void setTopology(Topology* topology, bool takeOwneship);
 
     //getting/setting the name of the global mesh (as opposed 
     //to the name of a subdomain \a nn, which is name_nn) 
index 4eab9fc10fceee19eed57786c769b4552fb2765b..e23ed3ccb1b0643b6b5cc01b868316eaab5837bc 100644 (file)
@@ -82,7 +82,7 @@ int MeshCollectionDriver::readSeq(const char* filename, const char* meshname)
   (_collection->getCZ()).clear();
   
   ParallelTopology* aPT = new ParallelTopology((_collection->getMesh()));
-  _collection->setTopology(aPT);
+  _collection->setTopology(aPT, true);
   _collection->setName(meshname);
   _collection->setDomainNames(meshname);
   return 0;
@@ -106,7 +106,7 @@ void MeshCollectionDriver::readMEDFileData(const ParaMEDMEM::MEDFileData* fileda
     }
 
   ParallelTopology* aPT = new ParallelTopology(_collection->getMesh());
-  _collection->setTopology(aPT);
+  _collection->setTopology(aPT, true);
   if ( nbDomains > 0 )
     {
       _collection->setName( filedata->getMeshes()->getMeshAtPos(0)->getName() );
@@ -186,7 +186,7 @@ void MeshCollectionDriver::readSubdomain(int idomain)
   localInformation.push_back(str+"meshName="+meshname);
   MyGlobals::_General_Informations.push_back(SerializeFromVectorOfString(localInformation));
   std::vector<std::string> localFields=BrowseAllFieldsOnMesh(file, meshname, idomain);
-  if (localFields.size()>0) 
+  if (localFields.size()>0)
     MyGlobals::_Field_Descriptions.push_back(SerializeFromVectorOfString(localFields));
 }
 
@@ -274,7 +274,19 @@ ParaMEDMEM::MEDFileMesh* MeshCollectionDriver::getMesh(int idomain) const
       for ( size_t i = 0; i < _collection->getCZ().size(); ++i )
         {
           ConnectZone* cz = _collection->getCZ()[i];
-          if ( !cz ) continue;
+          if ( !cz ||
+               cz->getLocalDomainNumber() != idomain )
+            continue;
+          {
+            std::ostringstream oss;
+            oss << "joint_" << cz->getDistantDomainNumber();
+            cz->setName( oss.str() );
+          }
+          {
+            std::ostringstream oss;
+            oss << "connect_zone_" << i;
+            cz->setDescription( oss.str() );
+          }
 
           MEDCouplingAutoRefCountObjectPtr< MEDFileJoint>
             joint = MEDFileJoint::New( cz->getName(), finalMeshName,
@@ -289,7 +301,7 @@ ParaMEDMEM::MEDFileMesh* MeshCollectionDriver::getMesh(int idomain) const
           if ( nodeCorr )
             {
               MEDCouplingAutoRefCountObjectPtr< MEDFileJointCorrespondence >
-                corr      = MEDFileJointCorrespondence::New( nodeCorr->getValueArray() );
+                corr = MEDFileJointCorrespondence::New( nodeCorr->getValueArray() );
               j1st->pushCorrespondence( corr );
             }
 
@@ -299,7 +311,7 @@ ParaMEDMEM::MEDFileMesh* MeshCollectionDriver::getMesh(int idomain) const
             {
               const MEDCouplingSkyLineArray * cellCorr =
                 cz->getEntityCorresp( types[it].first, types[it].second );
-              if ( cellCorr )
+              if ( cellCorr && cellCorr->getNumberOf() > 0 )
                 {
                   t1 = INTERP_KERNEL::NormalizedCellType( types[it].first );
                   t2 = INTERP_KERNEL::NormalizedCellType( types[it].second );
index 12a42615cf961851bd9f1313ab96068061126c54..ffccdb036cf26cd9ec030575cdaa45bd89d6b355 100644 (file)
@@ -72,9 +72,9 @@ int MeshCollectionMedAsciiDriver::read(ParaMEDMEM::MEDFileData* filedata)
     if ( (_collection->getMesh())[idomain] && (_collection->getMesh())[idomain]->getNumberOfNodes() > 0 )
       _collection->setNonEmptyMesh(idomain);
     }
-  ParallelTopology* aPT = new ParallelTopology((_collection->getMesh()), cz, cellglobal, nodeglobal, faceglobal);
-  _collection->setTopology(aPT);
   //creation of topology from mesh and connect zones
+  ParallelTopology* aPT = new ParallelTopology((_collection->getMesh()), cz, cellglobal, nodeglobal, faceglobal);
+  _collection->setTopology(aPT,true);
 
   return 0;
 }
@@ -150,7 +150,7 @@ int MeshCollectionMedAsciiDriver::read(const char* filename, ParaDomainSelector*
 
   //creation of topology from mesh and connect zones
   ParallelTopology* aPT = new ParallelTopology((_collection->getMesh()), (_collection->getCZ()), cellglobal, nodeglobal, faceglobal);
-  _collection->setTopology(aPT);
+  _collection->setTopology(aPT, true);
 
   for (int i=0; i<nbdomain; i++)
     {
index 50ba9428a46790c526c4425ff134b794a6872b0a..0fcb460be454ee8567135e42bd0ebdb07676a1b5 100644 (file)
@@ -169,7 +169,7 @@ int MeshCollectionMedXmlDriver::read(const char* filename, ParaDomainSelector* d
       //to know nb of cells on each proc to compute global cell ids from locally global
       domainSelector->gatherNbOf(_collection->getMesh());
     }
-  _collection->setTopology(aPT);
+  _collection->setTopology(aPT, true);
   _collection->setDomainNames(_collection->getName());
   return 0;
 }