From 8538c34eedffc9e9ed9e856a2a5f8fe62cc9e473 Mon Sep 17 00:00:00 2001 From: geay Date: Thu, 19 Jun 2014 18:08:38 +0200 Subject: [PATCH] MEDCouplingAMRAttribute.projectTo method to keep precision after a remesh. --- doc/doxygen/Doxyfile_med_user.in | 3 + src/MEDCoupling/MEDCouplingAMRAttribute.cxx | 177 ++++++++++++++++++ src/MEDCoupling/MEDCouplingAMRAttribute.hxx | 14 ++ .../MEDCouplingCartesianAMRMesh.cxx | 44 +++++ .../MEDCouplingCartesianAMRMesh.hxx | 3 + src/MEDCoupling/MEDCouplingStructuredMesh.cxx | 47 +++++ src/MEDCoupling/MEDCouplingStructuredMesh.hxx | 2 + src/MEDCoupling_Swig/MEDCouplingBasicsTest.py | 24 +++ src/MEDCoupling_Swig/MEDCouplingCommon.i | 27 +++ 9 files changed, 341 insertions(+) diff --git a/doc/doxygen/Doxyfile_med_user.in b/doc/doxygen/Doxyfile_med_user.in index 18b827dd7..99edbea32 100644 --- a/doc/doxygen/Doxyfile_med_user.in +++ b/doc/doxygen/Doxyfile_med_user.in @@ -126,6 +126,7 @@ FILE_PATTERNS = InterpKernelDEC.* \ MEDCoupling1GTUMesh.* \ MEDCouplingPointSet.* \ MEDCouplingCMesh.* \ + MEDCouplingIMesh.* \ MEDCouplingStructuredMesh.* \ MEDCouplingCurveLinearMesh.* \ MEDCouplingExtrudedMesh.* \ @@ -136,6 +137,8 @@ FILE_PATTERNS = InterpKernelDEC.* \ MEDCouplingFieldTemplate.* \ MEDCouplingFieldDiscretization.* \ MEDCouplingTimeDiscretization.* \ + MEDCouplingAMRAttribute.* \ + MEDCouplingCartesianAMRMesh.* \ MEDCouplingTimeLabel.* \ MEDCouplingRefCountObject.* \ MEDCouplingMemArray.* \ diff --git a/src/MEDCoupling/MEDCouplingAMRAttribute.cxx b/src/MEDCoupling/MEDCouplingAMRAttribute.cxx index 07d1b90bb..302e8185f 100644 --- a/src/MEDCoupling/MEDCouplingAMRAttribute.cxx +++ b/src/MEDCoupling/MEDCouplingAMRAttribute.cxx @@ -51,6 +51,21 @@ void DataArrayDoubleCollection::dellocTuples() _arrs[i].first->reAlloc(0); } +void DataArrayDoubleCollection::copyFrom(const DataArrayDoubleCollection& other) +{ + std::size_t sz(_arrs.size()); + if(sz!=other._arrs.size()) + throw INTERP_KERNEL::Exception("DataArrayDoubleCollection::copyFrom : size are not the same !"); + for(std::size_t i=0;icpyFrom(*otherArr); + } +} + void DataArrayDoubleCollection::spillInfoOnComponents(const std::vector< std::vector >& compNames) { std::size_t sz(_arrs.size()); @@ -75,6 +90,29 @@ void DataArrayDoubleCollection::spillNatures(const std::vector& n } } +std::vector< std::pair < std::string, std::vector > > DataArrayDoubleCollection::getInfoOnComponents() const +{ + std::size_t sz(_arrs.size()); + std::vector< std::pair < std::string, std::vector > > ret(sz); + for(std::size_t i=0;i >(elt->getName(),elt->getInfoOnComponents()); + } + return ret; +} + +std::vector DataArrayDoubleCollection::getNatures() const +{ + std::size_t sz(_arrs.size()); + std::vector ret(sz); + for(std::size_t i=0;i DataArrayDoubleCollection::retrieveFields() const { std::size_t sz(_arrs.size()); @@ -108,6 +146,25 @@ const DataArrayDouble *DataArrayDoubleCollection::getFieldWithName(const std::st throw INTERP_KERNEL::Exception(oss.str().c_str()); } +DataArrayDouble *DataArrayDoubleCollection::at(int pos) +{ + if(pos<0 || pos>=(int)_arrs.size()) + throw INTERP_KERNEL::Exception("DataArrayDoubleCollection::at (non const) : pos must be in [0,nbOfFields) !"); + return _arrs[pos].first; +} + +const DataArrayDouble *DataArrayDoubleCollection::at(int pos) const +{ + if(pos<0 || pos>=(int)_arrs.size()) + throw INTERP_KERNEL::Exception("DataArrayDoubleCollection::at : pos must be in [0,nbOfFields) !"); + return _arrs[pos].first; +} + +int DataArrayDoubleCollection::size() const +{ + return (int)_arrs.size(); +} + void DataArrayDoubleCollection::SynchronizeFineToCoarse(int ghostLev, const MEDCouplingCartesianAMRMeshGen *fatherOfFineMesh, int patchId, const DataArrayDoubleCollection *fine, DataArrayDoubleCollection *coarse) { if(!fine || !coarse) @@ -342,6 +399,26 @@ void MEDCouplingGridCollection::spillNatures(const std::vector& n (*it).second->spillNatures(nfs); } +std::vector< std::pair > > MEDCouplingGridCollection::getInfoOnComponents() const +{ + if(_map_of_dadc.empty()) + throw INTERP_KERNEL::Exception("MEDCouplingGridCollection::getInfoOnComponents : empty map !"); + const DataArrayDoubleCollection *elt(_map_of_dadc[0].second); + if(!elt) + throw INTERP_KERNEL::Exception("MEDCouplingGridCollection::getInfoOnComponents : null pointer !"); + return elt->getInfoOnComponents(); +} + +std::vector MEDCouplingGridCollection::getNatures() const +{ + if(_map_of_dadc.empty()) + throw INTERP_KERNEL::Exception("MEDCouplingGridCollection::getNatures : empty map !"); + const DataArrayDoubleCollection *elt(_map_of_dadc[0].second); + if(!elt) + throw INTERP_KERNEL::Exception("MEDCouplingGridCollection::getNatures : null pointer !"); + return elt->getNatures(); +} + bool MEDCouplingGridCollection::presenceOf(const MEDCouplingCartesianAMRMeshGen *m, int& pos) const { int ret(0); @@ -363,6 +440,52 @@ const DataArrayDoubleCollection& MEDCouplingGridCollection::getFieldsAt(int pos) return *_map_of_dadc[pos].second; } +DataArrayDoubleCollection& MEDCouplingGridCollection::getFieldsAt(int pos) +{ + if(pos<0 || pos>(int)_map_of_dadc.size()) + throw INTERP_KERNEL::Exception("MEDCouplingGridCollection::getFieldsAt (non const) : invalid pos given in input ! Must be in [0,size) !"); + return *_map_of_dadc[pos].second; +} + +/*! + * This method copies for all grids intersecting themselves (between \a this and \a other), the values of fields of \a other to the intersecting + * part of fields of \a this. The fields are expected to be the same between \a other and \a this. + * This methods makes the hypothesis that \a this and \a other share two god father that are compatible each other that is to say with the same cell grid structure. + */ +void MEDCouplingGridCollection::copyOverlappedZoneFrom(int ghostLev, const MEDCouplingGridCollection& other) +{ + for(std::vector< std::pair > >::iterator it=_map_of_dadc.begin();it!=_map_of_dadc.end();it++) + { + std::vector deltaThis,deltaOther; + std::vector< std::pair > rgThis((*it).first->positionRelativeToGodFather(deltaThis)); + std::vector thisSt((*it).first->getImageMesh()->getCellGridStructure()); + std::transform(thisSt.begin(),thisSt.end(),thisSt.begin(),std::bind2nd(std::plus(),2*ghostLev)); + for(std::vector< std::pair > >::const_iterator it2=other._map_of_dadc.begin();it2!=other._map_of_dadc.end();it2++) + { + std::vector< std::pair > rgOther((*it2).first->positionRelativeToGodFather(deltaOther)); + if(MEDCouplingStructuredMesh::AreRangesIntersect(rgThis,rgOther)) + { + std::vector< std::pair > isect(MEDCouplingStructuredMesh::IntersectRanges(rgThis,rgOther)); + std::vector< std::pair > pThis,pOther; + MEDCouplingStructuredMesh::ChangeReferenceFromGlobalOfCompactFrmt(rgThis,isect,pThis,true); + MEDCouplingStructuredMesh::ChangeReferenceFromGlobalOfCompactFrmt(rgOther,isect,pOther,true); + std::vector otherSt((*it2).first->getImageMesh()->getCellGridStructure()); + MEDCouplingStructuredMesh::ApplyGhostOnCompactFrmt(pThis,ghostLev); + MEDCouplingStructuredMesh::ApplyGhostOnCompactFrmt(pOther,ghostLev); + std::transform(otherSt.begin(),otherSt.end(),otherSt.begin(),std::bind2nd(std::plus(),2*ghostLev)); + int sz((*it2).second->size()); + for(int i=0;iat(i)); + DataArrayDouble *thisArr((*it).second->at(i)); + MEDCouplingAutoRefCountObjectPtr partOfOther(MEDCouplingStructuredMesh::ExtractFieldOfDoubleFrom(otherSt,otherArr,pOther)); + MEDCouplingStructuredMesh::AssignPartOfFieldOfDoubleUsing(thisSt,thisArr,pThis,partOfOther); + } + } + } + } +} + void MEDCouplingGridCollection::SynchronizeFineToCoarse(int ghostLev, const MEDCouplingGridCollection *fine, const MEDCouplingGridCollection *coarse) { if(!fine || !coarse) @@ -591,6 +714,11 @@ MEDCouplingCartesianAMRMesh *MEDCouplingDataForGodFather::getMyGodFather() return _gf; } +const MEDCouplingCartesianAMRMesh *MEDCouplingDataForGodFather::getMyGodFather() const +{ + return _gf; +} + MEDCouplingDataForGodFather::MEDCouplingDataForGodFather(MEDCouplingCartesianAMRMesh *gf):_gf(gf),_tlc(gf) { if(!gf) @@ -833,6 +961,55 @@ MEDCouplingFieldDouble *MEDCouplingAMRAttribute::buildCellFieldOnWithoutGhost(ME return ret.retn(); } +/*! + * This method is useful just after a remesh after a time step computation to project values in \a this to the new + * mesh \a targetGF. + * + * This method performs a projection from \a this to a target AMR mesh \a targetGF. + * This method performs the projection by trying to transfer the finest information to \a targetGF. + * \b WARNING this method does not update the ghost zone, if any. + * The level0 of \a this god father must have the same structure than those of \a targetGF. + * + * This method makes checks that ghost size of \a this and \a targetGF are the same, and that + * the number of levels in \a this and in \a targetGF are also the same. + */ +MEDCouplingAMRAttribute *MEDCouplingAMRAttribute::projectTo(MEDCouplingCartesianAMRMesh *targetGF) const +{ + if(!targetGF) + throw INTERP_KERNEL::Exception("MEDCouplingAMRAttribute::projectTo : given other target god is NULL !"); + if(_levs.empty()) + throw INTERP_KERNEL::Exception("MEDCouplingAMRAttribute::projectTo : no levels in this !"); + const MEDCouplingGridCollection *lev0(_levs[0]); + if(!lev0) + throw INTERP_KERNEL::Exception("MEDCouplingAMRAttribute::projectTo : lev0 is NULL !"); + std::vector< std::pair < std::string, std::vector > > fieldNames(lev0->getInfoOnComponents()); + MEDCouplingAutoRefCountObjectPtr ret(MEDCouplingAMRAttribute::New(targetGF,fieldNames,_ghost_lev)); + ret->spillNatures(lev0->getNatures()); + ret->alloc(); + int nbLevs(getNumberOfLevels()); + if(targetGF->getMaxNumberOfLevelsRelativeToThis()!=nbLevs) + throw INTERP_KERNEL::Exception("MEDCouplingAMRAttribute::projectTo : number of levels of this and targetGF must be the same !"); + // first step copy level0 + if(getMyGodFather()->getImageMesh()->getCellGridStructure()!=targetGF->getImageMesh()->getCellGridStructure()) + throw INTERP_KERNEL::Exception("MEDCouplingAMRAttribute::projectTo : god father of this and target ones do not have the same structure !"); + const DataArrayDoubleCollection& col(lev0->getFieldsAt(0)); + DataArrayDoubleCollection& colTarget(ret->_levs[0]->getFieldsAt(0)); + colTarget.copyFrom(col); + // then go deeper and deeper + for(int i=1;isynchronizeCoarseToFineByOneLevel(i-1); + MEDCouplingGridCollection *targetCol(ret->_levs[i]); + if(!targetCol) + throw INTERP_KERNEL::Exception("MEDCouplingAMRAttribute::projectTo : null lev of target !"); + const MEDCouplingGridCollection *thisCol(_levs[i]); + if(!thisCol) + throw INTERP_KERNEL::Exception("MEDCouplingAMRAttribute::projectTo : null lev of this !"); + targetCol->copyOverlappedZoneFrom(_ghost_lev,*thisCol); + } + return ret.retn(); +} + /*! * This method synchronizes from fine to coarse direction arrays. This method makes the hypothesis that \a this has been allocated before using * MEDCouplingAMRAttribute::alloc method. diff --git a/src/MEDCoupling/MEDCouplingAMRAttribute.hxx b/src/MEDCoupling/MEDCouplingAMRAttribute.hxx index 3d5727429..3a8b7d32f 100644 --- a/src/MEDCoupling/MEDCouplingAMRAttribute.hxx +++ b/src/MEDCoupling/MEDCouplingAMRAttribute.hxx @@ -35,10 +35,16 @@ namespace ParaMEDMEM DataArrayDoubleCollection *deepCpy() const; void allocTuples(int nbOfTuples); void dellocTuples(); + void copyFrom(const DataArrayDoubleCollection& other); void spillInfoOnComponents(const std::vector< std::vector >& compNames); void spillNatures(const std::vector& nfs); + std::vector< std::pair > > getInfoOnComponents() const; + std::vector getNatures() const; std::vector retrieveFields() const; const DataArrayDouble *getFieldWithName(const std::string& name) const; + DataArrayDouble *at(int pos); + const DataArrayDouble *at(int pos) const; + int size() const; static void SynchronizeFineToCoarse(int ghostLev, const MEDCouplingCartesianAMRMeshGen *fatherOfFineMesh, int patchId, const DataArrayDoubleCollection *fine, DataArrayDoubleCollection *coarse); static void SynchronizeCoarseToFine(int ghostLev, const MEDCouplingCartesianAMRMeshGen *fatherOfFineMesh, int patchId, const DataArrayDoubleCollection *coarse, DataArrayDoubleCollection *fine); static void SynchronizeFineEachOther(int patchId, int ghostLev, const MEDCouplingCartesianAMRMeshGen *fatherOfFineMesh, const std::vector& children, const std::vector& fieldsOnFine); @@ -69,8 +75,12 @@ namespace ParaMEDMEM void dealloc(); void spillInfoOnComponents(const std::vector< std::vector >& compNames); void spillNatures(const std::vector& nfs); + std::vector< std::pair > > getInfoOnComponents() const; + std::vector getNatures() const; bool presenceOf(const MEDCouplingCartesianAMRMeshGen *m, int& pos) const; const DataArrayDoubleCollection& getFieldsAt(int pos) const; + DataArrayDoubleCollection& getFieldsAt(int pos); + void copyOverlappedZoneFrom(int ghostLev, const MEDCouplingGridCollection& other); static void SynchronizeFineToCoarse(int ghostLev, const MEDCouplingGridCollection *fine, const MEDCouplingGridCollection *coarse); static void SynchronizeCoarseToFine(int ghostLev, const MEDCouplingGridCollection *coarse, const MEDCouplingGridCollection *fine); void synchronizeFineEachOther(int ghostLev, const std::vector< std::pair >& ps) const; @@ -95,6 +105,7 @@ namespace ParaMEDMEM friend class MEDCouplingCartesianAMRMesh; public: MEDCOUPLING_EXPORT MEDCouplingCartesianAMRMesh *getMyGodFather(); + MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRMesh *getMyGodFather() const; MEDCOUPLING_EXPORT virtual void synchronizeFineToCoarse() = 0; MEDCOUPLING_EXPORT virtual void synchronizeFineToCoarseBetween(int fromLev, int toLev) = 0; MEDCOUPLING_EXPORT virtual void synchronizeCoarseToFine() = 0; @@ -132,6 +143,8 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildCellFieldOnWithGhost(MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) const; MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildCellFieldOnWithoutGhost(MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) const; // + MEDCOUPLING_EXPORT MEDCouplingAMRAttribute *projectTo(MEDCouplingCartesianAMRMesh *targetGF) const; + // MEDCOUPLING_EXPORT void synchronizeFineToCoarse(); MEDCOUPLING_EXPORT void synchronizeFineToCoarseBetween(int fromLev, int toLev); MEDCOUPLING_EXPORT void synchronizeCoarseToFine(); @@ -140,6 +153,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT void synchronizeAllGhostZonesOfDirectChidrenOf(const MEDCouplingCartesianAMRMeshGen *mesh); MEDCOUPLING_EXPORT void synchronizeAllGhostZonesAtASpecifiedLevel(int level); MEDCOUPLING_EXPORT void synchronizeAllGhostZonesAtASpecifiedLevelUsingOnlyFather(int level); + // MEDCOUPLING_EXPORT void alloc(); MEDCOUPLING_EXPORT void dealloc(); MEDCOUPLING_EXPORT bool changeGodFather(MEDCouplingCartesianAMRMesh *gf); diff --git a/src/MEDCoupling/MEDCouplingCartesianAMRMesh.cxx b/src/MEDCoupling/MEDCouplingCartesianAMRMesh.cxx index 5f4dee55a..359ec9742 100644 --- a/src/MEDCoupling/MEDCouplingCartesianAMRMesh.cxx +++ b/src/MEDCoupling/MEDCouplingCartesianAMRMesh.cxx @@ -1731,6 +1731,44 @@ void MEDCouplingCartesianAMRMeshSub::detachFromFather() declareAsNew(); } +std::vector< std::pair > MEDCouplingCartesianAMRMeshSub::positionRelativeToGodFather(std::vector& st) const +{ + st=_father->getFactors(); + std::size_t dim(st.size()); + std::vector prev(st); + int id(_father->getPatchIdFromChildMesh(this)); + const MEDCouplingCartesianAMRPatch *p(_father->getPatch(id)); + std::vector< std::pair > ret(p->getBLTRRange()); + std::vector delta(MEDCouplingStructuredMesh::GetDimensionsFromCompactFrmt(ret)),start(dim); + std::transform(delta.begin(),delta.end(),prev.begin(),delta.begin(),std::multiplies()); + for(std::size_t i=0;i()); + const MEDCouplingCartesianAMRMeshGen *it(_father); + while(!dynamic_cast(it)) + { + const MEDCouplingCartesianAMRMeshSub *itc(static_cast(it)); + int id2(itc->_father->getPatchIdFromChildMesh(itc)); + const MEDCouplingCartesianAMRPatch *p2(itc->_father->getPatch(id2)); + const std::vector< std::pair >& start2(p2->getBLTRRange()); + std::vector tmp(dim); + for(std::size_t i=0;i_father->getFactors(); + std::transform(st.begin(),st.end(),prev.begin(),st.begin(),std::multiplies()); + std::transform(st.begin(),st.end(),tmp.begin(),tmp.begin(),std::multiplies()); + std::transform(start.begin(),start.end(),tmp.begin(),start.begin(),std::plus()); + it=itc->_father; + } + for(std::size_t i=0;i > MEDCouplingCartesianAMRMesh::positionRelativeToGodFather(std::vector& st) const +{ + st=_mesh->getCellGridStructure(); + return MEDCouplingStructuredMesh::GetCompactFrmtFromDimensions(st); +} + int MEDCouplingCartesianAMRMesh::getAbsoluteLevelRelativeTo(const MEDCouplingCartesianAMRMeshGen *ref) const { if(this==ref) diff --git a/src/MEDCoupling/MEDCouplingCartesianAMRMesh.hxx b/src/MEDCoupling/MEDCouplingCartesianAMRMesh.hxx index 76651d118..285f49226 100644 --- a/src/MEDCoupling/MEDCouplingCartesianAMRMesh.hxx +++ b/src/MEDCoupling/MEDCouplingCartesianAMRMesh.hxx @@ -146,6 +146,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT virtual const MEDCouplingCartesianAMRMeshGen *getGodFather() const = 0; MEDCOUPLING_EXPORT virtual int getAbsoluteLevel() const = 0; MEDCOUPLING_EXPORT virtual void detachFromFather() = 0; + MEDCOUPLING_EXPORT virtual std::vector< std::pair > positionRelativeToGodFather(std::vector& st) const = 0; MEDCOUPLING_EXPORT virtual int getAbsoluteLevelRelativeTo(const MEDCouplingCartesianAMRMeshGen *ref) const = 0; MEDCOUPLING_EXPORT std::vector getPositionRelativeTo(const MEDCouplingCartesianAMRMeshGen *ref) const; MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRPatch *getPatchAtPosition(const std::vector& pos) const; @@ -216,6 +217,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRMeshGen *getGodFather() const; MEDCOUPLING_EXPORT int getAbsoluteLevel() const; MEDCOUPLING_EXPORT void detachFromFather(); + MEDCOUPLING_EXPORT std::vector< std::pair > positionRelativeToGodFather(std::vector& st) const; MEDCOUPLING_EXPORT int getAbsoluteLevelRelativeTo(const MEDCouplingCartesianAMRMeshGen *ref) const; private: MEDCouplingCartesianAMRMeshSub(const MEDCouplingCartesianAMRMeshSub& other, MEDCouplingCartesianAMRMeshGen *father); @@ -234,6 +236,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRMeshGen *getGodFather() const; MEDCOUPLING_EXPORT int getAbsoluteLevel() const; MEDCOUPLING_EXPORT void detachFromFather(); + MEDCOUPLING_EXPORT std::vector< std::pair > positionRelativeToGodFather(std::vector& st) const; MEDCOUPLING_EXPORT int getAbsoluteLevelRelativeTo(const MEDCouplingCartesianAMRMeshGen *ref) const; MEDCOUPLING_EXPORT std::vector retrieveGridsAt(int absoluteLev) const; MEDCouplingCartesianAMRMesh *deepCpy(MEDCouplingCartesianAMRMeshGen *father) const; diff --git a/src/MEDCoupling/MEDCouplingStructuredMesh.cxx b/src/MEDCoupling/MEDCouplingStructuredMesh.cxx index 1e2186855..1b7bd952b 100644 --- a/src/MEDCoupling/MEDCouplingStructuredMesh.cxx +++ b/src/MEDCoupling/MEDCouplingStructuredMesh.cxx @@ -23,6 +23,7 @@ #include "MEDCouplingMemArray.hxx" #include "MEDCoupling1GTUMesh.hxx" #include "MEDCouplingUMesh.hxx" +#include "MEDCouplingIMesh.hxx"//tony to throw when optimization will be performed in AssignPartOfFieldOfDoubleUsing #include @@ -1469,6 +1470,8 @@ std::vector< std::pair > MEDCouplingStructuredMesh::GetCompactFrmtFromD /*! * This method returns the intersection zone of two ranges (in compact format) \a r1 and \a r2. * This method will throw exception if on one axis the intersection is empty. + * + * \sa AreRangesIntersect */ std::vector< std::pair > MEDCouplingStructuredMesh::IntersectRanges(const std::vector< std::pair >& r1, const std::vector< std::pair >& r2) { @@ -1499,6 +1502,36 @@ std::vector< std::pair > MEDCouplingStructuredMesh::IntersectRanges(con return ret; } +/*! + * This method states if \a r1 and \a r2 do overlap of not. If yes you can call IntersectRanges to know the intersection area. + * + * \sa IntersectRanges + */ +bool MEDCouplingStructuredMesh::AreRangesIntersect(const std::vector< std::pair >& r1, const std::vector< std::pair >& r2) +{ + std::size_t sz(r1.size()); + if(sz!=r2.size()) + throw INTERP_KERNEL::Exception("MEDCouplingStructuredMesh::AreRangesIntersect : the two ranges must have the same dimension !"); + for(std::size_t i=0;ir1[i].second) + { + std::ostringstream oss; oss << "MEDCouplingStructuredMesh::AreRangesIntersect : On axis " << i << " of range r1, end is before start !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + if(r2[i].first>r2[i].second) + { + std::ostringstream oss; oss << "MEDCouplingStructuredMesh::AreRangesIntersect : On axis " << i << " of range r2, end is before start !"; + throw INTERP_KERNEL::Exception(oss.str().c_str()); + } + if(r1[i].second<=r2[i].first) + return false; + if(r1[i].first>=r2[i].second) + return false; + } + return true; +} + /*! * This method is close to BuildExplicitIdsFrom except that instead of returning a DataArrayInt instance containing explicit ids it * enable elems in the vector of booleans (for performance reasons). As it is method for performance, this method is \b not @@ -1676,6 +1709,20 @@ DataArrayDouble *MEDCouplingStructuredMesh::ExtractFieldOfDoubleFrom(const std:: return ret.retn(); } +/*! + * This method assign a part of values in \a fieldOfDbl using entirely values of \b other. + * + * \param [in] st - the structure of \a fieldOfDbl. + * \param [in,out] fieldOfDbl - the array that will be partially filled using \a other. + * \param [in] partCompactFormat - the specification of the part. + * \param [in] other - the array that will be used to fill \a fieldOfDbl. + */ +void MEDCouplingStructuredMesh::AssignPartOfFieldOfDoubleUsing(const std::vector& st, DataArrayDouble *fieldOfDbl, const std::vector< std::pair >& partCompactFormat, const DataArrayDouble *other) +{//to be optimized + std::vector facts(st.size(),1.); + MEDCouplingIMesh::CondenseFineToCoarse(st,other,partCompactFormat,facts,fieldOfDbl); +} + /*! * This method changes the reference of a part of structured mesh \a partOfBigInAbs define in absolute reference to a new reference \a bigInAbs. * So this method only performs a translation by doing \a partOfBigRelativeToBig = \a partOfBigInAbs - \a bigInAbs diff --git a/src/MEDCoupling/MEDCouplingStructuredMesh.hxx b/src/MEDCoupling/MEDCouplingStructuredMesh.hxx index 532c56477..c6b957260 100644 --- a/src/MEDCoupling/MEDCouplingStructuredMesh.hxx +++ b/src/MEDCoupling/MEDCouplingStructuredMesh.hxx @@ -76,9 +76,11 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT static std::vector GetDimensionsFromCompactFrmt(const std::vector< std::pair >& partCompactFormat); MEDCOUPLING_EXPORT static std::vector< std::pair > GetCompactFrmtFromDimensions(const std::vector& dims); MEDCOUPLING_EXPORT static std::vector< std::pair > IntersectRanges(const std::vector< std::pair >& r1, const std::vector< std::pair >& r2); + MEDCOUPLING_EXPORT static bool AreRangesIntersect(const std::vector< std::pair >& r1, const std::vector< std::pair >& r2); MEDCOUPLING_EXPORT static void SwitchOnIdsFrom(const std::vector& st, const std::vector< std::pair >& partCompactFormat, std::vector& vectToSwitchOn); MEDCOUPLING_EXPORT static void ExtractFieldOfBoolFrom(const std::vector& st, const std::vector& fieldOfBool, const std::vector< std::pair >& partCompactFormat, std::vector& fieldOut); MEDCOUPLING_EXPORT static DataArrayDouble *ExtractFieldOfDoubleFrom(const std::vector& st, const DataArrayDouble *fieldOfDbl, const std::vector< std::pair >& partCompactFormat); + MEDCOUPLING_EXPORT static void AssignPartOfFieldOfDoubleUsing(const std::vector& st, DataArrayDouble *fieldOfDbl, const std::vector< std::pair >& partCompactFormat, const DataArrayDouble *other); MEDCOUPLING_EXPORT static void ChangeReferenceFromGlobalOfCompactFrmt(const std::vector< std::pair >& bigInAbs, const std::vector< std::pair >& partOfBigInAbs, std::vector< std::pair >& partOfBigRelativeToBig, bool check=true); MEDCOUPLING_EXPORT static void ChangeReferenceToGlobalOfCompactFrmt(const std::vector< std::pair >& bigInAbs, const std::vector< std::pair >& partOfBigRelativeToBig, std::vector< std::pair >& partOfBigInAbs, bool check=true); MEDCOUPLING_EXPORT static std::vector< std::pair > TranslateCompactFrmt(const std::vector< std::pair >& part, const std::vector& translation); diff --git a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py index 4316b0105..284954f02 100644 --- a/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py +++ b/src/MEDCoupling_Swig/MEDCouplingBasicsTest.py @@ -15405,6 +15405,13 @@ class MEDCouplingBasicsTest(unittest.TestCase): amr[1].addPatch([(4,7),(0,3)],[3,3]) amr[1].addPatch([(4,7),(3,6)],[3,3]) amr.addPatch([(0,3),(6,10)],[2,2]) + self.assertEqual(([(30,39),(27,36)],[6,6]),amr[1][3].getMesh().positionRelativeToGodFather()) + self.assertEqual(([(6,16),(6,12)],[2,2]),amr[1].getMesh().positionRelativeToGodFather()) + self.assertTrue(not MEDCouplingStructuredMesh.AreRangesIntersect([(30,39),(27,36)],[(6,16),(6,12)])) + self.assertTrue(MEDCouplingStructuredMesh.AreRangesIntersect([(30,39),(27,36)],[(28,32),(35,37)])) + da=DataArrayDouble([0.,1.,2.,3.,4.,5.,6.,7.,8.,9.,10.,11.]) + MEDCouplingStructuredMesh.AssignPartOfFieldOfDoubleUsing([3,4],da,[(1,3),(2,3)],DataArrayDouble([7.7,8.8])) + self.assertTrue(da.isEqual(DataArrayDouble([0.,1.,2.,3.,4.,5.,6.,7.7,8.8,9.,10.,11.]),1e-12)) att=MEDCouplingAMRAttribute(amr,[("YY",1)],szGhost) att.spillNatures([ConservativeVolumic]) att.alloc() @@ -15554,6 +15561,23 @@ class MEDCouplingBasicsTest(unittest.TestCase): self.assertTrue(fine[240:-240].isEqual(DataArrayDouble([362.5,362.5,363.5,363.5,364.5,364.5,365.5,365.5,366.5,366.5,367.5,367.5,362.5,362.5,363.5,363.5,364.5,364.5,365.5,365.5,366.5,366.5,367.5,367.5,372.5,372.5,266.1,267.1,268.1,269.1,270.1,271.1,272.1,273.1,377.5,377.5,372.5,372.5,278.1,279.1,280.1,281.1,282.1,283.1,284.1,285.1,377.5,377.5,372.5,372.5,290.1,291.1,292.1,293.1,294.1,295.1,296.1,297.1,377.5,377.5,382.5,382.5,302.1,303.1,304.1,305.1,306.1,307.1,308.1,309.1,387.5,387.5,382.5,382.5,314.1,315.1,316.1,317.1,318.1,319.1,320.1,321.1,387.5,387.5,382.5,382.5,326.1,327.1,328.1,329.1,330.1,331.1,332.1,333.1,387.5,387.5,392.5,392.5,393.5,393.5,394.5,394.5,395.5,395.5,396.5,396.5,397.5,397.5,392.5,392.5,393.5,393.5,394.5,394.5,395.5,395.5,396.5,396.5,397.5,397.5,362.5,362.5,363.5,363.5,364.5,364.5,365.5,365.5,366.5,366.5,367.5,367.5,362.5,362.5,363.5,363.5,364.5,364.5,365.5,365.5,366.5,366.5,367.5,367.5,372.5,372.5,386.1,387.1,388.1,389.1,390.1,391.1,392.1,393.1,377.5,377.5,372.5,372.5,398.1,399.1,400.1,401.1,402.1,403.1,404.1,405.1,377.5,377.5,372.5,372.5,410.1,411.1,412.1,413.1,414.1,415.1,416.1,417.1,377.5,377.5,382.5,382.5,422.1,423.1,424.1,425.1,426.1,427.1,428.1,429.1,387.5,387.5,382.5,382.5,434.1,435.1,436.1,437.1,438.1,439.1,440.1,441.1,387.5,387.5,382.5,382.5,446.1,447.1,448.1,449.1,450.1,451.1,452.1,453.1,387.5,387.5,392.5,392.5,393.5,393.5,394.5,394.5,395.5,395.5,396.5,396.5,397.5,397.5,392.5,392.5,393.5,393.5,394.5,394.5,395.5,395.5,396.5,396.5,397.5,397.5,362.5,362.5,363.5,363.5,364.5,364.5,365.5,365.5,366.5,366.5,367.5,367.5,362.5,362.5,363.5,363.5,364.5,364.5,365.5,365.5,366.5,366.5,367.5,367.5,372.5,372.5,506.1,507.1,508.1,509.1,510.1,511.1,512.1,513.1,377.5,377.5,372.5,372.5,518.1,519.1,520.1,521.1,522.1,523.1,524.1,525.1,377.5,377.5,372.5,372.5,530.1,531.1,532.1,533.1,534.1,535.1,536.1,537.1,377.5,377.5,382.5,382.5,542.1,543.1,544.1,545.1,546.1,547.1,548.1,549.1,387.5,387.5,382.5,382.5,554.1,555.1,556.1,557.1,558.1,559.1,560.1,561.1,387.5,387.5,382.5,382.5,566.1,567.1,568.1,569.1,570.1,571.1,572.1,573.1,387.5,387.5,392.5,392.5,393.5,393.5,394.5,394.5,395.5,395.5,396.5,396.5,397.5,397.5,392.5,392.5,393.5,393.5,394.5,394.5,395.5,395.5,396.5,396.5,397.5,397.5,362.5,362.5,363.5,363.5,364.5,364.5,365.5,365.5,366.5,366.5,367.5,367.5,362.5,362.5,363.5,363.5,364.5,364.5,365.5,365.5,366.5,366.5,367.5,367.5,372.5,372.5,626.1,627.1,628.1,629.1,630.1,631.1,632.1,633.1,377.5,377.5,372.5,372.5,638.1,639.1,640.1,641.1,642.1,643.1,644.1,645.1,377.5,377.5,372.5,372.5,650.1,651.1,652.1,653.1,654.1,655.1,656.1,657.1,377.5,377.5,382.5,382.5,662.1,663.1,664.1,665.1,666.1,667.1,668.1,669.1,387.5,387.5,382.5,382.5,674.1,675.1,676.1,677.1,678.1,679.1,680.1,681.1,387.5,387.5,382.5,382.5,686.1,687.1,688.1,689.1,690.1,691.1,692.1,693.1,387.5,387.5,392.5,392.5,393.5,393.5,394.5,394.5,395.5,395.5,396.5,396.5,397.5,397.5,392.5,392.5,393.5,393.5,394.5,394.5,395.5,395.5,396.5,396.5,397.5,397.5,472.5,472.5,473.5,473.5,474.5,474.5,475.5,475.5,476.5,476.5,477.5,477.5,472.5,472.5,473.5,473.5,474.5,474.5,475.5,475.5,476.5,476.5,477.5,477.5,482.5,482.5,746.1,747.1,748.1,749.1,750.1,751.1,752.1,753.1,487.5,487.5,482.5,482.5,758.1,759.1,760.1,761.1,762.1,763.1,764.1,765.1,487.5,487.5,482.5,482.5,770.1,771.1,772.1,773.1,774.1,775.1,776.1,777.1,487.5,487.5,492.5,492.5,782.1,783.1,784.1,785.1,786.1,787.1,788.1,789.1,497.5,497.5,492.5,492.5,794.1,795.1,796.1,797.1,798.1,799.1,800.1,801.1,497.5,497.5,492.5,492.5,806.1,807.1,808.1,809.1,810.1,811.1,812.1,813.1,497.5,497.5,502.5,502.5,503.5,503.5,504.5,504.5,505.5,505.5,506.5,506.5,507.5,507.5,502.5,502.5,503.5,503.5,504.5,504.5,505.5,505.5,506.5,506.5,507.5,507.5,472.5,472.5,473.5,473.5,474.5,474.5,475.5,475.5,476.5,476.5,477.5,477.5,472.5,472.5,473.5,473.5,474.5,474.5,475.5,475.5,476.5,476.5,477.5,477.5,482.5,482.5,866.1,867.1,868.1,869.1,870.1,871.1,872.1,873.1,487.5,487.5,482.5,482.5,878.1,879.1,880.1,881.1,882.1,883.1,884.1,885.1,487.5,487.5,482.5,482.5,890.1,891.1,892.1,893.1,894.1,895.1,896.1,897.1,487.5,487.5,492.5,492.5,902.1,903.1,904.1,905.1,906.1,907.1,908.1,909.1,497.5,497.5,492.5,492.5,914.1,915.1,916.1,917.1,918.1,919.1,920.1,921.1,497.5,497.5,492.5,492.5,926.1,927.1,928.1,929.1,930.1,931.1,932.1,933.1,497.5,497.5,502.5,502.5,503.5,503.5,504.5,504.5,505.5,505.5,506.5,506.5,507.5,507.5,502.5,502.5,503.5,503.5,504.5,504.5,505.5,505.5,506.5,506.5,507.5,507.5,472.5,472.5,473.5,473.5,474.5,474.5,475.5,475.5,476.5,476.5,477.5,477.5,472.5,472.5,473.5,473.5,474.5,474.5,475.5,475.5,476.5,476.5,477.5,477.5,482.5,482.5,986.1,987.1,988.1,989.1,990.1,991.1,992.1,993.1,487.5,487.5,482.5,482.5,998.1,999.1,1000.1,1001.1,1002.1,1003.1,1004.1,1005.1,487.5,487.5,482.5,482.5,1010.1,1011.1,1012.1,1013.1,1014.1,1015.1,1016.1,1017.1,487.5,487.5,492.5,492.5,1022.1,1023.1,1024.1,1025.1,1026.1,1027.1,1028.1,1029.1,497.5,497.5,492.5,492.5,1034.1,1035.1,1036.1,1037.1,1038.1,1039.1,1040.1,1041.1,497.5,497.5,492.5,492.5,1046.1,1047.1,1048.1,1049.1,1050.1,1051.1,1052.1,1053.1,497.5,497.5,502.5,502.5,503.5,503.5,504.5,504.5,505.5,505.5,506.5,506.5,507.5,507.5,502.5,502.5,503.5,503.5,504.5,504.5,505.5,505.5,506.5,506.5,507.5,507.5,472.5,472.5,473.5,473.5,474.5,474.5,475.5,475.5,476.5,476.5,477.5,477.5,472.5,472.5,473.5,473.5,474.5,474.5,475.5,475.5,476.5,476.5,477.5,477.5,482.5,482.5,1106.1,1107.1,1108.1,1109.1,1110.1,1111.1,1112.1,1113.1,487.5,487.5,482.5,482.5,1118.1,1119.1,1120.1,1121.1,1122.1,1123.1,1124.1,1125.1,487.5,487.5,482.5,482.5,1130.1,1131.1,1132.1,1133.1,1134.1,1135.1,1136.1,1137.1,487.5,487.5,492.5,492.5,1142.1,1143.1,1144.1,1145.1,1146.1,1147.1,1148.1,1149.1,497.5,497.5,492.5,492.5,1154.1,1155.1,1156.1,1157.1,1158.1,1159.1,1160.1,1161.1,497.5,497.5,492.5,492.5,1166.1,1167.1,1168.1,1169.1,1170.1,1171.1,1172.1,1173.1,497.5,497.5,502.5,502.5,503.5,503.5,504.5,504.5,505.5,505.5,506.5,506.5,507.5,507.5,502.5,502.5,503.5,503.5,504.5,504.5,505.5,505.5,506.5,506.5,507.5,507.5,582.5,582.5,583.5,583.5,584.5,584.5,585.5,585.5,586.5,586.5,587.5,587.5,582.5,582.5,583.5,583.5,584.5,584.5,585.5,585.5,586.5,586.5,587.5,587.5,592.5,592.5,1226.1,1227.1,1228.1,1229.1,1230.1,1231.1,1232.1,1233.1,597.5,597.5,592.5,592.5,1238.1,1239.1,1240.1,1241.1,1242.1,1243.1,1244.1,1245.1,597.5,597.5,592.5,592.5,1250.1,1251.1,1252.1,1253.1,1254.1,1255.1,1256.1,1257.1,597.5,597.5,602.5,602.5,1262.1,1263.1,1264.1,1265.1,1266.1,1267.1,1268.1,1269.1,607.5,607.5,602.5,602.5,1274.1,1275.1,1276.1,1277.1,1278.1,1279.1,1280.1,1281.1,607.5,607.5,602.5,602.5,1286.1,1287.1,1288.1,1289.1,1290.1,1291.1,1292.1,1293.1,607.5,607.5,612.5,612.5,613.5,613.5,614.5,614.5,615.5,615.5,616.5,616.5,617.5,617.5,612.5,612.5,613.5,613.5,614.5,614.5,615.5,615.5,616.5,616.5,617.5,617.5,582.5,582.5,583.5,583.5,584.5,584.5,585.5,585.5,586.5,586.5,587.5,587.5,582.5,582.5,583.5,583.5,584.5,584.5,585.5,585.5,586.5,586.5,587.5,587.5,592.5,592.5,1346.1,1347.1,1348.1,1349.1,1350.1,1351.1,1352.1,1353.1,597.5,597.5,592.5,592.5,1358.1,1359.1,1360.1,1361.1,1362.1,1363.1,1364.1,1365.1,597.5,597.5,592.5,592.5,1370.1,1371.1,1372.1,1373.1,1374.1,1375.1,1376.1,1377.1,597.5,597.5,602.5,602.5,1382.1,1383.1,1384.1,1385.1,1386.1,1387.1,1388.1,1389.1,607.5,607.5,602.5,602.5,1394.1,1395.1,1396.1,1397.1,1398.1,1399.1,1400.1,1401.1,607.5,607.5,602.5,602.5,1406.1,1407.1,1408.1,1409.1,1410.1,1411.1,1412.1,1413.1,607.5,607.5,612.5,612.5,613.5,613.5,614.5,614.5,615.5,615.5,616.5,616.5,617.5,617.5,612.5,612.5,613.5,613.5,614.5,614.5,615.5,615.5,616.5,616.5,617.5,617.5,582.5,582.5,583.5,583.5,584.5,584.5,585.5,585.5,586.5,586.5,587.5,587.5,582.5,582.5,583.5,583.5,584.5,584.5,585.5,585.5,586.5,586.5,587.5,587.5,592.5,592.5,1466.1,1467.1,1468.1,1469.1,1470.1,1471.1,1472.1,1473.1,597.5,597.5,592.5,592.5,1478.1,1479.1,1480.1,1481.1,1482.1,1483.1,1484.1,1485.1,597.5,597.5,592.5,592.5,1490.1,1491.1,1492.1,1493.1,1494.1,1495.1,1496.1,1497.1,597.5,597.5,602.5,602.5,1502.1,1503.1,1504.1,1505.1,1506.1,1507.1,1508.1,1509.1,607.5,607.5,602.5,602.5,1514.1,1515.1,1516.1,1517.1,1518.1,1519.1,1520.1,1521.1,607.5,607.5,602.5,602.5,1526.1,1527.1,1528.1,1529.1,1530.1,1531.1,1532.1,1533.1,607.5,607.5,612.5,612.5,613.5,613.5,614.5,614.5,615.5,615.5,616.5,616.5,617.5,617.5,612.5,612.5,613.5,613.5,614.5,614.5,615.5,615.5,616.5,616.5,617.5,617.5,582.5,582.5,583.5,583.5,584.5,584.5,585.5,585.5,586.5,586.5,587.5,587.5,582.5,582.5,583.5,583.5,584.5,584.5,585.5,585.5,586.5,586.5,587.5,587.5,592.5,592.5,1586.1,1587.1,1588.1,1589.1,1590.1,1591.1,1592.1,1593.1,597.5,597.5,592.5,592.5,1598.1,1599.1,1600.1,1601.1,1602.1,1603.1,1604.1,1605.1,597.5,597.5,592.5,592.5,1610.1,1611.1,1612.1,1613.1,1614.1,1615.1,1616.1,1617.1,597.5,597.5,602.5,602.5,1622.1,1623.1,1624.1,1625.1,1626.1,1627.1,1628.1,1629.1,607.5,607.5,602.5,602.5,1634.1,1635.1,1636.1,1637.1,1638.1,1639.1,1640.1,1641.1,607.5,607.5,602.5,602.5,1646.1,1647.1,1648.1,1649.1,1650.1,1651.1,1652.1,1653.1,607.5,607.5,612.5,612.5,613.5,613.5,614.5,614.5,615.5,615.5,616.5,616.5,617.5,617.5,612.5,612.5,613.5,613.5,614.5,614.5,615.5,615.5,616.5,616.5,617.5,617.5]),1e-12)) pass + def testSwig2AMR12(self): + """ This test check the MEDCouplingAMRAttribute.projectTo method.""" + amr0=MEDCouplingCartesianAMRMesh("mesh",2,[11,11],[0.,0.],[1.,1.]) + amr0.addPatch([(3,8),(0,3)],[2,2]) + amr0.addPatch([(3,8),(3,6)],[2,2]) + att0=MEDCouplingAMRAttribute(amr0,[("YY",1)],2) + att0.alloc() + att0.getFieldOn(amr0,"YY").iota(0.01) + att0.getFieldOn(amr0[0].getMesh(),"YY").iota(0.02) + att0.getFieldOn(amr0[1].getMesh(),"YY").iota(0.03) + amr1=MEDCouplingCartesianAMRMesh("mesh",2,[11,11],[0.,0.],[1.,1.]) + amr1.addPatch([(2,5),(1,4)],[2,2]) + att1=att0.projectTo(amr1) + self.assertTrue(att1.getFieldOn(amr1,"YY").isEqualWithoutConsideringStr(att0.getFieldOn(amr0,"YY"),1e-12)) + self.assertTrue(att1.getFieldOn(amr1[0].getMesh(),"YY").isEqualWithoutConsideringStr(DataArrayDouble([31.01,31.01,32.01,32.01,33.01,33.01,34.01,34.01,35.01,35.01,31.01,31.01,32.01,32.01,33.01,33.01,34.01,34.01,35.01,35.01,45.01,45.01,46.01,46.01,58.02,59.02,60.02,61.02,49.01,49.01,45.01,45.01,46.01,46.01,72.02,73.02,74.02,75.02,49.01,49.01,59.01,59.01,60.01,60.01,86.02,87.02,88.02,89.02,63.01,63.01,59.01,59.01,60.01,60.01,100.02,101.02,102.02,103.02,63.01,63.01,73.01,73.01,74.01,74.01,30.03,31.03,32.03,33.03,77.01,77.01,73.01,73.01,74.01,74.01,44.03,45.03,46.03,47.03,77.01,77.01,87.01,87.01,88.01,88.01,89.01,89.01,90.01,90.01,91.01,91.01,87.01,87.01,88.01,88.01,89.01,89.01,90.01,90.01,91.01,91.01]),1e-12)) + pass + pass if __name__ == '__main__': diff --git a/src/MEDCoupling_Swig/MEDCouplingCommon.i b/src/MEDCoupling_Swig/MEDCouplingCommon.i index 36d090f70..338505b32 100644 --- a/src/MEDCoupling_Swig/MEDCouplingCommon.i +++ b/src/MEDCoupling_Swig/MEDCouplingCommon.i @@ -360,6 +360,7 @@ using namespace INTERP_KERNEL; %newobject ParaMEDMEM::MEDCouplingAMRAttribute::deepCpy; %newobject ParaMEDMEM::MEDCouplingAMRAttribute::deepCpyWithoutGodFather; %newobject ParaMEDMEM::MEDCouplingAMRAttribute::getFieldOn; +%newobject ParaMEDMEM::MEDCouplingAMRAttribute::projectTo; %newobject ParaMEDMEM::MEDCouplingAMRAttribute::buildCellFieldOnRecurseWithoutOverlapWithoutGhost; %newobject ParaMEDMEM::MEDCouplingAMRAttribute::buildCellFieldOnWithGhost; %newobject ParaMEDMEM::MEDCouplingAMRAttribute::buildCellFieldOnWithoutGhost; @@ -2951,6 +2952,13 @@ namespace ParaMEDMEM return MEDCouplingStructuredMesh::ExtractFieldOfDoubleFrom(st,fieldOfDbl,inp); } + static void AssignPartOfFieldOfDoubleUsing(const std::vector& st, DataArrayDouble *fieldOfDbl, PyObject *partCompactFormat, const DataArrayDouble *other) throw(INTERP_KERNEL::Exception) + { + std::vector< std::pair > inp; + convertPyToVectorPairInt(partCompactFormat,inp); + MEDCouplingStructuredMesh::AssignPartOfFieldOfDoubleUsing(st,fieldOfDbl,inp,other); + } + static int DeduceNumberOfGivenRangeInCompactFrmt(PyObject *part) throw(INTERP_KERNEL::Exception) { std::vector< std::pair > inp; @@ -3012,6 +3020,14 @@ namespace ParaMEDMEM return retPy; } + static bool AreRangesIntersect(PyObject *r1, PyObject *r2) + { + std::vector< std::pair > r1Cpp,r2Cpp; + convertPyToVectorPairInt(r1,r1Cpp); + convertPyToVectorPairInt(r2,r2Cpp); + return MEDCouplingStructuredMesh::AreRangesIntersect(r1Cpp,r2Cpp); + } + static PyObject *IsPartStructured(PyObject *li, PyObject *st) throw(INTERP_KERNEL::Exception) { int szArr,sw,iTypppArr; @@ -5000,6 +5016,16 @@ namespace ParaMEDMEM return ret2; } + virtual PyObject *positionRelativeToGodFather() const throw(INTERP_KERNEL::Exception) + { + std::vector out1; + std::vector< std::pair > out0(self->positionRelativeToGodFather(out1)); + PyObject *ret(PyTuple_New(2)); + PyTuple_SetItem(ret,0,convertFromVectorPairInt(out0)); + PyTuple_SetItem(ret,1,convertIntArrToPyList2(out1)); + return ret; + } + virtual PyObject *retrieveGridsAt(int absoluteLev) const throw(INTERP_KERNEL::Exception) { std::vector ps(self->retrieveGridsAt(absoluteLev)); @@ -5169,6 +5195,7 @@ namespace ParaMEDMEM MEDCouplingFieldDouble *buildCellFieldOnWithGhost(MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) const throw(INTERP_KERNEL::Exception); MEDCouplingFieldDouble *buildCellFieldOnWithoutGhost(MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) const throw(INTERP_KERNEL::Exception); bool changeGodFather(MEDCouplingCartesianAMRMesh *gf) throw(INTERP_KERNEL::Exception); + MEDCouplingAMRAttribute *projectTo(MEDCouplingCartesianAMRMesh *targetGF) const throw(INTERP_KERNEL::Exception); %extend { static MEDCouplingAMRAttribute *New(MEDCouplingCartesianAMRMesh *gf, PyObject *fieldNames, int ghostLev) throw(INTERP_KERNEL::Exception) -- 2.39.2