X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2FMEDCoupling%2FMEDCouplingCartesianAMRMesh.hxx;h=7d87906c60a8a99a693e4064ceb6f74c79b0219c;hb=5dcdc2b6a915a809dd2d7831e4b2e85ae286328a;hp=bd38f61d28539b3f05230a7ec92546d341fd4b6c;hpb=db76a42f621406677b2bff14889a9e08f022bf8f;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling/MEDCouplingCartesianAMRMesh.hxx b/src/MEDCoupling/MEDCouplingCartesianAMRMesh.hxx index bd38f61d2..7d87906c6 100644 --- a/src/MEDCoupling/MEDCouplingCartesianAMRMesh.hxx +++ b/src/MEDCoupling/MEDCouplingCartesianAMRMesh.hxx @@ -37,11 +37,15 @@ namespace ParaMEDMEM class DataArrayByte; class DataArrayDouble; class MEDCoupling1SGTUMesh; + class MEDCouplingFieldDouble; class MEDCouplingCartesianAMRMesh; class MEDCouplingCartesianAMRMeshGen; /// @cond INTERNAL + /*! + * This class does not inherit from TimeLabel so only const method should exist. + */ class MEDCouplingCartesianAMRPatchGen : public RefCountObject { public: @@ -59,6 +63,9 @@ namespace ParaMEDMEM MEDCouplingAutoRefCountObjectPtr _mesh; }; + /*! + * This class does not inherit from TimeLabel so only const method should exist. + */ class MEDCouplingCartesianAMRPatch : public MEDCouplingCartesianAMRPatchGen { public: @@ -68,15 +75,37 @@ namespace ParaMEDMEM // end of direct forward to _mesh MEDCOUPLING_EXPORT int getNumberOfOverlapedCellsForFather() const; MEDCOUPLING_EXPORT bool isInMyNeighborhood(const MEDCouplingCartesianAMRPatch *other, int ghostLev) const; + MEDCOUPLING_EXPORT bool isInMyNeighborhoodExt(const MEDCouplingCartesianAMRPatch *other, int ghostLev) const; + MEDCOUPLING_EXPORT bool isInMyNeighborhoodDiffLev(const MEDCouplingCartesianAMRPatch *other, int ghostLev) const; // basic set/get MEDCOUPLING_EXPORT const std::vector< std::pair >& getBLTRRange() const { return _bl_tr; } + MEDCOUPLING_EXPORT std::vector computeCellGridSt() const; + MEDCOUPLING_EXPORT static bool IsInMyNeighborhood(int ghostLev, const std::vector< std::pair >& p1, const std::vector< std::pair >& p2); + // + static std::vector< std::vector< std::pair > > FindNeighborsOfSubPatchesOfSameLev(int ghostLev, const MEDCouplingCartesianAMRPatch *p1, const MEDCouplingCartesianAMRPatch *p2); + static void FindNeighborsOfSubPatchesOf(int ghostLev, const MEDCouplingCartesianAMRPatch *p1, const MEDCouplingCartesianAMRPatch *p2, std::vector< std::pair >& ret); + static void UpdateNeighborsOfOneWithTwo(int ghostLev, const std::vector& factors, const MEDCouplingCartesianAMRPatch *p1, const MEDCouplingCartesianAMRPatch *p2, DataArrayDouble *dataOnP1, const DataArrayDouble *dataOnP2); + static void UpdateNeighborsOfOneWithTwoExt(int ghostLev, const MEDCouplingCartesianAMRPatch *p1, const MEDCouplingCartesianAMRPatch *p2, DataArrayDouble *dataOnP1, const DataArrayDouble *dataOnP2); + static void UpdateNeighborsOfOneWithTwoMixedLev(int ghostLev, const MEDCouplingCartesianAMRPatch *p1, const MEDCouplingCartesianAMRPatch *p2, DataArrayDouble *dataOnP1, const DataArrayDouble *dataOnP2); + private: + static void ComputeZonesOfTwoRelativeToOneDiffLev(int ghostLev, const MEDCouplingCartesianAMRPatch *p1, const MEDCouplingCartesianAMRPatch *p2, std::vector< std::pair >& p1Zone, std::vector< std::pair >& p2Zone, std::vector& factToApplyOn2); private: std::size_t getHeapMemorySizeWithoutChildren() const; + static const MEDCouplingCartesianAMRMeshGen *FindCommonAncestor(const MEDCouplingCartesianAMRPatch *p1, const MEDCouplingCartesianAMRPatch *p2, int& lev); + static std::vector ComputeOffsetFromTwoToOne(const MEDCouplingCartesianAMRMeshGen *comAncestor, int lev, const MEDCouplingCartesianAMRPatch *p1, const MEDCouplingCartesianAMRPatch *p2); + static void UpdateNeighborsOfOneWithTwoInternal(int ghostLev, const std::vector& factors, const std::vector< std::pair >&p1 ,const std::vector< std::pair >&p2, DataArrayDouble *dataOnP1, const DataArrayDouble *dataOnP2); + public: + static void ApplyFactorsOnCompactFrmt(std::vector< std::pair >& partBeforeFact, const std::vector& factors); + static void ApplyGhostOnCompactFrmt(std::vector< std::pair >& partBeforeFact, int ghostSize); + static void ApplyAllGhostOnCompactFrmt(std::vector< std::pair >& partBeforeFact, int ghostSize); private: //! bottom left/top right cell range relative to \a _father std::vector< std::pair > _bl_tr; }; + /*! + * This class does not inherit from TimeLabel so only const method should exist. + */ class MEDCouplingCartesianAMRPatchGF : public MEDCouplingCartesianAMRPatchGen { public: @@ -87,6 +116,21 @@ namespace ParaMEDMEM class MEDCouplingDataForGodFather : public RefCountObject { + friend class MEDCouplingCartesianAMRMesh; + public: + MEDCOUPLING_EXPORT virtual void synchronizeFineToCoarse() = 0; + MEDCOUPLING_EXPORT virtual void synchronizeCoarseToFine() = 0; + MEDCOUPLING_EXPORT virtual void synchronizeAllGhostZones() = 0; + MEDCOUPLING_EXPORT virtual void alloc() = 0; + MEDCOUPLING_EXPORT virtual void dealloc() = 0; + protected: + MEDCouplingDataForGodFather(MEDCouplingCartesianAMRMesh *gf); + void checkGodFatherFrozen() const; + protected: + virtual bool changeGodFather(MEDCouplingCartesianAMRMesh *gf); + protected: + MEDCouplingCartesianAMRMesh *_gf; + TimeLabelConstOverseer _tlc; }; /// @endcond @@ -103,6 +147,7 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT void setFactors(const std::vector& newFactors); MEDCOUPLING_EXPORT int getMaxNumberOfLevelsRelativeToThis() const; MEDCOUPLING_EXPORT int getNumberOfCellsAtCurrentLevel() const; + MEDCOUPLING_EXPORT int getNumberOfCellsAtCurrentLevelGhost(int ghostLev) const; MEDCOUPLING_EXPORT int getNumberOfCellsRecursiveWithOverlap() const; MEDCOUPLING_EXPORT int getNumberOfCellsRecursiveWithoutOverlap() const; MEDCOUPLING_EXPORT const MEDCouplingIMesh *getImageMesh() const { return _mesh; } @@ -118,19 +163,32 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT void removeAllPatches(); MEDCOUPLING_EXPORT void removePatch(int patchId); MEDCOUPLING_EXPORT int getNumberOfPatches() const; + MEDCOUPLING_EXPORT int getPatchIdFromChildMesh(const MEDCouplingCartesianAMRMeshGen *mesh) const; + MEDCOUPLING_EXPORT std::vector< const MEDCouplingCartesianAMRPatch *> getPatches() const; MEDCOUPLING_EXPORT const MEDCouplingCartesianAMRPatch *getPatch(int patchId) const; MEDCOUPLING_EXPORT bool isPatchInNeighborhoodOf(int patchId1, int patchId2, int ghostLev) const; MEDCOUPLING_EXPORT DataArrayDouble *createCellFieldOnPatch(int patchId, const DataArrayDouble *cellFieldOnThis) const; + // coarse to fine MEDCOUPLING_EXPORT void fillCellFieldOnPatch(int patchId, const DataArrayDouble *cellFieldOnThis, DataArrayDouble *cellFieldOnPatch) const; MEDCOUPLING_EXPORT void fillCellFieldOnPatchGhost(int patchId, const DataArrayDouble *cellFieldOnThis, DataArrayDouble *cellFieldOnPatch, int ghostLev) const; + MEDCOUPLING_EXPORT void fillCellFieldOnPatchOnlyOnGhostZone(int patchId, const DataArrayDouble *cellFieldOnThis, DataArrayDouble *cellFieldOnPatch, int ghostLev) const; + // coarse to fine + fine to fine MEDCOUPLING_EXPORT void fillCellFieldOnPatchGhostAdv(int patchId, const DataArrayDouble *cellFieldOnThis, int ghostLev, const std::vector& arrsOnPatches) const; + // fine to fine + MEDCOUPLING_EXPORT void fillCellFieldOnPatchOnlyGhostAdv(int patchId, int ghostLev, const std::vector& arrsOnPatches) const; + MEDCOUPLING_EXPORT void fillCellFieldOnPatchOnlyOnGhostZoneWith(int ghostLev, const MEDCouplingCartesianAMRPatch *patchToBeModified, const MEDCouplingCartesianAMRPatch *neighborPatch, DataArrayDouble *cellFieldOnPatch, const DataArrayDouble *cellFieldNeighbor) const; + // fine to coarse MEDCOUPLING_EXPORT void fillCellFieldComingFromPatch(int patchId, const DataArrayDouble *cellFieldOnPatch, DataArrayDouble *cellFieldOnThis) const; MEDCOUPLING_EXPORT void fillCellFieldComingFromPatchGhost(int patchId, const DataArrayDouble *cellFieldOnPatch, DataArrayDouble *cellFieldOnThis, int ghostLev) const; + // MEDCOUPLING_EXPORT DataArrayInt *findPatchesInTheNeighborhoodOf(int patchId, int ghostLev) const; // MEDCOUPLING_EXPORT MEDCouplingUMesh *buildUnstructured() const; MEDCOUPLING_EXPORT MEDCoupling1SGTUMesh *buildMeshFromPatchEnvelop() const; MEDCOUPLING_EXPORT MEDCoupling1SGTUMesh *buildMeshOfDirectChildrenOnly() const; + MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildCellFieldOnRecurseWithoutOverlapWithoutGhost(int ghostSz, const std::vector& recurseArrs) const; + MEDCOUPLING_EXPORT DataArrayDouble *extractGhostFrom(int ghostSz, const DataArrayDouble *arr) const; + MEDCOUPLING_EXPORT std::vector getPatchIdsInTheNeighborhoodOf(int patchId, int ghostLev) const; protected: 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); @@ -138,9 +196,8 @@ namespace ParaMEDMEM void checkPatchId(int patchId) const; void checkFactorsAndIfNotSetAssign(const std::vector& factors); void retrieveGridsAtInternal(int lev, std::vector< MEDCouplingAutoRefCountObjectPtr >& grids) const; - static void ApplyFactorsOnCompactFrmt(std::vector< std::pair >& partBeforeFact, const std::vector& factors); - static void ApplyGhostOnCompactFrmt(std::vector< std::pair >& partBeforeFact, int ghostSize); - static void ApplyAllGhostOnCompactFrmt(std::vector< std::pair >& partBeforeFact, int ghostSize); + static int GetGhostLevelInFineRef(int ghostLev, const std::vector& factors); + std::vector extractSubTreeFromGlobalFlatten(const MEDCouplingCartesianAMRMeshGen *head, const std::vector& all) const; protected: MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; MEDCOUPLING_EXPORT std::vector getDirectChildren() const; @@ -166,12 +223,16 @@ namespace ParaMEDMEM MEDCOUPLING_EXPORT const MEDCouplingDataForGodFather *getDataConst() const { return _data; } MEDCOUPLING_EXPORT MEDCouplingDataForGodFather *getData() { return _data; } MEDCOUPLING_EXPORT void setData(MEDCouplingDataForGodFather *data); + MEDCOUPLING_EXPORT void allocData() const; + MEDCOUPLING_EXPORT void deallocData() const; private: 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; + void checkData() const; + ~MEDCouplingCartesianAMRMesh(); private: - MEDCouplingAutoRefCountObjectPtr _data; + mutable MEDCouplingAutoRefCountObjectPtr _data; }; }