From: Anthony Geay Date: Mon, 28 Nov 2022 08:06:16 +0000 (+0100) Subject: [EDF26299] : Quick fix for symmetrization of the behavior between families at nodes... X-Git-Tag: V9_11_0a1~27 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f0d1e7cd13bf1b4c9d08b12dc7113e4a36665515;p=tools%2Fmedcoupling.git [EDF26299] : Quick fix for symmetrization of the behavior between families at nodes and cells --- diff --git a/src/MEDLoader/MEDFileMesh.cxx b/src/MEDLoader/MEDFileMesh.cxx index 09bd0ad0d..e61ac9c6d 100644 --- a/src/MEDLoader/MEDFileMesh.cxx +++ b/src/MEDLoader/MEDFileMesh.cxx @@ -3692,7 +3692,7 @@ DataArrayIdType *MEDFileUMesh::getFamiliesArr(int meshDimRelToMaxExt, const std: std::vector famIds=getFamiliesIds(fams); if(meshDimRelToMaxExt==1) { - if((const DataArrayIdType *)_fam_coords) + if(_fam_coords.isNotNull()) { MCAuto 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 ret(DataArrayIdType::New()); + ret->alloc(0,1); + return ret.retn(); + } } const MEDFileUMeshSplitL1 *l1=getMeshAtLevSafe(meshDimRelToMaxExt); if(!famIds.empty()) diff --git a/src/MEDLoader/Swig/MEDLoaderTest3.py b/src/MEDLoader/Swig/MEDLoaderTest3.py index a9b2dff97..12842f733 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest3.py +++ b/src/MEDLoader/Swig/MEDLoaderTest3.py @@ -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 diff --git a/src/MEDLoader/Swig/MEDLoaderTest4.py b/src/MEDLoader/Swig/MEDLoaderTest4.py index 1e4cb2810..c81ec4b0a 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest4.py +++ b/src/MEDLoader/Swig/MEDLoaderTest4.py @@ -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__":