Salome HOME
RNV: Porting to swig-3
[tools/medcoupling.git] / src / MEDLoader / Swig / MEDLoaderDataForTest.py
index 22e8cfc28b27994d7c0e7ca897a78ae02e6a4a8c..369ccb266b76a77b2ef21a25c4316cc9a5382d5b 100644 (file)
@@ -1,10 +1,10 @@
 #  -*- coding: iso-8859-1 -*-
-# Copyright (C) 2007-2013  CEA/DEN, EDF R&D
+# Copyright (C) 2007-2016  CEA/DEN, EDF R&D
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
 # License as published by the Free Software Foundation; either
-# version 2.1 of the License.
+# version 2.1 of the License, or (at your option) any later version.
 #
 # This library is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -384,7 +384,7 @@ class MEDLoaderDataForTest:
         f1.setArray(array);
         tmp=array.getPointer();
         f1.setTime(2.,0,1);
-        f1.checkCoherency();
+        f1.checkConsistencyLight();
         return f1;
 
     def buildVecFieldOnNodes_1(cls):
@@ -402,7 +402,7 @@ class MEDLoaderDataForTest:
         array.setInfoOnComponent(1,"density [g/cm^3]");
         array.setInfoOnComponent(2,"temperature [K]");
         f1.setTime(2.12,2,3);
-        f1.checkCoherency();
+        f1.checkConsistencyLight();
         return f1;
 
     def buildVecFieldOnGauss_1(cls):
@@ -444,7 +444,7 @@ class MEDLoaderDataForTest:
         f.setName("MyFirstFieldOnGaussPoint");
         array.setInfoOnComponent(0,"power [MW/m^3]");
         array.setInfoOnComponent(1,"density");
-        f.checkCoherency();
+        f.checkConsistencyLight();
         return f;
 
     def buildVecFieldOnGauss_2(cls):
@@ -493,7 +493,7 @@ class MEDLoaderDataForTest:
         f.setName("MyFirstFieldOnGaussPoint");
         array.setInfoOnComponent(0,"power [MW/m^3]");
         array.setInfoOnComponent(1,"density");
-        f.checkCoherency();
+        f.checkConsistencyLight();
         return f;
 
     # idem buildVecFieldOnGauss_2 except that different discretizations are sorted inside one type
@@ -543,7 +543,7 @@ class MEDLoaderDataForTest:
         f.setName("MyFirstFieldOnGaussPoint");
         array.setInfoOnComponent(0,"power [MW/m^3]");
         array.setInfoOnComponent(1,"density");
-        f.checkCoherency();
+        f.checkConsistencyLight();
         return f;
 
     def buildVecFieldOnGaussNE_1(cls):
@@ -559,7 +559,7 @@ class MEDLoaderDataForTest:
         array.setInfoOnComponent(0,"power [W]");
         array.setInfoOnComponent(1,"temperature");
         f.setName("MyFieldOnGaussNE");
-        f.checkCoherency();
+        f.checkConsistencyLight();
         return f;
 
     def buildACompleteMEDDataStructureWithFieldsOnCells_1(cls):
@@ -599,7 +599,7 @@ class MEDLoaderDataForTest:
             f11Tmp.setMesh(m0)
             arr=DataArrayDouble(m0.getNumberOfCells(),1) ; arr.iota() ; arr+=1+i ; arr*=0.1
             f11Tmp.setArray(arr)
-            f11Tmp.checkCoherency()
+            f11Tmp.checkConsistencyLight()
             f11Tmp.setName(f1Name)
             f1.appendFieldNoProfileSBT(f11Tmp)
             pass
@@ -614,7 +614,7 @@ class MEDLoaderDataForTest:
             f21Tmp.setMesh(m0)
             arr=DataArrayDouble(m0.getNumberOfCells(),1) ; arr.iota() ; arr+=1+i
             f21Tmp.setArray(arr)
-            f21Tmp.checkCoherency()
+            f21Tmp.checkConsistencyLight()
             f21Tmp.setName(f2Name)
             f2.appendFieldNoProfileSBT(f21Tmp)
             f22Tmp=MEDCouplingFieldDouble(ON_CELLS,ONE_TIME)
@@ -622,7 +622,7 @@ class MEDLoaderDataForTest:
             f22Tmp.setMesh(m1)
             arr=DataArrayDouble(m1.getNumberOfCells(),1) ; arr.iota() ; arr+=100+1+i
             f22Tmp.setArray(arr)
-            f22Tmp.checkCoherency()
+            f22Tmp.checkConsistencyLight()
             f22Tmp.setName(f2Name)
             f2[it,order].setFieldNoProfileSBT(f22Tmp)
             pass
