]> SALOME platform Git repositories - modules/med.git/commitdiff
Salome HOME
Correction of bug of double pickelization of MEDFileUMesh instances.
authorAnthony Geay <anthony.geay@edf.fr>
Fri, 16 Oct 2015 14:18:49 +0000 (16:18 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Fri, 16 Oct 2015 14:18:49 +0000 (16:18 +0200)
src/MEDLoader/MEDFileMeshLL.cxx
src/MEDLoader/Swig/MEDLoaderTest3.py

index 639e0f7fa224bfd15d503025c00bbab29bddd6dd..218f7bb724c2c05df6dc657583f41f7ff3e31b3b 100644 (file)
@@ -1348,7 +1348,12 @@ void MEDFileUMeshAggregateCompute::forceComputationOfPartsFromUMesh() const
 {
   const MEDCouplingUMesh *m(_m);
   if(!m)
-    throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::forceComputationOfPartsFromUMesh : null UMesh !");
+    {
+      if(_m_parts.empty())
+        throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::forceComputationOfPartsFromUMesh : null UMesh !");
+      else
+        return ;// no needs to compte parts they are already here !
+    }
   std::vector<MEDCouplingUMesh *> ms(m->splitByType());
   std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingUMesh> > msMSafe(ms.begin(),ms.end());
   std::size_t sz(msMSafe.size());
index ce979a171cf6094c8120e5b118bbfce9a88d0cdc..ce9e0e076d575eea8713ddafb5b52451c582336a 100644 (file)
@@ -4627,6 +4627,32 @@ class MEDLoaderTest(unittest.TestCase):
       lvl = mfu2.getNonEmptyLevels()
       self.assertEqual((), lvl)
 
+    @unittest.skipUnless(MEDCouplingHasNumPyBindings(),"requires numpy")
+    def testMEDFileUMeshPickeling2(self):
+      """ Check that pickalization can be performed on a unpickalized instance. Non regression test."""
+      name="Mesh_1"
+      grpName1="HAUT"
+      grpName2="BASE"
+      hauteur=1.
+      nbOfNodesPerAxis=3
+      arr=DataArrayDouble(nbOfNodesPerAxis) ; arr.iota() ; arr/=(nbOfNodesPerAxis-1) ; arr*=hauteur
+      m=MEDCouplingCMesh() ; m.setCoords(arr,arr,arr) ; m=m.buildUnstructured() ; m.setName(name)
+      mesh=MEDFileUMesh() ; mesh[0]=m
+      m1=m.computeSkin() ; mesh[-1]=m1
+      #
+      bary1=m1.getBarycenterAndOwner()[:,2]
+      grp1=bary1.getIdsInRange(hauteur-1e-12,hauteur+1e-12) ; grp1.setName(grpName1)
+      grp2=bary1.getIdsInRange(0.-1e-12,0.+1e-12) ; grp2.setName(grpName2)
+      mesh.setGroupsAtLevel(-1,[grp1,grp2])
+      
+      import cPickle
+      st=cPickle.dumps(mesh,2)
+      mm=cPickle.loads(st)
+      st2=cPickle.dumps(mm,2)
+      mm2=cPickle.loads(st2)
+      self.assertTrue(mesh.isEqual(mm2,1e-12)[0])
+      pass
+
     pass
 
 if __name__ == "__main__":