From: geay Date: Mon, 16 Jun 2014 15:38:22 +0000 (+0200) Subject: Some debugs and improvements. Tests coming soon ! X-Git-Tag: V7_5_0a1~2^2~32^2~10 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=ee1d91dd1a7a0f9da39125e0be67ff4bbf1d95f4;p=tools%2Fmedcoupling.git Some debugs and improvements. Tests coming soon ! --- diff --git a/src/MEDCoupling/MEDCouplingAMRAttribute.cxx b/src/MEDCoupling/MEDCouplingAMRAttribute.cxx index b9c1559de..9e601b988 100644 --- a/src/MEDCoupling/MEDCouplingAMRAttribute.cxx +++ b/src/MEDCoupling/MEDCouplingAMRAttribute.cxx @@ -584,12 +584,12 @@ void MEDCouplingGridCollection::updateTime() const } } -MEDCouplingCartesianAMRMeshGen *MEDCouplingDataForGodFather::getMyGodFather() +MEDCouplingCartesianAMRMesh *MEDCouplingDataForGodFather::getMyGodFather() { return _gf; } -MEDCouplingDataForGodFather::MEDCouplingDataForGodFather(MEDCouplingCartesianAMRMeshGen *gf):_gf(gf),_tlc(gf) +MEDCouplingDataForGodFather::MEDCouplingDataForGodFather(MEDCouplingCartesianAMRMesh *gf):_gf(gf),_tlc(gf) { if(!gf) throw INTERP_KERNEL::Exception("MEDCouplingDataForGodFather constructor : A data has to be attached to a AMR Mesh instance !"); @@ -601,7 +601,7 @@ void MEDCouplingDataForGodFather::checkGodFatherFrozen() const _tlc.checkConst(); } -bool MEDCouplingDataForGodFather::changeGodFather(MEDCouplingCartesianAMRMeshGen *gf) +bool MEDCouplingDataForGodFather::changeGodFather(MEDCouplingCartesianAMRMesh *gf) { bool ret(_tlc.keepTrackOfNewTL(gf)); if(ret) @@ -618,9 +618,9 @@ MEDCouplingDataForGodFather::MEDCouplingDataForGodFather(const MEDCouplingDataFo other._tlc.checkConst(); if(deepCpyGF) { - const MEDCouplingCartesianAMRMeshGen *gf(other._gf); + const MEDCouplingCartesianAMRMesh *gf(other._gf); if(gf) - _gf=gf->deepCpy(); + _gf=gf->deepCpy(0); _tlc.keepTrackOfNewTL(_gf); } } @@ -628,12 +628,12 @@ MEDCouplingDataForGodFather::MEDCouplingDataForGodFather(const MEDCouplingDataFo /*! * This method creates, attach to a main AMR mesh \a gf ( called god father :-) ) and returns a data linked to \a gf ready for the computation. */ -MEDCouplingAMRAttribute *MEDCouplingAMRAttribute::New(MEDCouplingCartesianAMRMeshGen *gf, const std::vector< std::pair >& fieldNames, int ghostLev) +MEDCouplingAMRAttribute *MEDCouplingAMRAttribute::New(MEDCouplingCartesianAMRMesh *gf, const std::vector< std::pair >& fieldNames, int ghostLev) { return new MEDCouplingAMRAttribute(gf,fieldNames,ghostLev); } -MEDCouplingAMRAttribute *MEDCouplingAMRAttribute::New(MEDCouplingCartesianAMRMeshGen *gf, const std::vector< std::pair > >& fieldNames, int ghostLev) +MEDCouplingAMRAttribute *MEDCouplingAMRAttribute::New(MEDCouplingCartesianAMRMesh *gf, const std::vector< std::pair > >& fieldNames, int ghostLev) { std::size_t sz(fieldNames.size()); std::vector< std::pair > fieldNames2(sz); @@ -834,6 +834,7 @@ MEDCouplingFieldDouble *MEDCouplingAMRAttribute::buildCellFieldOnWithoutGhost(ME /*! * 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. + * This method \b DOES \b NOT \b UPDATE the ghost zones (neither the fine not the coarse) * * \sa synchronizeFineToCoarseBetween */ @@ -854,6 +855,7 @@ void MEDCouplingAMRAttribute::synchronizeFineToCoarse() * This method allows to synchronizes fields on fine patches on level \a fromLev to coarser patches at \a toLev level. * This method operates step by step performing the synchronization the \a fromLev to \a fromLev - 1, then \a fromLev -1 to \a fromLev - 2 ... * until reaching \a toLev level. + * This method \b DOES \b NOT \b UPDATE the ghost zones (neither the fine not the coarse). * * \param [in] fromLev - an existing level considered as fine so bigger than \a toLev * \param [in] toLev - an existing level considered as the target level to reach. @@ -875,6 +877,7 @@ void MEDCouplingAMRAttribute::synchronizeFineToCoarseBetween(int fromLev, int to /*! * This method synchronizes from coarse to fine arrays and fine to fine each other (if _ghost_lev is >0). This method makes the hypothesis that \a this has been allocated before using * MEDCouplingAMRAttribute::alloc method. + * This method \b DOES \b UPDATE \b the \b ghost \b zone (contrary to synchronizeFineToCoarse method) */ void MEDCouplingAMRAttribute::synchronizeCoarseToFine() { @@ -890,6 +893,7 @@ void MEDCouplingAMRAttribute::synchronizeCoarseToFine() * This method allows to synchronizes fields on coarse patches on level \a fromLev to their respective refined patches at \a toLev level. * This method operates step by step performing the synchronization the \a fromLev to \a fromLev + 1, then \a fromLev + 1 to \a fromLev + 2 ... * until reaching \a toLev level. + * This method \b DOES \b UPDATE \b the \b ghost \b zone (contrary to synchronizeFineToCoarseBetween method) * * \param [in] fromLev - an existing level considered as coarse so lower than \a toLev * \param [in] toLev - an existing level considered as the target level to reach. @@ -933,10 +937,10 @@ void MEDCouplingAMRAttribute::synchronizeAllGhostZones() // 2nd - classical direct sublevel inside common patch for(int i=1;isynchronizeFineEachOther(_ghost_lev,_neighbors[i]); + curLev->synchronizeFineEachOther(_ghost_lev,_neighbors[i]); } // 3rd - mixed level for(std::vector< std::pair >::const_iterator it=_mixed_lev_neighbors.begin();it!=_mixed_lev_neighbors.end();it++) @@ -953,7 +957,7 @@ void MEDCouplingAMRAttribute::synchronizeAllGhostZones() } /*! - * This method + * This method synchronizes all direct children of \a mesh each other. */ void MEDCouplingAMRAttribute::synchronizeAllGhostZonesOfDirectChidrenOf(const MEDCouplingCartesianAMRMeshGen *mesh) { @@ -962,15 +966,17 @@ void MEDCouplingAMRAttribute::synchronizeAllGhostZonesOfDirectChidrenOf(const ME int level(mesh->getAbsoluteLevelRelativeTo(_gf)),sz(getNumberOfLevels()); if(level<0 || level>=sz-1) throw INTERP_KERNEL::Exception("MEDCouplingAMRAttribute::synchronizeAllGhostZonesOfDirectChidrenOf : the specified level does not exist ! Must be in [0,nbOfLevelsOfThis-1) !"); - const DataArrayDoubleCollection& colCoarse(findCollectionAttachedTo(mesh)); - std::vector< const MEDCouplingCartesianAMRPatch *> directChildren(mesh->getPatches()); - std::size_t nbOfDirChildren(directChildren.size()); - for(std::size_t patchId=0;patchId >& itemsToFilter(_neighbors[level+1]); + std::vector< std::pair > itemsToSync; itemsToSync.reserve(itemsToFilter.size()); + for(std::vector< std::pair >::const_iterator it=itemsToFilter.begin();it!=itemsToFilter.end();it++) { - const DataArrayDoubleCollection& colFine(findCollectionAttachedTo(directChildren[patchId]->getMesh())); - DataArrayDoubleCollection *colFine2(const_cast(&colFine)); - DataArrayDoubleCollection::SynchronizeCoarseToFineOnlyInGhostZone(_ghost_lev,mesh,(int)patchId,&colCoarse,colFine2); + if((*it).first->getMesh()->getFather()==mesh && (*it).second->getMesh()->getFather()==mesh) + itemsToSync.push_back(std::pair((*it).first,(*it).second)); } + const MEDCouplingGridCollection *curLev(_levs[level+1]); + if(!curLev) + throw INTERP_KERNEL::Exception("MEDCouplingAMRAttribute::synchronizeAllGhostZonesOfDirectChidrenOf : presence of a NULL element !"); + curLev->synchronizeFineEachOther(_ghost_lev,itemsToSync); } /*! @@ -1008,7 +1014,7 @@ void MEDCouplingAMRAttribute::dealloc() } } -bool MEDCouplingAMRAttribute::changeGodFather(MEDCouplingCartesianAMRMeshGen *gf) +bool MEDCouplingAMRAttribute::changeGodFather(MEDCouplingCartesianAMRMesh *gf) { bool ret(MEDCouplingDataForGodFather::changeGodFather(gf)); return ret; @@ -1037,7 +1043,7 @@ void MEDCouplingAMRAttribute::updateTime() const {//tony } -MEDCouplingAMRAttribute::MEDCouplingAMRAttribute(MEDCouplingCartesianAMRMeshGen *gf, const std::vector< std::pair >& fieldNames, int ghostLev):MEDCouplingDataForGodFather(gf),_ghost_lev(ghostLev) +MEDCouplingAMRAttribute::MEDCouplingAMRAttribute(MEDCouplingCartesianAMRMesh *gf, const std::vector< std::pair >& fieldNames, int ghostLev):MEDCouplingDataForGodFather(gf),_ghost_lev(ghostLev) { //gf non empty, checked by constructor int maxLev(gf->getMaxNumberOfLevelsRelativeToThis()); @@ -1096,6 +1102,45 @@ MEDCouplingAMRAttribute::MEDCouplingAMRAttribute(const MEDCouplingAMRAttribute& _levs[i]=other._levs[i]->deepCpy(_gf,other._gf); } } + //_cross_lev_neighbors(other._cross_lev_neighbors) + sz=other._neighbors.size(); + for(std::size_t i=0;i >& neigh2(other._neighbors[i]); + std::size_t sz2(neigh2.size()); + std::vector< std::pair >& neigh3(_neighbors[i]); + for(std::size_t j=0;j pp1(p1->getMesh()->getPositionRelativeTo(other._gf)),pp2(p2->getMesh()->getPositionRelativeTo(other._gf)); + neigh3[j].first=_gf->getPatchAtPosition(pp1); + neigh3[j].second=_gf->getPatchAtPosition(pp2); + } + } + // + sz=other._mixed_lev_neighbors.size(); + for(std::size_t i=0;i pp1(p1->getMesh()->getPositionRelativeTo(other._gf)),pp2(p2->getMesh()->getPositionRelativeTo(other._gf)); + _mixed_lev_neighbors[i].first=_gf->getPatchAtPosition(pp1); + _mixed_lev_neighbors[i].second=_gf->getPatchAtPosition(pp2); + } + // + sz=other._cross_lev_neighbors.size(); + for(std::size_t i=0;i >& neigh2(other._cross_lev_neighbors[i]); + std::size_t sz2(neigh2.size()); + std::vector< std::pair >& neigh3(_cross_lev_neighbors[i]); + for(std::size_t j=0;j pp1(p1->getMesh()->getPositionRelativeTo(other._gf)),pp2(p2->getMesh()->getPositionRelativeTo(other._gf)); + neigh3[j].first=_gf->getPatchAtPosition(pp1); + neigh3[j].second=_gf->getPatchAtPosition(pp2); + } + } } const DataArrayDoubleCollection& MEDCouplingAMRAttribute::findCollectionAttachedTo(const MEDCouplingCartesianAMRMeshGen *m) const diff --git a/src/MEDCoupling/MEDCouplingAMRAttribute.hxx b/src/MEDCoupling/MEDCouplingAMRAttribute.hxx index a2ac9b418..b80c59b51 100644 --- a/src/MEDCoupling/MEDCouplingAMRAttribute.hxx +++ b/src/MEDCoupling/MEDCouplingAMRAttribute.hxx @@ -94,7 +94,7 @@ namespace ParaMEDMEM { friend class MEDCouplingCartesianAMRMesh; public: - MEDCOUPLING_EXPORT MEDCouplingCartesianAMRMeshGen *getMyGodFather(); + MEDCOUPLING_EXPORT MEDCouplingCartesianAMRMesh *getMyGodFather(); MEDCOUPLING_EXPORT virtual void synchronizeFineToCoarse() = 0; MEDCOUPLING_EXPORT virtual void synchronizeFineToCoarseBetween(int fromLev, int toLev) = 0; MEDCOUPLING_EXPORT virtual void synchronizeCoarseToFine() = 0; @@ -104,21 +104,21 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT virtual void alloc() = 0; MEDCOUPLING_EXPORT virtual void dealloc() = 0; protected: - MEDCouplingDataForGodFather(MEDCouplingCartesianAMRMeshGen *gf); + MEDCouplingDataForGodFather(MEDCouplingCartesianAMRMesh *gf); void checkGodFatherFrozen() const; protected: - virtual bool changeGodFather(MEDCouplingCartesianAMRMeshGen *gf); + virtual bool changeGodFather(MEDCouplingCartesianAMRMesh *gf); MEDCouplingDataForGodFather(const MEDCouplingDataForGodFather& other, bool deepCpyGF); protected: - MEDCouplingAutoRefCountObjectPtr _gf; + MEDCouplingAutoRefCountObjectPtr _gf; TimeLabelConstOverseer _tlc; }; class MEDCouplingAMRAttribute : public MEDCouplingDataForGodFather, public TimeLabel { public: - MEDCOUPLING_EXPORT static MEDCouplingAMRAttribute *New(MEDCouplingCartesianAMRMeshGen *gf, const std::vector< std::pair >& fieldNames, int ghostLev); - MEDCOUPLING_EXPORT static MEDCouplingAMRAttribute *New(MEDCouplingCartesianAMRMeshGen *gf, const std::vector< std::pair > >& fieldNames, int ghostLev); + MEDCOUPLING_EXPORT static MEDCouplingAMRAttribute *New(MEDCouplingCartesianAMRMesh *gf, const std::vector< std::pair >& fieldNames, int ghostLev); + MEDCOUPLING_EXPORT static MEDCouplingAMRAttribute *New(MEDCouplingCartesianAMRMesh *gf, const std::vector< std::pair > >& fieldNames, int ghostLev); MEDCOUPLING_EXPORT void spillInfoOnComponents(const std::vector< std::vector >& compNames); MEDCOUPLING_EXPORT void spillNatures(const std::vector& nfs); MEDCOUPLING_EXPORT MEDCouplingAMRAttribute *deepCpy() const; @@ -138,13 +138,13 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT void synchronizeAllGhostZonesOfDirectChidrenOf(const MEDCouplingCartesianAMRMeshGen *mesh); MEDCOUPLING_EXPORT void alloc(); MEDCOUPLING_EXPORT void dealloc(); - MEDCOUPLING_EXPORT bool changeGodFather(MEDCouplingCartesianAMRMeshGen *gf); + MEDCOUPLING_EXPORT bool changeGodFather(MEDCouplingCartesianAMRMesh *gf); // MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; MEDCOUPLING_EXPORT std::vector getDirectChildren() const; MEDCOUPLING_EXPORT void updateTime() const; private: - MEDCouplingAMRAttribute(MEDCouplingCartesianAMRMeshGen *gf, const std::vector< std::pair >& fieldNames, int ghostLev); + MEDCouplingAMRAttribute(MEDCouplingCartesianAMRMesh *gf, const std::vector< std::pair >& fieldNames, int ghostLev); MEDCouplingAMRAttribute(const MEDCouplingAMRAttribute& other, bool deepCpyGF); const DataArrayDoubleCollection& findCollectionAttachedTo(const MEDCouplingCartesianAMRMeshGen *m) const; void synchronizeFineToCoarseByOneLevel(int level); diff --git a/src/MEDCoupling/MEDCouplingCartesianAMRMesh.cxx b/src/MEDCoupling/MEDCouplingCartesianAMRMesh.cxx index b215d722d..9ae34266a 100644 --- a/src/MEDCoupling/MEDCouplingCartesianAMRMesh.cxx +++ b/src/MEDCoupling/MEDCouplingCartesianAMRMesh.cxx @@ -55,11 +55,11 @@ MEDCouplingCartesianAMRPatchGen::MEDCouplingCartesianAMRPatchGen(MEDCouplingCart _mesh=mesh; _mesh->incrRef(); } -MEDCouplingCartesianAMRPatchGen::MEDCouplingCartesianAMRPatchGen(const MEDCouplingCartesianAMRPatchGen& other):RefCountObject(other),_mesh(other._mesh) +MEDCouplingCartesianAMRPatchGen::MEDCouplingCartesianAMRPatchGen(const MEDCouplingCartesianAMRPatchGen& other, MEDCouplingCartesianAMRMeshGen *father):RefCountObject(other),_mesh(other._mesh) { const MEDCouplingCartesianAMRMeshGen *mesh(other._mesh); if(mesh) - _mesh=mesh->deepCpy(); + _mesh=mesh->deepCpy(father); } const MEDCouplingCartesianAMRMeshGen *MEDCouplingCartesianAMRPatchGen::getMeshSafe() const @@ -98,9 +98,9 @@ MEDCouplingCartesianAMRPatch::MEDCouplingCartesianAMRPatch(MEDCouplingCartesianA throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRPatch constructor : space dimension of father and input bottomLeft/topRight size mismatches !"); } -MEDCouplingCartesianAMRPatch *MEDCouplingCartesianAMRPatch::deepCpy() const +MEDCouplingCartesianAMRPatch *MEDCouplingCartesianAMRPatch::deepCpy(MEDCouplingCartesianAMRMeshGen *father) const { - return new MEDCouplingCartesianAMRPatch(*this); + return new MEDCouplingCartesianAMRPatch(*this,father); } void MEDCouplingCartesianAMRPatch::addPatch(const std::vector< std::pair >& bottomLeftTopRight, const std::vector& factors) @@ -489,7 +489,7 @@ void MEDCouplingCartesianAMRPatch::UpdateNeighborsOfOneWithTwoInternal(int ghost MEDCouplingIMesh::CondenseFineToCoarse(dimsCoarse,ghostVals,interstRange,fakeFactors,dataOnP1); } -MEDCouplingCartesianAMRPatch::MEDCouplingCartesianAMRPatch(const MEDCouplingCartesianAMRPatch& other):MEDCouplingCartesianAMRPatchGen(other),_bl_tr(other._bl_tr) +MEDCouplingCartesianAMRPatch::MEDCouplingCartesianAMRPatch(const MEDCouplingCartesianAMRPatch& other, MEDCouplingCartesianAMRMeshGen *father):MEDCouplingCartesianAMRPatchGen(other,father),_bl_tr(other._bl_tr) { } @@ -531,9 +531,9 @@ MEDCouplingCartesianAMRPatchGF::MEDCouplingCartesianAMRPatchGF(MEDCouplingCartes { } -MEDCouplingCartesianAMRPatchGF *MEDCouplingCartesianAMRPatchGF::deepCpy() const +MEDCouplingCartesianAMRPatchGF *MEDCouplingCartesianAMRPatchGF::deepCpy(MEDCouplingCartesianAMRMeshGen *father) const { - return new MEDCouplingCartesianAMRPatchGF(*this); + return new MEDCouplingCartesianAMRPatchGF(*this,father); } std::size_t MEDCouplingCartesianAMRPatchGF::getHeapMemorySizeWithoutChildren() const @@ -541,7 +541,7 @@ std::size_t MEDCouplingCartesianAMRPatchGF::getHeapMemorySizeWithoutChildren() c return sizeof(MEDCouplingCartesianAMRPatchGF); } -MEDCouplingCartesianAMRPatchGF::MEDCouplingCartesianAMRPatchGF(const MEDCouplingCartesianAMRPatchGF& other):MEDCouplingCartesianAMRPatchGen(other) +MEDCouplingCartesianAMRPatchGF::MEDCouplingCartesianAMRPatchGF(const MEDCouplingCartesianAMRPatchGF& other, MEDCouplingCartesianAMRMeshGen *father):MEDCouplingCartesianAMRPatchGen(other,father) { } @@ -632,45 +632,6 @@ int MEDCouplingCartesianAMRMeshGen::getNumberOfCellsRecursiveWithoutOverlap() co return ret; } -const MEDCouplingCartesianAMRMeshGen *MEDCouplingCartesianAMRMeshGen::getFather() const -{ - return _father; -} - -const MEDCouplingCartesianAMRMeshGen *MEDCouplingCartesianAMRMeshGen::getGodFather() const -{ - if(_father==0) - return this; - else - return _father->getGodFather(); -} - -/*! - * This method returns the level of \a this. 0 for god father. 1 for children of god father ... - */ -int MEDCouplingCartesianAMRMeshGen::getAbsoluteLevel() const -{ - if(_father==0) - return 0; - else - return _father->getAbsoluteLevel()+1; -} - -int MEDCouplingCartesianAMRMeshGen::getAbsoluteLevelRelativeTo(const MEDCouplingCartesianAMRMeshGen *ref) const -{ - if(this==ref) - return 0; - if(_father==0) - { - if(ref==0) - return 0; - else - throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMeshGen::getAbsoluteLevelRelativeTo : ref is not in the progeny of this !"); - } - else - return _father->getAbsoluteLevelRelativeTo(ref)+1; -} - /*! * This method returns a vector of size equal to getAbsoluteLevelRelativeTo. It allows to find position an absolute position of \a this * relative to \a ref (that is typically the god father). @@ -733,23 +694,7 @@ std::vector MEDCouplingCartesianAMRMeshGen::r { if(absoluteLev<0) throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMesh::retrieveGridsAt : absolute level must be >=0 !"); - if(_father) - return getGodFather()->retrieveGridsAt(absoluteLev); - // - std::vector< MEDCouplingAutoRefCountObjectPtr > rets; - retrieveGridsAtInternal(absoluteLev,rets); - std::vector< MEDCouplingCartesianAMRPatchGen * > ret(rets.size()); - for(std::size_t i=0;iretrieveGridsAt(absoluteLev); } /*! @@ -1038,6 +983,30 @@ void DealWithCut(const InternalPatch *patchToBeSplit, int axisId, int cutPlace, /// @endcond +void MEDCouplingCartesianAMRMeshGen::removeAllPatches() +{ + _patches.clear(); + declareAsNew(); +} + +void MEDCouplingCartesianAMRMeshGen::removePatch(int patchId) +{ + checkPatchId(patchId); + int sz((int)_patches.size()),j(0); + std::vector< MEDCouplingAutoRefCountObjectPtr > patches(sz-1); + for(int i=0;i(_patches[patchId]->getMesh()))->detachFromFather(); + _patches=patches; + declareAsNew(); +} + +int MEDCouplingCartesianAMRMeshGen::getNumberOfPatches() const +{ + return (int)_patches.size(); +} + /*! * This method creates patches in \a this (by destroying the patches if any). This method uses \a criterion array as a field on cells on this level. * This method only create patches at level 0 relative to \a this. @@ -1046,7 +1015,7 @@ void MEDCouplingCartesianAMRMeshGen::createPatchesFromCriterion(const INTERP_KER { int nbCells(getNumberOfCellsAtCurrentLevel()); if(nbCells!=(int)criterion.size()) - throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMesh::createPatchesFromCriterion : the number of tuples of criterion array must be equal to the number of cells at the current level !"); + throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMeshGen::createPatchesFromCriterion : the number of tuples of criterion array must be equal to the number of cells at the current level !"); _patches.clear(); std::vector cgs(_mesh->getCellGridStructure()); std::vector< MEDCouplingAutoRefCountObjectPtr > listOfPatches,listOfPatchesOK; @@ -1091,7 +1060,7 @@ void MEDCouplingCartesianAMRMeshGen::createPatchesFromCriterion(const INTERP_KER void MEDCouplingCartesianAMRMeshGen::createPatchesFromCriterion(const INTERP_KERNEL::BoxSplittingOptions& bso, const DataArrayByte *criterion, const std::vector& factors) { if(!criterion || !criterion->isAllocated()) - throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMesh::createPatchesFromCriterion : the criterion DataArrayByte instance must be allocated and not NULL !"); + throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMeshGen::createPatchesFromCriterion : the criterion DataArrayByte instance must be allocated and not NULL !"); std::vector crit(criterion->toVectorOfBool());//check that criterion has one component. createPatchesFromCriterion(bso,crit,factors); declareAsNew(); @@ -1105,82 +1074,6 @@ void MEDCouplingCartesianAMRMeshGen::createPatchesFromCriterion(const INTERP_KER createPatchesFromCriterion(bso,inp,factors); } -/*! - * This method creates a multi level patches split at once. - * This method calls as times as size of \a bso createPatchesFromCriterion. Size of \a bso and size of \a factors must be the same ! - * \b WARNING, after the call the number of levels in \a this is equal to bso.size() + 1 ! - * - * \param [in] bso - * \param [in] criterion - * \param [in] factors - * \param [in] eps - See DataArrayDouble::toVectorOfBool for more information about the semantic of eps. - * - * \sa createPatchesFromCriterion - */ -void MEDCouplingCartesianAMRMeshGen::createPatchesFromCriterionML(const std::vector& bso, const DataArrayDouble *criterion, const std::vector< std::vector >& factors, double eps) -{ - std::size_t nbOfLevs(bso.size()); - if(nbOfLevs!=factors.size()) - throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMeshGen::createPatchesFromCriterionML : size of vectors must be the same !"); - if(nbOfLevs==0) - return ; - if(!bso[0]) - throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMeshGen::createPatchesFromCriterionML : pointers in 1st arg must be not NULL !"); - createPatchesFromCriterion(*bso[0],criterion,factors[0],eps); - for(std::size_t i=1;i elts(retrieveGridsAt((int)(i))); - std::size_t sz(elts.size()); - std::vector< MEDCouplingAutoRefCountObjectPtr > elts2(sz); - std::vector< MEDCouplingAutoRefCountObjectPtr > elts3(sz); - for(std::size_t ii=0;ii > fieldNames(1); fieldNames[0].first=TMP_STR; fieldNames[0].second=1; - MEDCouplingAutoRefCountObjectPtr att(MEDCouplingAMRAttribute::New(this,fieldNames,0)); - att->alloc(); - DataArrayDouble *tmpDa(const_cast(att->getFieldOn(this,TMP_STR))); - tmpDa->cpyFrom(*criterion); - att->synchronizeCoarseToFine(); - for(std::size_t ii=0;iigetFieldOn(const_cast(elts[ii]->getMesh()),TMP_STR)); - elts3[ii]=const_cast(critOnLeaf); elts3[ii]->incrRef(); - } - att=0; - for(std::size_t ii=0;ii(elts[ii]->getMesh())->createPatchesFromCriterion(*bso[i],elts3[ii],factors[i],eps); - } -} - -void MEDCouplingCartesianAMRMeshGen::removeAllPatches() -{ - _patches.clear(); - declareAsNew(); -} - -void MEDCouplingCartesianAMRMeshGen::removePatch(int patchId) -{ - checkPatchId(patchId); - int sz((int)_patches.size()),j(0); - std::vector< MEDCouplingAutoRefCountObjectPtr > patches(sz-1); - for(int i=0;i(_patches[patchId]->getMesh()))->detachFromFather(); - _patches=patches; - declareAsNew(); -} - -int MEDCouplingCartesianAMRMeshGen::getNumberOfPatches() const -{ - return (int)_patches.size(); -} - int MEDCouplingCartesianAMRMeshGen::getPatchIdFromChildMesh(const MEDCouplingCartesianAMRMeshGen *mesh) const { int ret(0); @@ -1214,7 +1107,7 @@ const MEDCouplingCartesianAMRPatch *MEDCouplingCartesianAMRMeshGen::getPatch(int bool MEDCouplingCartesianAMRMeshGen::isPatchInNeighborhoodOf(int patchId1, int patchId2, int ghostLev) const { const MEDCouplingCartesianAMRPatch *p1(getPatch(patchId1)),*p2(getPatch(patchId2)); - return p1->isInMyNeighborhood(p2,GetGhostLevelInFineRef(ghostLev,_factors)); + return p1->isInMyNeighborhood(p2,ghostLev); } /*! @@ -1586,7 +1479,7 @@ std::string MEDCouplingCartesianAMRMeshGen::buildPythonDumpOfThis() const return oss.str(); } -MEDCouplingCartesianAMRMeshGen::MEDCouplingCartesianAMRMeshGen(const MEDCouplingCartesianAMRMeshGen& other, MEDCouplingCartesianAMRMeshGen *father):_father(father),_mesh(other._mesh),_patches(other._patches),_factors(other._factors) +MEDCouplingCartesianAMRMeshGen::MEDCouplingCartesianAMRMeshGen(const MEDCouplingCartesianAMRMeshGen& other):RefCountObject(other),_mesh(other._mesh),_patches(other._patches),_factors(other._factors) { const MEDCouplingIMesh *mesh(other._mesh); if(mesh) @@ -1596,20 +1489,18 @@ MEDCouplingCartesianAMRMeshGen::MEDCouplingCartesianAMRMeshGen(const MEDCoupling { const MEDCouplingCartesianAMRPatch *patch(other._patches[i]); if(patch) - _patches[i]=patch->deepCpy(); + _patches[i]=patch->deepCpy(this); } } MEDCouplingCartesianAMRMeshGen::MEDCouplingCartesianAMRMeshGen(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop, - const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop):_father(0) + const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop) { _mesh=MEDCouplingIMesh::New(meshName,spaceDim,nodeStrctStart,nodeStrctStop,originStart,originStop,dxyzStart,dxyzStop); } -MEDCouplingCartesianAMRMeshGen::MEDCouplingCartesianAMRMeshGen(MEDCouplingCartesianAMRMeshGen *father, MEDCouplingIMesh *mesh):_father(father) +MEDCouplingCartesianAMRMeshGen::MEDCouplingCartesianAMRMeshGen(MEDCouplingIMesh *mesh) { - if(!_father) - throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMeshGen(MEDCouplingIMesh *mesh) constructor : empty father !"); if(!mesh) throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMeshGen(MEDCouplingIMesh *mesh) constructor : The input mesh is null !"); mesh->checkCoherency(); @@ -1749,20 +1640,6 @@ void MEDCouplingCartesianAMRMeshGen::dumpPatchesOf(const std::string& varName, s } } -/*! - * \sa getPositionRelativeTo - */ -void MEDCouplingCartesianAMRMeshGen::getPositionRelativeToInternal(const MEDCouplingCartesianAMRMeshGen *ref, std::vector& ret) const -{ - if(this==ref) - return ; - if(!_father) - throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMeshGen::getPositionRelativeToInternal : ref is not in the progeny of this !"); - int myId(_father->getPatchIdFromChildMesh(this)); - ret.push_back(myId); - _father->getPositionRelativeToInternal(ref,ret); -} - std::size_t MEDCouplingCartesianAMRMeshGen::getHeapMemorySizeWithoutChildren() const { return sizeof(MEDCouplingCartesianAMRMeshGen); @@ -1796,17 +1673,71 @@ void MEDCouplingCartesianAMRMeshGen::updateTime() const } } -MEDCouplingCartesianAMRMeshSub::MEDCouplingCartesianAMRMeshSub(MEDCouplingCartesianAMRMeshGen *father, MEDCouplingIMesh *mesh):MEDCouplingCartesianAMRMeshGen(father,mesh) +MEDCouplingCartesianAMRMeshSub::MEDCouplingCartesianAMRMeshSub(MEDCouplingCartesianAMRMeshGen *father, MEDCouplingIMesh *mesh):MEDCouplingCartesianAMRMeshGen(mesh),_father(father) +{ + if(!_father) + throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMeshSub(MEDCouplingCartesianAMRMeshGen *father, MEDCouplingIMesh *mesh) constructor : empty father !"); +} + +const MEDCouplingCartesianAMRMeshGen *MEDCouplingCartesianAMRMeshSub::getFather() const +{ + return _father; +} + +const MEDCouplingCartesianAMRMeshGen *MEDCouplingCartesianAMRMeshSub::getGodFather() const +{ + if(!_father) + throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMeshSub::getGodFather : Impossible to find a god father because there is a hole in chain !"); + return _father->getGodFather(); +} + +/*! + * This method returns the level of \a this. 0 for god father. 1 for children of god father ... + */ +int MEDCouplingCartesianAMRMeshSub::getAbsoluteLevel() const +{ + if(!_father) + throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMeshSub::getAbsoluteLevel : Impossible to find a god father because there is a hole in chain !"); + return _father->getAbsoluteLevel()+1; +} + +void MEDCouplingCartesianAMRMeshSub::detachFromFather() { + _father=0; + declareAsNew(); } -MEDCouplingCartesianAMRMeshSub::MEDCouplingCartesianAMRMeshSub(const MEDCouplingCartesianAMRMeshSub& other, MEDCouplingCartesianAMRMeshGen *father):MEDCouplingCartesianAMRMeshGen(other,father) +int MEDCouplingCartesianAMRMeshSub::getAbsoluteLevelRelativeTo(const MEDCouplingCartesianAMRMeshGen *ref) const { + if(this==ref) + return 0; + if(_father==0) + throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMeshSub::getAbsoluteLevelRelativeTo : ref is not in the progeny of this !"); + else + return _father->getAbsoluteLevelRelativeTo(ref)+1; } -MEDCouplingCartesianAMRMeshSub *MEDCouplingCartesianAMRMeshSub::deepCpy() const +MEDCouplingCartesianAMRMeshSub::MEDCouplingCartesianAMRMeshSub(const MEDCouplingCartesianAMRMeshSub& other, MEDCouplingCartesianAMRMeshGen *father):MEDCouplingCartesianAMRMeshGen(other),_father(father) +{ +} + +MEDCouplingCartesianAMRMeshSub *MEDCouplingCartesianAMRMeshSub::deepCpy(MEDCouplingCartesianAMRMeshGen *fath) const +{ + return new MEDCouplingCartesianAMRMeshSub(*this,fath); +} + +/*! + * \sa getPositionRelativeTo + */ +void MEDCouplingCartesianAMRMeshSub::getPositionRelativeToInternal(const MEDCouplingCartesianAMRMeshGen *ref, std::vector& ret) const { - return new MEDCouplingCartesianAMRMeshSub(*this,_father); + if(this==ref) + return ; + if(!_father) + throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMeshSub::getPositionRelativeToInternal : ref is not in the progeny of this !"); + int myId(_father->getPatchIdFromChildMesh(this)); + ret.push_back(myId); + _father->getPositionRelativeToInternal(ref,ret); } MEDCouplingCartesianAMRMesh *MEDCouplingCartesianAMRMesh::New(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop, @@ -1815,12 +1746,110 @@ MEDCouplingCartesianAMRMesh *MEDCouplingCartesianAMRMesh::New(const std::string& return new MEDCouplingCartesianAMRMesh(meshName,spaceDim,nodeStrctStart,nodeStrctStop,originStart,originStop,dxyzStart,dxyzStop); } -MEDCouplingCartesianAMRMesh *MEDCouplingCartesianAMRMesh::deepCpy() const +const MEDCouplingCartesianAMRMeshGen *MEDCouplingCartesianAMRMesh::getFather() const +{ + //I'm god father ! No father ! + return 0; +} + +const MEDCouplingCartesianAMRMeshGen *MEDCouplingCartesianAMRMesh::getGodFather() const +{ + return this; +} + +int MEDCouplingCartesianAMRMesh::getAbsoluteLevel() const +{ + return 0; +} + +void MEDCouplingCartesianAMRMesh::detachFromFather() +{//not a bug - do nothing +} + +int MEDCouplingCartesianAMRMesh::getAbsoluteLevelRelativeTo(const MEDCouplingCartesianAMRMeshGen *ref) const { + if(this==ref) + return 0; + throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMesh::getAbsoluteLevelRelativeTo : ref is not in the progeny of this !"); +} + +std::vector MEDCouplingCartesianAMRMesh::retrieveGridsAt(int absoluteLev) const +{ + std::vector< MEDCouplingAutoRefCountObjectPtr > rets; + retrieveGridsAtInternal(absoluteLev,rets); + std::vector< MEDCouplingCartesianAMRPatchGen * > ret(rets.size()); + for(std::size_t i=0;i& bso, const DataArrayDouble *criterion, const std::vector< std::vector >& factors, double eps) +{ + std::size_t nbOfLevs(bso.size()); + if(nbOfLevs!=factors.size()) + throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMesh::createPatchesFromCriterionML : size of vectors must be the same !"); + if(nbOfLevs==0) + return ; + if(!bso[0]) + throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMesh::createPatchesFromCriterionML : pointers in 1st arg must be not NULL !"); + createPatchesFromCriterion(*bso[0],criterion,factors[0],eps); + for(std::size_t i=1;i elts(retrieveGridsAt((int)(i))); + std::size_t sz(elts.size()); + std::vector< MEDCouplingAutoRefCountObjectPtr > elts2(sz); + std::vector< MEDCouplingAutoRefCountObjectPtr > elts3(sz); + for(std::size_t ii=0;ii > fieldNames(1); fieldNames[0].first=TMP_STR; fieldNames[0].second=1; + MEDCouplingAutoRefCountObjectPtr att(MEDCouplingAMRAttribute::New(this,fieldNames,0)); + att->alloc(); + DataArrayDouble *tmpDa(const_cast(att->getFieldOn(this,TMP_STR))); + tmpDa->cpyFrom(*criterion); + att->synchronizeCoarseToFine(); + for(std::size_t ii=0;iigetFieldOn(const_cast(elts[ii]->getMesh()),TMP_STR)); + elts3[ii]=const_cast(critOnLeaf); elts3[ii]->incrRef(); + } + att=0; + for(std::size_t ii=0;ii(elts[ii]->getMesh())->createPatchesFromCriterion(*bso[i],elts3[ii],factors[i],eps); + } +} + +void MEDCouplingCartesianAMRMesh::getPositionRelativeToInternal(const MEDCouplingCartesianAMRMeshGen *ref, std::vector& ret) const +{ + +} + +MEDCouplingCartesianAMRMesh::MEDCouplingCartesianAMRMesh(const MEDCouplingCartesianAMRMesh& other):MEDCouplingCartesianAMRMeshGen(other) { } diff --git a/src/MEDCoupling/MEDCouplingCartesianAMRMesh.hxx b/src/MEDCoupling/MEDCouplingCartesianAMRMesh.hxx index 02202ac2a..0beca01dc 100644 --- a/src/MEDCoupling/MEDCouplingCartesianAMRMesh.hxx +++ b/src/MEDCoupling/MEDCouplingCartesianAMRMesh.hxx @@ -49,13 +49,13 @@ namespace ParaMEDMEM class MEDCouplingCartesianAMRPatchGen : public RefCountObject { public: - MEDCOUPLING_EXPORT virtual MEDCouplingCartesianAMRPatchGen *deepCpy() const = 0; + MEDCOUPLING_EXPORT virtual MEDCouplingCartesianAMRPatchGen *deepCpy(MEDCouplingCartesianAMRMeshGen *father) const = 0; MEDCOUPLING_EXPORT int getNumberOfCellsRecursiveWithOverlap() const; MEDCOUPLING_EXPORT int getNumberOfCellsRecursiveWithoutOverlap() const; MEDCOUPLING_EXPORT int getMaxNumberOfLevelsRelativeToThis() const; MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRMeshGen *getMesh() const { return _mesh; } protected: - MEDCouplingCartesianAMRPatchGen(const MEDCouplingCartesianAMRPatchGen& other); + MEDCouplingCartesianAMRPatchGen(const MEDCouplingCartesianAMRPatchGen& other, MEDCouplingCartesianAMRMeshGen *father); MEDCouplingCartesianAMRPatchGen(MEDCouplingCartesianAMRMeshGen *mesh); const MEDCouplingCartesianAMRMeshGen *getMeshSafe() const; MEDCouplingCartesianAMRMeshGen *getMeshSafe(); @@ -72,7 +72,7 @@ namespace ParaMEDMEM { public: MEDCouplingCartesianAMRPatch(MEDCouplingCartesianAMRMeshGen *mesh, const std::vector< std::pair >& bottomLeftTopRight); - MEDCouplingCartesianAMRPatch *deepCpy() const; + MEDCouplingCartesianAMRPatch *deepCpy(MEDCouplingCartesianAMRMeshGen *father) const; // direct forward to _mesh MEDCOUPLING_EXPORT void addPatch(const std::vector< std::pair >& bottomLeftTopRight, const std::vector& factors); // end of direct forward to _mesh @@ -101,7 +101,7 @@ namespace ParaMEDMEM static void ApplyFactorsOnCompactFrmt(std::vector< std::pair >& partBeforeFact, const std::vector& factors); static void ApplyAllGhostOnCompactFrmt(std::vector< std::pair >& partBeforeFact, int ghostSize); private: - MEDCouplingCartesianAMRPatch(const MEDCouplingCartesianAMRPatch& other); + MEDCouplingCartesianAMRPatch(const MEDCouplingCartesianAMRPatch& other, MEDCouplingCartesianAMRMeshGen *father); private: //! bottom left/top right cell range relative to \a _father std::vector< std::pair > _bl_tr; @@ -114,11 +114,11 @@ namespace ParaMEDMEM { public: MEDCouplingCartesianAMRPatchGF(MEDCouplingCartesianAMRMesh *mesh); - MEDCouplingCartesianAMRPatchGF *deepCpy() const; + MEDCouplingCartesianAMRPatchGF *deepCpy(MEDCouplingCartesianAMRMeshGen *father) const; private: std::size_t getHeapMemorySizeWithoutChildren() const; private: - MEDCouplingCartesianAMRPatchGF(const MEDCouplingCartesianAMRPatchGF& other); + MEDCouplingCartesianAMRPatchGF(const MEDCouplingCartesianAMRPatchGF& other, MEDCouplingCartesianAMRMeshGen *father); }; /// @endcond @@ -131,7 +131,7 @@ namespace ParaMEDMEM class MEDCouplingCartesianAMRMeshGen : public RefCountObject, public TimeLabel { public: - MEDCOUPLING_EXPORT virtual MEDCouplingCartesianAMRMeshGen *deepCpy() const = 0; + MEDCOUPLING_EXPORT virtual MEDCouplingCartesianAMRMeshGen *deepCpy(MEDCouplingCartesianAMRMeshGen *father) const = 0; MEDCOUPLING_EXPORT int getSpaceDimension() const; MEDCOUPLING_EXPORT const std::vector& getFactors() const { return _factors; } MEDCOUPLING_EXPORT void setFactors(const std::vector& newFactors); @@ -142,23 +142,22 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT int getNumberOfCellsRecursiveWithoutOverlap() const; MEDCOUPLING_EXPORT const MEDCouplingIMesh *getImageMesh() const { return _mesh; } // - MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRMeshGen *getFather() const; - MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRMeshGen *getGodFather() const; - MEDCOUPLING_EXPORT int getAbsoluteLevel() const; - MEDCOUPLING_EXPORT int getAbsoluteLevelRelativeTo(const MEDCouplingCartesianAMRMeshGen *ref) const; + MEDCOUPLING_EXPORT virtual const MEDCouplingCartesianAMRMeshGen *getFather() const = 0; + MEDCOUPLING_EXPORT virtual const MEDCouplingCartesianAMRMeshGen *getGodFather() const = 0; + MEDCOUPLING_EXPORT virtual int getAbsoluteLevel() const = 0; + MEDCOUPLING_EXPORT virtual void detachFromFather() = 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; MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRMeshGen *getMeshAtPosition(const std::vector& pos) const; - MEDCOUPLING_EXPORT std::vector retrieveGridsAt(int absoluteLev) const; - MEDCOUPLING_EXPORT void detachFromFather(); + MEDCOUPLING_EXPORT virtual std::vector retrieveGridsAt(int absoluteLev) const; MEDCOUPLING_EXPORT void addPatch(const std::vector< std::pair >& bottomLeftTopRight, const std::vector& factors); - MEDCOUPLING_EXPORT void createPatchesFromCriterion(const INTERP_KERNEL::BoxSplittingOptions& bso, const std::vector& criterion, const std::vector& factors); - MEDCOUPLING_EXPORT void createPatchesFromCriterion(const INTERP_KERNEL::BoxSplittingOptions& bso, const DataArrayByte *criterion, const std::vector& factors); - MEDCOUPLING_EXPORT void createPatchesFromCriterion(const INTERP_KERNEL::BoxSplittingOptions& bso, const DataArrayDouble *criterion, const std::vector& factors, double eps); - MEDCOUPLING_EXPORT void createPatchesFromCriterionML(const std::vector& bso, const DataArrayDouble *criterion, const std::vector< std::vector >& factors, double eps); MEDCOUPLING_EXPORT void removeAllPatches(); MEDCOUPLING_EXPORT void removePatch(int patchId); MEDCOUPLING_EXPORT int getNumberOfPatches() const; + MEDCOUPLING_EXPORT void createPatchesFromCriterion(const INTERP_KERNEL::BoxSplittingOptions& bso, const std::vector& criterion, const std::vector& factors); + MEDCOUPLING_EXPORT void createPatchesFromCriterion(const INTERP_KERNEL::BoxSplittingOptions& bso, const DataArrayByte *criterion, const std::vector& factors); + MEDCOUPLING_EXPORT void createPatchesFromCriterion(const INTERP_KERNEL::BoxSplittingOptions& bso, const DataArrayDouble *criterion, const std::vector& factors, double eps); MEDCOUPLING_EXPORT int getPatchIdFromChildMesh(const MEDCouplingCartesianAMRMeshGen *mesh) const; MEDCOUPLING_EXPORT std::vector< const MEDCouplingCartesianAMRPatch *> getPatches() const; MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRPatch *getPatch(int patchId) const; @@ -187,24 +186,23 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT std::vector getPatchIdsInTheNeighborhoodOf(int patchId, int ghostLev) const; MEDCOUPLING_EXPORT std::string buildPythonDumpOfThis() const; protected: - MEDCouplingCartesianAMRMeshGen(const MEDCouplingCartesianAMRMeshGen& other, MEDCouplingCartesianAMRMeshGen *father); + MEDCouplingCartesianAMRMeshGen(const MEDCouplingCartesianAMRMeshGen& other); MEDCouplingCartesianAMRMeshGen(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop, const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop); - MEDCouplingCartesianAMRMeshGen(MEDCouplingCartesianAMRMeshGen *father, MEDCouplingIMesh *mesh); + MEDCouplingCartesianAMRMeshGen(MEDCouplingIMesh *mesh); void checkPatchId(int patchId) const; void checkFactorsAndIfNotSetAssign(const std::vector& factors); void retrieveGridsAtInternal(int lev, std::vector< MEDCouplingAutoRefCountObjectPtr >& grids) const; static int GetGhostLevelInFineRef(int ghostLev, const std::vector& factors); std::vector extractSubTreeFromGlobalFlatten(const MEDCouplingCartesianAMRMeshGen *head, const std::vector& all) const; void dumpPatchesOf(const std::string& varName, std::ostream& oss) const; - void getPositionRelativeToInternal(const MEDCouplingCartesianAMRMeshGen *ref, std::vector& ret) const; + public: + virtual void getPositionRelativeToInternal(const MEDCouplingCartesianAMRMeshGen *ref, std::vector& ret) const = 0; protected: MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; MEDCOUPLING_EXPORT std::vector getDirectChildren() const; MEDCOUPLING_EXPORT void updateTime() const; protected: - MEDCouplingCartesianAMRMeshGen *_father; - private: MEDCouplingAutoRefCountObjectPtr _mesh; std::vector< MEDCouplingAutoRefCountObjectPtr > _patches; std::vector _factors; @@ -214,9 +212,17 @@ namespace ParaMEDMEM { public: MEDCouplingCartesianAMRMeshSub(MEDCouplingCartesianAMRMeshGen *father, MEDCouplingIMesh *mesh); + MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRMeshGen *getFather() const; + MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRMeshGen *getGodFather() const; + MEDCOUPLING_EXPORT int getAbsoluteLevel() const; + MEDCOUPLING_EXPORT void detachFromFather(); + MEDCOUPLING_EXPORT int getAbsoluteLevelRelativeTo(const MEDCouplingCartesianAMRMeshGen *ref) const; private: MEDCouplingCartesianAMRMeshSub(const MEDCouplingCartesianAMRMeshSub& other, MEDCouplingCartesianAMRMeshGen *father); - MEDCouplingCartesianAMRMeshSub *deepCpy() const; + MEDCouplingCartesianAMRMeshSub *deepCpy(MEDCouplingCartesianAMRMeshGen *father) const; + void getPositionRelativeToInternal(const MEDCouplingCartesianAMRMeshGen *ref, std::vector& ret) const; + protected: + MEDCouplingCartesianAMRMeshGen *_father; }; class MEDCouplingCartesianAMRMesh : public MEDCouplingCartesianAMRMeshGen @@ -224,8 +230,16 @@ namespace ParaMEDMEM public: MEDCOUPLING_EXPORT static MEDCouplingCartesianAMRMesh *New(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop, const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop); + MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRMeshGen *getFather() const; + MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRMeshGen *getGodFather() const; + MEDCOUPLING_EXPORT int getAbsoluteLevel() const; + MEDCOUPLING_EXPORT void detachFromFather(); + MEDCOUPLING_EXPORT int getAbsoluteLevelRelativeTo(const MEDCouplingCartesianAMRMeshGen *ref) const; + MEDCOUPLING_EXPORT std::vector retrieveGridsAt(int absoluteLev) const; + MEDCouplingCartesianAMRMesh *deepCpy(MEDCouplingCartesianAMRMeshGen *father) const; + MEDCOUPLING_EXPORT void createPatchesFromCriterionML(const std::vector& bso, const DataArrayDouble *criterion, const std::vector< std::vector >& factors, double eps); private: - MEDCouplingCartesianAMRMesh *deepCpy() const; + void getPositionRelativeToInternal(const MEDCouplingCartesianAMRMeshGen *ref, std::vector& ret) const; MEDCouplingCartesianAMRMesh(const MEDCouplingCartesianAMRMesh& other); MEDCouplingCartesianAMRMesh(const std::string& meshName, int spaceDim, const int *nodeStrctStart, const int *nodeStrctStop, const double *originStart, const double *originStop, const double *dxyzStart, const double *dxyzStop); diff --git a/src/MEDCoupling_Swig/MEDCouplingCommon.i b/src/MEDCoupling_Swig/MEDCouplingCommon.i index b51868769..95a69ff91 100644 --- a/src/MEDCoupling_Swig/MEDCouplingCommon.i +++ b/src/MEDCoupling_Swig/MEDCouplingCommon.i @@ -338,7 +338,6 @@ using namespace INTERP_KERNEL; %newobject ParaMEDMEM::MEDCouplingMultiFields::New; %newobject ParaMEDMEM::MEDCouplingMultiFields::deepCpy; %newobject ParaMEDMEM::MEDCouplingFieldOverTime::New; -%newobject ParaMEDMEM::MEDCouplingCartesianAMRPatchGen::deepCpy; %newobject ParaMEDMEM::MEDCouplingCartesianAMRPatchGen::getMesh; %newobject ParaMEDMEM::MEDCouplingCartesianAMRPatchGen::__getitem__; %newobject ParaMEDMEM::MEDCouplingCartesianAMRMeshGen::deepCpy; @@ -4840,7 +4839,6 @@ namespace ParaMEDMEM class MEDCouplingCartesianAMRPatchGen : public RefCountObject { public: - virtual MEDCouplingCartesianAMRPatchGen *deepCpy() const throw(INTERP_KERNEL::Exception); int getNumberOfCellsRecursiveWithOverlap() const throw(INTERP_KERNEL::Exception); int getNumberOfCellsRecursiveWithoutOverlap() const throw(INTERP_KERNEL::Exception); int getMaxNumberOfLevelsRelativeToThis() const throw(INTERP_KERNEL::Exception); @@ -4920,7 +4918,7 @@ namespace ParaMEDMEM class MEDCouplingCartesianAMRMeshGen : public RefCountObject, public TimeLabel { public: - virtual MEDCouplingCartesianAMRMeshGen *deepCpy() const throw(INTERP_KERNEL::Exception); + virtual MEDCouplingCartesianAMRMeshGen *deepCpy(MEDCouplingCartesianAMRMeshGen *father) const throw(INTERP_KERNEL::Exception); int getAbsoluteLevel() const throw(INTERP_KERNEL::Exception); int getAbsoluteLevelRelativeTo(const MEDCouplingCartesianAMRMeshGen *ref) const throw(INTERP_KERNEL::Exception); std::vector getPositionRelativeTo(const MEDCouplingCartesianAMRMeshGen *ref) const throw(INTERP_KERNEL::Exception); @@ -4933,6 +4931,7 @@ namespace ParaMEDMEM int getNumberOfCellsRecursiveWithOverlap() const throw(INTERP_KERNEL::Exception); int getNumberOfCellsRecursiveWithoutOverlap() const throw(INTERP_KERNEL::Exception); bool isPatchInNeighborhoodOf(int patchId1, int patchId2, int ghostLev) const throw(INTERP_KERNEL::Exception); + virtual void detachFromFather() throw(INTERP_KERNEL::Exception); // int getNumberOfPatches() const throw(INTERP_KERNEL::Exception); int getPatchIdFromChildMesh(const MEDCouplingCartesianAMRMeshGen *mesh) const throw(INTERP_KERNEL::Exception); @@ -4943,7 +4942,6 @@ namespace ParaMEDMEM MEDCoupling1SGTUMesh *buildMeshOfDirectChildrenOnly() const throw(INTERP_KERNEL::Exception); void removeAllPatches() throw(INTERP_KERNEL::Exception); void removePatch(int patchId) throw(INTERP_KERNEL::Exception); - void detachFromFather() throw(INTERP_KERNEL::Exception); void createPatchesFromCriterion(const INTERP_KERNEL::BoxSplittingOptions& bso, const DataArrayByte *criterion, const std::vector& factors) throw(INTERP_KERNEL::Exception); void createPatchesFromCriterion(const INTERP_KERNEL::BoxSplittingOptions& bso, const DataArrayDouble *criterion, const std::vector& factors, double eps) throw(INTERP_KERNEL::Exception); DataArrayDouble *createCellFieldOnPatch(int patchId, const DataArrayDouble *cellFieldOnThis) const throw(INTERP_KERNEL::Exception); @@ -4997,16 +4995,7 @@ namespace ParaMEDMEM return ret2; } - void createPatchesFromCriterionML(PyObject *bso, const DataArrayDouble *criterion, PyObject *factors, double eps) throw(INTERP_KERNEL::Exception) - { - std::vector inp0; - convertFromPyObjVectorOfObj(bso,SWIGTYPE_p_INTERP_KERNEL__BoxSplittingOptions,"BoxSplittingOptions",inp0); - std::vector< std::vector > inp2; - convertPyToVectorOfVectorOfInt(factors,inp2); - self->createPatchesFromCriterionML(inp0,criterion,inp2,eps); - } - - PyObject *retrieveGridsAt(int absoluteLev) const throw(INTERP_KERNEL::Exception) + virtual PyObject *retrieveGridsAt(int absoluteLev) const throw(INTERP_KERNEL::Exception) { std::vector ps(self->retrieveGridsAt(absoluteLev)); int sz(ps.size()); @@ -5023,7 +5012,7 @@ namespace ParaMEDMEM return self->buildCellFieldOnRecurseWithoutOverlapWithoutGhost(ghostSz,inp); } - MEDCouplingCartesianAMRMeshGen *getFather() const throw(INTERP_KERNEL::Exception) + virtual MEDCouplingCartesianAMRMeshGen *getFather() const throw(INTERP_KERNEL::Exception) { MEDCouplingCartesianAMRMeshGen *ret(const_cast(self->getFather())); if(ret) @@ -5031,7 +5020,7 @@ namespace ParaMEDMEM return ret; } - MEDCouplingCartesianAMRMeshGen *getGodFather() const throw(INTERP_KERNEL::Exception) + virtual MEDCouplingCartesianAMRMeshGen *getGodFather() const throw(INTERP_KERNEL::Exception) { MEDCouplingCartesianAMRMeshGen *ret(const_cast(self->getGodFather())); if(ret) @@ -5124,6 +5113,15 @@ namespace ParaMEDMEM return MEDCouplingCartesianAMRMesh::New(meshName,spaceDim,nodeStrctPtr,nodeStrctPtr+sz,originPtr,originPtr+sz1,dxyzPtr,dxyzPtr+sz2); } + void createPatchesFromCriterionML(PyObject *bso, const DataArrayDouble *criterion, PyObject *factors, double eps) throw(INTERP_KERNEL::Exception) + { + std::vector inp0; + convertFromPyObjVectorOfObj(bso,SWIGTYPE_p_INTERP_KERNEL__BoxSplittingOptions,"BoxSplittingOptions",inp0); + std::vector< std::vector > inp2; + convertPyToVectorOfVectorOfInt(factors,inp2); + self->createPatchesFromCriterionML(inp0,criterion,inp2,eps); + } + MEDCouplingCartesianAMRMesh(const std::string& meshName, int spaceDim, PyObject *nodeStrct, PyObject *origin, PyObject *dxyz) throw(INTERP_KERNEL::Exception) { return ParaMEDMEM_MEDCouplingCartesianAMRMesh_New(meshName,spaceDim,nodeStrct,origin,dxyz); @@ -5144,9 +5142,9 @@ namespace ParaMEDMEM virtual void dealloc() throw(INTERP_KERNEL::Exception); %extend { - MEDCouplingCartesianAMRMeshGen *getMyGodFather() throw(INTERP_KERNEL::Exception) + MEDCouplingCartesianAMRMesh *getMyGodFather() throw(INTERP_KERNEL::Exception) { - MEDCouplingCartesianAMRMeshGen *ret(self->getMyGodFather()); + MEDCouplingCartesianAMRMesh *ret(self->getMyGodFather()); if(ret) ret->incrRef(); return ret;