Salome HOME
Indices are stored as mcIdType type instead of int to support switch to 64bits indexing
[tools/medcoupling.git] / src / MEDLoader / MEDFileFieldInternal.hxx
1 // Copyright (C) 2007-2019  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 (EDF R&D)
20
21 #ifndef __MEDFILEFIELDINTERNAL_HXX__
22 #define __MEDFILEFIELDINTERNAL_HXX__
23
24 #include "MEDLoaderDefines.hxx"
25 #include "MEDFileUtilities.hxx"
26 #include "NormalizedGeometricTypes"
27 #include "InterpKernelAutoPtr.hxx"
28 #include "MCAuto.hxx"
29
30 #include "med.h"
31
32 #include <string>
33 #include <list>
34
35 namespace MEDCoupling
36 {
37   class MEDFileGTKeeper
38   {
39   public:
40     virtual MEDFileGTKeeper *deepCopy() const = 0;
41     virtual INTERP_KERNEL::NormalizedCellType getGeoType() const = 0;
42     virtual std::string getRepr() const = 0;
43     virtual bool isEqual(const MEDFileGTKeeper *other) const = 0;
44     virtual ~MEDFileGTKeeper();
45   };
46
47   class MEDFileGTKeeperSta : public MEDFileGTKeeper
48   {
49   public:
50     MEDFileGTKeeperSta(INTERP_KERNEL::NormalizedCellType gt):_geo_type(gt) { }
51     MEDFileGTKeeper *deepCopy() const;
52     INTERP_KERNEL::NormalizedCellType getGeoType() const;
53     std::string getRepr() const;
54     bool isEqual(const MEDFileGTKeeper *other) const;
55   private:
56     INTERP_KERNEL::NormalizedCellType _geo_type;
57   };
58
59   
60   class MEDFileStructureElement;
61   class MEDFileUMesh;
62   
63   class MEDFileGTKeeperDyn : public MEDFileGTKeeper
64   {
65   public:
66     MEDFileGTKeeperDyn(const MEDFileUMesh *mesh, const MEDFileUMesh *section, const MEDFileStructureElement *se);
67     MEDFileGTKeeper *deepCopy() const;
68     INTERP_KERNEL::NormalizedCellType getGeoType() const;
69     std::string getRepr() const;
70     bool isEqual(const MEDFileGTKeeper *other) const;
71     const MEDFileUMesh *getMesh() const { return _mesh; }
72     const MEDFileUMesh *getSection() const { return _section; }
73     const MEDFileStructureElement *getSE() const { return _se; }
74   private:
75     MCConstAuto<MEDFileUMesh> _mesh;
76     MCConstAuto<MEDFileUMesh> _section;
77     MCConstAuto<MEDFileStructureElement> _se;
78   };
79
80   class MEDFileEntities;
81   
82   class MEDFileFieldLoc : public RefCountObject
83   {
84   public:
85     MEDLOADER_EXPORT void simpleRepr(std::ostream& oss) const;
86     MEDLOADER_EXPORT std::string getName() const { return _name; }
87     MEDLOADER_EXPORT void setName(const std::string& name);
88     static MEDFileFieldLoc *New(med_idt fid, const std::string& locName);
89     static MEDFileFieldLoc *New(med_idt fid, int i, const MEDFileEntities *entities);
90     static MEDFileFieldLoc *New(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w);
91     std::size_t getHeapMemorySizeWithoutChildren() const;
92     std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
93     MEDFileFieldLoc *deepCopy() const;
94     bool isOnStructureElement() const;
95     const MEDFileGTKeeper *getUndergroundGTKeeper() const { return _gt; }
96     MEDLOADER_EXPORT int getNbOfGaussPtPerCell() const { return _nb_gauss_pt; }
97     MEDLOADER_EXPORT void writeLL(med_idt fid) const;
98     MEDLOADER_EXPORT std::string repr() const;
99     MEDLOADER_EXPORT bool isName(const std::string& name) const { return _name==name; }
100     MEDLOADER_EXPORT int getDimension() const { return _dim; }
101     MEDLOADER_EXPORT int getNumberOfGaussPoints() const { return _nb_gauss_pt; }
102     MEDLOADER_EXPORT int getNumberOfPointsInCells() const { return _nb_node_per_cell; }
103     MEDLOADER_EXPORT const std::vector<double>& getRefCoords() const { return _ref_coo; }
104     MEDLOADER_EXPORT const std::vector<double>& getGaussCoords() const { return _gs_coo; }
105     MEDLOADER_EXPORT const std::vector<double>& getGaussWeights() const { return _w; }
106     MEDLOADER_EXPORT INTERP_KERNEL::NormalizedCellType getGeoType() const { return _gt->getGeoType(); }
107     MEDLOADER_EXPORT bool isEqual(const MEDFileFieldLoc& other, double eps) const;
108   private:
109     MEDFileFieldLoc(const MEDFileFieldLoc& other);
110     MEDFileFieldLoc(med_idt fid, const std::string& locName);
111     MEDFileFieldLoc(med_idt fid, int id, const MEDFileEntities *entities);
112     MEDFileFieldLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w);
113   private:
114     int _dim;
115     int _nb_gauss_pt;
116     INTERP_KERNEL::AutoCppPtr<MEDFileGTKeeper> _gt;
117     int _nb_node_per_cell;
118     std::string _name;
119     std::vector<double> _ref_coo;
120     std::vector<double> _gs_coo;
121     std::vector<double> _w;
122   };
123
124   /// @cond INTERNAL
125   class MEDFileFieldPerMeshPerTypeCommon;
126   class MEDFileFieldPerMeshPerType;
127   class MEDCouplingFieldTemplate;
128   class MEDFileFieldNameScope;
129   class MEDFileFieldGlobsReal;
130   class MEDCouplingMesh;
131   
132   class MEDFileFieldPerMeshPerTypePerDisc : public RefCountObject, public MEDFileWritable
133   {
134   public:
135     static MEDFileFieldPerMeshPerTypePerDisc *NewOnRead(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, int profileIt, const PartDefinition *pd);
136     static MEDFileFieldPerMeshPerTypePerDisc *New(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, mcIdType locId);
137     static MEDFileFieldPerMeshPerTypePerDisc *New(const MEDFileFieldPerMeshPerTypePerDisc& other);
138     std::size_t getHeapMemorySizeWithoutChildren() const;
139     std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
140     MEDFileFieldPerMeshPerTypePerDisc *deepCopy(MEDFileFieldPerMeshPerTypeCommon *father) const;
141     void assignFieldNoProfile(mcIdType& start, mcIdType offset, mcIdType nbOfCells, const MEDCouplingFieldTemplate *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc);
142     void assignFieldProfile(bool isPflAlone, mcIdType& start, const DataArrayIdType *multiTypePfl, const DataArrayIdType *idsInPfl, DataArrayIdType *locIds, mcIdType nbOfEltsInWholeMesh, const MEDCouplingFieldTemplate *field, const DataArray *arrr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc);
143     void assignNodeFieldNoProfile(mcIdType& start, const MEDCouplingFieldTemplate *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob);
144     void getCoarseData(TypeOfField& type, std::pair<mcIdType,mcIdType>& dad, std::string& pfl, std::string& loc) const;
145     void writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const;
146     const MEDFileFieldPerMeshPerTypeCommon *getFather() const;
147     void loadOnlyStructureOfDataRecursively(med_idt fid, mcIdType& start, const MEDFileFieldNameScope& nasc);
148     void loadBigArray(med_idt fid, const MEDFileFieldNameScope& nasc);
149     void setNewStart(mcIdType newValueOfStart);
150     int getIteration() const;
151     int getOrder() const;
152     double getTime() const;
153     std::string getMeshName() const;
154     TypeOfField getType() const;
155     void simpleRepr(int bkOffset, std::ostream& oss, int id) const;
156     void fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const;
157     void setType(TypeOfField newType);
158     INTERP_KERNEL::NormalizedCellType getGeoType() const;
159     std::size_t getNumberOfComponents() const;
160     mcIdType getNumberOfTuples() const;
161     mcIdType getStart() const { return _start; }
162     mcIdType getEnd() const { return _end; }
163     void setEnd(mcIdType endd) { _end=endd; }
164     mcIdType getNumberOfVals() const { return _nval; }
165     void incrementNbOfVals(mcIdType deltaNbVal);
166     DataArray *getOrCreateAndGetArray();
167     const DataArray *getOrCreateAndGetArray() const;
168     const std::vector<std::string>& getInfo() const;
169     std::string getProfile() const;
170     void setProfile(const std::string& newPflName);
171     std::string getLocalization() const;
172     void setLocalization(const std::string& newLocName);
173     mcIdType getLocId() const { return _loc_id; }
174     void setLocId(mcIdType newId) const { _loc_id=newId; }
175     void setFather(MEDFileFieldPerMeshPerTypeCommon *newFather) { _father=newFather; }
176     void changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
177     void changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
178     void getFieldAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<mcIdType,mcIdType> >& dads, std::vector<const DataArrayIdType *>& pfls, std::vector<int>& locs,
179                          std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const;
180     void fillValues(int discId, mcIdType& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<mcIdType,mcIdType> > >& entries) const;
181     mcIdType fillEltIdsFromCode(mcIdType offset, const std::vector<mcIdType>& codeOfMesh, const MEDFileFieldGlobsReal& glob, mcIdType *ptToFill) const;
182     mcIdType fillTupleIds(mcIdType *ptToFill) const;
183     static int ConvertType(TypeOfField type, mcIdType locId);
184     static std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries);
185     static bool RenumberChunks(mcIdType offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
186                                const DataArrayIdType *explicitIdsInMesh, const std::vector<mcIdType>& newCode,
187                                MEDFileFieldGlobsReal& glob, DataArrayDouble *arr, std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> >& result);
188     static MEDFileFieldPerMeshPerTypePerDisc *NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayIdType *idsOfMeshElt,
189                                                                           bool isPfl, mcIdType nbi, mcIdType offset, std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
190                                                                           MEDFileFieldGlobsReal& glob, bool &notInExisting);
191     static MCAuto<MEDFileFieldPerMeshPerTypePerDisc> Aggregate(mcIdType &start, const std::vector<std::pair<int,const MEDFileFieldPerMeshPerTypePerDisc *> >& pms, const std::vector< std::vector< std::pair<int,mcIdType> > >& dts, TypeOfField tof, MEDFileFieldPerMeshPerType *father, std::vector<std::pair< int, std::pair<mcIdType,mcIdType> > >& extractInfo);
192     MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type):_type(type),_father(fath),_start(-1),_end(-1),_nval(-1),_loc_id(-5),_profile_it(-1) { }
193   private:
194     MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, mcIdType profileIt, const PartDefinition *pd);
195     MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerTypeCommon *fath, TypeOfField type, mcIdType profileIt, const std::string& dummy);
196     MEDFileFieldPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDisc& other);
197     MEDFileFieldPerMeshPerTypePerDisc();
198   private:
199     void goReadZeValuesInFile(med_idt fid, const std::string& fieldName, int nbOfCompo, int iteration, int order, med_entity_type menti, med_geometry_type mgeoti, unsigned char *startFeedingPtr);
200   private:
201     TypeOfField _type;
202     MEDFileFieldPerMeshPerTypeCommon *_father;
203     mcIdType _start;
204     mcIdType _end;
205     //! _nval is different than end-start in case of ON_GAUSS_PT and ON_GAUSS_NE ! (_nval=(_end-_start)/nbi)
206     mcIdType _nval;
207     std::string _profile;
208     std::string _localization;
209     //! only on assignment -3 : ON_NODES, -2 : ON_CELLS, -1 : ON_GAUSS_NE, 0..* : ON_GAUSS_PT
210     mutable mcIdType _loc_id;
211     mutable mcIdType _profile_it;
212     MCAuto<PartDefinition> _pd;
213   public:
214     mutable mcIdType _tmp_work1;
215   };
216
217   class MEDFileFieldVisitor;
218   class MEDFileFieldPerMesh;
219   
220   class MEDFileFieldPerMeshPerTypeCommon : public RefCountObject, public MEDFileWritable
221   {
222   public:
223     std::size_t getHeapMemorySizeWithoutChildren() const;
224     std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
225     void assignFieldNoProfile(mcIdType& start, mcIdType offset, mcIdType nbOfCells, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc);
226     void assignFieldProfile(bool isPflAlone, mcIdType& start, const DataArrayIdType *multiTypePfl, const DataArrayIdType *idsInPfl, DataArrayIdType *locIds, mcIdType nbOfEltsInWholeMesh, const MEDCouplingFieldTemplate *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc);
227     void assignNodeFieldNoProfile(mcIdType& start, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob);
228     void assignNodeFieldProfile(mcIdType& start, const DataArrayIdType *pfl, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc);
229     const MEDFileFieldPerMesh *getFather() const;
230     void loadOnlyStructureOfDataRecursively(med_idt fid, mcIdType &start, const MEDFileFieldNameScope& nasc);
231     void loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc);
232     void writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const;
233     bool isUniqueLevel(int& dim) const;
234     void fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const;
235     void fillFieldSplitedByType(std::vector< std::pair<mcIdType,mcIdType> >& dads, std::vector<TypeOfField>& types, std::vector<std::string>& pfls, std::vector<std::string>& locs) const;
236     int getIteration() const;
237     int getOrder() const;
238     double getTime() const;
239     std::string getMeshName() const;
240     void getSizes(mcIdType& globalSz, mcIdType& nbOfEntries) const;
241     std::size_t getNumberOfComponents() const;
242     bool presenceOfMultiDiscPerGeoType() const;
243     void pushDiscretization(MEDFileFieldPerMeshPerTypePerDisc *disc);
244     DataArray *getOrCreateAndGetArray();
245     const DataArray *getOrCreateAndGetArray() const;
246     const std::vector<std::string>& getInfo() const;
247     std::vector<std::string> getPflsReallyUsed() const;
248     std::vector<std::string> getLocsReallyUsed() const;
249     std::vector<std::string> getPflsReallyUsedMulti() const;
250     std::vector<std::string> getLocsReallyUsedMulti() const;
251     void changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
252     void changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
253     MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenLocId(mcIdType locId);
254     const MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenLocId(mcIdType locId) const;
255     int getNumberOfLoc() const { return (int)_field_pm_pt_pd.size(); }
256     int locIdOfLeaf(const MEDFileFieldPerMeshPerTypePerDisc *leaf) const;
257     void fillValues(mcIdType& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<mcIdType,mcIdType> > >& entries) const;
258     void setLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves);
259     bool keepOnlySpatialDiscretization(TypeOfField tof, mcIdType &globalNum, std::vector< std::pair<mcIdType,mcIdType> >& its);
260     bool keepOnlyGaussDiscretization(std::size_t idOfDisc, mcIdType &globalNum, std::vector< std::pair<mcIdType,mcIdType> >& its);
261     static med_entity_type ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType);
262     MEDFileFieldPerMeshPerTypeCommon(MEDFileFieldPerMesh *father):_father(father) { }
263     void setFather(MEDFileFieldPerMesh *father);
264     void accept(MEDFileFieldVisitor& visitor) const;
265   public:
266     virtual ~MEDFileFieldPerMeshPerTypeCommon();
267     virtual void getDimension(int& dim) const = 0;
268     virtual INTERP_KERNEL::NormalizedCellType getGeoType() const = 0;
269     virtual void entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const = 0;
270     virtual void simpleRepr(int bkOffset, std::ostream& oss, int id) const = 0;
271     virtual std::string getGeoTypeRepr() const = 0;
272     virtual MEDFileFieldPerMeshPerTypeCommon *deepCopy(MEDFileFieldPerMesh *father) const = 0;
273     virtual void getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<mcIdType,mcIdType> >& dads, std::vector<const DataArrayIdType *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const = 0;
274   protected:
275     void deepCopyElements();
276     std::vector<mcIdType> addNewEntryIfNecessary(const MEDCouplingFieldTemplate *field, mcIdType offset, mcIdType nbOfCells);
277     std::vector<mcIdType> addNewEntryIfNecessaryGauss(const MEDCouplingFieldTemplate *field, mcIdType offset, mcIdType nbOfCells);
278     std::vector<mcIdType> addNewEntryIfNecessary(const MEDCouplingFieldTemplate *field, const DataArrayIdType *subCells);
279     std::vector<mcIdType> addNewEntryIfNecessaryGauss(const MEDCouplingFieldTemplate *field, const DataArrayIdType *subCells);
280   private:
281     MEDFileFieldPerMesh *_father;
282   protected:
283     std::vector< MCAuto<MEDFileFieldPerMeshPerTypePerDisc> > _field_pm_pt_pd;
284   };
285
286   class MEDFileFieldPerMeshPerType : public MEDFileFieldPerMeshPerTypeCommon
287   {
288   public:
289     static MEDFileFieldPerMeshPerType *New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType);
290     static MEDFileFieldPerMeshPerType *NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd);
291     static MCAuto<MEDFileFieldPerMeshPerType> Aggregate(mcIdType &start, const std::vector< std::pair<int,const MEDFileFieldPerMeshPerType *> >& pms, const std::vector< std::vector< std::pair<int,mcIdType> > >& dts, INTERP_KERNEL::NormalizedCellType gt, MEDFileFieldPerMesh *father, std::vector<std::pair< int, std::pair<mcIdType,mcIdType> > >& extractInfo);
292   public:// overload of abstract methods
293     void getDimension(int& dim) const;
294     INTERP_KERNEL::NormalizedCellType getGeoType() const;
295     void entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const;
296     void simpleRepr(int bkOffset, std::ostream& oss, int id) const;
297     std::string getGeoTypeRepr() const;
298     MEDFileFieldPerMeshPerType *deepCopy(MEDFileFieldPerMesh *father) const;
299     void getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<mcIdType,mcIdType> >& dads, std::vector<const DataArrayIdType *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const;
300   private:
301     MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc, const PartDefinition *pd);
302     MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *father, INTERP_KERNEL::NormalizedCellType gt);
303   private:
304     INTERP_KERNEL::NormalizedCellType _geo_type;
305   };
306
307   class MEDFileFieldPerMeshPerTypeDyn : public MEDFileFieldPerMeshPerTypeCommon
308   {
309   public:
310     static MEDFileFieldPerMeshPerTypeDyn *NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileEntities *entities, int idGT, const MEDFileFieldNameScope& nasc);
311     int getDynGT() const;
312     std::string getModelName() const;
313   public:
314     void getDimension(int& dim) const;
315     INTERP_KERNEL::NormalizedCellType getGeoType() const;
316     void entriesForMEDfile(TypeOfField mct, med_geometry_type& gt, med_entity_type& ent) const;
317     void simpleRepr(int bkOffset, std::ostream& oss, int id) const;
318     std::string getGeoTypeRepr() const;
319     MEDFileFieldPerMeshPerTypeDyn *deepCopy(MEDFileFieldPerMesh *father) const;
320     void getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<mcIdType,mcIdType> >& dads, std::vector<const DataArrayIdType *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const;
321   private:
322     MEDFileFieldPerMeshPerTypeDyn(med_idt fid, MEDFileFieldPerMesh *fath, const MEDFileStructureElement *se, const MEDFileFieldNameScope& nasc);
323   private:
324     MCConstAuto<MEDFileStructureElement> _se;
325   };
326   
327   class MEDFileMesh;
328   class MEDFileAnyTypeField1TSWithoutSDA;
329   class MEDFileField1TSWithoutSDA;
330   
331   class MEDFileFieldPerMesh : public RefCountObject, public MEDFileWritable
332   {
333   public:
334     static MEDFileFieldPerMesh *New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh);
335     static MEDFileFieldPerMesh *NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const MEDFileEntities *entities);
336     std::size_t getHeapMemorySizeWithoutChildren() const;
337     std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
338     MEDFileFieldPerMesh *deepCopy(MEDFileAnyTypeField1TSWithoutSDA *father) const;
339     void simpleRepr(int bkOffset,std::ostream& oss, int id) const;
340     void copyTinyInfoFrom(const MEDCouplingMesh *mesh);
341     void assignFieldProfile(mcIdType& start, const DataArrayIdType *multiTypePfl, const std::vector<mcIdType>& code, const std::vector<mcIdType>& code2, const std::vector<DataArrayIdType *>& idsInPflPerType, const std::vector<DataArrayIdType *>& idsPerType, const MEDCouplingFieldTemplate *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc);
342     void assignFieldNoProfileNoRenum(mcIdType& start, const std::vector<mcIdType>& code, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc);
343     void assignNodeFieldNoProfile(mcIdType& start, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob);
344     void assignNodeFieldProfile(mcIdType& start, const DataArrayIdType *pfl, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc);
345     void loadOnlyStructureOfDataRecursively(med_idt fid, mcIdType &start, const MEDFileFieldNameScope& nasc);
346     void loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc);
347     void writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const;
348     void fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const;
349     std::vector< std::vector< std::pair<mcIdType,mcIdType> > > getFieldSplitedByType(std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const;
350     void accept(MEDFileFieldVisitor& visitor) const;
351     void getDimension(int& dim) const;
352     bool isUniqueLevel(int& dim) const;
353     double getTime() const;
354     int getIteration() const;
355     int getOrder() const;
356     int getMeshIteration() const { return _mesh_iteration; }
357     int getMeshOrder() const { return _mesh_order; }
358     std::string getMeshName() const;
359     void setMeshName(const std::string& meshName);
360     std::size_t getNumberOfComponents() const;
361     bool presenceOfMultiDiscPerGeoType() const;
362     bool presenceOfStructureElements() const;
363     bool onlyStructureElements() const;
364     void killStructureElements();
365     void keepOnlyStructureElements();
366     void keepOnlyOnSE(const std::string& seName);
367     void getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const;
368     DataArray *getOrCreateAndGetArray();
369     const DataArray *getOrCreateAndGetArray() const;
370     const std::vector<std::string>& getInfo() const;
371     std::vector<std::string> getPflsReallyUsed() const;
372     std::vector<std::string> getLocsReallyUsed() const;
373     std::vector<std::string> getPflsReallyUsedMulti() const;
374     std::vector<std::string> getLocsReallyUsedMulti() const;
375     void convertMedBallIntoClassic();
376     bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab);
377     bool renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<mcIdType>& oldCode, const std::vector<mcIdType>& newCode, const DataArrayIdType *renumO2N, MEDFileFieldGlobsReal& glob);
378     void keepOnlySpatialDiscretization(TypeOfField tof, mcIdType &globalNum, std::vector< std::pair<mcIdType,mcIdType> >& its);
379     void keepOnlyGaussDiscretization(std::size_t idOfDisc, mcIdType &globalNum, std::vector< std::pair<mcIdType,mcIdType> >& its);
380     void changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
381     void changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
382     MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray> &arrOut, const MEDFileFieldNameScope& nasc) const;
383     DataArray *getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayIdType *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const;
384     void getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<mcIdType,mcIdType> > >& entries) const;
385     MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, mcIdType locId);
386     const MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, mcIdType locId) const;
387     static MCAuto<MEDFileFieldPerMesh> Aggregate(mcIdType &start, const std::vector<const MEDFileFieldPerMesh *>& pms, const std::vector< std::vector< std::pair<int,mcIdType> > >& dts, MEDFileAnyTypeField1TSWithoutSDA *father, std::vector<std::pair< int, std::pair<mcIdType,mcIdType> > >& extractInfo);
388   private:
389     int addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type);
390     MEDCouplingFieldDouble *finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
391                                         const std::vector< std::pair<mcIdType,mcIdType> >& dads, const std::vector<int>& locs, const MEDCouplingMesh *mesh, bool& isPfl, MCAuto<DataArray> &arrOut, const MEDFileFieldNameScope& nasc) const;
392     MEDCouplingFieldDouble *finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
393                                          const std::vector< std::pair<mcIdType,mcIdType> >& dads, const std::vector<int>& locs,
394                                          const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
395                                          const MEDCouplingMesh *mesh, const DataArrayIdType *da, bool& isPfl, MCAuto<DataArray> &arrOut, const MEDFileFieldNameScope& nasc) const;
396     MEDCouplingFieldDouble *finishFieldNode2(const MEDFileFieldGlobsReal *glob,
397                                              const std::vector< std::pair<mcIdType,mcIdType> >& dads, const std::vector<int>& locs,
398                                              const MEDCouplingMesh *mesh, const DataArrayIdType *da, bool& isPfl, MCAuto<DataArray> &arrOut, const MEDFileFieldNameScope& nasc) const;
399     DataArray *finishField4(const std::vector< std::pair<mcIdType,mcIdType> >& dads, const DataArrayIdType *pflIn, mcIdType nbOfElems, DataArrayIdType *&pflOut) const;
400     void assignNewLeaves(const std::vector< MCAuto< MEDFileFieldPerMeshPerTypePerDisc > >& leaves);
401     static void SortArraysPerType(const MEDFileFieldGlobsReal *glob, TypeOfField type, 
402                                   const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes, const std::vector< std::pair<mcIdType,mcIdType> >& dads, const std::vector<const DataArrayIdType *>& pfls, const std::vector<int>& locs,
403                                   std::vector<mcIdType>& code, std::vector<DataArrayIdType *>& notNullPfls);
404     static mcIdType ComputeNbOfElems(const MEDFileFieldGlobsReal *glob, TypeOfField type, const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes, const std::vector< std::pair<mcIdType,mcIdType> >& dads, const std::vector<int>& locs);
405     MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc, const MEDFileMesh *mm, const MEDFileEntities *entities);
406     MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh);
407     MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const std::string& meshName, int meshIt, int meshOrd):_mesh_iteration(meshIt),_mesh_order(meshOrd),_father(fath) { }
408   private:
409     int _mesh_iteration;
410     int _mesh_order;
411     MEDFileAnyTypeField1TSWithoutSDA *_father;
412     std::vector< MCAuto< MEDFileFieldPerMeshPerTypeCommon > > _field_pm_pt;
413   };
414 }
415
416 #endif