From: geay Date: Fri, 13 Jun 2014 13:12:35 +0000 (+0200) Subject: Debug on condensation with ghostSz>1 + more synchronization methods. X-Git-Tag: V7_5_0a1~2^2~32^2~11 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=d36300c7c483fb3a2eebc4ba89c67600447e37a9;p=tools%2Fmedcoupling.git Debug on condensation with ghostSz>1 + more synchronization methods. --- diff --git a/src/MEDCoupling/MEDCouplingAMRAttribute.cxx b/src/MEDCoupling/MEDCouplingAMRAttribute.cxx index f27671edd..b9c1559de 100644 --- a/src/MEDCoupling/MEDCouplingAMRAttribute.cxx +++ b/src/MEDCoupling/MEDCouplingAMRAttribute.cxx @@ -298,9 +298,9 @@ MEDCouplingGridCollection *MEDCouplingGridCollection::New(const std::vector pos(other._map_of_dadc[i].first->getPositionRelativeTo(oldGf)); + _map_of_dadc[i].first=newGf->getMeshAtPosition(pos); const DataArrayDoubleCollection *dac(other._map_of_dadc[i].second); if(dac) _map_of_dadc[i].second=dac->deepCpy(); @@ -583,13 +584,9 @@ void MEDCouplingGridCollection::updateTime() const } } -MEDCouplingCartesianAMRPatchGF::MEDCouplingCartesianAMRPatchGF(MEDCouplingCartesianAMRMesh *mesh):MEDCouplingCartesianAMRPatchGen(mesh) +MEDCouplingCartesianAMRMeshGen *MEDCouplingDataForGodFather::getMyGodFather() { -} - -std::size_t MEDCouplingCartesianAMRPatchGF::getHeapMemorySizeWithoutChildren() const -{ - return sizeof(MEDCouplingCartesianAMRPatchGF); + return _gf; } MEDCouplingDataForGodFather::MEDCouplingDataForGodFather(MEDCouplingCartesianAMRMeshGen *gf):_gf(gf),_tlc(gf) @@ -616,9 +613,16 @@ bool MEDCouplingDataForGodFather::changeGodFather(MEDCouplingCartesianAMRMeshGen return ret; } -MEDCouplingDataForGodFather::MEDCouplingDataForGodFather(const MEDCouplingDataForGodFather& other):RefCountObject(other),_gf(other._gf),_tlc(other._gf) +MEDCouplingDataForGodFather::MEDCouplingDataForGodFather(const MEDCouplingDataForGodFather& other, bool deepCpyGF):RefCountObject(other),_gf(other._gf),_tlc(other._gf) { other._tlc.checkConst(); + if(deepCpyGF) + { + const MEDCouplingCartesianAMRMeshGen *gf(other._gf); + if(gf) + _gf=gf->deepCpy(); + _tlc.keepTrackOfNewTL(_gf); + } } /*! @@ -671,7 +675,12 @@ void MEDCouplingAMRAttribute::spillNatures(const std::vector& nfs MEDCouplingAMRAttribute *MEDCouplingAMRAttribute::deepCpy() const { - return new MEDCouplingAMRAttribute(*this); + return new MEDCouplingAMRAttribute(*this,true); +} + +MEDCouplingAMRAttribute *MEDCouplingAMRAttribute::deepCpyWithoutGodFather() const +{ + return new MEDCouplingAMRAttribute(*this,false); } /*! @@ -912,17 +921,17 @@ void MEDCouplingAMRAttribute::synchronizeCoarseToFineBetween(int fromLev, int to */ void MEDCouplingAMRAttribute::synchronizeAllGhostZones() { - if(_levs.empty()) + int sz(getNumberOfLevels()); + if(sz==0) throw INTERP_KERNEL::Exception("MEDCouplingAMRAttribute::synchronizeFineEachOther : not any levels in this !"); // 1st - synchronize from coarse to the finest all the patches (excepted the god father one) - std::size_t sz(_levs.size()); - for(std::size_t i=1;isynchronizeFineEachOtherExt(_ghost_lev,_cross_lev_neighbors[i]); } } +/*! + * This method + */ +void MEDCouplingAMRAttribute::synchronizeAllGhostZonesOfDirectChidrenOf(const MEDCouplingCartesianAMRMeshGen *mesh) +{ + if(!mesh) + throw INTERP_KERNEL::Exception("MEDCouplingAMRAttribute::synchronizeAllGhostZonesOfDirectChidrenOf : input mesh is NULL !"); + 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;patchIdgetMesh())); + DataArrayDoubleCollection *colFine2(const_cast(&colFine)); + DataArrayDoubleCollection::SynchronizeCoarseToFineOnlyInGhostZone(_ghost_lev,mesh,(int)patchId,&colCoarse,colFine2); + } +} + /*! * This method allocates all DataArrayDouble instances stored recursively in \a this. * @@ -1055,7 +1085,7 @@ MEDCouplingAMRAttribute::MEDCouplingAMRAttribute(MEDCouplingCartesianAMRMeshGen } } -MEDCouplingAMRAttribute::MEDCouplingAMRAttribute(const MEDCouplingAMRAttribute& other):MEDCouplingDataForGodFather(other),_ghost_lev(other._ghost_lev),_levs(other._levs.size()),_neighbors(other._neighbors),_mixed_lev_neighbors(other._mixed_lev_neighbors),_cross_lev_neighbors(other._cross_lev_neighbors) +MEDCouplingAMRAttribute::MEDCouplingAMRAttribute(const MEDCouplingAMRAttribute& other, bool deepCpyGF):MEDCouplingDataForGodFather(other,deepCpyGF),_ghost_lev(other._ghost_lev),_levs(other._levs.size()),_neighbors(other._neighbors),_mixed_lev_neighbors(other._mixed_lev_neighbors),_cross_lev_neighbors(other._cross_lev_neighbors) { std::size_t sz(other._levs.size()); for(std::size_t i=0;ideepCpy(); + _levs[i]=other._levs[i]->deepCpy(_gf,other._gf); } } } diff --git a/src/MEDCoupling/MEDCouplingAMRAttribute.hxx b/src/MEDCoupling/MEDCouplingAMRAttribute.hxx index 2b7eb68d3..a2ac9b418 100644 --- a/src/MEDCoupling/MEDCouplingAMRAttribute.hxx +++ b/src/MEDCoupling/MEDCouplingAMRAttribute.hxx @@ -64,7 +64,7 @@ namespace ParaMEDMEM { public: static MEDCouplingGridCollection *New(const std::vector& ms, const std::vector< std::pair >& fieldNames); - MEDCouplingGridCollection *deepCpy() const; + MEDCouplingGridCollection *deepCpy(const MEDCouplingCartesianAMRMeshGen *newGf, const MEDCouplingCartesianAMRMeshGen *oldGf) const; void alloc(int ghostLev); void dealloc(); void spillInfoOnComponents(const std::vector< std::vector >& compNames); @@ -80,7 +80,7 @@ namespace ParaMEDMEM void fillIfInTheProgenyOf(const std::string& fieldName, const MEDCouplingCartesianAMRMeshGen *head, std::vector& recurseArrs) const; private: MEDCouplingGridCollection(const std::vector& ms, const std::vector< std::pair >& fieldNames); - MEDCouplingGridCollection(const MEDCouplingGridCollection& other); + MEDCouplingGridCollection(const MEDCouplingGridCollection& other, const MEDCouplingCartesianAMRMeshGen *newGf, const MEDCouplingCartesianAMRMeshGen *oldGf); std::size_t getHeapMemorySizeWithoutChildren() const; std::vector getDirectChildren() const; void updateTime() const; @@ -94,11 +94,13 @@ namespace ParaMEDMEM { friend class MEDCouplingCartesianAMRMesh; public: + MEDCOUPLING_EXPORT MEDCouplingCartesianAMRMeshGen *getMyGodFather(); MEDCOUPLING_EXPORT virtual void synchronizeFineToCoarse() = 0; MEDCOUPLING_EXPORT virtual void synchronizeFineToCoarseBetween(int fromLev, int toLev) = 0; MEDCOUPLING_EXPORT virtual void synchronizeCoarseToFine() = 0; MEDCOUPLING_EXPORT virtual void synchronizeCoarseToFineBetween(int fromLev, int toLev) = 0; MEDCOUPLING_EXPORT virtual void synchronizeAllGhostZones() = 0; + MEDCOUPLING_EXPORT virtual void synchronizeAllGhostZonesOfDirectChidrenOf(const MEDCouplingCartesianAMRMeshGen *mesh) = 0; MEDCOUPLING_EXPORT virtual void alloc() = 0; MEDCOUPLING_EXPORT virtual void dealloc() = 0; protected: @@ -106,7 +108,7 @@ namespace ParaMEDMEM void checkGodFatherFrozen() const; protected: virtual bool changeGodFather(MEDCouplingCartesianAMRMeshGen *gf); - MEDCouplingDataForGodFather(const MEDCouplingDataForGodFather& other); + MEDCouplingDataForGodFather(const MEDCouplingDataForGodFather& other, bool deepCpyGF); protected: MEDCouplingAutoRefCountObjectPtr _gf; TimeLabelConstOverseer _tlc; @@ -120,6 +122,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT void spillInfoOnComponents(const std::vector< std::vector >& compNames); MEDCOUPLING_EXPORT void spillNatures(const std::vector& nfs); MEDCOUPLING_EXPORT MEDCouplingAMRAttribute *deepCpy() const; + MEDCOUPLING_EXPORT MEDCouplingAMRAttribute *deepCpyWithoutGodFather() const; MEDCOUPLING_EXPORT int getNumberOfLevels() const; MEDCOUPLING_EXPORT std::vector retrieveFieldsOn(MEDCouplingCartesianAMRMeshGen *mesh) const; MEDCOUPLING_EXPORT const DataArrayDouble *getFieldOn(MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) const; @@ -132,6 +135,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT void synchronizeCoarseToFine(); MEDCOUPLING_EXPORT void synchronizeCoarseToFineBetween(int fromLev, int toLev); MEDCOUPLING_EXPORT void synchronizeAllGhostZones(); + MEDCOUPLING_EXPORT void synchronizeAllGhostZonesOfDirectChidrenOf(const MEDCouplingCartesianAMRMeshGen *mesh); MEDCOUPLING_EXPORT void alloc(); MEDCOUPLING_EXPORT void dealloc(); MEDCOUPLING_EXPORT bool changeGodFather(MEDCouplingCartesianAMRMeshGen *gf); @@ -141,7 +145,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT void updateTime() const; private: MEDCouplingAMRAttribute(MEDCouplingCartesianAMRMeshGen *gf, const std::vector< std::pair >& fieldNames, int ghostLev); - MEDCouplingAMRAttribute(const MEDCouplingAMRAttribute& other); + MEDCouplingAMRAttribute(const MEDCouplingAMRAttribute& other, bool deepCpyGF); const DataArrayDoubleCollection& findCollectionAttachedTo(const MEDCouplingCartesianAMRMeshGen *m) const; void synchronizeFineToCoarseByOneLevel(int level); void synchronizeCoarseToFineByOneLevel(int level); diff --git a/src/MEDCoupling/MEDCouplingCartesianAMRMesh.cxx b/src/MEDCoupling/MEDCouplingCartesianAMRMesh.cxx index 3b38301ef..b215d722d 100644 --- a/src/MEDCoupling/MEDCouplingCartesianAMRMesh.cxx +++ b/src/MEDCoupling/MEDCouplingCartesianAMRMesh.cxx @@ -55,6 +55,13 @@ MEDCouplingCartesianAMRPatchGen::MEDCouplingCartesianAMRPatchGen(MEDCouplingCart _mesh=mesh; _mesh->incrRef(); } +MEDCouplingCartesianAMRPatchGen::MEDCouplingCartesianAMRPatchGen(const MEDCouplingCartesianAMRPatchGen& other):RefCountObject(other),_mesh(other._mesh) +{ + const MEDCouplingCartesianAMRMeshGen *mesh(other._mesh); + if(mesh) + _mesh=mesh->deepCpy(); +} + const MEDCouplingCartesianAMRMeshGen *MEDCouplingCartesianAMRPatchGen::getMeshSafe() const { const MEDCouplingCartesianAMRMeshGen *mesh(_mesh); @@ -91,6 +98,11 @@ MEDCouplingCartesianAMRPatch::MEDCouplingCartesianAMRPatch(MEDCouplingCartesianA throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRPatch constructor : space dimension of father and input bottomLeft/topRight size mismatches !"); } +MEDCouplingCartesianAMRPatch *MEDCouplingCartesianAMRPatch::deepCpy() const +{ + return new MEDCouplingCartesianAMRPatch(*this); +} + void MEDCouplingCartesianAMRPatch::addPatch(const std::vector< std::pair >& bottomLeftTopRight, const std::vector& factors) { return getMeshSafe()->addPatch(bottomLeftTopRight,factors); @@ -477,6 +489,10 @@ void MEDCouplingCartesianAMRPatch::UpdateNeighborsOfOneWithTwoInternal(int ghost MEDCouplingIMesh::CondenseFineToCoarse(dimsCoarse,ghostVals,interstRange,fakeFactors,dataOnP1); } +MEDCouplingCartesianAMRPatch::MEDCouplingCartesianAMRPatch(const MEDCouplingCartesianAMRPatch& other):MEDCouplingCartesianAMRPatchGen(other),_bl_tr(other._bl_tr) +{ +} + /*! * \param [in,out] partBeforeFact - the part of a image mesh in compact format that will be put in refined reference. * \param [in] factors - the factors per axis. @@ -511,6 +527,24 @@ void MEDCouplingCartesianAMRPatch::ApplyAllGhostOnCompactFrmt(std::vector< std:: } } +MEDCouplingCartesianAMRPatchGF::MEDCouplingCartesianAMRPatchGF(MEDCouplingCartesianAMRMesh *mesh):MEDCouplingCartesianAMRPatchGen(mesh) +{ +} + +MEDCouplingCartesianAMRPatchGF *MEDCouplingCartesianAMRPatchGF::deepCpy() const +{ + return new MEDCouplingCartesianAMRPatchGF(*this); +} + +std::size_t MEDCouplingCartesianAMRPatchGF::getHeapMemorySizeWithoutChildren() const +{ + return sizeof(MEDCouplingCartesianAMRPatchGF); +} + +MEDCouplingCartesianAMRPatchGF::MEDCouplingCartesianAMRPatchGF(const MEDCouplingCartesianAMRPatchGF& other):MEDCouplingCartesianAMRPatchGen(other) +{ +} + /// @endcond int MEDCouplingCartesianAMRMeshGen::getSpaceDimension() const @@ -612,14 +646,82 @@ const MEDCouplingCartesianAMRMeshGen *MEDCouplingCartesianAMRMeshGen::getGodFath } /*! - * This method returns the level of \a this. 0 for god father. -1 for children of god father ... + * 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; + 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). + * + * \sa getPatchAtPosition + */ +std::vector MEDCouplingCartesianAMRMeshGen::getPositionRelativeTo(const MEDCouplingCartesianAMRMeshGen *ref) const +{ + if(!ref) + throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMeshGen::getPositionRelativeTo : input pointer is NULL !"); + std::vector ret; + getPositionRelativeToInternal(ref,ret); + std::reverse(ret.begin(),ret.end()); + return ret; +} + +/*! + * \sa getPositionRelativeTo, getMeshAtPosition + */ +const MEDCouplingCartesianAMRPatch *MEDCouplingCartesianAMRMeshGen::getPatchAtPosition(const std::vector& pos) const +{ + std::size_t sz(pos.size()); + if(sz==0) + throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMeshGen::getPatchAtPosition : empty input -> no patch by definition !"); + int patchId(pos[0]); + const MEDCouplingCartesianAMRPatch *elt(getPatch(patchId)); + if(sz==1) + return elt; + if(!elt || !elt->getMesh()) + throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMeshGen::getPatchAtPosition : NULL element found during walk !"); + std::vector pos2(pos.begin()+1,pos.end()); + return elt->getMesh()->getPatchAtPosition(pos2); +} + +const MEDCouplingCartesianAMRMeshGen *MEDCouplingCartesianAMRMeshGen::getMeshAtPosition(const std::vector& pos) const +{ + std::size_t sz(pos.size()); + if(sz==0) + return this; + int patchId(pos[0]); + const MEDCouplingCartesianAMRPatch *elt(getPatch(patchId)); + if(sz==1) + { + if(!elt) + throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMeshGen::getMeshAtPosition : NULL patch !"); + return elt->getMesh(); + } + if(!elt || !elt->getMesh()) + throw INTERP_KERNEL::Exception("MEDCouplingCartesianAMRMeshGen::getPatchAtPosition : NULL element found during walk !"); + std::vector pos2(pos.begin()+1,pos.end()); + return elt->getMesh()->getMeshAtPosition(pos2); } /*! @@ -1006,6 +1108,7 @@ void MEDCouplingCartesianAMRMeshGen::createPatchesFromCriterion(const INTERP_KER /*! * 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 @@ -1483,6 +1586,20 @@ 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) +{ + const MEDCouplingIMesh *mesh(other._mesh); + if(mesh) + _mesh=static_cast(mesh->deepCpy()); + std::size_t sz(other._patches.size()); + for(std::size_t i=0;ideepCpy(); + } +} + 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) { @@ -1632,6 +1749,20 @@ 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); @@ -1669,12 +1800,30 @@ MEDCouplingCartesianAMRMeshSub::MEDCouplingCartesianAMRMeshSub(MEDCouplingCartes { } +MEDCouplingCartesianAMRMeshSub::MEDCouplingCartesianAMRMeshSub(const MEDCouplingCartesianAMRMeshSub& other, MEDCouplingCartesianAMRMeshGen *father):MEDCouplingCartesianAMRMeshGen(other,father) +{ +} + +MEDCouplingCartesianAMRMeshSub *MEDCouplingCartesianAMRMeshSub::deepCpy() const +{ + return new MEDCouplingCartesianAMRMeshSub(*this,_father); +} + MEDCouplingCartesianAMRMesh *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) { return new MEDCouplingCartesianAMRMesh(meshName,spaceDim,nodeStrctStart,nodeStrctStop,originStart,originStop,dxyzStart,dxyzStop); } +MEDCouplingCartesianAMRMesh *MEDCouplingCartesianAMRMesh::deepCpy() const +{ + return new MEDCouplingCartesianAMRMesh(*this); +} + +MEDCouplingCartesianAMRMesh::MEDCouplingCartesianAMRMesh(const MEDCouplingCartesianAMRMesh& other):MEDCouplingCartesianAMRMeshGen(other,0) +{ +} + MEDCouplingCartesianAMRMesh::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):MEDCouplingCartesianAMRMeshGen(meshName,spaceDim,nodeStrctStart,nodeStrctStop,originStart,originStop,dxyzStart,dxyzStop) { diff --git a/src/MEDCoupling/MEDCouplingCartesianAMRMesh.hxx b/src/MEDCoupling/MEDCouplingCartesianAMRMesh.hxx index 00fb07239..02202ac2a 100644 --- a/src/MEDCoupling/MEDCouplingCartesianAMRMesh.hxx +++ b/src/MEDCoupling/MEDCouplingCartesianAMRMesh.hxx @@ -49,11 +49,13 @@ namespace ParaMEDMEM class MEDCouplingCartesianAMRPatchGen : public RefCountObject { public: + MEDCOUPLING_EXPORT virtual MEDCouplingCartesianAMRPatchGen *deepCpy() 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(MEDCouplingCartesianAMRMeshGen *mesh); const MEDCouplingCartesianAMRMeshGen *getMeshSafe() const; MEDCouplingCartesianAMRMeshGen *getMeshSafe(); @@ -70,6 +72,7 @@ namespace ParaMEDMEM { public: MEDCouplingCartesianAMRPatch(MEDCouplingCartesianAMRMeshGen *mesh, const std::vector< std::pair >& bottomLeftTopRight); + MEDCouplingCartesianAMRPatch *deepCpy() 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 @@ -97,6 +100,8 @@ namespace ParaMEDMEM public: 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); private: //! bottom left/top right cell range relative to \a _father std::vector< std::pair > _bl_tr; @@ -109,8 +114,11 @@ namespace ParaMEDMEM { public: MEDCouplingCartesianAMRPatchGF(MEDCouplingCartesianAMRMesh *mesh); + MEDCouplingCartesianAMRPatchGF *deepCpy() const; private: std::size_t getHeapMemorySizeWithoutChildren() const; + private: + MEDCouplingCartesianAMRPatchGF(const MEDCouplingCartesianAMRPatchGF& other); }; /// @endcond @@ -123,6 +131,7 @@ namespace ParaMEDMEM class MEDCouplingCartesianAMRMeshGen : public RefCountObject, public TimeLabel { public: + MEDCOUPLING_EXPORT virtual MEDCouplingCartesianAMRMeshGen *deepCpy() const = 0; MEDCOUPLING_EXPORT int getSpaceDimension() const; MEDCOUPLING_EXPORT const std::vector& getFactors() const { return _factors; } MEDCOUPLING_EXPORT void setFactors(const std::vector& newFactors); @@ -136,6 +145,10 @@ namespace ParaMEDMEM 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 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 void addPatch(const std::vector< std::pair >& bottomLeftTopRight, const std::vector& factors); @@ -174,6 +187,7 @@ 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 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); @@ -183,12 +197,14 @@ namespace ParaMEDMEM 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; protected: MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; MEDCOUPLING_EXPORT std::vector getDirectChildren() const; MEDCOUPLING_EXPORT void updateTime() const; - private: + protected: MEDCouplingCartesianAMRMeshGen *_father; + private: MEDCouplingAutoRefCountObjectPtr _mesh; std::vector< MEDCouplingAutoRefCountObjectPtr > _patches; std::vector _factors; @@ -198,6 +214,9 @@ namespace ParaMEDMEM { public: MEDCouplingCartesianAMRMeshSub(MEDCouplingCartesianAMRMeshGen *father, MEDCouplingIMesh *mesh); + private: + MEDCouplingCartesianAMRMeshSub(const MEDCouplingCartesianAMRMeshSub& other, MEDCouplingCartesianAMRMeshGen *father); + MEDCouplingCartesianAMRMeshSub *deepCpy() const; }; class MEDCouplingCartesianAMRMesh : public MEDCouplingCartesianAMRMeshGen @@ -206,6 +225,8 @@ namespace ParaMEDMEM 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); private: + MEDCouplingCartesianAMRMesh *deepCpy() 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); MEDCOUPLING_EXPORT std::vector getDirectChildren() const; diff --git a/src/MEDCoupling/MEDCouplingIMesh.cxx b/src/MEDCoupling/MEDCouplingIMesh.cxx index 0e2eeca19..f5821c9e6 100644 --- a/src/MEDCoupling/MEDCouplingIMesh.cxx +++ b/src/MEDCoupling/MEDCouplingIMesh.cxx @@ -461,7 +461,7 @@ void MEDCouplingIMesh::CondenseFineToCoarseGhost(const std::vector& coarseS { int nxwg(coarseSt[0]+2*ghostSize); int kk(fineLocInCoarse[0].first+ghostSize+nxwg*(fineLocInCoarse[1].first+ghostSize)),fact1(facts[1]),fact0(facts[0]); - inPtr+=(dims[0]*fact0+2*ghostSize)*nbCompo; + inPtr+=(dims[0]*fact0+2*ghostSize)*ghostSize*nbCompo; for(int j=0;j getPositionRelativeTo(const MEDCouplingCartesianAMRMeshGen *ref) const throw(INTERP_KERNEL::Exception); int getSpaceDimension() const throw(INTERP_KERNEL::Exception); const std::vector& getFactors() const throw(INTERP_KERNEL::Exception); void setFactors(const std::vector& newFactors) throw(INTERP_KERNEL::Exception); @@ -4981,6 +4979,24 @@ namespace ParaMEDMEM return ret; } + MEDCouplingCartesianAMRPatch *getPatchAtPosition(const std::vector& pos) const throw(INTERP_KERNEL::Exception) + { + const MEDCouplingCartesianAMRPatch *ret(self->getPatchAtPosition(pos)); + MEDCouplingCartesianAMRPatch *ret2(const_cast(ret)); + if(ret2) + ret2->incrRef(); + return ret2; + } + + MEDCouplingCartesianAMRMeshGen *getMeshAtPosition(const std::vector& pos) const throw(INTERP_KERNEL::Exception) + { + const MEDCouplingCartesianAMRMeshGen *ret(self->getMeshAtPosition(pos)); + MEDCouplingCartesianAMRMeshGen *ret2(const_cast(ret)); + if(ret2) + ret2->incrRef(); + return ret2; + } + void createPatchesFromCriterionML(PyObject *bso, const DataArrayDouble *criterion, PyObject *factors, double eps) throw(INTERP_KERNEL::Exception) { std::vector inp0; @@ -5114,12 +5130,36 @@ namespace ParaMEDMEM } } }; + + class MEDCouplingDataForGodFather : public RefCountObject + { + public: + virtual void synchronizeFineToCoarse() throw(INTERP_KERNEL::Exception); + virtual void synchronizeFineToCoarseBetween(int fromLev, int toLev) throw(INTERP_KERNEL::Exception); + virtual void synchronizeCoarseToFine() throw(INTERP_KERNEL::Exception); + virtual void synchronizeCoarseToFineBetween(int fromLev, int toLev) throw(INTERP_KERNEL::Exception); + virtual void synchronizeAllGhostZones() throw(INTERP_KERNEL::Exception); + virtual void synchronizeAllGhostZonesOfDirectChidrenOf(const MEDCouplingCartesianAMRMeshGen *mesh) throw(INTERP_KERNEL::Exception); + virtual void alloc() throw(INTERP_KERNEL::Exception); + virtual void dealloc() throw(INTERP_KERNEL::Exception); + %extend + { + MEDCouplingCartesianAMRMeshGen *getMyGodFather() throw(INTERP_KERNEL::Exception) + { + MEDCouplingCartesianAMRMeshGen *ret(self->getMyGodFather()); + if(ret) + ret->incrRef(); + return ret; + } + } + }; class MEDCouplingAMRAttribute : public MEDCouplingDataForGodFather, public TimeLabel { public: int getNumberOfLevels() const throw(INTERP_KERNEL::Exception); MEDCouplingAMRAttribute *deepCpy() const throw(INTERP_KERNEL::Exception); + MEDCouplingAMRAttribute *deepCpyWithoutGodFather() const throw(INTERP_KERNEL::Exception); MEDCouplingFieldDouble *buildCellFieldOnRecurseWithoutOverlapWithoutGhost(MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) const throw(INTERP_KERNEL::Exception); 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);