@@ -639,7 +639,7 @@ class MEDLoaderDataForTest:
             f31Tmp.setMesh(m0Part)
             arr=DataArrayDouble(m0Part.getNumberOfCells(),1) ; arr.iota() ; arr+=1000+i+1
             f31Tmp.setArray(arr)
-            f31Tmp.checkCoherency()
+            f31Tmp.checkConsistencyLight()
             f31Tmp.setName(f3Name)
             f3.appendFieldProfile(f31Tmp,mm,0,pfl1)
             pfl2=DataArrayInt([0,3]) ; pfl2.setName("pfl2Bottom")
@@ -649,7 +649,7 @@ class MEDLoaderDataForTest:
             f32Tmp.setMesh(m1Part)
             arr=DataArrayDouble(m1Part.getNumberOfCells(),1) ; arr.iota() ; arr+=2000+1+i
             f32Tmp.setArray(arr)
-            f32Tmp.checkCoherency()
+            f32Tmp.checkConsistencyLight()
             f32Tmp.setName(f3Name)
             f3[it,order].setFieldProfile(f32Tmp,mm,-1,pfl2)
             pass
@@ -657,6 +657,55 @@ class MEDLoaderDataForTest:
         #
         data=MEDFileData() ; data.setMeshes(ms) ; data.setFields(fs)
         return data
+
+    def buildAMEDFileDataWithGroupOnOneFamilyForSauv(self):
+        # Coordinates
+        coords = [0.,0., 0.,1., 1.,1., 1.,0.]
+        # lvl 0 connectivity
+        conn2D   = [1,2,3,4]
+        # lvl -1 connectivity
+        conn1D   = [0,1, 1,2, 2,3, 4,1]
+        # lvl 0 mesh
+        mesh2D=MEDCouplingUMesh.New()
+        mesh2D.setMeshDimension(2)
+        mesh2D.allocateCells(1)
+        mesh2D.insertNextCell(NORM_QUAD4,4,conn2D)
+        mesh2D.finishInsertingCells()
+        # lvl -1 mesh
+        mesh1D=MEDCouplingUMesh.New()
+        mesh1D.setMeshDimension(1)
+        mesh1D.allocateCells(4)
+        mesh1D.insertNextCell(NORM_SEG2,2,conn1D[0:2])
+        mesh1D.insertNextCell(NORM_SEG2,2,conn1D[2:4])
+        mesh1D.insertNextCell(NORM_SEG2,2,conn1D[4:6])
+        mesh1D.insertNextCell(NORM_SEG2,2,conn1D[6:8])
+        mesh1D.finishInsertingCells()
+        # assigning coordinates
+        meshCoords=DataArrayDouble.New()
+        meshCoords.setValues(coords, 4, 2)
+        mesh2D.setCoords(meshCoords)
+        mesh1D.setCoords(meshCoords)
+        # Creating a multi level mesh
+        mm = MEDFileUMesh.New()
+        mm.setMeshAtLevel(0, mesh2D)
+        mm.setMeshAtLevel(-1, mesh1D)
+        mm.setName("carre")
+        # Creating groups
+        # Creating a group with an element on level -1
+        grp0_LM1 = DataArrayInt.New([0])
+        grp0_LM1.setName("grp0_LM1")
+        # Creating a group with all elements on level -1
+        grp1_LM1 = DataArrayInt.New([0,1,2,3])
+        grp1_LM1.setName("grp1_LM1")
+        #
+        mm.setGroupsAtLevel(-1,[grp0_LM1,grp1_LM1])
+        #
+        ms=MEDFileMeshes.New()
+        ms.setMeshAtPos(0,mm)
+        mfd=MEDFileData.New()
+        mfd.setMeshes(ms)
+        #
+        return mfd
     
     build1DMesh_1=classmethod(build1DMesh_1)
     build2DCurveMesh_1=classmethod(build2DCurveMesh_1)
@@ -675,4 +724,5 @@ class MEDLoaderDataForTest:
     buildVecFieldOnGauss_2_Simpler=classmethod(buildVecFieldOnGauss_2_Simpler)
     buildVecFieldOnGaussNE_1=classmethod(buildVecFieldOnGaussNE_1)
     buildACompleteMEDDataStructureWithFieldsOnCells_1=classmethod(buildACompleteMEDDataStructureWithFieldsOnCells_1)
+    buildAMEDFileDataWithGroupOnOneFamilyForSauv=classmethod(buildAMEDFileDataWithGroupOnOneFamilyForSauv)
     pass