From: geay Date: Wed, 16 Apr 2014 13:44:24 +0000 (+0200) Subject: Improvements linked to debug EDF 7972 X-Git-Tag: V7_4_0rc1~29 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0a6567af86caa60471271b1184d29e2ccd547687;p=modules%2Fmed.git Improvements linked to debug EDF 7972 --- diff --git a/src/MEDCoupling/MEDCouplingRefCountObject.cxx b/src/MEDCoupling/MEDCouplingRefCountObject.cxx index f30864a89..5284c02bd 100644 --- a/src/MEDCoupling/MEDCouplingRefCountObject.cxx +++ b/src/MEDCoupling/MEDCouplingRefCountObject.cxx @@ -22,6 +22,7 @@ #include "MED_version.h" #include +#include using namespace ParaMEDMEM; @@ -80,6 +81,49 @@ std::size_t BigMemoryObject::getHeapMemorySize() const return ret+GetHeapMemoryOfSet(s1,s2); } +/*! + * This method returns all the progeny of \a this (this is \b not included in returned vector). + * All the progeny means all the subobjects (children), subsubobjects (little children), ... of \a this. + * The elements in returned array are reported only once even if they appear several times in the progeny of \a this. + */ +std::vector BigMemoryObject::getAllTheProgeny() const +{ + std::vector s1(getDirectChildren()); + std::vector ret; + while(!s1.empty()) + { + ret.insert(ret.end(),s1.begin(),s1.end()); + std::vector s3; + for(std::vector::const_iterator it0=s1.begin();it0!=s1.end();it0++) + { + std::vector s2; + if(*it0) + s2=(*it0)->getDirectChildren(); + for(std::vector::const_iterator it1=s2.begin();it1!=s2.end();it1++) + { + if(*it1) + if(std::find(ret.begin(),ret.end(),*it1)==ret.end()) + s3.push_back(*it1); + } + } + s1=s3; + } + return ret; +} + +/*! + * This method scan all the progeny of \a this (\a this excluded) to see if \a obj is part of it. + * If obj is NULL false is returned. + * \sa BigMemoryObject::getAllTheProgeny + */ +bool BigMemoryObject::isObjectInTheProgeny(const BigMemoryObject *obj) const +{ + if(!obj) + return false; + std::vector objs(getAllTheProgeny()); + return std::find(objs.begin(),objs.end(),obj)!=objs.end(); +} + std::size_t BigMemoryObject::GetHeapMemorySizeOfObjs(const std::vector& objs) { std::size_t ret(0); diff --git a/src/MEDCoupling/MEDCouplingRefCountObject.hxx b/src/MEDCoupling/MEDCouplingRefCountObject.hxx index fd55536f2..31a23be0a 100644 --- a/src/MEDCoupling/MEDCouplingRefCountObject.hxx +++ b/src/MEDCoupling/MEDCouplingRefCountObject.hxx @@ -67,6 +67,8 @@ namespace ParaMEDMEM public: MEDCOUPLING_EXPORT std::size_t getHeapMemorySize() const; MEDCOUPLING_EXPORT std::string getHeapMemorySizeStr() const; + MEDCOUPLING_EXPORT std::vector getAllTheProgeny() const; + MEDCOUPLING_EXPORT bool isObjectInTheProgeny(const BigMemoryObject *obj) const; MEDCOUPLING_EXPORT static std::size_t GetHeapMemorySizeOfObjs(const std::vector& objs); MEDCOUPLING_EXPORT virtual std::size_t getHeapMemorySizeWithoutChildren() const = 0; MEDCOUPLING_EXPORT virtual std::vector getDirectChildren() const = 0; diff --git a/src/MEDCoupling_Swig/MEDCouplingRefCountObject.i b/src/MEDCoupling_Swig/MEDCouplingRefCountObject.i index 0db2e7e7e..e6ca9aae2 100644 --- a/src/MEDCoupling_Swig/MEDCouplingRefCountObject.i +++ b/src/MEDCoupling_Swig/MEDCouplingRefCountObject.i @@ -68,6 +68,7 @@ namespace ParaMEDMEM public: std::size_t getHeapMemorySize() const throw(INTERP_KERNEL::Exception); std::string getHeapMemorySizeStr() const throw(INTERP_KERNEL::Exception); + bool isObjectInTheProgeny(const BigMemoryObject *obj) const throw(INTERP_KERNEL::Exception); virtual std::size_t getHeapMemorySizeWithoutChildren() const throw(INTERP_KERNEL::Exception); virtual ~BigMemoryObject(); %extend @@ -81,6 +82,15 @@ namespace ParaMEDMEM return ret; } + PyObject *getAllTheProgeny() const throw(INTERP_KERNEL::Exception) + { + std::vector c(self->getAllTheProgeny()); + PyObject *ret(PyList_New(c.size())); + for(std::size_t i=0;i cppObjs; diff --git a/src/MEDLoader/MEDFileFieldOverView.cxx b/src/MEDLoader/MEDFileFieldOverView.cxx index 47ec2a37e..9bea050d6 100644 --- a/src/MEDLoader/MEDFileFieldOverView.cxx +++ b/src/MEDLoader/MEDFileFieldOverView.cxx @@ -668,7 +668,7 @@ MEDUMeshMultiLev *MEDUMeshMultiLev::New(const MEDFileUMesh *m, const std::vector return new MEDUMeshMultiLev(m,levs); } -MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDFileUMesh *m, const std::vector& levs):MEDMeshMultiLev(m),_is_holding_a_ref_already_held(true) +MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDFileUMesh *m, const std::vector& levs):MEDMeshMultiLev(m) { if(!m) throw INTERP_KERNEL::Exception("MEDUMeshMultiLev constructor : null input pointer !"); @@ -771,7 +771,7 @@ MEDUMeshMultiLev *MEDUMeshMultiLev::New(const MEDFileUMesh *m, const std::vector return new MEDUMeshMultiLev(m,gts,pfls,nbEntities); } -MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDFileUMesh *m, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities):MEDMeshMultiLev(m,m->getNumberOfNodes(),gts,pfls,nbEntities),_is_holding_a_ref_already_held(true) +MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDFileUMesh *m, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities):MEDMeshMultiLev(m,m->getNumberOfNodes(),gts,pfls,nbEntities) { std::size_t sz(gts.size()); if(sz<1) @@ -897,11 +897,11 @@ MEDMeshMultiLev *MEDUMeshMultiLev::prepare() const return new MEDUMeshMultiLev(*this); } -MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDUMeshMultiLev& other):MEDMeshMultiLev(other),_is_holding_a_ref_already_held(other._is_holding_a_ref_already_held),_parts(other._parts),_coords(other._coords) +MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDUMeshMultiLev& other):MEDMeshMultiLev(other),_parts(other._parts),_coords(other._coords) { } -MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDStructuredMeshMultiLev& other, const MEDCouplingAutoRefCountObjectPtr& part):MEDMeshMultiLev(other),_is_holding_a_ref_already_held(false) +MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDStructuredMeshMultiLev& other, const MEDCouplingAutoRefCountObjectPtr& part):MEDMeshMultiLev(other) { _parts.resize(1); _parts[0]=part; @@ -1064,26 +1064,12 @@ bool MEDUMeshMultiLev::buildVTUArrays(DataArrayDouble *& coords, DataArrayByte * reorderNodesIfNecessary(a,d,f); if(a->getNumberOfComponents()!=3) a=a->changeNbOfComponents(3,0.); - coords=a.retn(); - if(!_is_holding_a_ref_already_held) - { - if(tmp==((DataArrayDouble *)a)) - { - if(_parts.empty()) - { const_cast(this)->_coords=0; } - else - { const_cast(this)->_parts[0]->setCoords(0); } - } - } - types=b.retn(); cellLocations=c.retn(); cells=d.retn(); + coords=a.retn(); types=b.retn(); cellLocations=c.retn(); cells=d.retn(); if(!isPolyh) { faceLocations=0; faces=0; } else { faceLocations=e.retn(); faces=f.retn(); } - if(_is_holding_a_ref_already_held) - return tmp==((DataArrayDouble *)a); - else - return false; + return _mesh->isObjectInTheProgeny(coords); } void MEDUMeshMultiLev::reorderNodesIfNecessary(MEDCouplingAutoRefCountObjectPtr& coords, DataArrayInt *nodalConnVTK, DataArrayInt *polyhedNodalConnVTK) const diff --git a/src/MEDLoader/MEDFileFieldOverView.hxx b/src/MEDLoader/MEDFileFieldOverView.hxx index 0cc6f2bf4..84dfed483 100644 --- a/src/MEDLoader/MEDFileFieldOverView.hxx +++ b/src/MEDLoader/MEDFileFieldOverView.hxx @@ -147,8 +147,6 @@ namespace ParaMEDMEM MEDUMeshMultiLev(const MEDFileUMesh *m, const std::vector& levs); MEDUMeshMultiLev(const MEDFileUMesh *m, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities); private: - //! this boolean will desappear shortly. It is always equal to true except for the case where a partial cartesian mesh leads to a unstructured mesh. - bool _is_holding_a_ref_already_held; std::vector< MEDCouplingAutoRefCountObjectPtr > _parts; //! this attribute is used only for mesh with no cells but having coordinates. For classical umeshes those pointer is equal to pointer of coordinates of instances in this->_parts. MEDCouplingAutoRefCountObjectPtr _coords; diff --git a/src/MEDLoader/MEDFileMesh.cxx b/src/MEDLoader/MEDFileMesh.cxx index 921d63865..90375565a 100644 --- a/src/MEDLoader/MEDFileMesh.cxx +++ b/src/MEDLoader/MEDFileMesh.cxx @@ -4001,6 +4001,8 @@ std::vector MEDFileStructuredMesh::getDirectChildren() ret.push_back((const DataArrayAsciiChar *)_names_faces); if((const DataArrayInt *)_rev_num_cells) ret.push_back((const DataArrayInt *)_rev_num_cells); + if((const MEDCoupling1SGTUMesh*)_faces_if_necessary) + ret.push_back((const MEDCoupling1SGTUMesh*)_faces_if_necessary); return ret; } diff --git a/src/MEDLoader/MEDFileMeshLL.cxx b/src/MEDLoader/MEDFileMeshLL.cxx index f78b400c3..79493967f 100644 --- a/src/MEDLoader/MEDFileMeshLL.cxx +++ b/src/MEDLoader/MEDFileMeshLL.cxx @@ -512,6 +512,20 @@ void MEDFileUMeshPermCompute::updateTime() const _num_time=_st->_num->getTimeOfThis(); } +std::vector MEDFileUMeshPermCompute::getDirectChildren() const +{ + std::vector ret; + const MEDCouplingUMesh *elt(_m); + if(elt) + ret.push_back(elt); + return ret; +} + +std::size_t MEDFileUMeshPermCompute::getHeapMemorySizeWithoutChildren() const +{ + return sizeof(MEDFileUMeshPermCompute); +} + MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(const MEDFileUMeshSplitL1& other):RefCountObject(other),_m_by_types(other._m_by_types),_fam(other._fam),_num(other._num),_names(other._names),_rev_num(other._rev_num),_m(this) { } @@ -597,6 +611,7 @@ std::vector MEDFileUMeshSplitL1::getDirectChildren() co { std::vector ret; ret.push_back(&_m_by_types); + ret.push_back(&_m); if((const DataArrayInt*)_fam) ret.push_back((const DataArrayInt*)_fam); if((const DataArrayInt*)_num) diff --git a/src/MEDLoader/MEDFileMeshLL.hxx b/src/MEDLoader/MEDFileMeshLL.hxx index 08c65e077..f353a7b75 100644 --- a/src/MEDLoader/MEDFileMeshLL.hxx +++ b/src/MEDLoader/MEDFileMeshLL.hxx @@ -123,13 +123,15 @@ namespace ParaMEDMEM class MEDFileMesh; class MEDFileUMeshSplitL1; - class MEDFileUMeshPermCompute + class MEDFileUMeshPermCompute : public BigMemoryObject { public: MEDFileUMeshPermCompute(const MEDFileUMeshSplitL1* st); operator MEDCouplingUMesh *() const; void operator=(MEDCouplingUMesh *m); void updateTime() const; + std::vector getDirectChildren() const; + std::size_t getHeapMemorySizeWithoutChildren() const; private: const MEDFileUMeshSplitL1 *_st; mutable std::size_t _mpt_time; diff --git a/src/MEDLoader/Swig/MEDLoaderTest4.py b/src/MEDLoader/Swig/MEDLoaderTest4.py index a0006742d..09135bc07 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest4.py +++ b/src/MEDLoader/Swig/MEDLoaderTest4.py @@ -4228,7 +4228,7 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(v.isEqual(arrGauss,1e-12)) ; self.assertTrue(v.isEqualWithoutConsideringStr(DataArrayDouble(range(27)),1e-12)) ; self.assertEqual(v.getInfoOnComponents(),["gaussc"]) ffGauss=allFMTSLeavesPerCommonSupport1[0][0][1][0] pass - + def test30(self): """ This test is focused on cartesian meshes. Here the cartesian mesh "CartMesh" has a field on HEXA8 (FieldOnCells) and a field on QUAD4 (FieldOnFaces). So the first one (FieldOnCells) lies on a cartesian mesh whereas the second one lies on unstructured one. @@ -4327,8 +4327,10 @@ class MEDLoaderTest4(unittest.TestCase): mml=fcscp.buildFromScratchDataSetSupport(0,fields) mml2=mml.prepare() self.assertTrue(isinstance(mml2,MEDUMeshMultiLev)) # here UMesh is important + ref=ms[0].getImplicitFaceMesh().getCoords().getHiddenCppPointer() ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() - self.assertTrue(not ncc)# BUG EDF 7972 ! here all the nodes are taken, BUT the coordinates comes from a non available array in file so in memory ! so false is returned ! + self.assertEqual(ref,a0.getHiddenCppPointer()) + self.assertTrue(ncc) self.assertTrue(a1.isEqual(DataArrayByte([9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9,9]))) self.assertTrue(a2.isEqual(DataArrayInt([0,5,10,15,20,25,30,35,40,45,50,55,60,65,70,75,80,85,90,95,100,105,110,115,120,125,130,135,140,145,150,155,160,165,170,175,180,185,190,195,200,205,210,215,220,225,230,235,240,245,250,255,260,265,270,275,280,285,290,295,300,305,310,315,320,325,330,335,340,345,350,355,360,365,370,375,380,385,390,395,400,405,410,415,420,425,430,435,440,445,450,455,460,465,470,475,480,485]))) self.assertTrue(a3.isEqual(DataArrayInt([4,0,12,15,3,4,12,24,27,15,4,24,36,39,27,4,36,48,51,39,4,3,15,18,6,4,15,27,30,18,4,27,39,42,30,4,39,51,54,42,4,6,18,21,9,4,18,30,33,21,4,30,42,45,33,4,42,54,57,45,4,1,13,16,4,4,13,25,28,16,4,25,37,40,28,4,37,49,52,40,4,4,16,19,7,4,16,28,31,19,4,28,40,43,31,4,40,52,55,43,4,7,19,22,10,4,19,31,34,22,4,31,43,46,34,4,43,55,58,46,4,2,14,17,5,4,14,26,29,17,4,26,38,41,29,4,38,50,53,41,4,5,17,20,8,4,17,29,32,20,4,29,41,44,32,4,41,53,56,44,4,8,20,23,11,4,20,32,35,23,4,32,44,47,35,4,44,56,59,47,4,0,12,13,1,4,12,24,25,13,4,24,36,37,25,4,36,48,49,37,4,1,13,14,2,4,13,25,26,14,4,25,37,38,26,4,37,49,50,38,4,3,15,16,4,4,15,27,28,16,4,27,39,40,28,4,39,51,52,40,4,4,16,17,5,4,16,28,29,17,4,28,40,41,29,4,40,52,53,41,4,6,18,19,7,4,18,30,31,19,4,30,42,43,31,4,42,54,55,43,4,7,19,20,8,4,19,31,32,20,4,31,43,44,32,4,43,55,56,44,4,9,21,22,10,4,21,33,34,22,4,33,45,46,34,4,45,57,58,46,4,10,22,23,11,4,22,34,35,23,4,34,46,47,35,4,46,58,59,47,4,0,1,4,3,4,3,4,7,6,4,6,7,10,9,4,1,2,5,4,4,4,5,8,7,4,7,8,11,10,4,12,13,16,15,4,15,16,19,18,4,18,19,22,21,4,13,14,17,16,4,16,17,20,19,4,19,20,23,22,4,24,25,28,27,4,27,28,31,30,4,30,31,34,33,4,25,26,29,28,4,28,29,32,31,4,31,32,35,34,4,36,37,40,39,4,39,40,43,42,4,42,43,46,45,4,37,38,41,40,4,40,41,44,43,4,43,44,47,46,4,48,49,52,51,4,51,52,55,54,4,54,55,58,57,4,49,50,53,52,4,52,53,56,55,4,55,56,59,58]))) @@ -4345,7 +4347,188 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(v.isEqual(myarr,1e-12)) pass pass - + + def test31(self): + """non regression test of EDF 7972""" + fname="ForMEDReader31.med" + c=MEDCouplingCMesh() + arrX=DataArrayDouble(3) ; arrX.iota() + arrY=DataArrayDouble(4) ; arrY.iota() + arrZ=DataArrayDouble(5) ; arrZ.iota() + c.setCoords(arrX,arrY,arrZ) + c.setName("CartMesh") + cc=MEDFileCMesh() + cc.setMesh(c) + famIdCells=DataArrayInt(24) ; famIdCells[:]=0 + cc.setFamilyFieldArr(0,famIdCells) + #cc.setFamilyFieldArr(-1,famIdFaces) + cc.addFamily("FacesX",-1) ; cc.addFamily("FacesY",-2) ; cc.addFamily("FacesZ",-3) + cc.setFamiliesOnGroup("FacesX1",["FacesX"]) + cc.setFamiliesOnGroup("FacesY1",["FacesY"]) + cc.setFamiliesOnGroup("FacesZ1",["FacesZ"]) + fmts0=MEDFileFieldMultiTS() + fmts1=MEDFileFieldMultiTS() + pfl=DataArrayInt(11) ; pfl.iota() ; pfl.setName("PflOnHECA8") + for i in xrange(30): + f1ts=MEDFileField1TS() + fFaces=MEDCouplingFieldDouble(ON_CELLS) ; fFaces.setName("FieldOnCells") + arr=DataArrayDouble(11) ; arr.iota() ; arr[i%11]=100. + fFaces.setArray(arr) + fFaces.setTime(float(i)+0.1,i,-1) + fFaces.setMesh(c.buildUnstructured()[:11]) + f1ts.setFieldProfile(fFaces,cc,0,pfl)# here, a test is done to check that "NORM_HEXA8" string is not 30 times appended at the end of pfl name. + self.assertEqual("PflOnHECA8",pfl.getName()) + fmts0.pushBackTimeStep(f1ts) + pass + fs=MEDFileFields() + fs.pushField(fmts0) + cc.write(fname,2) + fs.write(fname,0) + ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values + ms=MEDFileMeshes(fname) + fields=MEDFileFields(fname,False) + fields.removeFieldsWithoutAnyTimeStep() + fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] + allFMTSLeavesToDisplay=[] + for fields in fields_per_mesh: + allFMTSLeavesToDisplay2=[] + for fmts in fields: + allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + pass + allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) + pass + self.assertEqual(len(allFMTSLeavesToDisplay),1) + self.assertEqual(len(allFMTSLeavesToDisplay[0]),1) + allFMTSLeavesPerTimeSeries=MEDFileAnyTypeFieldMultiTS.SplitIntoCommonTimeSeries(sum(allFMTSLeavesToDisplay,[])) + self.assertEqual(len(allFMTSLeavesPerTimeSeries),1) + self.assertEqual(len(allFMTSLeavesPerTimeSeries[0]),1) + allFMTSLeavesPerCommonSupport1=MEDFileAnyTypeFieldMultiTS.SplitPerCommonSupport(allFMTSLeavesToDisplay[0],ms[ms.getMeshesNames()[0]]) + self.assertEqual(len(allFMTSLeavesPerCommonSupport1),1) + self.assertEqual(len(allFMTSLeavesPerCommonSupport1[0][0]),1) + # + mst=MEDFileMeshStruct.New(ms[0]) + # + fcscp=allFMTSLeavesPerCommonSupport1[0][1] + mml=fcscp.buildFromScratchDataSetSupport(0,fields) + mml2=mml.prepare() + self.assertTrue(isinstance(mml2,MEDUMeshMultiLev)) # here UMesh is important + ncc,a0,a1,a2,a3,a4,a5=mml2.buildVTUArrays() + self.assertTrue(not ncc)# here ncc=False because the coordinates are not in ms neither in children. This is the most important line in the test. + self.assertTrue(a0.isEqual(DataArrayDouble([0.,0.,0.,1.,0.,0.,2.,0.,0.,0.,1.,0.,1.,1.,0.,2.,1.,0.,0.,2.,0.,1.,2.,0.,2.,2.,0.,0.,3.,0.,1.,3.,0.,2.,3.,0.,0.,0.,1.,1.,0.,1.,2.,0.,1.,0.,1.,1.,1.,1.,1.,2.,1.,1.,0.,2.,1.,1.,2.,1.,2.,2.,1.,0.,3.,1.,1.,3.,1.,2.,3.,1.,0.,0.,2.,1.,0.,2.,2.,0.,2.,0.,1.,2.,1.,1.,2.,2.,1.,2.,0.,2.,2.,1.,2.,2.,2.,2.,2.,0.,3.,2.,1.,3.,2.,2.,3.,2.,0.,0.,3.,1.,0.,3.,2.,0.,3.,0.,1.,3.,1.,1.,3.,2.,1.,3.,0.,2.,3.,1.,2.,3.,2.,2.,3.,0.,3.,3.,1.,3.,3.,2.,3.,3.,0.,0.,4.,1.,0.,4.,2.,0.,4.,0.,1.,4.,1.,1.,4.,2.,1.,4.,0.,2.,4.,1.,2.,4.,2.,2.,4.,0.,3.,4.,1.,3.,4.,2.,3.,4.],60,3),1e-12)) + self.assertTrue(a1.isEqual(DataArrayByte([12,12,12,12,12,12,12,12,12,12,12]))) + self.assertTrue(a2.isEqual(DataArrayInt([0,9,18,27,36,45,54,63,72,81,90]))) + self.assertTrue(a3.isEqual(DataArrayInt([8,1,0,3,4,13,12,15,16,8,2,1,4,5,14,13,16,17,8,4,3,6,7,16,15,18,19,8,5,4,7,8,17,16,19,20,8,7,6,9,10,19,18,21,22,8,8,7,10,11,20,19,22,23,8,13,12,15,16,25,24,27,28,8,14,13,16,17,26,25,28,29,8,16,15,18,19,28,27,30,31,8,17,16,19,20,29,28,31,32,8,19,18,21,22,31,30,33,34]))) + self.assertTrue(a4 is None) + self.assertTrue(a5 is None) + for i in xrange(30): + ffCell=allFMTSLeavesPerCommonSupport1[0][0][0][i] + fsst=MEDFileField1TSStructItem.BuildItemFrom(ffCell,mst) + ffCell.loadArraysIfNecessary() + v=mml2.buildDataArray(fsst,fields,ffCell.getUndergroundDataArray()) + # self.assertEqual(v.getHiddenCppPointer(),ffCell.getUndergroundDataArray().getHiddenCppPointer()) # to be improved... maybe this line could be true + myarr=DataArrayDouble(11) ; myarr.iota() ; myarr[i%11]=100. + self.assertEqual(ffCell.getName(),"FieldOnCells") + self.assertTrue(v.isEqual(myarr,1e-12)) + pass + pass + + def test32(self): + """ This test is close to test30 except that here the profiles on dim-1 of structured mesh is considered here.""" + fname="ForMEDReader32.med" + c=MEDCouplingCMesh() + arrX=DataArrayDouble(3) ; arrX.iota() + arrY=DataArrayDouble(4) ; arrY.iota() + arrZ=DataArrayDouble(5) ; arrZ.iota() + c.setCoords(arrX,arrY,arrZ) + c.setName("CartMesh") + cc=MEDFileCMesh() + cc.setMesh(c) + tmpFacesMesh=c.build1SGTSubLevelMesh() + famIdFaces=DataArrayInt(98) ; famIdFaces[:36]=-1 ; famIdFaces[36:68]=-2 ; famIdFaces[68:]=-3 + famIdCells=DataArrayInt(24) ; famIdCells[:]=0 + cc.setFamilyFieldArr(0,famIdCells) + #cc.setFamilyFieldArr(-1,famIdFaces) + cc.addFamily("FacesX",-1) ; cc.addFamily("FacesY",-2) ; cc.addFamily("FacesZ",-3) + cc.setFamiliesOnGroup("FacesX1",["FacesX"]) + cc.setFamiliesOnGroup("FacesY1",["FacesY"]) + cc.setFamiliesOnGroup("FacesZ1",["FacesZ"]) + fmts0=MEDFileFieldMultiTS() + fmts1=MEDFileFieldMultiTS() + pfl=DataArrayInt(31) ; pfl.iota() ; pfl.setName("PflOnQUAD4") + for i in xrange(30): + f1ts=MEDFileField1TS() + fFaces=MEDCouplingFieldDouble(ON_CELLS) ; fFaces.setName("FieldOnFaces") + arr=DataArrayDouble(31) ; arr.iota() ; arr[i]=100. + fFaces.setArray(arr) + fFaces.setTime(float(i)+0.1,i,-1) + fFaces.setMesh(tmpFacesMesh[:31]) + f1ts.setFieldProfile(fFaces,cc,-1,pfl)# here, a test is done to check that "NORM_QUAD4" string is not 30 times appended at the end of pfl name. + self.assertEqual("PflOnQUAD4",pfl.getName()) + fmts0.pushBackTimeStep(f1ts) + # + f1ts=MEDFileField1TS() + fCells=MEDCouplingFieldDouble(ON_CELLS) ; fCells.setName("FieldOnCells") + arr=DataArrayDouble(24) ; arr.iota() ; arr[i%24]=30. + fCells.setArray(arr) + fCells.setTime(float(i)+0.1,i,-1) + fCells.setMesh(c) + f1ts.setFieldNoProfileSBT(fCells) + fmts1.pushBackTimeStep(f1ts) + pass + fs=MEDFileFields() + fs.pushField(fmts0) + fs.pushField(fmts1) + cc.write(fname,2) + fs.write(fname,0) + ########## GO for reading in MEDReader,by not loading all. Mesh is fully loaded but not fields values + ms=MEDFileMeshes(fname) + fields=MEDFileFields(fname,False) + fields.removeFieldsWithoutAnyTimeStep() + fields_per_mesh=[fields.partOfThisLyingOnSpecifiedMeshName(meshName) for meshName in ms.getMeshesNames()] + allFMTSLeavesToDisplay=[] + for fields in fields_per_mesh: + allFMTSLeavesToDisplay2=[] + for fmts in fields: + allFMTSLeavesToDisplay2+=fmts.splitDiscretizations() + pass + allFMTSLeavesToDisplay.append(allFMTSLeavesToDisplay2) + pass + self.assertEqual(len(allFMTSLeavesToDisplay),1) + self.assertEqual(len(allFMTSLeavesToDisplay[0]),2) + allFMTSLeavesPerTimeSeries=MEDFileAnyTypeFieldMultiTS.SplitIntoCommonTimeSeries(sum(allFMTSLeavesToDisplay,[])) + self.assertEqual(len(allFMTSLeavesPerTimeSeries),1) + self.assertEqual(len(allFMTSLeavesPerTimeSeries[0]),2) + allFMTSLeavesPerCommonSupport1=MEDFileAnyTypeFieldMultiTS.SplitPerCommonSupport(allFMTSLeavesToDisplay[0],ms[ms.getMeshesNames()[0]]) + self.assertEqual(len(allFMTSLeavesPerCommonSupport1),2) + self.assertEqual(len(allFMTSLeavesPerCommonSupport1[0][0]),1) + self.assertEqual(len(allFMTSLeavesPerCommonSupport1[1][0]),1) + # + mst=MEDFileMeshStruct.New(ms[0]) + # + fcscp=allFMTSLeavesPerCommonSupport1[0][1] + mml=fcscp.buildFromScratchDataSetSupport(0,fields) + mml2=mml.prepare() + self.assertTrue(isinstance(mml2,MEDCMeshMultiLev)) # here CMesh is important + (a,b,c),d=mml2.buildVTUArrays() + self.assertTrue(d)#d is True because the a,b and c are directly those in the internal data structure + self.assertTrue(a.isEqual(arrX,1e-12)) + self.assertTrue(b.isEqual(arrY,1e-12)) + self.assertTrue(c.isEqual(arrZ,1e-12)) + for i in xrange(30): + ffCell=allFMTSLeavesPerCommonSupport1[0][0][0][i] + fsst=MEDFileField1TSStructItem.BuildItemFrom(ffCell,mst) + ffCell.loadArraysIfNecessary() + v=mml2.buildDataArray(fsst,fields,ffCell.getUndergroundDataArray()) + self.assertEqual(v.getHiddenCppPointer(),ffCell.getUndergroundDataArray().getHiddenCppPointer()) + myarr=DataArrayDouble(24) ; myarr.iota() ; myarr[i%24]=30. + self.assertEqual(ffCell.getName(),"FieldOnCells") + self.assertTrue(v.isEqual(myarr,1e-12)) + pass + # + fcscp=allFMTSLeavesPerCommonSupport1[1][1] + mml=fcscp.buildFromScratchDataSetSupport(0,fields) + #mml2=mml.prepare() + pass pass unittest.main()