From: Anthony Geay Date: Tue, 20 Feb 2018 06:51:13 +0000 (+0100) Subject: For MED profiles aficionados X-Git-Tag: V8_5_0a1~6 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=95f52dedb9c2f3f0bc3d617e9eddc833ee787258;p=tools%2Fmedcoupling.git For MED profiles aficionados --- diff --git a/src/MEDLoader/MEDFileField.txx b/src/MEDLoader/MEDFileField.txx index 42e3edad3..8b385e2e5 100644 --- a/src/MEDLoader/MEDFileField.txx +++ b/src/MEDLoader/MEDFileField.txx @@ -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 - void setFieldProfileFlatly(const typename Traits::FieldType *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) + void MEDFileTemplateField1TS::setFieldProfileFlatly(const typename Traits::FieldType *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) { setFieldProfileGeneral(field,mesh,meshDimRelToMax,profile,false); } diff --git a/src/MEDLoader/Swig/MEDLoaderTest3.py b/src/MEDLoader/Swig/MEDLoaderTest3.py index d091d2972..934d384a3 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest3.py +++ b/src/MEDLoader/Swig/MEDLoaderTest3.py @@ -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