]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
[EDF26299] : Quick fix for symmetrization of the behavior between families at nodes...
authorAnthony Geay <anthony.geay@edf.fr>
Mon, 28 Nov 2022 08:06:16 +0000 (09:06 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Mon, 28 Nov 2022 08:06:16 +0000 (09:06 +0100)
src/MEDLoader/MEDFileMesh.cxx
src/MEDLoader/Swig/MEDLoaderTest3.py
src/MEDLoader/Swig/MEDLoaderTest4.py

index 09bd0ad0dbe26b83d5e6dfa91b27d8a13703d8f3..e61ac9c6dcfec2bb12861f1144abfd3d646029aa 100644 (file)
@@ -3692,7 +3692,7 @@ DataArrayIdType *MEDFileUMesh::getFamiliesArr(int meshDimRelToMaxExt, const std:
   std::vector<mcIdType> famIds=getFamiliesIds(fams);
   if(meshDimRelToMaxExt==1)
     {
-      if((const DataArrayIdType *)_fam_coords)
+      if(_fam_coords.isNotNull())
         {
           MCAuto<DataArrayIdType> da;
           if(!famIds.empty())
@@ -3705,7 +3705,11 @@ DataArrayIdType *MEDFileUMesh::getFamiliesArr(int meshDimRelToMaxExt, const std:
             return da.retn();
         }
       else
-        throw INTERP_KERNEL::Exception("MEDFileUMesh::getFamiliesArr : no family array specified on nodes !");
+      {
+        MCAuto<DataArrayIdType> ret(DataArrayIdType::New());
+        ret->alloc(0,1);
+        return ret.retn();
+      }
     }
   const MEDFileUMeshSplitL1 *l1=getMeshAtLevSafe(meshDimRelToMaxExt);
   if(!famIds.empty())
index a9b2dff97851e6e5488df9f3fcb5bab4431957fd..12842f733bb25c2208378fbf89113f54a72d8429 100644 (file)
@@ -115,13 +115,15 @@ class MEDLoaderTest3(unittest.TestCase):
         self.assertEqual([1,2,4,13,15],medmesh.getFamiliesArr(0,["Family_-5","Family_-3"],True).getValues());
         self.assertEqual([18,1,2,3,4,13,14,15],medmesh.getGroupsArr(0,["mesh2","mesh4","mesh3"],True).getValues());
         famn=medmesh.getFamilyNameGivenId(0)
-        self.assertRaises(InterpKernelException,medmesh.getNodeFamilyArr,famn,True);
+        #self.assertRaises(InterpKernelException,medmesh.getNodeFamilyArr,famn,True) # EDF26299
+        self.assertTrue(medmesh.getNodeFamilyArr(famn,True).isEqualWithoutConsideringStr(DataArrayInt([])))
         #without renum
         self.assertEqual([2,3,5,14,16],medmesh.getGroupArr(0,"mesh2").getValues());
         self.assertEqual([2,3,16],medmesh.getFamilyArr(0,"Family_-3").getValues());
         self.assertEqual([2,3,5,14,16],medmesh.getFamiliesArr(0,["Family_-5","Family_-3"]).getValues());
         self.assertEqual([0,2,3,4,5,14,15,16],medmesh.getGroupsArr(0,["mesh2","mesh3","mesh4"],False).getValues());
-        self.assertRaises(InterpKernelException,medmesh.getNodeFamilyArr,famn,False);
+        #self.assertRaises(InterpKernelException,medmesh.getNodeFamilyArr,famn,False) # EDF26299
+        self.assertTrue(medmesh.getNodeFamilyArr(famn,False).isEqualWithoutConsideringStr(DataArrayInt([])))
         pass
 
     # this tests emulates MEDMEM ( Except that it works ! ) The permutation are NOT taken into account
index 1e4cb28104a70f03d748abfd9cccc8d1f938ff6e..c81ec4b0a6c03b3b0e6420fb0f378a4570d97012 100644 (file)
@@ -5646,6 +5646,36 @@ class MEDLoaderTest4(unittest.TestCase):
         self.assertNotEqual(mm_reload.getGlobalNumFieldAtLevel(1).getClassName() , "DataArrayMedInt")
         pass
 
+    def test44(self):
+        """
+        EDF26299 : symmetrization of the behavior between families at nodes and cells
+        """
+        arr = DataArrayDouble([0,1,2])
+        cmesh = MEDCouplingCMesh("TEST")
+        cmesh.setCoords(arr, arr, arr)
+        umesh3d = cmesh.buildUnstructured()
+        umesh2d = umesh3d.computeSkin()
+
+        cas1 = MEDFileUMesh()
+
+        cas1[0] = umesh3d
+        cas1[-1] = umesh2d
+        cas2 = cas1.deepCopy()
+
+        # cas1 only groups on cells
+        gcell1 = DataArrayInt([1])
+        gcell1.setName("GCELL1")
+        cas1.setGroupsAtLevel(0, [gcell1])
+
+
+        # Cas2 only groups on nodes
+        gnode1 = DataArrayInt([1])
+        gnode1.setName("GNODE1")
+        cas2.setGroupsAtLevel(1, [gnode1])
+        # On demande un groupe sur un niveau ou ce groupe n'existe pas
+        self.assertTrue( cas2.getGroupArr(0, "GNODE1").isEqualWithoutConsideringStr( DataArrayInt([]) ) ) # Expected to return empty array on both cases
+        self.assertTrue( cas1.getGroupArr(1, "GCELL1").isEqualWithoutConsideringStr( DataArrayInt([]) ) ) # Expected to return empty array on both cases
+
     pass
 
 if __name__ == "__main__":