1 // Copyright (C) 2007-2014 CEA/DEN, EDF R&D
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Lesser General Public License for more details.
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 // Author : Anthony Geay
21 #ifndef __MEDCOUPLINGAMRATTRIBUTE_HXX__
22 #define __MEDCOUPLINGAMRATTRIBUTE_HXX__
24 #include "MEDCoupling.hxx"
25 #include "MEDCouplingNatureOfFieldEnum"
26 #include "MEDCouplingCartesianAMRMesh.hxx"
31 class DataArrayDoubleCollection : public RefCountObject, public TimeLabel
34 static DataArrayDoubleCollection *New(const std::vector< std::pair<std::string,int> >& fieldNames);
35 void allocTuples(int nbOfTuples);
37 void spillInfoOnComponents(const std::vector< std::vector<std::string> >& compNames);
38 void spillNatures(const std::vector<NatureOfField>& nfs);
39 std::vector<DataArrayDouble *> retrieveFields() const;
40 const DataArrayDouble *getFieldWithName(const std::string& name) const;
41 static void SynchronizeFineToCoarse(int ghostLev, const MEDCouplingCartesianAMRMeshGen *fatherOfFineMesh, int patchId, const DataArrayDoubleCollection *fine, DataArrayDoubleCollection *coarse);
42 static void SynchronizeCoarseToFine(int ghostLev, const MEDCouplingCartesianAMRMeshGen *fatherOfFineMesh, int patchId, const DataArrayDoubleCollection *coarse, DataArrayDoubleCollection *fine);
43 static void SynchronizeFineEachOther(int patchId, int ghostLev, const MEDCouplingCartesianAMRMeshGen *fatherOfFineMesh, const std::vector<const MEDCouplingCartesianAMRMeshGen *>& children, const std::vector<DataArrayDoubleCollection *>& fieldsOnFine);
44 static void SynchronizeCoarseToFineOnlyInGhostZone(int ghostLev, const MEDCouplingCartesianAMRMeshGen *fatherOfFineMesh, int patchId, const DataArrayDoubleCollection *coarse, DataArrayDoubleCollection *fine);
45 static void SynchronizeGhostZoneOfOneUsingTwo(int ghostLev, const MEDCouplingCartesianAMRPatch *p1, const DataArrayDoubleCollection *p1dac, const MEDCouplingCartesianAMRPatch *p2, const DataArrayDoubleCollection *p2dac);
46 void synchronizeMyGhostZoneUsing(int ghostLev, const DataArrayDoubleCollection& other, const MEDCouplingCartesianAMRPatch *thisp, const MEDCouplingCartesianAMRPatch *otherp, const MEDCouplingCartesianAMRMeshGen *father) const;
47 void synchronizeMyGhostZoneUsingExt(int ghostLev, const DataArrayDoubleCollection& other, const MEDCouplingCartesianAMRPatch *thisp, const MEDCouplingCartesianAMRPatch *otherp) const;
49 DataArrayDoubleCollection(const std::vector< std::pair<std::string,int> >& fieldNames);
50 std::size_t getHeapMemorySizeWithoutChildren() const;
51 std::vector<const BigMemoryObject *> getDirectChildren() const;
52 void updateTime() const;
53 static void CheckDiscriminantNames(const std::vector<std::string>& names);
54 static bool IsConservativeNature(NatureOfField n);
55 static void CheckSameNatures(NatureOfField n1, NatureOfField n2);
56 static void CheckValidNature(NatureOfField n);
58 std::vector< std::pair< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble>, NatureOfField > > _arrs;
61 class MEDCouplingGridCollection : public RefCountObject, public TimeLabel
64 static MEDCouplingGridCollection *New(const std::vector<const MEDCouplingCartesianAMRMeshGen *>& ms, const std::vector< std::pair<std::string,int> >& fieldNames);
65 void alloc(int ghostLev);
67 void spillInfoOnComponents(const std::vector< std::vector<std::string> >& compNames);
68 void spillNatures(const std::vector<NatureOfField>& nfs);
69 bool presenceOf(const MEDCouplingCartesianAMRMeshGen *m, int& pos) const;
70 const DataArrayDoubleCollection& getFieldsAt(int pos) const;
71 static void SynchronizeFineToCoarse(int ghostLev, const MEDCouplingGridCollection *fine, const MEDCouplingGridCollection *coarse);
72 static void SynchronizeCoarseToFine(int ghostLev, const MEDCouplingGridCollection *coarse, const MEDCouplingGridCollection *fine);
73 void synchronizeFineEachOther(int ghostLev, const std::vector< std::pair<const MEDCouplingCartesianAMRPatch *,const MEDCouplingCartesianAMRPatch *> >& ps) const;
74 void synchronizeFineEachOtherExt(int ghostLev, const std::vector< std::pair<const MEDCouplingCartesianAMRPatch *,const MEDCouplingCartesianAMRPatch *> >& ps) const;
75 std::vector< std::pair<const MEDCouplingCartesianAMRPatch *,const MEDCouplingCartesianAMRPatch *> > findNeighbors(int ghostLev) const;
76 static void SynchronizeCoarseToFineOnlyInGhostZone(int ghostLev, const MEDCouplingGridCollection *coarse, const MEDCouplingGridCollection *fine);
77 void fillIfInTheProgenyOf(const std::string& fieldName, const MEDCouplingCartesianAMRMeshGen *head, std::vector<const DataArrayDouble *>& recurseArrs) const;
79 MEDCouplingGridCollection(const std::vector<const MEDCouplingCartesianAMRMeshGen *>& ms, const std::vector< std::pair<std::string,int> >& fieldNames);
80 std::size_t getHeapMemorySizeWithoutChildren() const;
81 std::vector<const BigMemoryObject *> getDirectChildren() const;
82 void updateTime() const;
84 std::vector< std::pair<const MEDCouplingCartesianAMRMeshGen *,MEDCouplingAutoRefCountObjectPtr<DataArrayDoubleCollection> > > _map_of_dadc;
89 class MEDCouplingDataForGodFather : public RefCountObject
91 friend class MEDCouplingCartesianAMRMesh;
93 MEDCOUPLING_EXPORT virtual void synchronizeFineToCoarse() = 0;
94 MEDCOUPLING_EXPORT virtual void synchronizeCoarseToFine() = 0;
95 MEDCOUPLING_EXPORT virtual void synchronizeAllGhostZones() = 0;
96 MEDCOUPLING_EXPORT virtual void alloc() = 0;
97 MEDCOUPLING_EXPORT virtual void dealloc() = 0;
99 MEDCouplingDataForGodFather(MEDCouplingCartesianAMRMeshGen *gf);
100 void checkGodFatherFrozen() const;
102 virtual bool changeGodFather(MEDCouplingCartesianAMRMeshGen *gf);
104 MEDCouplingAutoRefCountObjectPtr<MEDCouplingCartesianAMRMeshGen> _gf;
105 TimeLabelConstOverseer _tlc;
108 class MEDCouplingAMRAttribute : public MEDCouplingDataForGodFather, public TimeLabel
111 MEDCOUPLING_EXPORT static MEDCouplingAMRAttribute *New(MEDCouplingCartesianAMRMeshGen *gf, const std::vector< std::pair<std::string,int> >& fieldNames, int ghostLev);
112 MEDCOUPLING_EXPORT static MEDCouplingAMRAttribute *New(MEDCouplingCartesianAMRMeshGen *gf, const std::vector< std::pair<std::string, std::vector<std::string> > >& fieldNames, int ghostLev);
113 MEDCOUPLING_EXPORT void spillInfoOnComponents(const std::vector< std::vector<std::string> >& compNames);
114 MEDCOUPLING_EXPORT void spillNatures(const std::vector<NatureOfField>& nfs);
115 MEDCOUPLING_EXPORT std::vector<DataArrayDouble *> retrieveFieldsOn(MEDCouplingCartesianAMRMeshGen *mesh) const;
116 MEDCOUPLING_EXPORT const DataArrayDouble *getFieldOn(MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) const;
117 MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildCellFieldOnRecurseWithoutOverlapWithoutGhost(MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) const;
118 MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildCellFieldOnWithGhost(MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) const;
119 MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildCellFieldOnWithoutGhost(MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) const;
121 MEDCOUPLING_EXPORT void synchronizeFineToCoarse();
122 MEDCOUPLING_EXPORT void synchronizeCoarseToFine();
123 MEDCOUPLING_EXPORT void synchronizeAllGhostZones();
124 MEDCOUPLING_EXPORT void alloc();
125 MEDCOUPLING_EXPORT void dealloc();
126 MEDCOUPLING_EXPORT bool changeGodFather(MEDCouplingCartesianAMRMeshGen *gf);
128 MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
129 MEDCOUPLING_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
130 MEDCOUPLING_EXPORT void updateTime() const;
132 MEDCouplingAMRAttribute(MEDCouplingCartesianAMRMeshGen *gf, const std::vector< std::pair<std::string,int> >& fieldNames, int ghostLev);
133 const DataArrayDoubleCollection& findCollectionAttachedTo(const MEDCouplingCartesianAMRMeshGen *m) const;
136 std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingGridCollection> > _levs;
137 std::vector< std::vector< std::pair<const MEDCouplingCartesianAMRPatch *,const MEDCouplingCartesianAMRPatch *> > > _neighbors;
138 std::vector< std::pair<const MEDCouplingCartesianAMRPatch *,const MEDCouplingCartesianAMRPatch *> > _mixed_lev_neighbors;
139 std::vector< std::vector< std::pair<const MEDCouplingCartesianAMRPatch *,const MEDCouplingCartesianAMRPatch *> > > _cross_lev_neighbors;