Salome HOME
726aac1e92bf21330bd274d4e4bd259302b96866
[tools/medcoupling.git] / src / MEDCoupling / MEDCouplingAMRAttribute.hxx
1 // Copyright (C) 2007-2014  CEA/DEN, EDF R&D
2 //
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.
7 //
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.
12 //
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
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Anthony Geay
20
21 #ifndef __MEDCOUPLINGAMRATTRIBUTE_HXX__
22 #define __MEDCOUPLINGAMRATTRIBUTE_HXX__
23
24 #include "MEDCoupling.hxx"
25 #include "MEDCouplingCartesianAMRMesh.hxx"
26
27 namespace ParaMEDMEM
28 {
29   /// @cond INTERNAL
30   class DataArrayDoubleCollection : public RefCountObject, public TimeLabel
31   {
32   public:
33     static DataArrayDoubleCollection *New(const std::vector< std::pair<std::string,int> >& fieldNames);
34     void allocTuples(int nbOfTuples);
35     void dellocTuples();
36     void spillInfoOnComponents(const std::vector< std::vector<std::string> >& compNames);
37     std::vector<DataArrayDouble *> retrieveFields() const;
38     const DataArrayDouble *getFieldWithName(const std::string& name) const;
39     static void SynchronizeFineToCoarse(int ghostLev, const MEDCouplingCartesianAMRMeshGen *fatherOfFineMesh, int patchId, const DataArrayDoubleCollection *fine, DataArrayDoubleCollection *coarse);
40     static void SynchronizeCoarseToFine(int ghostLev, const MEDCouplingCartesianAMRMeshGen *fatherOfFineMesh, int patchId, const DataArrayDoubleCollection *coarse, DataArrayDoubleCollection *fine);
41     static void SynchronizeFineEachOther(int patchId, int ghostLev, const MEDCouplingCartesianAMRMeshGen *fatherOfFineMesh, const std::vector<const MEDCouplingCartesianAMRMeshGen *>& children, const std::vector<DataArrayDoubleCollection *>& fieldsOnFine);
42     static void SynchronizeCoarseToFineOnlyInGhostZone(int ghostLev, const MEDCouplingCartesianAMRMeshGen *fatherOfFineMesh, int patchId, const DataArrayDoubleCollection *coarse, DataArrayDoubleCollection *fine);
43   private:
44     DataArrayDoubleCollection(const std::vector< std::pair<std::string,int> >& fieldNames);
45     std::size_t getHeapMemorySizeWithoutChildren() const;
46     std::vector<const BigMemoryObject *> getDirectChildren() const;
47     void updateTime() const;
48     static void CheckDiscriminantNames(const std::vector<std::string>& names);
49   private:
50     std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayDouble> > _arrs;
51   };
52
53   class MEDCouplingGridCollection : public RefCountObject, public TimeLabel
54   {
55   public:
56     static MEDCouplingGridCollection *New(const std::vector<const MEDCouplingCartesianAMRMeshGen *>& ms, const std::vector< std::pair<std::string,int> >& fieldNames);
57     void alloc(int ghostLev);
58     void dealloc();
59     void spillInfoOnComponents(const std::vector< std::vector<std::string> >& compNames);
60     bool presenceOf(const MEDCouplingCartesianAMRMeshGen *m, int& pos) const;
61     const DataArrayDoubleCollection& retrieveFieldsAt(int pos) const;
62     static void SynchronizeFineToCoarse(int ghostLev, const MEDCouplingGridCollection *fine, const MEDCouplingGridCollection *coarse);
63     static void SynchronizeCoarseToFine(int ghostLev, const MEDCouplingGridCollection *coarse, const MEDCouplingGridCollection *fine);
64     void synchronizeFineEachOther(int ghostLev) const;
65     static void SynchronizeCoarseToFineOnlyInGhostZone(int ghostLev, const MEDCouplingGridCollection *coarse, const MEDCouplingGridCollection *fine);
66     void fillIfInTheProgenyOf(const std::string& fieldName, const MEDCouplingCartesianAMRMeshGen *head, std::vector<const DataArrayDouble *>& recurseArrs) const;
67   private:
68     MEDCouplingGridCollection(const std::vector<const MEDCouplingCartesianAMRMeshGen *>& ms, const std::vector< std::pair<std::string,int> >& fieldNames);
69     std::size_t getHeapMemorySizeWithoutChildren() const;
70     std::vector<const BigMemoryObject *> getDirectChildren() const;
71     void updateTime() const;
72   private:
73     std::vector< std::pair<const MEDCouplingCartesianAMRMeshGen *,MEDCouplingAutoRefCountObjectPtr<DataArrayDoubleCollection> > > _map_of_dadc;
74   };
75
76   /// @endcond
77
78   class MEDCouplingAMRAttribute : public MEDCouplingDataForGodFather, public TimeLabel
79   {
80   public:
81     MEDCOUPLING_EXPORT static MEDCouplingAMRAttribute *New(MEDCouplingCartesianAMRMesh *gf, const std::vector< std::pair<std::string,int> >& fieldNames);
82     MEDCOUPLING_EXPORT static MEDCouplingAMRAttribute *New(MEDCouplingCartesianAMRMesh *gf, const std::vector< std::pair<std::string, std::vector<std::string> > >& fieldNames);
83     MEDCOUPLING_EXPORT void spillInfoOnComponents(const std::vector< std::vector<std::string> >& compNames);
84     MEDCOUPLING_EXPORT std::vector<DataArrayDouble *> retrieveFieldsOn(MEDCouplingCartesianAMRMeshGen *mesh) const;
85     MEDCOUPLING_EXPORT const DataArrayDouble *getFieldOn(MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) const;
86     MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildCellFieldOnRecurseWithoutOverlapWithoutGhost(int ghostLev, MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) const;
87     MEDCOUPLING_EXPORT MEDCouplingFieldDouble *buildCellFieldOnWithGhost(int ghostLev, MEDCouplingCartesianAMRMeshGen *mesh, const std::string& fieldName) const;
88     //
89     MEDCOUPLING_EXPORT void synchronizeFineToCoarse(int ghostLev);
90     MEDCOUPLING_EXPORT void synchronizeCoarseToFine(int ghostLev);
91     MEDCOUPLING_EXPORT void synchronizeCoarseToFineOnlyInGhostZone(int ghostLev);
92     MEDCOUPLING_EXPORT void synchronizeFineEachOtherInGhostZone(int ghostLev);
93     MEDCOUPLING_EXPORT void alloc(int ghostLev);
94     MEDCOUPLING_EXPORT void dealloc();
95     MEDCOUPLING_EXPORT bool changeGodFather(MEDCouplingCartesianAMRMesh *gf);
96     //
97     MEDCOUPLING_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
98     MEDCOUPLING_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
99     MEDCOUPLING_EXPORT void updateTime() const;
100   private:
101     MEDCouplingAMRAttribute(MEDCouplingCartesianAMRMesh *gf, const std::vector< std::pair<std::string,int> >& fieldNames);
102   private:
103     std::vector< MEDCouplingAutoRefCountObjectPtr<MEDCouplingGridCollection> > _levs;
104   };
105 }
106
107 #endif