]> SALOME platform Git repositories - tools/medcoupling.git/commitdiff
Salome HOME
For MED profiles aficionados
authorAnthony Geay <anthony.geay@edf.fr>
Tue, 20 Feb 2018 06:51:13 +0000 (07:51 +0100)
committerAnthony Geay <anthony.geay@edf.fr>
Tue, 20 Feb 2018 06:51:13 +0000 (07:51 +0100)
src/MEDLoader/MEDFileField.txx
src/MEDLoader/Swig/MEDLoaderTest3.py

index 42e3edad307a7b4367193757b3fe70f4a1baa94f..8b385e2e5adabff86af14a1b70a8998f481fcacb 100644 (file)
@@ -691,11 +691,11 @@ namespace MEDCoupling
   }
 
   /*!
-   * Same as setFieldProfile except that here profile will be created un
+   * Same as setFieldProfile except that here profile will be created unconditionally
    * \sa setFieldProfile
    */
   template<class T>
-  void setFieldProfileFlatly(const typename Traits<T>::FieldType *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
+  void MEDFileTemplateField1TS<T>::setFieldProfileFlatly(const typename Traits<T>::FieldType *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile)
   {
     setFieldProfileGeneral(field,mesh,meshDimRelToMax,profile,false);
   }
index d091d2972ddc60995c5bc906a8f6c789a66e2444..934d384a3ac0a6d9a39509d32f2e230807ff040a 100644 (file)
@@ -6362,6 +6362,44 @@ class MEDLoaderTest3(unittest.TestCase):
         self.assertTrue(fToTest.getArray().isEqual(4*exp1,1e-12))
         
         pass
+
+    def testSetFieldProfileFlatly1(self):
+        """ Sometimes for downstream code fan of profiles, profile are requested unconditionally. setFieldProfile try to reduce at most profile usage. So setFieldProfileFlatly has been added to always create
+        a profile."""
+        arr=DataArrayDouble(10) ; arr.iota()
+        m=MEDCouplingCMesh() ; m.setCoords(arr,arr)
+        m=m.buildUnstructured()
+        m2=m.deepCopy()
+        m2.simplexize(0)
+        m=MEDCouplingUMesh.MergeUMeshes(m2,m)
+        m.setName("mesh")
+        mm=MEDFileUMesh()
+        mm[0]=m
+        f=MEDCouplingFieldDouble(ON_CELLS)
+        f.setMesh(m)
+        arr=DataArrayDouble(m.getNumberOfCells())
+        arr.iota()
+        f.setArray(arr)
+        f.setName("field")
+        pfl=DataArrayInt(m.getNumberOfCells()) ; pfl.iota() ; pfl.setName("pfl")
+        #
+        refSp=[(3,[(0,(0,162),'','')]),(4,[(0,(162,243),'','')])]
+        refSp1=[(3,[(0,(0,162),'pfl_NORM_TRI3','')]),(4,[(0,(162,243),'pfl_NORM_QUAD4','')])]
+        #
+        f1ts=MEDFileField1TS()
+        f1ts.setFieldProfile(f,mm,0,pfl)
+        self.assertEqual(f1ts.getPfls(),()) # here setFieldProfile has detected useless pfl -> no pfl
+        self.assertEqual(f1ts.getFieldSplitedByType(),refSp)
+        self.assertTrue(f1ts.field(mm).isEqual(f,1e-12,1e-12)) # the essential
+        #
+        f1ts=MEDFileField1TS()
+        f1ts.setFieldProfileFlatly(f,mm,0,pfl) # no optimization attempt. Create pfl unconditionally
+        self.assertEqual(f1ts.getPfls(),("%s_NORM_TRI3"%pfl.getName(),"%s_NORM_QUAD4"%pfl.getName()))
+        self.assertEqual(f1ts.getFieldSplitedByType(),refSp1)
+        self.assertTrue(f1ts.field(mm).isEqual(f,1e-12,1e-12)) # the essential
+        self.assertTrue(f1ts.getProfile("pfl_NORM_TRI3").isIota(162))
+        self.assertTrue(f1ts.getProfile("pfl_NORM_QUAD4").isIota(81))
+        pass
     
     pass