From: ageay Date: Thu, 28 Nov 2013 16:46:01 +0000 (+0000) Subject: Optimization of reading process to reduce at most copies. X-Git-Tag: V7_3_0b1~22 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=7a5613bdf41382fa99817f2c549b8eab28b47057;p=modules%2Fmed.git Optimization of reading process to reduce at most copies. Externalize famIds for new MEDReader to perform filtering on output datasets. --- diff --git a/src/MEDLoader/MEDFileFieldOverView.cxx b/src/MEDLoader/MEDFileFieldOverView.cxx index c9c047ef6..ebead6485 100644 --- a/src/MEDLoader/MEDFileFieldOverView.cxx +++ b/src/MEDLoader/MEDFileFieldOverView.cxx @@ -206,6 +206,92 @@ DataArray *MEDMeshMultiLev::buildDataArray(const MEDFileField1TSStructItem& fst, return constructDataArray(fst,globs,vals); } +/*! + * \param [out] famIds - Can be null. If not null the instance has to be dealt by the caller (decrRef). + * \param [out] isWithoutCopy - When true the returned instance \a famIds if not null is directly those in the data structure. + */ +void MEDMeshMultiLev::retrieveFamilyIdsOnCells(DataArrayInt *& famIds, bool& isWithoutCopy) const +{ + const DataArrayInt *fids(_cell_fam_ids); + if(!fids) + { famIds=0; isWithoutCopy=true; return ; } + std::size_t sz(_geo_types.size()); + bool presenceOfPfls(false); + for(std::size_t i=0;i(fids); famIds->incrRef(); isWithoutCopy=_cell_fam_ids_nocpy; return ; } + //bad luck the slowest part + isWithoutCopy=false; + std::vector< MEDCouplingAutoRefCountObjectPtr > retSafe(sz); + std::vector< const DataArrayInt *> ret(sz); + int start(0); + for(std::size_t i=0;i tmp(fids->selectByTupleId2(start,start+lgth,1)); + retSafe[i]=tmp->selectByTupleIdSafe(pfl->begin(),pfl->end()); + } + else + { + retSafe[i]=fids->selectByTupleId2(start,start+lgth,1); + } + ret[i]=retSafe[i]; + start+=lgth; + } + famIds=DataArrayInt::Aggregate(ret); +} + +/*! + * \param [out] numIds - Can be null. If not null the instance has to be dealt by the caller (decrRef). + * \param [out] isWithoutCopy - When true the returned instance \a numIds if not null is directly those in the data structure. + */ +void MEDMeshMultiLev::retrieveNumberIdsOnCells(DataArrayInt *& numIds, bool& isWithoutCopy) const +{ + const DataArrayInt *nids(_cell_num_ids); + if(!nids) + { numIds=0; isWithoutCopy=true; return ; } + std::size_t sz(_geo_types.size()); + bool presenceOfPfls(false); + for(std::size_t i=0;i(nids); numIds->incrRef(); isWithoutCopy=_cell_num_ids_nocpy; return ; } + //bad luck the slowest part + isWithoutCopy=false; + std::vector< MEDCouplingAutoRefCountObjectPtr > retSafe(sz); + std::vector< const DataArrayInt *> ret(sz); + int start(0); + for(std::size_t i=0;i tmp(nids->selectByTupleId2(start,start+lgth,1)); + retSafe[i]=tmp->selectByTupleIdSafe(pfl->begin(),pfl->end()); + } + else + { + retSafe[i]=nids->selectByTupleId2(start,start+lgth,1); + } + ret[i]=retSafe[i]; + start+=lgth; + } + numIds=DataArrayInt::Aggregate(ret); +} + std::string MEDMeshMultiLev::getPflNameOfId(int id) const { std::size_t sz(_pfls.size()); @@ -382,11 +468,11 @@ DataArray *MEDMeshMultiLev::constructDataArray(const MEDFileField1TSStructItem& } } -MEDMeshMultiLev::MEDMeshMultiLev() +MEDMeshMultiLev::MEDMeshMultiLev():_nb_nodes(0),_cell_fam_ids_nocpy(false) { } -MEDMeshMultiLev::MEDMeshMultiLev(int nbNodes, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities):_geo_types(gts),_nb_entities(nbEntities),_nb_nodes(nbNodes) +MEDMeshMultiLev::MEDMeshMultiLev(int nbNodes, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities):_geo_types(gts),_nb_entities(nbEntities),_nb_nodes(nbNodes),_cell_fam_ids_nocpy(false),_cell_num_ids_nocpy(false) { std::size_t sz(_geo_types.size()); if(sz!=pfls.size() || sz!=nbEntities.size()) @@ -400,7 +486,7 @@ MEDMeshMultiLev::MEDMeshMultiLev(int nbNodes, const std::vector _parts.resize(sz); _pfls.resize(sz); _geo_types.resize(sz); + _nb_entities.resize(sz); for(std::size_t i=0;i throw INTERP_KERNEL::Exception("MEDUMeshMultiLev constructor : presence of a null pointer !"); _parts[i]=obj; _geo_types[i]=obj->getCellModelEnum(); + _nb_entities[i]=obj->getNumberOfCells(); + } + // ids fields management + _cell_fam_ids_nocpy=(levs.size()==1); + if(_cell_fam_ids_nocpy) + { + const DataArrayInt *tmp(m->getFamilyFieldAtLevel(levs[0])); + if(tmp) + { + tmp->incrRef(); + _cell_fam_ids=(const_cast(tmp)); + } + } + else + { + std::vector tmps(levs.size()); + bool f(true); + for(std::size_t i=0;igetFamilyFieldAtLevel(levs[i]); + if(!tmps[i]) + f=false; + } + if(f) + _cell_fam_ids=DataArrayInt::Aggregate(tmps); + } + _cell_num_ids_nocpy=(levs.size()==1); + if(_cell_num_ids_nocpy) + { + const DataArrayInt *tmp(m->getNumberFieldAtLevel(levs[0])); + if(tmp) + { + tmp->incrRef(); + _cell_num_ids=(const_cast(tmp)); + } + } + else + { + std::vector tmps(levs.size()); + bool n(true); + for(std::size_t i=0;igetNumberFieldAtLevel(levs[i]); + if(!tmps[i]) + n=false; + } + if(n) + _cell_num_ids=DataArrayInt::Aggregate(tmps); } } @@ -453,6 +588,20 @@ MEDUMeshMultiLev::MEDUMeshMultiLev(const MEDFileUMesh *m, const std::vectorincrRef(); _parts[i]=elt; } + // ids fields management + _cell_fam_ids_nocpy=false; + std::vector< MEDCouplingAutoRefCountObjectPtr > famIdsSafe(sz); + std::vector famIds(sz); + bool f(true); + for(std::size_t i=0;iextractFamilyFieldOnGeoType(gts[i]); + famIds[i]=famIdsSafe[i]; + if(!famIds[i]) + f=false; + } + if(f) + _cell_fam_ids=DataArrayInt::Aggregate(famIds); } void MEDUMeshMultiLev::selectPartOfNodes(const DataArrayInt *pflNodes) @@ -793,6 +942,21 @@ MEDCMeshMultiLev::MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vector throw INTERP_KERNEL::Exception("MEDCMeshMultiLev constructor 2 : presence of null pointer for an vector of double along an axis !"); _coords[i]=elt; } + // 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); + } } MEDCMeshMultiLev::MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities):MEDStructuredMeshMultiLev(m->getNumberOfNodes(),gts,pfls,nbEntities) @@ -813,6 +977,21 @@ MEDCMeshMultiLev::MEDCMeshMultiLev(const MEDFileCMesh *m, const std::vectorincrRef(); } + // 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); + } } MEDCMeshMultiLev::MEDCMeshMultiLev(const MEDCMeshMultiLev& other):MEDStructuredMeshMultiLev(other),_coords(other._coords) @@ -908,6 +1087,21 @@ MEDCurveLinearMeshMultiLev::MEDCurveLinearMeshMultiLev(const MEDFileCurveLinearM coords->incrRef(); _coords=coords; _structure=m->getMesh()->getNodeGridStructure(); + // 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); + } } MEDCurveLinearMeshMultiLev::MEDCurveLinearMeshMultiLev(const MEDFileCurveLinearMesh *m, const std::vector& gts, const std::vector& pfls, const std::vector& nbEntities):MEDStructuredMeshMultiLev(m->getNumberOfNodes(),gts,pfls,nbEntities) @@ -925,6 +1119,21 @@ MEDCurveLinearMeshMultiLev::MEDCurveLinearMeshMultiLev(const MEDFileCurveLinearM coords->incrRef(); _coords=coords; _structure=m->getMesh()->getNodeGridStructure(); + // 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); + } } MEDCurveLinearMeshMultiLev::MEDCurveLinearMeshMultiLev(const MEDCurveLinearMeshMultiLev& other):MEDStructuredMeshMultiLev(other),_coords(other._coords),_structure(other._structure) diff --git a/src/MEDLoader/MEDFileFieldOverView.hxx b/src/MEDLoader/MEDFileFieldOverView.hxx index ff4ce6c41..3b5aea18b 100644 --- a/src/MEDLoader/MEDFileFieldOverView.hxx +++ b/src/MEDLoader/MEDFileFieldOverView.hxx @@ -80,6 +80,8 @@ namespace ParaMEDMEM void setNodeReduction(const DataArrayInt *nr); bool isFastlyTheSameStruct(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs) const; MEDLOADER_EXPORT DataArray *buildDataArray(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs, const DataArray *vals) const; + MEDLOADER_EXPORT void retrieveFamilyIdsOnCells(DataArrayInt *& famIds, bool& isWithoutCopy) const; + MEDLOADER_EXPORT void retrieveNumberIdsOnCells(DataArrayInt *& numIds, bool& isWithoutCopy) const; virtual void selectPartOfNodes(const DataArrayInt *pflNodes) = 0; virtual MEDMeshMultiLev *prepare() const = 0; int getNumberOfCells(INTERP_KERNEL::NormalizedCellType t) const; @@ -97,6 +99,11 @@ namespace ParaMEDMEM std::vector _nb_entities; MEDCouplingAutoRefCountObjectPtr _node_reduction; int _nb_nodes; + // + MEDCouplingAutoRefCountObjectPtr _cell_fam_ids; + bool _cell_fam_ids_nocpy; + MEDCouplingAutoRefCountObjectPtr _cell_num_ids; + bool _cell_num_ids_nocpy; public: static const int PARAMEDMEM_2_VTKTYPE_LGTH=34; static const unsigned char PARAMEDMEM_2_VTKTYPE[PARAMEDMEM_2_VTKTYPE_LGTH]; diff --git a/src/MEDLoader/MEDFileMesh.cxx b/src/MEDLoader/MEDFileMesh.cxx index a873bdfae..2e7760173 100644 --- a/src/MEDLoader/MEDFileMesh.cxx +++ b/src/MEDLoader/MEDFileMesh.cxx @@ -2966,6 +2966,36 @@ MEDCoupling1GTUMesh *MEDFileUMesh::getDirectUndergroundSingleGeoTypeMesh(INTERP_ return sp->getDirectUndergroundSingleGeoTypeMesh(gt); } +/*! + * This method extracts from whole family field ids the part relative to the input parameter \a gt. + * \param [in] gt - the geometric type for which the family field is asked. + * \return DataArrayInt * - a pointer to DataArrayInt that the caller is to + * delete using decrRef() as it is no more needed. + * \sa MEDFileUMesh::extractNumberFieldOnGeoType + */ +DataArrayInt *MEDFileUMesh::extractFamilyFieldOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const +{ + const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(gt); + int lev=(int)cm.getDimension()-getMeshDimension(); + const MEDFileUMeshSplitL1 *sp(getMeshAtLevSafe(lev)); + return sp->extractFamilyFieldOnGeoType(gt); +} + +/*! + * This method extracts from whole number field ids the part relative to the input parameter \a gt. + * \param [in] gt - the geometric type for which the number field is asked. + * \return DataArrayInt * - a pointer to DataArrayInt that the caller is to + * delete using decrRef() as it is no more needed. + * \sa MEDFileUMesh::extractFamilyFieldOnGeoType + */ +DataArrayInt *MEDFileUMesh::extractNumberFieldOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const +{ + const INTERP_KERNEL::CellModel& cm=INTERP_KERNEL::CellModel::GetCellModel(gt); + int lev=(int)cm.getDimension()-getMeshDimension(); + const MEDFileUMeshSplitL1 *sp(getMeshAtLevSafe(lev)); + return sp->extractNumberFieldOnGeoType(gt); +} + const MEDFileUMeshSplitL1 *MEDFileUMesh::getMeshAtLevSafe(int meshDimRelToMaxExt) const { if(meshDimRelToMaxExt==1) diff --git a/src/MEDLoader/MEDFileMesh.hxx b/src/MEDLoader/MEDFileMesh.hxx index 87455300a..564d8a0af 100644 --- a/src/MEDLoader/MEDFileMesh.hxx +++ b/src/MEDLoader/MEDFileMesh.hxx @@ -244,6 +244,8 @@ namespace ParaMEDMEM MEDLOADER_EXPORT MEDCouplingUMesh *getLevelM3Mesh(bool renum=false) const; MEDLOADER_EXPORT std::vector getDirectUndergroundSingleGeoTypeMeshes(int meshDimRelToMax) const; MEDLOADER_EXPORT MEDCoupling1GTUMesh *getDirectUndergroundSingleGeoTypeMesh(INTERP_KERNEL::NormalizedCellType gt) const; + MEDLOADER_EXPORT DataArrayInt *extractFamilyFieldOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const; + MEDLOADER_EXPORT DataArrayInt *extractNumberFieldOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const; // MEDLOADER_EXPORT void setFamilyNameAttachedOnId(int id, const std::string& newFamName); MEDLOADER_EXPORT void setCoords(DataArrayDouble *coords); diff --git a/src/MEDLoader/MEDFileMeshLL.cxx b/src/MEDLoader/MEDFileMeshLL.cxx index cbc4dc6e6..595a22e2d 100644 --- a/src/MEDLoader/MEDFileMeshLL.cxx +++ b/src/MEDLoader/MEDFileMeshLL.cxx @@ -535,13 +535,25 @@ MEDFileUMeshSplitL1::MEDFileUMeshSplitL1(const MEDFileUMeshL2& l2, const char *m { for(int i=0;igetFam(); - _fam=DataArrayInt::Aggregate(fams); + if(sz!=1) + _fam=DataArrayInt::Aggregate(fams); + else + { + fams[0]->incrRef(); + _fam=const_cast(fams[0]); + } } if(l2.isNumDefinedOnLev(id)) { for(int i=0;igetNum(); - _num=DataArrayInt::Aggregate(nums); + if(sz!=1) + _num=DataArrayInt::Aggregate(nums); + else + { + nums[0]->incrRef(); + _num=const_cast(nums[0]); + } computeRevNum(); } if(l2.isNamesDefinedOnLev(id)) @@ -775,6 +787,26 @@ MEDCouplingUMesh *MEDFileUMeshSplitL1::getWholeMesh(bool renum) const return tmp.retn(); } +DataArrayInt *MEDFileUMeshSplitL1::extractFamilyFieldOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const +{ + const DataArrayInt *fam(_fam); + if(!fam) + return 0; + int start(0),stop(0); + _m_by_types.getStartStopOfGeoTypeWithoutComputation(gt,start,stop); + return fam->selectByTupleId2(start,stop,1); +} + +DataArrayInt *MEDFileUMeshSplitL1::extractNumberFieldOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const +{ + const DataArrayInt *num(_num); + if(!num) + return 0; + int start(0),stop(0); + _m_by_types.getStartStopOfGeoTypeWithoutComputation(gt,start,stop); + return num->selectByTupleId2(start,stop,1); +} + DataArrayInt *MEDFileUMeshSplitL1::getOrCreateAndGetFamilyField() { if((DataArrayInt *)_fam) @@ -1044,6 +1076,27 @@ MEDCoupling1GTUMesh *MEDFileUMeshAggregateCompute::getPartWithoutComputation(INT throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getPartWithoutComputation : the geometric type is not existing !"); } +void MEDFileUMeshAggregateCompute::getStartStopOfGeoTypeWithoutComputation(INTERP_KERNEL::NormalizedCellType gt, int& start, int& stop) const +{ + start=0; stop=0; + std::vector v(getPartsWithoutComputation()); + std::size_t sz(v.size()); + for(std::size_t i=0;igetCellModelEnum()==gt) + { + stop=start+v[i]->getNumberOfCells(); + return; + } + else + start+=v[i]->getNumberOfCells(); + } + } + throw INTERP_KERNEL::Exception("MEDFileUMeshAggregateCompute::getStartStopOfGeoTypeWithoutComputation : the geometric type is not existing !"); +} + void MEDFileUMeshAggregateCompute::forceComputationOfPartsFromUMesh() const { const MEDCouplingUMesh *m(_m); diff --git a/src/MEDLoader/MEDFileMeshLL.hxx b/src/MEDLoader/MEDFileMeshLL.hxx index 172b9c8d5..4857330d7 100644 --- a/src/MEDLoader/MEDFileMeshLL.hxx +++ b/src/MEDLoader/MEDFileMeshLL.hxx @@ -147,6 +147,7 @@ namespace ParaMEDMEM std::vector getParts() const; std::vector getPartsWithoutComputation() const; MEDCoupling1GTUMesh *getPartWithoutComputation(INTERP_KERNEL::NormalizedCellType gt) const; + void getStartStopOfGeoTypeWithoutComputation(INTERP_KERNEL::NormalizedCellType gt, int& start, int& stop) const; std::size_t getTimeOfThis() const; std::size_t getHeapMemorySizeWithoutChildren() const; std::vector getDirectChildren() const; @@ -198,6 +199,8 @@ namespace ParaMEDMEM MEDCouplingUMesh *getWholeMesh(bool renum) const; std::vector getDirectUndergroundSingleGeoTypeMeshes() const { return _m_by_types.getPartsWithoutComputation(); } MEDCoupling1GTUMesh *getDirectUndergroundSingleGeoTypeMesh(INTERP_KERNEL::NormalizedCellType gt) const { return _m_by_types.getPartWithoutComputation(gt); } + DataArrayInt *extractFamilyFieldOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const; + DataArrayInt *extractNumberFieldOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const; std::vector getDistributionOfTypes() const { return _m_by_types.getDistributionOfTypes(); } DataArrayInt *getOrCreateAndGetFamilyField(); const DataArrayInt *getFamilyField() const; diff --git a/src/MEDLoader/Swig/MEDLoaderCommon.i b/src/MEDLoader/Swig/MEDLoaderCommon.i index 7d915e52a..b515d136c 100644 --- a/src/MEDLoader/Swig/MEDLoaderCommon.i +++ b/src/MEDLoader/Swig/MEDLoaderCommon.i @@ -105,6 +105,8 @@ using namespace ParaMEDMEM; %newobject ParaMEDMEM::MEDFileUMesh::getLevelM2Mesh; %newobject ParaMEDMEM::MEDFileUMesh::getLevelM3Mesh; %newobject ParaMEDMEM::MEDFileUMesh::getDirectUndergroundSingleGeoTypeMesh; +%newobject ParaMEDMEM::MEDFileUMesh::extractFamilyFieldOnGeoType; +%newobject ParaMEDMEM::MEDFileUMesh::extractNumberFieldOnGeoType; %newobject ParaMEDMEM::MEDFileUMesh::zipCoords; %newobject ParaMEDMEM::MEDFileCMesh::New; %newobject ParaMEDMEM::MEDFileCurveLinearMesh::New; @@ -734,6 +736,8 @@ namespace ParaMEDMEM void setMeshAtLevel(int meshDimRelToMax, MEDCouplingUMesh *m, bool newOrOld=false) throw(INTERP_KERNEL::Exception); void optimizeFamilies() throw(INTERP_KERNEL::Exception); DataArrayInt *zipCoords() throw(INTERP_KERNEL::Exception); + DataArrayInt *extractFamilyFieldOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const throw(INTERP_KERNEL::Exception); + DataArrayInt *extractNumberFieldOnGeoType(INTERP_KERNEL::NormalizedCellType gt) const throw(INTERP_KERNEL::Exception); %extend { MEDFileUMesh(const char *fileName, const char *mName, int dt=-1, int it=-1, MEDFileMeshReadSelector *mrs=0) throw(INTERP_KERNEL::Exception) @@ -2835,6 +2839,35 @@ namespace ParaMEDMEM DataArray *buildDataArray(const MEDFileField1TSStructItem& fst, const MEDFileFieldGlobsReal *globs, const DataArray *vals) const throw(INTERP_KERNEL::Exception); protected: ~MEDMeshMultiLev(); + public: + %extend + { + PyObject *retrieveFamilyIdsOnCells() const throw(INTERP_KERNEL::Exception) + { + DataArrayInt *famIds(0); + bool isWithoutCopy(false); + self->retrieveFamilyIdsOnCells(famIds,isWithoutCopy); + PyObject *ret=PyTuple_New(2); + PyObject *ret1Py=isWithoutCopy?Py_True:Py_False; + Py_XINCREF(ret1Py); + PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(famIds),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,ret1Py); + return ret; + } + + PyObject *retrieveNumberIdsOnCells() const throw(INTERP_KERNEL::Exception) + { + DataArrayInt *numIds(0); + bool isWithoutCopy(false); + self->retrieveNumberIdsOnCells(numIds,isWithoutCopy); + PyObject *ret=PyTuple_New(2); + PyObject *ret1Py=isWithoutCopy?Py_True:Py_False; + Py_XINCREF(ret1Py); + PyTuple_SetItem(ret,0,SWIG_NewPointerObj(SWIG_as_voidptr(numIds),SWIGTYPE_p_ParaMEDMEM__DataArrayInt, SWIG_POINTER_OWN | 0 )); + PyTuple_SetItem(ret,1,ret1Py); + return ret; + } + } }; class MEDUMeshMultiLev : public MEDMeshMultiLev diff --git a/src/MEDLoader/Swig/MEDLoaderTest4.py b/src/MEDLoader/Swig/MEDLoaderTest4.py index 71b025dd3..203d24288 100644 --- a/src/MEDLoader/Swig/MEDLoaderTest4.py +++ b/src/MEDLoader/Swig/MEDLoaderTest4.py @@ -50,6 +50,8 @@ class MEDLoaderTest4(unittest.TestCase): m.setName("mesh") ; m.getCoords().setInfoOnComponents(["XX [m]","YYY [km]"]) m1=m.buildDescendingConnectivity()[0] mm=MEDFileUMesh() ; mm.setMeshes([m,m1]) + fam=DataArrayInt(9) ; fam.iota(0) ; mm.setFamilyFieldArr(0,fam) + fam=DataArrayInt(32) ; fam.iota(20) ; mm.setFamilyFieldArr(-1,fam) # fieldName="zeField" fs=MEDFileFieldMultiTS() @@ -182,6 +184,9 @@ class MEDLoaderTest4(unittest.TestCase): self.assertTrue(a3.isEqual(DataArrayInt([2,0,1,2,1,2,2,2,0,2,3,4,2,4,5,2,5,3,2,6,7,2,7,8,2,8,6,2,9,10,2,10,11,2,11,9,2,12,13,2,13,14,2,14,15,2,15,12,2,16,17,2,17,18,2,18,19,2,19,16,2,20,21,2,21,22,2,22,23,2,23,20,2,24,25,2,25,26,2,26,27,2,27,24,2,28,29,2,29,30,2,30,31,2,31,28,3,0,1,2,3,3,4,5,3,6,7,8,3,9,10,11,4,12,13,14,15,4,16,17,18,19,4,20,21,22,23,4,24,25,26,27,4,28,29,30,31]))) self.assertTrue(a4 is None) self.assertTrue(a5 is None) + a6,a7=mml2.retrieveFamilyIdsOnCells() + self.assertTrue(a6.isEqual(DataArrayInt([20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,0,1,2,3,4,5,6,7,8]))) + self.assertTrue(not a7) for i in xrange(5): fsst=MEDFileField1TSStructItem.BuildItemFrom(fields[0][i],mst) fields[0][i].loadArraysIfNecessary()