From: ageay Date: Fri, 17 Jan 2014 07:06:04 +0000 (+0000) Subject: Correction of bug on Cartesian and CurveLinear mesh when a profile on that mesh leads... X-Git-Tag: V7_3_1b1^2~25 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=501e8ec34cacc31fd672d2e401e718e48e5d9905;p=modules%2Fmed.git Correction of bug on Cartesian and CurveLinear mesh when a profile on that mesh leads to cartesian/curvelinear mesh --- diff --git a/src/MEDLoader/MEDFileFieldOverView.cxx b/src/MEDLoader/MEDFileFieldOverView.cxx index c7c3e5287..da8dd8ec3 100644 --- a/src/MEDLoader/MEDFileFieldOverView.cxx +++ b/src/MEDLoader/MEDFileFieldOverView.cxx @@ -1024,11 +1024,11 @@ void MEDUMeshMultiLev::reorderNodesIfNecessary(MEDCouplingAutoRefCountObjectPtr< //= -MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev() +MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev():_is_internal(true) { } -MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m, const std::vector& lev) +MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m, const std::vector& lev):_is_internal(true) { // ids fields management _cell_fam_ids_nocpy=true; _cell_num_ids_nocpy=true; @@ -1062,7 +1062,7 @@ MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDFileStructuredMesh } } -MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m, int nbOfNodes, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities):MEDMeshMultiLev(nbOfNodes,gts,pfls,nbEntities) +MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDFileStructuredMesh *m, int nbOfNodes, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities):MEDMeshMultiLev(nbOfNodes,gts,pfls,nbEntities),_is_internal(true) { // ids fields management _cell_fam_ids_nocpy=true; _cell_num_ids_nocpy=true; @@ -1096,6 +1096,10 @@ MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDFileStructuredMesh } } +MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDStructuredMeshMultiLev& other):MEDMeshMultiLev(other),_is_internal(true) +{ +} + void MEDStructuredMeshMultiLev::selectPartOfNodes(const DataArrayInt *pflNodes) { if(!pflNodes || !pflNodes->isAllocated()) @@ -1121,10 +1125,6 @@ void MEDStructuredMeshMultiLev::selectPartOfNodes(const DataArrayInt *pflNodes) _pfls[0]=cellIdsSafe; } -MEDStructuredMeshMultiLev::MEDStructuredMeshMultiLev(const MEDStructuredMeshMultiLev& other):MEDMeshMultiLev(other) -{ -} - //= MEDCMeshMultiLev *MEDCMeshMultiLev::New(const MEDFileCMesh *m, const std::vector& levs) @@ -1203,6 +1203,7 @@ MEDMeshMultiLev *MEDCMeshMultiLev::prepare() const if(MEDCouplingStructuredMesh::IsPartStructured(pfl->begin(),pfl->end(),cgs,cellParts)) { MEDCouplingAutoRefCountObjectPtr ret(new MEDCMeshMultiLev(*this)); + ret->_is_internal=false; if(nr) { nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); } ret->_nb_entities[0]=pfl->getNumberOfTuples(); @@ -1248,8 +1249,12 @@ MEDMeshMultiLev *MEDCMeshMultiLev::prepare() const } } -std::vector< DataArrayDouble * > MEDCMeshMultiLev::buildVTUArrays() const +/*! + * \a param [out] isInternal if true the returned pointers are those in main data structure. If false those pointers have been built espacially for that method. + */ +std::vector< DataArrayDouble * > MEDCMeshMultiLev::buildVTUArrays(bool& isInternal) const { + isInternal=_is_internal; std::size_t sz(_coords.size()); std::vector< DataArrayDouble * > ret(sz); for(std::size_t i=0;i MEDCurveLinearMeshMultiLev::getNodeGridStructure() const MEDMeshMultiLev *MEDCurveLinearMeshMultiLev::prepare() const { - const DataArrayInt *pfl(_pfls[0]),*nr(_node_reduction); + const DataArrayInt *pfl(0),*nr(_node_reduction); + if(!_pfls.empty()) + pfl=_pfls[0]; MEDCouplingAutoRefCountObjectPtr nnr; std::vector cgs,ngs(getNodeGridStructure()); cgs.resize(ngs.size()); @@ -1334,6 +1341,7 @@ MEDMeshMultiLev *MEDCurveLinearMeshMultiLev::prepare() const } MEDCouplingAutoRefCountObjectPtr p(MEDCouplingStructuredMesh::BuildExplicitIdsFrom(ngs,nodeParts)); MEDCouplingAutoRefCountObjectPtr ret(new MEDCurveLinearMeshMultiLev(*this)); + ret->_is_internal=false; if(nr) { nnr=nr->deepCpy(); nnr->sort(true); ret->setNodeReduction(nnr); } ret->_nb_entities[0]=pfl->getNumberOfTuples(); @@ -1375,8 +1383,9 @@ MEDMeshMultiLev *MEDCurveLinearMeshMultiLev::prepare() const } } -void MEDCurveLinearMeshMultiLev::buildVTUArrays(DataArrayDouble *&coords, std::vector& nodeStrct) const +void MEDCurveLinearMeshMultiLev::buildVTUArrays(DataArrayDouble *&coords, std::vector& nodeStrct, bool& isInternal) const { + isInternal=_is_internal; nodeStrct=_structure; const DataArrayDouble *coo(_coords); if(!coo) diff --git a/src/MEDLoader/MEDFileFieldOverView.hxx b/src/MEDLoader/MEDFileFieldOverView.hxx index e8d13ebfe..6e5014ebf 100644 --- a/src/MEDLoader/MEDFileFieldOverView.hxx +++ b/src/MEDLoader/MEDFileFieldOverView.hxx @@ -151,6 +151,8 @@ namespace ParaMEDMEM 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); + protected: + bool _is_internal; }; class MEDCMeshMultiLev : public MEDStructuredMeshMultiLev @@ -160,7 +162,7 @@ namespace ParaMEDMEM static MEDCMeshMultiLev *New(const MEDFileCMesh *m, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities); std::vector getNodeGridStructure() const; MEDMeshMultiLev *prepare() const; - MEDLOADER_EXPORT std::vector< DataArrayDouble * > buildVTUArrays() const; + MEDLOADER_EXPORT std::vector< DataArrayDouble * > buildVTUArrays(bool& isInternal) const; private: MEDCMeshMultiLev(const MEDCMeshMultiLev& other); MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vector& levs); @@ -176,7 +178,7 @@ namespace ParaMEDMEM static MEDCurveLinearMeshMultiLev *New(const MEDFileCurveLinearMesh *m, const std::vector& gts, const std::vector& pfls , const std::vector& nbEntities); std::vector getNodeGridStructure() const; MEDMeshMultiLev *prepare() const; - MEDLOADER_EXPORT void buildVTUArrays(DataArrayDouble *&coords, std::vector& nodeStrct) const; + MEDLOADER_EXPORT void buildVTUArrays(DataArrayDouble *&coords, std::vector& nodeStrct, bool& isInternal) const; private: MEDCurveLinearMeshMultiLev(const MEDCurveLinearMeshMultiLev& other); MEDCurveLinearMeshMultiLev(const MEDFileCurveLinearMesh *m, const std::vector& levs); diff --git a/src/MEDLoader/Swig/MEDLoaderCommon.i b/src/MEDLoader/Swig/MEDLoaderCommon.i index 7c557c9ab..e3812d071 100644 --- a/src/MEDLoader/Swig/MEDLoaderCommon.i +++ b/src/MEDLoader/Swig/MEDLoaderCommon.i @@ -2969,11 +2969,17 @@ namespace ParaMEDMEM { PyObject *buildVTUArrays() const throw(INTERP_KERNEL::Exception) { - std::vector< DataArrayDouble * > objs(self->buildVTUArrays()); + bool isInternal; + std::vector< DataArrayDouble * > objs(self->buildVTUArrays(isInternal)); std::size_t sz(objs.size()); - PyObject *ret=PyList_New(sz); + PyObject *ret(PyTuple_New(2)); + PyObject *ret0=PyList_New(sz); for(std::size_t i=0;i ret1; - self->buildVTUArrays(ret0,ret1); + bool ret2; + self->buildVTUArrays(ret0,ret1,ret2); std::size_t sz(ret1.size()); - PyObject *ret=PyTuple_New(2); + PyObject *ret=PyTuple_New(3); PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(ret0),SWIGTYPE_p_ParaMEDMEM__DataArrayDouble, SWIG_POINTER_OWN | 0 )); PyObject *ret1Py=PyList_New(sz); for(std::size_t i=0;i CMesh not a UMesh - a,b=mml2.buildVTUArrays() + (a,b),c=mml2.buildVTUArrays() + self.assertTrue(not c)# c is False because this a sub support specialy built for buildVTUArrays self.assertTrue(a.isEqual(coordsX[[2,3,4]],1e-12)) self.assertTrue(b.isEqual(coordsY,1e-12)) a6,a7=mml2.retrieveFamilyIdsOnCells() @@ -1289,7 +1291,8 @@ class MEDLoaderTest4(unittest.TestCase): mml=fcscp.buildFromScratchDataSetSupport(0,fields) mml2=mml.prepare() self.assertTrue(isinstance(mml2,MEDCurveLinearMeshMultiLev)) - a,b=mml2.buildVTUArrays() + a,b,c=mml2.buildVTUArrays() + self.assertTrue(c)#True here because a is directly coming from internal data without copy self.assertTrue(a.isEqual(a0Exp,1e-12)) self.assertEqual(b,[5,3]) a6,a7=mml2.retrieveFamilyIdsOnCells() @@ -1325,7 +1328,8 @@ class MEDLoaderTest4(unittest.TestCase): mml=fcscp.buildFromScratchDataSetSupport(0,fields) mml2=mml.prepare() self.assertTrue(isinstance(mml2,MEDCurveLinearMeshMultiLev)) # here the 2nd support is a part of CMesh that is also a CMesh -> CMesh not a UMesh - a,b=mml2.buildVTUArrays() + a,b,c=mml2.buildVTUArrays() + self.assertTrue(not c)#False here because a is the result of a computation not the internal strucutre self.assertTrue(a.isEqual(a0Exp[pfl2],1e-12)) self.assertEqual(b,[3,3]) a6,a7=mml2.retrieveFamilyIdsOnCells() @@ -3472,7 +3476,8 @@ class MEDLoaderTest4(unittest.TestCase): mml=fcscp.buildFromScratchDataSetSupport(0,fields) mml2=mml.prepare() self.assertTrue(isinstance(mml2,MEDCMeshMultiLev)) - a,b,c=mml2.buildVTUArrays() + (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(arr0,1e-12)) self.assertTrue(b.isEqual(arr1,1e-12)) self.assertTrue(c.isEqual(arr2,1e-12))