X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2FMEDCoupling%2FMEDCouplingAMRAttribute.hxx;h=e8565077c281ccc23970777c36e3da70fd29f328;hb=b7e277ad50223814bc479c5bd64cf12abe8fc959;hp=6651aa416a099d7e89a0034eaec6dabb747ec455;hpb=e92e242ba1cb78f30c63f208b6bc049869a7d43f;p=tools%2Fmedcoupling.git diff --git a/src/MEDCoupling/MEDCouplingAMRAttribute.hxx b/src/MEDCoupling/MEDCouplingAMRAttribute.hxx index 6651aa416..e8565077c 100644 --- a/src/MEDCoupling/MEDCouplingAMRAttribute.hxx +++ b/src/MEDCoupling/MEDCouplingAMRAttribute.hxx @@ -1,4 +1,4 @@ -// Copyright (C) 2007-2014 CEA/DEN, EDF R&D +// Copyright (C) 2007-2016 CEA/DEN, EDF R&D // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -22,62 +22,160 @@ #define __MEDCOUPLINGAMRATTRIBUTE_HXX__ #include "MEDCoupling.hxx" +#include "MEDCouplingNatureOfFieldEnum" #include "MEDCouplingCartesianAMRMesh.hxx" -namespace ParaMEDMEM +namespace MEDCoupling { /// @cond INTERNAL class DataArrayDoubleCollection : public RefCountObject, public TimeLabel { public: static DataArrayDoubleCollection *New(const std::vector< std::pair >& fieldNames); + DataArrayDoubleCollection *deepCopy() 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 *getFieldWithName(const std::string& name); + 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); + static void SynchronizeCoarseToFineOnlyInGhostZone(int ghostLev, const MEDCouplingCartesianAMRMeshGen *fatherOfFineMesh, int patchId, const DataArrayDoubleCollection *coarse, DataArrayDoubleCollection *fine); + static void SynchronizeGhostZoneOfOneUsingTwo(int ghostLev, const MEDCouplingCartesianAMRPatch *p1, const DataArrayDoubleCollection *p1dac, const MEDCouplingCartesianAMRPatch *p2, const DataArrayDoubleCollection *p2dac); + void synchronizeMyGhostZoneUsing(int ghostLev, const DataArrayDoubleCollection& other, const MEDCouplingCartesianAMRPatch *thisp, const MEDCouplingCartesianAMRPatch *otherp, const MEDCouplingCartesianAMRMeshGen *father) const; + void synchronizeMyGhostZoneUsingExt(int ghostLev, const DataArrayDoubleCollection& other, const MEDCouplingCartesianAMRPatch *thisp, const MEDCouplingCartesianAMRPatch *otherp) const; private: DataArrayDoubleCollection(const std::vector< std::pair >& fieldNames); + DataArrayDoubleCollection(const DataArrayDoubleCollection& other); std::size_t getHeapMemorySizeWithoutChildren() const; - std::vector getDirectChildren() const; + std::vector getDirectChildrenWithNull() const; void updateTime() const; static void CheckDiscriminantNames(const std::vector& names); + static bool IsConservativeNature(NatureOfField n); + static void CheckSameNatures(NatureOfField n1, NatureOfField n2); + static void CheckValidNature(NatureOfField n); private: - std::vector< MEDCouplingAutoRefCountObjectPtr > _arrs; + std::vector< std::pair< MCAuto, NatureOfField > > _arrs; }; class MEDCouplingGridCollection : public RefCountObject, public TimeLabel { public: static MEDCouplingGridCollection *New(const std::vector& ms, const std::vector< std::pair >& fieldNames); + MEDCouplingGridCollection *deepCopy(const MEDCouplingCartesianAMRMeshGen *newGf, const MEDCouplingCartesianAMRMeshGen *oldGf) const; void alloc(int ghostLev); 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; + void synchronizeFineEachOtherExt(int ghostLev, const std::vector< std::pair >& ps) const; + std::vector< std::pair > findNeighbors(int ghostLev) const; + static void SynchronizeCoarseToFineOnlyInGhostZone(int ghostLev, const MEDCouplingGridCollection *coarse, const MEDCouplingGridCollection *fine); + 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, const MEDCouplingCartesianAMRMeshGen *newGf, const MEDCouplingCartesianAMRMeshGen *oldGf); std::size_t getHeapMemorySizeWithoutChildren() const; - std::vector getDirectChildren() const; + std::vector getDirectChildrenWithNull() const; void updateTime() const; private: - std::vector< std::pair > > _map_of_dadc; + std::vector< std::pair > > _map_of_dadc; }; + /// @endcond + class MEDCouplingDataForGodFather : public RefCountObject + { + 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; + 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 synchronizeAllGhostZonesAtASpecifiedLevel(int level) = 0; + MEDCOUPLING_EXPORT virtual void synchronizeAllGhostZonesAtASpecifiedLevelUsingOnlyFather(int level) = 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); + MEDCouplingDataForGodFather(const MEDCouplingDataForGodFather& other, bool deepCpyGF); + protected: + MCAuto _gf; + TimeLabelConstOverseer _tlc; + }; + class MEDCouplingAMRAttribute : public MEDCouplingDataForGodFather, public TimeLabel { public: - MEDCOUPLING_EXPORT static MEDCouplingAMRAttribute *New(MEDCouplingCartesianAMRMesh *gf, const std::vector< std::pair >& fieldNames); + 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 *deepCopy() 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; + MEDCOUPLING_EXPORT DataArrayDouble *getFieldOn(MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName); + MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildCellFieldOnRecurseWithoutOverlapWithoutGhost(MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) const; + MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildCellFieldOnWithGhost(MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) const; + MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildCellFieldOnWithoutGhost(MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) const; + MEDCOUPLING_EXPORT std::string writeVTHB(const std::string& fileName) const; + // + MEDCOUPLING_EXPORT MEDCouplingAMRAttribute *projectTo(MEDCouplingCartesianAMRMesh *targetGF) const; + // + MEDCOUPLING_EXPORT void synchronizeFineToCoarse(); + MEDCOUPLING_EXPORT void synchronizeFineToCoarseBetween(int fromLev, int toLev); + 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 synchronizeAllGhostZonesAtASpecifiedLevel(int level); + MEDCOUPLING_EXPORT void synchronizeAllGhostZonesAtASpecifiedLevelUsingOnlyFather(int level); // - MEDCOUPLING_EXPORT void alloc(int ghostLev); + MEDCOUPLING_EXPORT void alloc(); MEDCOUPLING_EXPORT void dealloc(); MEDCOUPLING_EXPORT bool changeGodFather(MEDCouplingCartesianAMRMesh *gf); // MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const; - MEDCOUPLING_EXPORT std::vector getDirectChildren() const; + MEDCOUPLING_EXPORT std::vector getDirectChildrenWithNull() const; MEDCOUPLING_EXPORT void updateTime() const; private: - MEDCouplingAMRAttribute(MEDCouplingCartesianAMRMesh *gf, const std::vector< std::pair >& fieldNames); + 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); + void synchronizeCoarseToFineByOneLevel(int level); private: - std::vector< MEDCouplingAutoRefCountObjectPtr > _levs; + int _ghost_lev; + std::vector< MCAuto > _levs; + std::vector< std::vector< std::pair > > _neighbors; + std::vector< std::pair > _mixed_lev_neighbors; + std::vector< std::vector< std::pair > > _cross_lev_neighbors; }; }