From 82a97147deebde0a6eb1904da55e7d5c690778b5 Mon Sep 17 00:00:00 2001 From: geay Date: Thu, 17 Apr 2014 10:54:25 +0200 Subject: [PATCH] Bug correction of families on faces for cartesian meshes. --- src/MEDLoader/MEDFileFieldOverView.cxx | 58 +++++++++++--------------- src/MEDLoader/MEDFileFieldOverView.hxx | 8 +++- src/MEDLoader/Swig/MEDLoaderTest4.py | 3 ++ 3 files changed, 35 insertions(+), 34 deletions(-) diff --git a/src/MEDLoader/MEDFileFieldOverView.cxx b/src/MEDLoader/MEDFileFieldOverView.cxx index 2ec178935..42b4759eb 100644 --- a/src/MEDLoader/MEDFileFieldOverView.cxx +++ b/src/MEDLoader/MEDFileFieldOverView.cxx @@ -1182,11 +1182,21 @@ void MEDUMeshMultiLev::appendVertices(const DataArrayInt *verticesToAdd, DataArr //= -MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m):MEDMeshMultiLev(m),_is_internal(true) +MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m, const std::vector& lev):MEDMeshMultiLev(m),_is_internal(true) { + initStdFieldOfIntegers(m); } -MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m, const std::vector& lev):MEDMeshMultiLev(m),_is_internal(true) +MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m, int nbOfNodes, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities):MEDMeshMultiLev(m,nbOfNodes,gts,pfls,nbEntities),_is_internal(true) +{ + initStdFieldOfIntegers(m); +} + +MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDStructuredMeshMultiLev& other):MEDMeshMultiLev(other),_is_internal(true),_face_fam_ids(other._face_fam_ids),_face_fam_ids_nocpy(other._face_fam_ids_nocpy),_face_num_ids(other._face_num_ids),_face_num_ids_nocpy(other._face_num_ids_nocpy) +{ +} + +void MEDStructuredMeshMultiLev::initStdFieldOfIntegers(const MEDFileStructuredMesh *m) { // ids fields management _cell_fam_ids_nocpy=true; _cell_num_ids_nocpy=true; @@ -1218,44 +1228,28 @@ MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDFileStructuredMesh tmp->incrRef(); _node_num_ids=const_cast(tmp); } -} - -MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m, int nbOfNodes, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities):MEDMeshMultiLev(m,nbOfNodes,gts,pfls,nbEntities),_is_internal(true) -{ - // ids fields management - _cell_fam_ids_nocpy=true; _cell_num_ids_nocpy=true; - const DataArrayInt *tmp(0); - tmp=m->getFamilyFieldAtLevel(0); - if(tmp) - { - tmp->incrRef(); - _cell_fam_ids=const_cast(tmp); - } - tmp=m->getNumberFieldAtLevel(0); - if(tmp) - { - tmp->incrRef(); - _cell_num_ids=const_cast(tmp); - } - // - _node_fam_ids_nocpy=true; _node_num_ids_nocpy=true; - tmp=0; - tmp=m->getFamilyFieldAtLevel(1); + // faces (if any) + _face_fam_ids_nocpy=true; _face_num_ids_nocpy=true; + tmp=m->getFamilyFieldAtLevel(-1); if(tmp) { tmp->incrRef(); - _node_fam_ids=const_cast(tmp); + _face_fam_ids=const_cast(tmp); } - tmp=m->getNumberFieldAtLevel(1); + tmp=m->getNumberFieldAtLevel(-1); if(tmp) { tmp->incrRef(); - _node_num_ids=const_cast(tmp); + _face_num_ids=const_cast(tmp); } } -MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDStructuredMeshMultiLev& other):MEDMeshMultiLev(other),_is_internal(true) +void MEDStructuredMeshMultiLev::moveFaceToCell() const { + const_cast(this)->_cell_fam_ids_nocpy=_face_fam_ids_nocpy; + const_cast(this)->_cell_num_ids_nocpy=_face_num_ids_nocpy; + const_cast(this)->_cell_fam_ids=_face_fam_ids; const_cast(this)->_face_fam_ids=0; + const_cast(this)->_cell_num_ids=_face_num_ids; const_cast(this)->_face_num_ids=0; } bool MEDStructuredMeshMultiLev::prepareForImplicitUnstructuredMeshCase(MEDMeshMultiLev *&ret) const @@ -1275,12 +1269,10 @@ bool MEDStructuredMeshMultiLev::prepareForImplicitUnstructuredMeshCase(MEDMeshMu if(!_pfls.empty()) pfl=_pfls[0]; MEDCouplingAutoRefCountObjectPtr facesIfPresent2(facesIfPresent); facesIfPresent->incrRef(); + moveFaceToCell(); MEDCouplingAutoRefCountObjectPtr ret2(new MEDUMeshMultiLev(*this,facesIfPresent2)); if(pfl) - { - ret2->setCellReduction(pfl); - //throw INTERP_KERNEL::Exception("MEDStructuredMeshMultiLev::prepareForImplicitUnstructuredMeshCase : case is not treated yet for profile on implicit unstructured mesh."); - } + ret2->setCellReduction(pfl); if(nr) throw INTERP_KERNEL::Exception("MEDStructuredMeshMultiLev::prepareForImplicitUnstructuredMeshCase : case is not treated yet for node reduction on implicit unstructured mesh."); ret=ret2.retn(); diff --git a/src/MEDLoader/MEDFileFieldOverView.hxx b/src/MEDLoader/MEDFileFieldOverView.hxx index bc642b319..85ddb2a5e 100644 --- a/src/MEDLoader/MEDFileFieldOverView.hxx +++ b/src/MEDLoader/MEDFileFieldOverView.hxx @@ -159,15 +159,21 @@ namespace ParaMEDMEM void selectPartOfNodes(const DataArrayInt *pflNodes); virtual std::vector getNodeGridStructure() const = 0; protected: - MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m); MEDStructuredMeshMultiLev(const MEDStructuredMeshMultiLev& other); MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m, const std::vector& lev); MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m, int nbOfNodes, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities); void dealWithImplicitUnstructuredMesh(const MEDFileMesh *m); protected: + void moveFaceToCell() const; bool prepareForImplicitUnstructuredMeshCase(MEDMeshMultiLev *&ret) const; + private: + void initStdFieldOfIntegers(const MEDFileStructuredMesh *m); protected: bool _is_internal; + MEDCouplingAutoRefCountObjectPtr _face_fam_ids; + bool _face_fam_ids_nocpy; + MEDCouplingAutoRefCountObjectPtr _face_num_ids; + bool _face_num_ids_nocpy; }; class MEDCMeshMultiLev : public MEDStructuredMeshMultiLev diff --git a/src/MEDLoader/Swig/MEDLoaderTest4.py b/src/MEDLoader/Swig/MEDLoaderTest4.py index 56d0b4a57..2425b10f6 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest4.py +++ b/src/MEDLoader/Swig/MEDLoaderTest4.py @@ -4537,6 +4537,9 @@ class MEDLoaderTest4(unittest.TestCase): 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]))) self.assertTrue(a4 is None) self.assertTrue(a5 is None) + a6,a7=mml2.retrieveFamilyIdsOnCells() + self.assertTrue(a6 is None) + self.assertTrue(a7) for i in xrange(30): ffCell=allFMTSLeavesPerCommonSupport1[1][0][0][i] fsst=MEDFileField1TSStructItem.BuildItemFrom(ffCell,mst) -- 2.39.2