Salome HOME
Merge branch 'origin/agy/V731rc2'
[modules/med.git] / src / MEDLoader / MEDFileField.hxx
1 // Copyright (C) 2007-2013  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.
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 (CEA/DEN)
20
21 #ifndef __MEDFILEFIELD_HXX__
22 #define __MEDFILEFIELD_HXX__
23
24 #include "MEDLoaderDefines.hxx"
25
26 #include "MEDFileFieldOverView.hxx"
27 #include "MEDFileUtilities.hxx"
28
29 #include "MEDCouplingAutoRefCountObjectPtr.hxx"
30 #include "MEDCouplingRefCountObject.hxx"
31 #include "MEDCouplingMemArray.hxx"
32
33 #include "NormalizedUnstructuredMesh.hxx"
34 #include "InterpKernelException.hxx"
35
36 #include <vector>
37 #include <string>
38 #include <list>
39 #include <set>
40
41 #include "med.h"
42
43 namespace ParaMEDMEM
44 {
45   class MEDFileFieldGlobs;
46   class MEDCouplingMesh;
47   class MEDCouplingFieldDouble;
48   class MEDFileMesh;
49
50   class MEDFileFieldLoc : public RefCountObject
51   {
52   public:
53     MEDLOADER_EXPORT void simpleRepr(std::ostream& oss) const;
54     MEDLOADER_EXPORT std::string getName() const { return _name; }
55     MEDLOADER_EXPORT void setName(const std::string& name);
56     static MEDFileFieldLoc *New(med_idt fid, const std::string& locName);
57     static MEDFileFieldLoc *New(med_idt fid, int id);
58     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);
59     std::size_t getHeapMemorySizeWithoutChildren() const;
60     std::vector<const BigMemoryObject *> getDirectChildren() const;
61     MEDFileFieldLoc *deepCpy() const;
62     MEDLOADER_EXPORT int getNbOfGaussPtPerCell() const { return _nb_gauss_pt; }
63     MEDLOADER_EXPORT void writeLL(med_idt fid) const;
64     MEDLOADER_EXPORT std::string repr() const;
65     MEDLOADER_EXPORT bool isName(const std::string& name) const { return _name==name; }
66     MEDLOADER_EXPORT int getDimension() const { return _dim; }
67     MEDLOADER_EXPORT int getNumberOfGaussPoints() const { return _nb_gauss_pt; }
68     MEDLOADER_EXPORT int getNumberOfPointsInCells() const { return _nb_node_per_cell; }
69     MEDLOADER_EXPORT const std::vector<double>& getRefCoords() const { return _ref_coo; }
70     MEDLOADER_EXPORT const std::vector<double>& getGaussCoords() const { return _gs_coo; }
71     MEDLOADER_EXPORT const std::vector<double>& getGaussWeights() const { return _w; }
72     MEDLOADER_EXPORT INTERP_KERNEL::NormalizedCellType getGeoType() const { return _geo_type; }
73     MEDLOADER_EXPORT bool isEqual(const MEDFileFieldLoc& other, double eps) const;
74   private:
75     MEDFileFieldLoc(med_idt fid, const std::string& locName);
76     MEDFileFieldLoc(med_idt fid, int id);
77     MEDFileFieldLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w);
78   private:
79     int _dim;
80     int _nb_gauss_pt;
81     int _nb_node_per_cell;
82     std::string _name;
83     INTERP_KERNEL::NormalizedCellType _geo_type;
84     std::vector<double> _ref_coo;
85     std::vector<double> _gs_coo;
86     std::vector<double> _w;
87   };
88
89 /// @cond INTERNAL
90   class MEDFileAnyTypeField1TSWithoutSDA;
91   class MEDFileFieldPerMeshPerType;
92   class MEDFileField1TSWithoutSDA;
93   class MEDFileFieldNameScope;
94   class MEDFileFieldGlobsReal;
95   class MEDFileFieldPerMesh;
96
97   class MEDFileFieldPerMeshPerTypePerDisc : public RefCountObject, public MEDFileWritable
98   {
99   public:
100     static MEDFileFieldPerMeshPerTypePerDisc *NewOnRead(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt);
101     static MEDFileFieldPerMeshPerTypePerDisc *New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId);
102     static MEDFileFieldPerMeshPerTypePerDisc *New(const MEDFileFieldPerMeshPerTypePerDisc& other);
103     std::size_t getHeapMemorySizeWithoutChildren() const;
104     std::vector<const BigMemoryObject *> getDirectChildren() const;
105     MEDFileFieldPerMeshPerTypePerDisc *deepCpy(MEDFileFieldPerMeshPerType *father) const;
106     void assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc);
107     void assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arrr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc);
108     void assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arrr, MEDFileFieldGlobsReal& glob);
109     void getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const;
110     void writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const;
111     const MEDFileFieldPerMeshPerType *getFather() const;
112     void loadOnlyStructureOfDataRecursively(med_idt fid, int& start, const MEDFileFieldNameScope& nasc);
113     void loadBigArray(med_idt fid, const MEDFileFieldNameScope& nasc);
114     void setNewStart(int newValueOfStart);
115     int getIteration() const;
116     int getOrder() const;
117     double getTime() const;
118     std::string getMeshName() const;
119     TypeOfField getType() const;
120     void simpleRepr(int bkOffset, std::ostream& oss, int id) const;
121     void fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const;
122     void setType(TypeOfField newType);
123     INTERP_KERNEL::NormalizedCellType getGeoType() const;
124     int getNumberOfComponents() const;
125     int getNumberOfTuples() const;
126     int getStart() const { return _start; }
127     int getEnd() const { return _end; }
128     DataArray *getOrCreateAndGetArray();
129     const DataArray *getOrCreateAndGetArray() const;
130     const std::vector<std::string>& getInfo() const;
131     std::string getProfile() const;
132     void setProfile(const std::string& newPflName);
133     std::string getLocalization() const;
134     void setLocalization(const std::string& newLocName);
135     int getLocId() const { return _loc_id; }
136     void setLocId(int newId) const { _loc_id=newId; }
137     void setFather(MEDFileFieldPerMeshPerType *newFather) { _father=newFather; }
138     void changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
139     void changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
140     void getFieldAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs,
141                          std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const;
142     void fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const;
143     int fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const;
144     int fillTupleIds(int *ptToFill) const;
145     static int ConvertType(TypeOfField type, int locId);
146     static std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries);
147     static bool RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
148                                const DataArrayInt *explicitIdsInMesh, const std::vector<int>& newCode,
149                                MEDFileFieldGlobsReal& glob, DataArrayDouble *arr, std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >& result);
150     static MEDFileFieldPerMeshPerTypePerDisc *NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
151                                                                           bool isPfl, int nbi, int offset, std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
152                                                                           MEDFileFieldGlobsReal& glob, bool &notInExisting) throw(INTERP_KERNEL::Exception);
153   private:
154     MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt);
155     MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt, const std::string& dummy);
156     MEDFileFieldPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDisc& other);
157     MEDFileFieldPerMeshPerTypePerDisc();
158   private:
159     TypeOfField _type;
160     MEDFileFieldPerMeshPerType *_father;
161     int _start;
162     int _end;
163     //! _nval is different than end-start in case of ON_GAUSS_PT and ON_GAUSS_NE ! (_nval=(_end-_start)/nbi)
164     int _nval;
165     std::string _profile;
166     std::string _localization;
167     //! only on assignement -3 : ON_NODES, -2 : ON_CELLS, -1 : ON_GAUSS_NE, 0..* : ON_GAUSS_PT
168     mutable int _loc_id;
169     mutable int _profile_it;
170   public:
171     mutable int _tmp_work1;
172   };
173
174   class MEDFileFieldPerMeshPerType : public RefCountObject, public MEDFileWritable
175   {
176   public:
177     static MEDFileFieldPerMeshPerType *New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType);
178     static MEDFileFieldPerMeshPerType *NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc);
179     std::size_t getHeapMemorySizeWithoutChildren() const;
180     std::vector<const BigMemoryObject *> getDirectChildren() const;
181     MEDFileFieldPerMeshPerType *deepCpy(MEDFileFieldPerMesh *father) const;
182     void assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc);
183     void assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc);
184     void assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob);
185     void assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc);
186     const MEDFileFieldPerMesh *getFather() const;
187     void loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc);
188     void loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc);
189     void writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const;
190     void getDimension(int& dim) const;
191     void fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const;
192     void fillFieldSplitedByType(std::vector< std::pair<int,int> >& dads, std::vector<TypeOfField>& types, std::vector<std::string>& pfls, std::vector<std::string>& locs) const;
193     int getIteration() const;
194     int getOrder() const;
195     double getTime() const;
196     std::string getMeshName() const;
197     void simpleRepr(int bkOffset, std::ostream& oss, int id) const;
198     void getSizes(int& globalSz, int& nbOfEntries) const;
199     INTERP_KERNEL::NormalizedCellType getGeoType() const;
200     int getNumberOfComponents() const;
201     DataArray *getOrCreateAndGetArray();
202     const DataArray *getOrCreateAndGetArray() const;
203     const std::vector<std::string>& getInfo() const;
204     std::vector<std::string> getPflsReallyUsed() const;
205     std::vector<std::string> getLocsReallyUsed() const;
206     std::vector<std::string> getPflsReallyUsedMulti() const;
207     std::vector<std::string> getLocsReallyUsedMulti() const;
208     void changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
209     void changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
210     MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenLocId(int locId);
211     const MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenLocId(int locId) const;
212     void getFieldAtLevel(int meshDim, TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs, std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const;
213     void fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const;
214     void setLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves);
215     bool keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its);
216     static med_entity_type ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType);
217   private:
218     std::vector<int> addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells);
219     std::vector<int> addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells);
220     std::vector<int> addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells);
221     std::vector<int> addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells);
222     MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType, const MEDFileFieldNameScope& nasc);
223     MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType);
224   private:
225     MEDFileFieldPerMesh *_father;
226     std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > _field_pm_pt_pd;
227     INTERP_KERNEL::NormalizedCellType _geo_type;
228   };
229
230   class MEDFileFieldPerMesh : public RefCountObject, public MEDFileWritable
231   {
232   public:
233     static MEDFileFieldPerMesh *New(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh);
234     static MEDFileFieldPerMesh *NewOnRead(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc);
235     std::size_t getHeapMemorySizeWithoutChildren() const;
236     std::vector<const BigMemoryObject *> getDirectChildren() const;
237     MEDFileFieldPerMesh *deepCpy(MEDFileAnyTypeField1TSWithoutSDA *father) const;
238     void simpleRepr(int bkOffset,std::ostream& oss, int id) const;
239     void copyTinyInfoFrom(const MEDCouplingMesh *mesh);
240     void assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const std::vector<int>& code, const std::vector<int>& code2, const std::vector<DataArrayInt *>& idsInPflPerType, const std::vector<DataArrayInt *>& idsPerType, const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc);
241     void assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc);
242     void assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob);
243     void assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc);
244     void loadOnlyStructureOfDataRecursively(med_idt fid, int &start, const MEDFileFieldNameScope& nasc);
245     void loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc);
246     void writeLL(med_idt fid, const MEDFileFieldNameScope& nasc) const;
247     void fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const;
248     std::vector< std::vector< std::pair<int,int> > > 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;
249     void getDimension(int& dim) const;
250     double getTime() const;
251     int getIteration() const;
252     int getOrder() const;
253     int getMeshIteration() const { return _mesh_iteration; }
254     int getMeshOrder() const { return _mesh_order; }
255     std::string getMeshName() const { return _mesh_name; }
256     int getNumberOfComponents() const;
257     DataArray *getOrCreateAndGetArray();
258     const DataArray *getOrCreateAndGetArray() const;
259     const std::vector<std::string>& getInfo() const;
260     std::vector<std::string> getPflsReallyUsed() const;
261     std::vector<std::string> getLocsReallyUsed() const;
262     std::vector<std::string> getPflsReallyUsedMulti() const;
263     std::vector<std::string> getLocsReallyUsedMulti() const;
264     bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab);
265     bool renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N, MEDFileFieldGlobsReal& glob);
266     void keepOnlySpatialDiscretization(TypeOfField tof, int &globalNum, std::vector< std::pair<int,int> >& its);
267     void changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
268     void changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
269     MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray> &arrOut, const MEDFileFieldNameScope& nasc) const;
270     DataArray *getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const;
271     void getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const;
272     MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId);
273     const MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const;
274   private:
275     int addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type);
276     MEDCouplingFieldDouble *finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
277                                         const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs, const MEDCouplingMesh *mesh, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray> &arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception);
278     MEDCouplingFieldDouble *finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
279                                          const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
280                                          const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
281                                          const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray> &arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception);
282     MEDCouplingFieldDouble *finishFieldNode2(const MEDFileFieldGlobsReal *glob,
283                                              const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
284                                              const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl, MEDCouplingAutoRefCountObjectPtr<DataArray> &arrOut, const MEDFileFieldNameScope& nasc) const throw(INTERP_KERNEL::Exception);
285     DataArray *finishField4(const std::vector< std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const;
286     void assignNewLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves);
287     static void SortArraysPerType(const MEDFileFieldGlobsReal *glob, TypeOfField type, 
288                                   const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes, const std::vector< std::pair<int,int> >& dads, const std::vector<const DataArrayInt *>& pfls, const std::vector<int>& locs,
289                                   std::vector<int>& code, std::vector<DataArrayInt *>& notNullPfls);
290     static int ComputeNbOfElems(const MEDFileFieldGlobsReal *glob, TypeOfField type, const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes, const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs);
291     MEDFileFieldPerMesh(med_idt fid, MEDFileAnyTypeField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder, const MEDFileFieldNameScope& nasc);
292     MEDFileFieldPerMesh(MEDFileAnyTypeField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh);
293   private:
294     std::string _mesh_name;
295     int _mesh_iteration;
296     int _mesh_order;
297     int _mesh_csit;
298     MEDFileAnyTypeField1TSWithoutSDA *_father;
299     std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > _field_pm_pt;
300   };
301
302   class MEDFileFieldGlobsReal;
303
304   class MEDFileFieldGlobs : public RefCountObject
305   {
306   public:
307     static MEDFileFieldGlobs *New(const std::string& fname);
308     static MEDFileFieldGlobs *New();
309     std::size_t getHeapMemorySizeWithoutChildren() const;
310     std::vector<const BigMemoryObject *> getDirectChildren() const;
311     MEDFileFieldGlobs *deepCpy() const;
312     MEDFileFieldGlobs *shallowCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const;
313     MEDFileFieldGlobs *deepCpyPart(const std::vector<std::string>& pfls, const std::vector<std::string>& locs) const;
314     void simpleRepr(std::ostream& oss) const;
315     void appendGlobs(const MEDFileFieldGlobs& other, double eps);
316     void checkGlobsPflsPartCoherency(const std::vector<std::string>& pflsUsed) const;
317     void checkGlobsLocsPartCoherency(const std::vector<std::string>& locsUsed) const;
318     void loadProfileInFile(med_idt fid, int id, const std::string& pflName);
319     void loadProfileInFile(med_idt fid, int id);
320     void loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real);
321     void loadAllGlobals(med_idt fid);
322     void writeGlobals(med_idt fid, const MEDFileWritable& opt) const;
323     std::vector<std::string> getPfls() const;
324     std::vector<std::string> getLocs() const;
325     bool existsPfl(const std::string& pflName) const;
326     bool existsLoc(const std::string& locName) const;
327     std::string createNewNameOfPfl() const;
328     std::string createNewNameOfLoc() const;
329     std::vector< std::vector<int> > whichAreEqualProfiles() const;
330     std::vector< std::vector<int> > whichAreEqualLocs(double eps) const;
331     void setFileName(const std::string& fileName);
332     void changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
333     void changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
334     int getNbOfGaussPtPerCell(int locId) const;
335     int getLocalizationId(const std::string& loc) const;
336     std::string getFileName() const { return _file_name; }
337     const MEDFileFieldLoc& getLocalizationFromId(int locId) const;
338     const MEDFileFieldLoc& getLocalization(const std::string& locName) const;
339     const DataArrayInt *getProfileFromId(int pflId) const;
340     const DataArrayInt *getProfile(const std::string& pflName) const;
341     MEDFileFieldLoc& getLocalizationFromId(int locId);
342     MEDFileFieldLoc& getLocalization(const std::string& locName);
343     DataArrayInt *getProfile(const std::string& pflName);
344     DataArrayInt *getProfileFromId(int pflId);
345     void killProfileIds(const std::vector<int>& pflIds);
346     void killLocalizationIds(const std::vector<int>& locIds);
347     //
348     void appendProfile(DataArrayInt *pfl);
349     void appendLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w);
350     //
351     static std::string CreateNewNameNotIn(const std::string& prefix, const std::vector<std::string>& namesToAvoid);
352   protected:
353     MEDFileFieldGlobs(const std::string& fname);
354     MEDFileFieldGlobs();
355     ~MEDFileFieldGlobs();
356   protected:
357     std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > _pfls;
358     std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> > _locs;
359     std::string _file_name;
360   };
361
362 /// @endcond INTERNAL
363
364   class MEDFileFieldGlobsReal
365   {
366   public:
367     MEDLOADER_EXPORT MEDFileFieldGlobsReal(const std::string& fname);
368     MEDLOADER_EXPORT MEDFileFieldGlobsReal();
369     MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
370     MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
371     MEDLOADER_EXPORT void simpleReprGlobs(std::ostream& oss) const;
372     MEDLOADER_EXPORT void resetContent();
373     MEDLOADER_EXPORT void shallowCpyGlobs(const MEDFileFieldGlobsReal& other);
374     MEDLOADER_EXPORT void deepCpyGlobs(const MEDFileFieldGlobsReal& other);
375     MEDLOADER_EXPORT void shallowCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other);
376     MEDLOADER_EXPORT void deepCpyOnlyUsedGlobs(const MEDFileFieldGlobsReal& other);
377     MEDLOADER_EXPORT void appendGlobs(const MEDFileFieldGlobsReal& other, double eps);
378     MEDLOADER_EXPORT void checkGlobsCoherency() const;
379     MEDLOADER_EXPORT void checkGlobsPflsPartCoherency() const;
380     MEDLOADER_EXPORT void checkGlobsLocsPartCoherency() const;
381     MEDLOADER_EXPORT virtual std::vector<std::string> getPflsReallyUsed() const = 0;
382     MEDLOADER_EXPORT virtual std::vector<std::string> getLocsReallyUsed() const = 0;
383     MEDLOADER_EXPORT virtual std::vector<std::string> getPflsReallyUsedMulti() const = 0;
384     MEDLOADER_EXPORT virtual std::vector<std::string> getLocsReallyUsedMulti() const = 0;
385     MEDLOADER_EXPORT virtual void changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) = 0;
386     MEDLOADER_EXPORT virtual void changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) = 0;
387     MEDLOADER_EXPORT virtual ~MEDFileFieldGlobsReal();
388     //
389     MEDLOADER_EXPORT void loadProfileInFile(med_idt fid, int id, const std::string& pflName);
390     MEDLOADER_EXPORT void loadProfileInFile(med_idt fid, int id);
391     MEDLOADER_EXPORT void loadGlobals(med_idt fid);
392     MEDLOADER_EXPORT void loadAllGlobals(med_idt fid);
393     MEDLOADER_EXPORT void writeGlobals(med_idt fid, const MEDFileWritable& opt) const;
394     MEDLOADER_EXPORT std::vector<std::string> getPfls() const;
395     MEDLOADER_EXPORT std::vector<std::string> getLocs() const;
396     MEDLOADER_EXPORT bool existsPfl(const std::string& pflName) const;
397     MEDLOADER_EXPORT bool existsLoc(const std::string& locName) const;
398     MEDLOADER_EXPORT std::string createNewNameOfPfl() const;
399     MEDLOADER_EXPORT std::string createNewNameOfLoc() const;
400     MEDLOADER_EXPORT std::vector< std::vector<int> > whichAreEqualProfiles() const;
401     MEDLOADER_EXPORT std::vector< std::vector<int> > whichAreEqualLocs(double eps) const;
402     MEDLOADER_EXPORT void setFileName(const std::string& fileName);
403     MEDLOADER_EXPORT void changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
404     MEDLOADER_EXPORT void changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
405     MEDLOADER_EXPORT void changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
406     MEDLOADER_EXPORT void changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
407     MEDLOADER_EXPORT void changePflName(const std::string& oldName, const std::string& newName);
408     MEDLOADER_EXPORT void changeLocName(const std::string& oldName, const std::string& newName);
409     MEDLOADER_EXPORT std::vector< std::pair<std::vector<std::string>, std::string > > zipPflsNames();
410     MEDLOADER_EXPORT std::vector< std::pair<std::vector<std::string>, std::string > > zipLocsNames(double eps);
411     MEDLOADER_EXPORT int getNbOfGaussPtPerCell(int locId) const;
412     MEDLOADER_EXPORT int getLocalizationId(const std::string& loc) const;
413     MEDLOADER_EXPORT std::string getFileName() const;
414     MEDLOADER_EXPORT const MEDFileFieldLoc& getLocalizationFromId(int locId) const;
415     MEDLOADER_EXPORT const MEDFileFieldLoc& getLocalization(const std::string& locName) const;
416     MEDLOADER_EXPORT MEDFileFieldLoc& getLocalizationFromId(int locId);
417     MEDLOADER_EXPORT MEDFileFieldLoc& getLocalization(const std::string& locName);
418     MEDLOADER_EXPORT const DataArrayInt *getProfile(const std::string& pflName) const;
419     MEDLOADER_EXPORT const DataArrayInt *getProfileFromId(int pflId) const;
420     MEDLOADER_EXPORT DataArrayInt *getProfile(const std::string& pflName);
421     MEDLOADER_EXPORT DataArrayInt *getProfileFromId(int pflId);
422     MEDLOADER_EXPORT void killProfileIds(const std::vector<int>& pflIds);
423     MEDLOADER_EXPORT void killLocalizationIds(const std::vector<int>& locIds);
424     //
425     MEDLOADER_EXPORT void appendProfile(DataArrayInt *pfl);
426     MEDLOADER_EXPORT void appendLoc(const std::string& locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w);
427   protected:
428     MEDFileFieldGlobs *contentNotNull();
429     const MEDFileFieldGlobs *contentNotNull() const;
430   protected:
431     MEDCouplingAutoRefCountObjectPtr< MEDFileFieldGlobs > _globals;
432   };
433
434   class MEDFileFieldNameScope
435   {
436   public:
437     MEDLOADER_EXPORT MEDFileFieldNameScope();
438     MEDLOADER_EXPORT MEDFileFieldNameScope(const std::string& fieldName);
439     MEDLOADER_EXPORT std::string getName() const;
440     MEDLOADER_EXPORT void setName(const std::string& fieldName);
441     MEDLOADER_EXPORT std::string getDtUnit() const;
442     MEDLOADER_EXPORT void setDtUnit(const std::string& dtUnit);
443     MEDLOADER_EXPORT void copyNameScope(const MEDFileFieldNameScope& other);
444   protected:
445     std::string _name;
446     std::string _dt_unit;
447   };
448
449   /*!
450    * SDA is for Shared Data Arrays such as profiles.
451    */
452   class MEDFileAnyTypeField1TSWithoutSDA : public RefCountObject, public MEDFileFieldNameScope
453   {
454   public:
455     MEDLOADER_EXPORT MEDFileAnyTypeField1TSWithoutSDA();
456     MEDLOADER_EXPORT MEDFileAnyTypeField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order);
457     MEDLOADER_EXPORT int getIteration() const { return _iteration; }
458     MEDLOADER_EXPORT int getOrder() const { return _order; }
459     MEDLOADER_EXPORT double getTime(int& iteration, int& order) const { iteration=_iteration; order=_order; return _dt; }
460     MEDLOADER_EXPORT void setTime(int iteration, int order, double val) { _dt=val; _iteration=iteration; _order=order; }
461     MEDLOADER_EXPORT int getDimension() const;
462     MEDLOADER_EXPORT std::string getMeshName() const;
463     MEDLOADER_EXPORT void setMeshName(const std::string& newMeshName);
464     MEDLOADER_EXPORT bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab);
465     MEDLOADER_EXPORT int getMeshIteration() const;
466     MEDLOADER_EXPORT int getMeshOrder() const;
467     MEDLOADER_EXPORT bool isDealingTS(int iteration, int order) const;
468     MEDLOADER_EXPORT std::pair<int,int> getDtIt() const;
469     MEDLOADER_EXPORT void fillIteration(std::pair<int,int>& p) const;
470     MEDLOADER_EXPORT void fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const;
471     MEDLOADER_EXPORT std::vector<TypeOfField> getTypesOfFieldAvailable() const;
472     //
473     MEDLOADER_EXPORT std::vector<std::string> getPflsReallyUsed2() const;
474     MEDLOADER_EXPORT std::vector<std::string> getLocsReallyUsed2() const;
475     MEDLOADER_EXPORT std::vector<std::string> getPflsReallyUsedMulti2() const;
476     MEDLOADER_EXPORT std::vector<std::string> getLocsReallyUsedMulti2() const;
477     MEDLOADER_EXPORT void changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
478     MEDLOADER_EXPORT void changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
479     //
480     MEDLOADER_EXPORT int getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const;
481     MEDLOADER_EXPORT std::vector< std::vector<std::pair<int,int> > > getFieldSplitedByType(const std::string& mname, 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;
482     //
483     MEDLOADER_EXPORT MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId);
484     MEDLOADER_EXPORT const MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const;
485     MEDLOADER_EXPORT void deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other);
486   public:
487     MEDLOADER_EXPORT int getNumberOfComponents() const;
488     MEDLOADER_EXPORT const std::vector<std::string>& getInfo() const;
489     MEDLOADER_EXPORT std::vector<std::string>& getInfo();
490     MEDLOADER_EXPORT void setInfo(const std::vector<std::string>& infos);
491     MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
492     MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
493     MEDLOADER_EXPORT int copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr);
494     MEDLOADER_EXPORT void setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc);
495     MEDLOADER_EXPORT void setFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc);
496     MEDLOADER_EXPORT virtual void simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const;
497     MEDLOADER_EXPORT virtual MEDFileAnyTypeField1TSWithoutSDA *deepCpy() const = 0;
498     MEDLOADER_EXPORT virtual MEDFileAnyTypeField1TSWithoutSDA *shallowCpy() const = 0;
499     MEDLOADER_EXPORT virtual std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > splitComponents() const;
500     MEDLOADER_EXPORT virtual const char *getTypeStr() const = 0;
501     MEDLOADER_EXPORT virtual DataArray *getUndergroundDataArray() const = 0;
502     MEDLOADER_EXPORT virtual DataArray *getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const = 0;
503     MEDLOADER_EXPORT virtual void setArray(DataArray *arr) = 0;
504     MEDLOADER_EXPORT virtual DataArray *createNewEmptyDataArrayInstance() const = 0;
505     MEDLOADER_EXPORT virtual DataArray *getOrCreateAndGetArray() = 0;
506     MEDLOADER_EXPORT virtual const DataArray *getOrCreateAndGetArray() const = 0;
507   public:
508     MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray> &arrOut, const MEDFileFieldNameScope& nasc) const;
509     MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MEDCouplingAutoRefCountObjectPtr<DataArray> &arrOut, const MEDFileFieldNameScope& nasc) const;
510     MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MEDCouplingAutoRefCountObjectPtr<DataArray> &arrOut, const MEDFileFieldNameScope& nasc) const;
511     MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, const DataArrayInt *cellRenum, const DataArrayInt *nodeRenum, MEDCouplingAutoRefCountObjectPtr<DataArray> &arrOut, const MEDFileFieldNameScope& nasc) const;
512     DataArray *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const;
513   public:
514     MEDLOADER_EXPORT bool renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N, MEDFileFieldGlobsReal& glob);
515     MEDLOADER_EXPORT std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > splitDiscretizations() const;
516     MEDLOADER_EXPORT int keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its);
517   public:
518     MEDLOADER_EXPORT void allocNotFromFile(int newNbOfTuples);
519     MEDLOADER_EXPORT bool allocIfNecessaryTheArrayToReceiveDataFromFile();
520     MEDLOADER_EXPORT void loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc);
521     MEDLOADER_EXPORT void loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc);
522     MEDLOADER_EXPORT void loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc);
523     MEDLOADER_EXPORT void loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc);
524     MEDLOADER_EXPORT void unloadArrays();
525     MEDLOADER_EXPORT void writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const;
526   protected:
527     int getMeshIdFromMeshName(const std::string& mName) const;
528     int addNewEntryIfNecessary(const MEDCouplingMesh *mesh);
529     void updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops);
530   protected:
531     std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > > _field_per_mesh;
532     int _iteration;
533     int _order;
534     double _dt;
535   public:
536     //! only useable on reading
537     mutable int _csit;
538     // -3 means allocated and build from scratch
539     // -2 means allocated and read from a file
540     // -1 means not allocated and build from scratch
541     // >=0 means not allocated and read from a file
542     mutable int _nb_of_tuples_to_be_allocated;
543   };
544
545   class MEDFileIntField1TSWithoutSDA;
546   
547   /*!
548    * SDA is for Shared Data Arrays such as profiles.
549    */
550   class MEDFileField1TSWithoutSDA : public MEDFileAnyTypeField1TSWithoutSDA
551   {
552   public:
553     MEDLOADER_EXPORT const char *getTypeStr() const;
554     MEDLOADER_EXPORT DataArray *getUndergroundDataArray() const;
555     MEDLOADER_EXPORT DataArray *getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const;
556     MEDLOADER_EXPORT DataArrayDouble *getUndergroundDataArrayDouble() const;
557     MEDLOADER_EXPORT DataArrayDouble *getUndergroundDataArrayDoubleExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const;
558     MEDLOADER_EXPORT std::vector< std::vector<DataArrayDouble *> > getFieldSplitedByType2(const std::string& mname, 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;
559     MEDLOADER_EXPORT static void CheckMeshDimRel(int meshDimRelToMax);
560     MEDLOADER_EXPORT static std::vector<int> CheckSBTMesh(const MEDCouplingMesh *mesh);
561     MEDLOADER_EXPORT static MEDFileField1TSWithoutSDA *New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos);
562   public:
563     MEDLOADER_EXPORT MEDFileField1TSWithoutSDA();
564     MEDLOADER_EXPORT MEDFileField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos);
565     MEDLOADER_EXPORT MEDFileAnyTypeField1TSWithoutSDA *shallowCpy() const;
566     MEDLOADER_EXPORT MEDFileAnyTypeField1TSWithoutSDA *deepCpy() const;
567     MEDLOADER_EXPORT void setArray(DataArray *arr);
568     MEDLOADER_EXPORT DataArray *createNewEmptyDataArrayInstance() const;
569     MEDLOADER_EXPORT DataArray *getOrCreateAndGetArray();
570     MEDLOADER_EXPORT const DataArray *getOrCreateAndGetArray() const;
571     MEDLOADER_EXPORT DataArrayDouble *getOrCreateAndGetArrayDouble();
572     MEDLOADER_EXPORT const DataArrayDouble *getOrCreateAndGetArrayDouble() const;
573     MEDLOADER_EXPORT MEDFileIntField1TSWithoutSDA *convertToInt() const;
574   protected:
575     MEDCouplingAutoRefCountObjectPtr< DataArrayDouble > _arr;
576   public:
577     static const char TYPE_STR[];
578   };
579
580   /*!
581    * SDA is for Shared Data Arrays such as profiles.
582    */
583   class MEDFileIntField1TSWithoutSDA : public MEDFileAnyTypeField1TSWithoutSDA
584   {
585   public:
586     MEDLOADER_EXPORT MEDFileIntField1TSWithoutSDA();
587     MEDLOADER_EXPORT static MEDFileIntField1TSWithoutSDA *New(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos);
588     MEDLOADER_EXPORT MEDFileAnyTypeField1TSWithoutSDA *deepCpy() const;
589     MEDLOADER_EXPORT MEDFileAnyTypeField1TSWithoutSDA *shallowCpy() const;
590     MEDLOADER_EXPORT const char *getTypeStr() const;
591     MEDLOADER_EXPORT DataArray *getUndergroundDataArray() const;
592     MEDLOADER_EXPORT DataArray *getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const;
593     MEDLOADER_EXPORT void setArray(DataArray *arr);
594     MEDLOADER_EXPORT DataArray *createNewEmptyDataArrayInstance() const;
595     MEDLOADER_EXPORT DataArray *getOrCreateAndGetArray();
596     MEDLOADER_EXPORT const DataArray *getOrCreateAndGetArray() const;
597     MEDLOADER_EXPORT DataArrayInt *getOrCreateAndGetArrayInt();
598     MEDLOADER_EXPORT const DataArrayInt *getOrCreateAndGetArrayInt() const;
599     MEDLOADER_EXPORT DataArrayInt *getUndergroundDataArrayInt() const;
600     MEDLOADER_EXPORT DataArrayInt *getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const;
601     MEDLOADER_EXPORT MEDFileField1TSWithoutSDA *convertToDouble() const;
602   protected:
603     MEDFileIntField1TSWithoutSDA(const std::string& fieldName, int csit, int iteration, int order, const std::vector<std::string>& infos);
604   protected:
605     MEDCouplingAutoRefCountObjectPtr< DataArrayInt > _arr;
606   public:
607     MEDLOADER_EXPORT static const char TYPE_STR[];
608   };
609
610   /*!
611    * User class.
612    */
613   class MEDFileAnyTypeField1TS : public RefCountObject, public MEDFileWritable, public MEDFileFieldGlobsReal
614   {
615   protected:
616     MEDLOADER_EXPORT MEDFileAnyTypeField1TS();
617     MEDLOADER_EXPORT MEDFileAnyTypeField1TS(const std::string& fileName, bool loadAll);
618     MEDLOADER_EXPORT MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll);
619     MEDLOADER_EXPORT MEDFileAnyTypeField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll);
620     MEDLOADER_EXPORT MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent);
621     MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, const std::string& fileName);
622     MEDLOADER_EXPORT static MEDFileAnyTypeField1TSWithoutSDA *BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll);
623     MEDLOADER_EXPORT static MEDFileAnyTypeField1TSWithoutSDA *BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll);
624     MEDLOADER_EXPORT static MEDFileAnyTypeField1TSWithoutSDA *BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll);
625     MEDLOADER_EXPORT void writeLL(med_idt fid) const;
626     // direct forwarding to MEDFileAnyTypeField1TSWithoutSDA instance _content
627   public:
628     MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *New(const std::string& fileName, bool loadAll=true);
629     MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true);
630     MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll=true);
631     MEDLOADER_EXPORT int getDimension() const;
632     MEDLOADER_EXPORT int getIteration() const;
633     MEDLOADER_EXPORT int getOrder() const;
634     MEDLOADER_EXPORT double getTime(int& iteration, int& order) const;
635     MEDLOADER_EXPORT void setTime(int iteration, int order, double val);
636     MEDLOADER_EXPORT std::string getName() const;
637     MEDLOADER_EXPORT void setName(const std::string& name);
638     MEDLOADER_EXPORT std::string simpleRepr() const;
639     MEDLOADER_EXPORT void simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const;
640     MEDLOADER_EXPORT std::string getDtUnit() const;
641     MEDLOADER_EXPORT void setDtUnit(const std::string& dtUnit);
642     MEDLOADER_EXPORT std::string getMeshName() const;
643     MEDLOADER_EXPORT void setMeshName(const std::string& newMeshName);
644     MEDLOADER_EXPORT bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab);
645     MEDLOADER_EXPORT int getMeshIteration() const;
646     MEDLOADER_EXPORT int getMeshOrder() const;
647     MEDLOADER_EXPORT int getNumberOfComponents() const;
648     MEDLOADER_EXPORT bool isDealingTS(int iteration, int order) const;
649     MEDLOADER_EXPORT std::pair<int,int> getDtIt() const;
650     MEDLOADER_EXPORT void fillIteration(std::pair<int,int>& p) const;
651     MEDLOADER_EXPORT void fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const;
652     MEDLOADER_EXPORT void setInfo(const std::vector<std::string>& infos);
653     MEDLOADER_EXPORT const std::vector<std::string>& getInfo() const;
654     MEDLOADER_EXPORT std::vector<std::string>& getInfo();
655     MEDLOADER_EXPORT std::vector<TypeOfField> getTypesOfFieldAvailable() const;
656     MEDLOADER_EXPORT std::vector< std::vector<std::pair<int,int> > > getFieldSplitedByType(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
657                                                                           std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception);
658     MEDLOADER_EXPORT MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId);
659     MEDLOADER_EXPORT const MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const;
660     MEDLOADER_EXPORT int getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const;
661   public:
662     MEDLOADER_EXPORT void write(const std::string& fileName, int mode) const;
663     MEDLOADER_EXPORT void loadArrays();
664     MEDLOADER_EXPORT void loadArraysIfNecessary();
665     MEDLOADER_EXPORT void unloadArrays();
666     MEDLOADER_EXPORT void unloadArraysWithoutDataLoss();
667     MEDLOADER_EXPORT std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > splitComponents() const;
668     MEDLOADER_EXPORT std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeField1TS > > splitDiscretizations() const;
669     MEDLOADER_EXPORT MEDFileAnyTypeField1TS *deepCpy() const;
670     MEDLOADER_EXPORT int copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr);
671     MEDLOADER_EXPORT virtual MEDFileAnyTypeField1TS *shallowCpy() const = 0;
672   public:
673     //! underground method see MEDFileField1TSWithoutSDA::setProfileNameOnLeaf
674     MEDLOADER_EXPORT void setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob=false);
675     //! underground method see MEDFileField1TSWithoutSDA::setLocNameOnLeaf
676     MEDLOADER_EXPORT void setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob=false);
677     MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
678     MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
679     MEDLOADER_EXPORT std::vector<std::string> getPflsReallyUsed() const;
680     MEDLOADER_EXPORT std::vector<std::string> getLocsReallyUsed() const;
681     MEDLOADER_EXPORT std::vector<std::string> getPflsReallyUsedMulti() const;
682     MEDLOADER_EXPORT std::vector<std::string> getLocsReallyUsedMulti() const;
683     MEDLOADER_EXPORT void changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
684     MEDLOADER_EXPORT void changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
685   public:
686     MEDLOADER_EXPORT static int LocateField2(med_idt fid, const std::string& fileName, int fieldIdCFormat, bool checkFieldId, std::string& fieldName, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut);
687     MEDLOADER_EXPORT static int LocateField(med_idt fid, const std::string& fileName, const std::string& fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut);
688   public:
689     MEDLOADER_EXPORT virtual med_field_type getMEDFileFieldType() const = 0;
690     MEDLOADER_EXPORT MEDFileAnyTypeField1TSWithoutSDA *contentNotNullBase();
691     MEDLOADER_EXPORT const MEDFileAnyTypeField1TSWithoutSDA *contentNotNullBase() const;
692   protected:
693     MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> _content;
694   };
695   
696   class MEDFileIntField1TS;
697   
698   /*!
699    * User class.
700    */
701   class MEDFileField1TS : public MEDFileAnyTypeField1TS
702   {
703   public:
704     MEDLOADER_EXPORT static MEDFileField1TS *New(const std::string& fileName, bool loadAll=true);
705     MEDLOADER_EXPORT static MEDFileField1TS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true);
706     MEDLOADER_EXPORT static MEDFileField1TS *New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll=true);
707     MEDLOADER_EXPORT static MEDFileField1TS *New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent);
708     MEDLOADER_EXPORT static MEDFileField1TS *New();
709     MEDLOADER_EXPORT MEDFileIntField1TS *convertToInt(bool isDeepCpyGlobs=true) const;
710     //
711     MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const;
712     MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int renumPol=0) const;
713     MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const;
714     MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol=0) const;
715     MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol=0) const;
716     MEDLOADER_EXPORT DataArrayDouble *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const;
717     //
718     MEDLOADER_EXPORT void setFieldNoProfileSBT(const MEDCouplingFieldDouble *field);
719     MEDLOADER_EXPORT void setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile);
720     // direct forwarding to MEDFileField1TSWithoutSDA instance _content
721   public:
722     MEDLOADER_EXPORT MEDFileAnyTypeField1TS *shallowCpy() const;
723     MEDLOADER_EXPORT DataArrayDouble *getUndergroundDataArray() const;
724     MEDLOADER_EXPORT DataArrayDouble *getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const;
725     
726     MEDLOADER_EXPORT std::vector< std::vector<DataArrayDouble *> > getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
727                                                                                           std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception);
728   public:
729     MEDLOADER_EXPORT static void SetDataArrayDoubleInField(MEDCouplingFieldDouble *f, MEDCouplingAutoRefCountObjectPtr<DataArray>& arr);
730     MEDLOADER_EXPORT static DataArrayDouble *ReturnSafelyDataArrayDouble(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr);
731   private:
732     med_field_type getMEDFileFieldType() const { return MED_FLOAT64; }
733     const MEDFileField1TSWithoutSDA *contentNotNull() const;
734     MEDFileField1TSWithoutSDA *contentNotNull();
735   private:
736     MEDFileField1TS(const std::string& fileName, bool loadAll);
737     MEDFileField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll);
738     MEDFileField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll);
739     MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent);
740     MEDFileField1TS();
741   };
742
743   class MEDFileIntField1TS : public MEDFileAnyTypeField1TS
744   {
745   public:
746     MEDLOADER_EXPORT static MEDFileIntField1TS *New();
747     MEDLOADER_EXPORT static MEDFileIntField1TS *New(const std::string& fileName, bool loadAll=true);
748     MEDLOADER_EXPORT static MEDFileIntField1TS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true);
749     MEDLOADER_EXPORT static MEDFileIntField1TS *New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll=true);
750     MEDLOADER_EXPORT static MEDFileIntField1TS *New(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent);
751     MEDLOADER_EXPORT MEDFileField1TS *convertToDouble(bool isDeepCpyGlobs=true) const;
752     MEDLOADER_EXPORT MEDFileAnyTypeField1TS *shallowCpy() const;
753     //
754     MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol=0) const;
755     MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, DataArrayInt* &arrOut, int renumPol=0) const;
756     MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol=0) const;
757     MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol=0) const;
758     MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol=0) const;
759     MEDLOADER_EXPORT DataArrayInt *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const;
760     //
761     MEDLOADER_EXPORT void setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals);
762     MEDLOADER_EXPORT void setFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile);
763     MEDLOADER_EXPORT DataArrayInt *getUndergroundDataArray() const;
764   public:
765     MEDLOADER_EXPORT static DataArrayInt *ReturnSafelyDataArrayInt(MEDCouplingAutoRefCountObjectPtr<DataArray>& arr);
766   private:
767     med_field_type getMEDFileFieldType() const { return MED_INT32; }
768     const MEDFileIntField1TSWithoutSDA *contentNotNull() const;
769     MEDFileIntField1TSWithoutSDA *contentNotNull();
770   private:
771     MEDFileIntField1TS();
772     MEDFileIntField1TS(const std::string& fileName, bool loadAll);
773     MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, bool loadAll);
774     MEDFileIntField1TS(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll);
775     MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent);
776   };
777   
778   class MEDFileAnyTypeFieldMultiTSWithoutSDA : public RefCountObject, public MEDFileFieldNameScope
779   {
780   protected:
781     MEDFileAnyTypeFieldMultiTSWithoutSDA();
782     MEDFileAnyTypeFieldMultiTSWithoutSDA(const std::string& fieldName);
783     MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll);
784     MEDFileAnyTypeFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll);
785   public:
786     MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
787     MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
788     MEDLOADER_EXPORT virtual MEDFileAnyTypeFieldMultiTSWithoutSDA *deepCpy() const;
789     MEDLOADER_EXPORT virtual std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > splitComponents() const;
790     MEDLOADER_EXPORT virtual std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > splitDiscretizations() const;
791     MEDLOADER_EXPORT virtual const char *getTypeStr() const = 0;
792     MEDLOADER_EXPORT virtual MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const = 0;
793     MEDLOADER_EXPORT virtual MEDFileAnyTypeFieldMultiTSWithoutSDA *createNew() const = 0;
794     MEDLOADER_EXPORT virtual MEDFileAnyTypeField1TSWithoutSDA *createNew1TSWithoutSDAEmptyInstance() const = 0;
795     MEDLOADER_EXPORT virtual void checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const = 0;
796     MEDLOADER_EXPORT const std::vector<std::string>& getInfo() const;
797     MEDLOADER_EXPORT void setInfo(const std::vector<std::string>& info);
798     MEDLOADER_EXPORT int getTimeStepPos(int iteration, int order) const;
799     MEDLOADER_EXPORT const MEDFileAnyTypeField1TSWithoutSDA& getTimeStepEntry(int iteration, int order) const;
800     MEDLOADER_EXPORT MEDFileAnyTypeField1TSWithoutSDA& getTimeStepEntry(int iteration, int order);
801     MEDLOADER_EXPORT std::string getMeshName() const;
802     MEDLOADER_EXPORT void setMeshName(const std::string& newMeshName);
803     MEDLOADER_EXPORT bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab);
804     MEDLOADER_EXPORT int getNumberOfTS() const;
805     MEDLOADER_EXPORT void eraseEmptyTS();
806     MEDLOADER_EXPORT void eraseTimeStepIds(const int *startIds, const int *endIds);
807     MEDLOADER_EXPORT void eraseTimeStepIds2(int bg, int end, int step);
808     MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *buildFromTimeStepIds(const int *startIds, const int *endIds) const;
809     MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *buildFromTimeStepIds2(int bg, int end, int step) const;
810     MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const;
811     MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const;
812     MEDLOADER_EXPORT int getPosOfTimeStep(int iteration, int order) const;
813     MEDLOADER_EXPORT int getPosGivenTime(double time, double eps=1e-8) const;
814     MEDLOADER_EXPORT std::vector< std::pair<int,int> > getIterations() const;
815     MEDLOADER_EXPORT std::vector< std::pair<int,int> > getTimeSteps(std::vector<double>& ret1) const;
816     MEDLOADER_EXPORT void pushBackTimeStep(MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA>& tse);
817     MEDLOADER_EXPORT void synchronizeNameScope();
818     MEDLOADER_EXPORT void simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const;
819     MEDLOADER_EXPORT int getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const;
820     MEDLOADER_EXPORT void appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArray *arr, MEDFileFieldGlobsReal& glob);
821     MEDLOADER_EXPORT void appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArray *arr, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob);
822     MEDLOADER_EXPORT std::vector< std::vector< std::pair<int,int> > > getFieldSplitedByType(int iteration, int order, const std::string& mname, 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;
823     MEDLOADER_EXPORT std::vector< std::vector<TypeOfField> > getTypesOfFieldAvailable() const;
824     MEDLOADER_EXPORT DataArray *getUndergroundDataArray(int iteration, int order) const;
825     MEDLOADER_EXPORT DataArray *getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const;
826     MEDLOADER_EXPORT bool renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N, MEDFileFieldGlobsReal& glob);
827     MEDLOADER_EXPORT void loadStructureOrStructureAndBigArraysRecursively(med_idt fid, int nbPdt, med_field_type fieldTyp, bool loadAll);
828     MEDLOADER_EXPORT void writeLL(med_idt fid, const MEDFileWritable& opts) const;
829     MEDLOADER_EXPORT void loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc);
830     MEDLOADER_EXPORT void loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc);
831     MEDLOADER_EXPORT void unloadArrays();
832   public:
833     MEDLOADER_EXPORT const MEDFileAnyTypeField1TSWithoutSDA *getTimeStepAtPos2(int pos) const;
834     MEDLOADER_EXPORT MEDFileAnyTypeField1TSWithoutSDA *getTimeStepAtPos2(int pos);
835     MEDLOADER_EXPORT std::vector<std::string> getPflsReallyUsed2() const;
836     MEDLOADER_EXPORT std::vector<std::string> getLocsReallyUsed2() const;
837     MEDLOADER_EXPORT std::vector<std::string> getPflsReallyUsedMulti2() const;
838     MEDLOADER_EXPORT std::vector<std::string> getLocsReallyUsedMulti2() const;
839     MEDLOADER_EXPORT void changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
840     MEDLOADER_EXPORT void changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
841     MEDLOADER_EXPORT void setIteration(int i, MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> ts);
842   protected:
843     virtual med_field_type getMEDFileFieldType() const = 0;
844     void copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr);
845     void checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field, const DataArray *arr) const;
846     void checkThatComponentsMatch(const std::vector<std::string>& compos) const;
847     void checkThatNbOfCompoOfTSMatchThis() const;
848   protected:
849     std::vector<std::string> _infos;
850     std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeField1TSWithoutSDA> > _time_steps;
851   };
852
853   class MEDFileIntFieldMultiTSWithoutSDA;
854
855   class MEDFileFieldMultiTSWithoutSDA : public MEDFileAnyTypeFieldMultiTSWithoutSDA
856   {
857   public:
858     MEDLOADER_EXPORT static MEDFileFieldMultiTSWithoutSDA *New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll);
859     MEDLOADER_EXPORT MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll);
860     MEDLOADER_EXPORT const char *getTypeStr() const;
861     MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const;
862     MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *createNew() const;
863     MEDLOADER_EXPORT std::vector< std::vector<DataArrayDouble *> > getFieldSplitedByType2(int iteration, int order, const std::string& mname, 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;
864     MEDLOADER_EXPORT MEDFileIntFieldMultiTSWithoutSDA *convertToInt() const;
865   protected:
866     MEDFileFieldMultiTSWithoutSDA(const std::string& fieldName);
867     MEDFileFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll);
868     med_field_type getMEDFileFieldType() const { return MED_FLOAT64; }
869     MEDFileAnyTypeField1TSWithoutSDA *createNew1TSWithoutSDAEmptyInstance() const;
870     void checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const;
871   public:
872     MEDLOADER_EXPORT MEDFileFieldMultiTSWithoutSDA();
873   };
874
875   class MEDFileIntFieldMultiTSWithoutSDA : public MEDFileAnyTypeFieldMultiTSWithoutSDA
876   {
877   public:
878     MEDLOADER_EXPORT static MEDFileIntFieldMultiTSWithoutSDA *New(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll);
879     MEDLOADER_EXPORT MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, int fieldId, bool loadAll);
880     MEDLOADER_EXPORT const char *getTypeStr() const;
881     MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *shallowCpy() const;
882     MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSWithoutSDA *createNew() const;
883     MEDLOADER_EXPORT MEDFileFieldMultiTSWithoutSDA *convertToDouble() const;
884   protected:
885     MEDFileIntFieldMultiTSWithoutSDA(const std::string& fieldName);
886     MEDFileIntFieldMultiTSWithoutSDA(med_idt fid, const std::string& fieldName, med_field_type fieldTyp, const std::vector<std::string>& infos, int nbOfStep, const std::string& dtunit, bool loadAll);
887     med_field_type getMEDFileFieldType() const { return MED_INT32; }
888     MEDFileAnyTypeField1TSWithoutSDA *createNew1TSWithoutSDAEmptyInstance() const;
889     void checkCoherencyOfType(const MEDFileAnyTypeField1TSWithoutSDA *f1ts) const;
890   public:
891     MEDLOADER_EXPORT MEDFileIntFieldMultiTSWithoutSDA();
892   };
893
894   class MEDFileAnyTypeFieldMultiTSIterator;
895   class MEDFileFastCellSupportComparator;
896   /*!
897    * User class.
898    */
899   class MEDFileAnyTypeFieldMultiTS : public RefCountObject, public MEDFileWritable, public MEDFileFieldGlobsReal
900   {
901   protected:
902     MEDFileAnyTypeFieldMultiTS();
903     MEDFileAnyTypeFieldMultiTS(const std::string& fileName, bool loadAll);
904     MEDFileAnyTypeFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll);
905     MEDFileAnyTypeFieldMultiTS(const MEDFileAnyTypeFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent);
906     static MEDFileAnyTypeFieldMultiTS *BuildNewInstanceFromContent(MEDFileAnyTypeFieldMultiTSWithoutSDA *c, const std::string& fileName);
907     static MEDFileAnyTypeFieldMultiTSWithoutSDA *BuildContentFrom(med_idt fid, const std::string& fileName, bool loadAll);
908     static MEDFileAnyTypeFieldMultiTSWithoutSDA *BuildContentFrom(med_idt fid, const std::string& fileName, const std::string& fieldName, bool loadAll);
909   public:
910     MEDLOADER_EXPORT static MEDFileAnyTypeFieldMultiTS *New(const std::string& fileName, bool loadAll=true);
911     MEDLOADER_EXPORT static MEDFileAnyTypeFieldMultiTS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true);
912     MEDLOADER_EXPORT void loadArrays();
913     MEDLOADER_EXPORT void loadArraysIfNecessary();
914     MEDLOADER_EXPORT void unloadArrays();
915     MEDLOADER_EXPORT void unloadArraysWithoutDataLoss();
916     MEDLOADER_EXPORT void write(const std::string& fileName, int mode) const;
917     MEDLOADER_EXPORT void writeLL(med_idt fid) const;
918     MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
919     MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
920     MEDLOADER_EXPORT virtual MEDFileAnyTypeFieldMultiTS *deepCpy() const;
921     MEDLOADER_EXPORT std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > splitComponents() const;
922     MEDLOADER_EXPORT std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileAnyTypeFieldMultiTS > > splitDiscretizations() const;
923     MEDLOADER_EXPORT virtual MEDFileAnyTypeFieldMultiTS *shallowCpy() const = 0;
924     MEDLOADER_EXPORT virtual void checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const = 0;
925     //
926     MEDLOADER_EXPORT virtual MEDFileAnyTypeField1TS *getTimeStepAtPos(int pos) const = 0;
927     MEDLOADER_EXPORT MEDFileAnyTypeField1TS *getTimeStep(int iteration, int order) const;
928     MEDLOADER_EXPORT MEDFileAnyTypeField1TS *getTimeStepGivenTime(double time, double eps=1e-8) const;
929     MEDLOADER_EXPORT static std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > SplitIntoCommonTimeSeries(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS);
930     MEDLOADER_EXPORT static std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > SplitPerCommonSupport(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> >& fsc);
931     MEDLOADER_EXPORT static int CheckSupportAcrossTime(MEDFileAnyTypeFieldMultiTS *f0, MEDFileAnyTypeFieldMultiTS *f1, const MEDFileMesh *mesh, TypeOfField& tof0, TypeOfField& tof1);
932   public:// direct forwarding to MEDFileField1TSWithoutSDA instance _content
933     MEDLOADER_EXPORT std::string getName() const;
934     MEDLOADER_EXPORT void setName(const std::string& name);
935     MEDLOADER_EXPORT std::string getDtUnit() const;
936     MEDLOADER_EXPORT void setDtUnit(const std::string& dtUnit);
937     MEDLOADER_EXPORT std::string getMeshName() const;
938     MEDLOADER_EXPORT void setMeshName(const std::string& newMeshName);
939     MEDLOADER_EXPORT std::string simpleRepr() const;
940     MEDLOADER_EXPORT void simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const;
941     MEDLOADER_EXPORT int getNumberOfTS() const;
942     MEDLOADER_EXPORT void eraseEmptyTS();
943     MEDLOADER_EXPORT void eraseTimeStepIds(const int *startIds, const int *endIds);
944     MEDLOADER_EXPORT void eraseTimeStepIds2(int bg, int end, int step);
945     MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *buildSubPart(const int *startIds, const int *endIds) const;
946     MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *buildSubPartSlice(int bg, int end, int step) const;
947     MEDLOADER_EXPORT std::vector< std::pair<int,int> > getTimeSteps(std::vector<double>& ret1) const;
948     MEDLOADER_EXPORT std::vector< std::pair<int,int> > getIterations() const;
949     MEDLOADER_EXPORT void pushBackTimeSteps(const std::vector<MEDFileAnyTypeField1TS *>& f1ts);
950     MEDLOADER_EXPORT void pushBackTimeStep(MEDFileAnyTypeField1TS *f1ts);
951     MEDLOADER_EXPORT void synchronizeNameScope();
952     MEDLOADER_EXPORT int getPosOfTimeStep(int iteration, int order) const;
953     MEDLOADER_EXPORT int getPosGivenTime(double time, double eps=1e-8) const;
954     MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSIterator *iterator();
955     MEDLOADER_EXPORT bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab);
956     MEDLOADER_EXPORT const std::vector<std::string>& getInfo() const;
957     MEDLOADER_EXPORT void setInfo(const std::vector<std::string>& info);
958     MEDLOADER_EXPORT int getNumberOfComponents() const;
959     MEDLOADER_EXPORT int getNonEmptyLevels(int iteration, int order, const std::string& mname, std::vector<int>& levs) const;
960     MEDLOADER_EXPORT std::vector< std::vector<TypeOfField> > getTypesOfFieldAvailable() const;
961     MEDLOADER_EXPORT std::vector< std::vector< std::pair<int,int> > > getFieldSplitedByType(int iteration, int order, const std::string& mname, 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;
962     MEDLOADER_EXPORT MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> getContent();
963   public:
964     MEDLOADER_EXPORT std::vector<std::string> getPflsReallyUsed() const;
965     MEDLOADER_EXPORT std::vector<std::string> getLocsReallyUsed() const;
966     MEDLOADER_EXPORT std::vector<std::string> getPflsReallyUsedMulti() const;
967     MEDLOADER_EXPORT std::vector<std::string> getLocsReallyUsedMulti() const;
968     MEDLOADER_EXPORT void changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
969     MEDLOADER_EXPORT void changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
970   protected:
971     MEDFileAnyTypeFieldMultiTSWithoutSDA *contentNotNullBase();
972     const MEDFileAnyTypeFieldMultiTSWithoutSDA *contentNotNullBase() const;
973   private:
974     static std::vector< std::vector<MEDFileAnyTypeFieldMultiTS *> > SplitPerCommonSupportNotNodesAlg(const std::vector<MEDFileAnyTypeFieldMultiTS *>& vectFMTS, const MEDFileMesh *mesh, std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFastCellSupportComparator> >& cmps);
975   protected:
976     MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> _content;
977   };
978
979   class MEDFileIntFieldMultiTS;
980
981   /*!
982    * User class.
983    */
984   class MEDFileFieldMultiTS : public MEDFileAnyTypeFieldMultiTS
985   {
986   public:
987     MEDLOADER_EXPORT static MEDFileFieldMultiTS *New();
988     MEDLOADER_EXPORT static MEDFileFieldMultiTS *New(const std::string& fileName, bool loadAll=true);
989     MEDLOADER_EXPORT static MEDFileFieldMultiTS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true);
990     MEDLOADER_EXPORT static MEDFileFieldMultiTS *New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent);
991     MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *shallowCpy() const;
992     MEDLOADER_EXPORT void checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const;
993     MEDLOADER_EXPORT MEDFileIntFieldMultiTS *convertToInt(bool isDeepCpyGlobs=true) const;
994     //
995     MEDLOADER_EXPORT MEDFileAnyTypeField1TS *getTimeStepAtPos(int pos) const;
996     MEDLOADER_EXPORT MEDFileAnyTypeField1TS *getTimeStep(int iteration, int order) const;
997     MEDLOADER_EXPORT MEDFileAnyTypeField1TS *getTimeStepGivenTime(double time, double eps=1e-8) const;
998     //
999     MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol=0) const;
1000     MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol=0) const;
1001     MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const;
1002     MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol=0) const;
1003     MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const std::string& mname, int iteration, int order, int meshDimRelToMax, int renumPol=0) const;
1004     MEDLOADER_EXPORT DataArrayDouble *getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const;
1005     //
1006     MEDLOADER_EXPORT void appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field);
1007     MEDLOADER_EXPORT void appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile);
1008     MEDLOADER_EXPORT std::vector< std::vector<DataArrayDouble *> > getFieldSplitedByType2(int iteration, int order, const std::string& mname, 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;
1009     MEDLOADER_EXPORT DataArrayDouble *getUndergroundDataArray(int iteration, int order) const;
1010     MEDLOADER_EXPORT DataArrayDouble *getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const;
1011   private:
1012     const MEDFileFieldMultiTSWithoutSDA *contentNotNull() const;
1013     MEDFileFieldMultiTSWithoutSDA *contentNotNull();
1014   private:
1015     MEDFileFieldMultiTS();
1016     MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent);
1017     MEDFileFieldMultiTS(const std::string& fileName, bool loadAll);
1018     MEDFileFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll);
1019   };
1020
1021   /*!
1022    * User class.
1023    */
1024   class MEDFileIntFieldMultiTS : public MEDFileAnyTypeFieldMultiTS
1025   {
1026   public:
1027     MEDLOADER_EXPORT static MEDFileIntFieldMultiTS *New();
1028     MEDLOADER_EXPORT static MEDFileIntFieldMultiTS *New(const std::string& fileName, bool loadAll=true);
1029     MEDLOADER_EXPORT static MEDFileIntFieldMultiTS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true);
1030     MEDLOADER_EXPORT static MEDFileIntFieldMultiTS *New(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent);
1031     MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *shallowCpy() const;
1032     MEDLOADER_EXPORT void checkCoherencyOfType(const MEDFileAnyTypeField1TS *f1ts) const;
1033     MEDLOADER_EXPORT MEDFileAnyTypeField1TS *getTimeStepAtPos(int pos) const;
1034     MEDLOADER_EXPORT MEDFileFieldMultiTS *convertToDouble(bool isDeepCpyGlobs=true) const;
1035     //
1036     MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol=0) const;
1037     MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int iteration, int order, DataArrayInt* &arrOut, int renumPol=0) const;
1038     MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt* &arrOut, int renumPol=0) const;
1039     MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, DataArrayInt* &arrOut, int renumPol=0) const;
1040     MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, int iteration, int order, const std::string& mname, int meshDimRelToMax, DataArrayInt* &arrOut, int renumPol=0) const;
1041     MEDLOADER_EXPORT DataArrayInt *getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const;
1042     //
1043     MEDLOADER_EXPORT void appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals);
1044     MEDLOADER_EXPORT void appendFieldProfile(const MEDCouplingFieldDouble *field, const DataArrayInt *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile);
1045     //
1046     MEDLOADER_EXPORT DataArrayInt *getUndergroundDataArray(int iteration, int order) const;
1047   private:
1048     const MEDFileIntFieldMultiTSWithoutSDA *contentNotNull() const;
1049     MEDFileIntFieldMultiTSWithoutSDA *contentNotNull();
1050   private:
1051     MEDFileIntFieldMultiTS();
1052     MEDFileIntFieldMultiTS(const MEDFileIntFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent);
1053     MEDFileIntFieldMultiTS(const std::string& fileName, bool loadAll);
1054     MEDFileIntFieldMultiTS(const std::string& fileName, const std::string& fieldName, bool loadAll);
1055   };
1056
1057   class MEDFileAnyTypeFieldMultiTSIterator
1058   {
1059   public:
1060     MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTSIterator(MEDFileAnyTypeFieldMultiTS *fmts);
1061     MEDLOADER_EXPORT ~MEDFileAnyTypeFieldMultiTSIterator();
1062     MEDLOADER_EXPORT MEDFileAnyTypeField1TS *nextt();
1063   private:
1064     MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTS> _fmts;
1065      int _iter_id;
1066      int _nb_iter;
1067   };
1068
1069   class MEDFileFieldsIterator;
1070
1071   /*!
1072    * Use class.
1073    */
1074   class MEDFileFields : public RefCountObject, public MEDFileFieldGlobsReal, public MEDFileWritable
1075   {
1076   public:
1077     MEDLOADER_EXPORT static MEDFileFields *New();
1078     MEDLOADER_EXPORT static MEDFileFields *New(const std::string& fileName, bool loadAll=true);
1079     MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
1080     MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildren() const;
1081     MEDLOADER_EXPORT MEDFileFields *deepCpy() const;
1082     MEDLOADER_EXPORT MEDFileFields *shallowCpy() const;
1083     MEDLOADER_EXPORT void write(const std::string& fileName, int mode) const;
1084     MEDLOADER_EXPORT void writeLL(med_idt fid) const;
1085     MEDLOADER_EXPORT void loadArrays();
1086     MEDLOADER_EXPORT void loadArraysIfNecessary();
1087     MEDLOADER_EXPORT void unloadArrays();
1088     MEDLOADER_EXPORT void unloadArraysWithoutDataLoss();
1089     MEDLOADER_EXPORT int getNumberOfFields() const;
1090     MEDLOADER_EXPORT std::vector< std::pair<int,int> > getCommonIterations(bool& areThereSomeForgottenTS) const;
1091     MEDLOADER_EXPORT std::vector<std::string> getFieldsNames() const;
1092     MEDLOADER_EXPORT std::vector<std::string> getMeshesNames() const;
1093     MEDLOADER_EXPORT std::string simpleRepr() const;
1094     MEDLOADER_EXPORT void simpleRepr(int bkOffset, std::ostream& oss) const;
1095     //
1096     MEDLOADER_EXPORT void resize(int newSize);
1097     MEDLOADER_EXPORT void pushField(MEDFileAnyTypeFieldMultiTS *field);
1098     MEDLOADER_EXPORT void pushFields(const std::vector<MEDFileAnyTypeFieldMultiTS *>& fields);
1099     MEDLOADER_EXPORT void setFieldAtPos(int i, MEDFileAnyTypeFieldMultiTS *field);
1100     MEDLOADER_EXPORT int getPosFromFieldName(const std::string& fieldName) const;
1101     MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *getFieldAtPos(int i) const;
1102     MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *getFieldWithName(const std::string& fieldName) const;
1103     MEDLOADER_EXPORT MEDFileFields *buildSubPart(const int *startIds, const int *endIds) const;
1104     MEDLOADER_EXPORT bool removeFieldsWithoutAnyTimeStep();
1105     MEDLOADER_EXPORT MEDFileFields *partOfThisLyingOnSpecifiedMeshName(const std::string& meshName) const;
1106     MEDLOADER_EXPORT MEDFileFields *partOfThisLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const;
1107     MEDLOADER_EXPORT MEDFileFields *partOfThisNotLyingOnSpecifiedTimeSteps(const std::vector< std::pair<int,int> >& timeSteps) const;
1108     MEDLOADER_EXPORT MEDFileFieldsIterator *iterator();
1109     MEDLOADER_EXPORT void destroyFieldAtPos(int i);
1110     MEDLOADER_EXPORT void destroyFieldsAtPos(const int *startIds, const int *endIds);
1111     MEDLOADER_EXPORT void destroyFieldsAtPos2(int bg, int end, int step);
1112     MEDLOADER_EXPORT bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab);
1113     MEDLOADER_EXPORT bool renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N);
1114   public:
1115     MEDLOADER_EXPORT std::vector<std::string> getPflsReallyUsed() const;
1116     MEDLOADER_EXPORT std::vector<std::string> getLocsReallyUsed() const;
1117     MEDLOADER_EXPORT std::vector<std::string> getPflsReallyUsedMulti() const;
1118     MEDLOADER_EXPORT std::vector<std::string> getLocsReallyUsedMulti() const;
1119     MEDLOADER_EXPORT void changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
1120     MEDLOADER_EXPORT void changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
1121   private:
1122     MEDFileFields();
1123     MEDFileFields(const std::string& fileName, bool loadAll);
1124   private:
1125     std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileAnyTypeFieldMultiTSWithoutSDA> > _fields;
1126   };
1127
1128   class MEDFileFieldsIterator
1129   {
1130   public:
1131     MEDLOADER_EXPORT MEDFileFieldsIterator(MEDFileFields *fs);
1132     MEDLOADER_EXPORT ~MEDFileFieldsIterator();
1133     MEDLOADER_EXPORT MEDFileAnyTypeFieldMultiTS *nextt();
1134   private:
1135     MEDCouplingAutoRefCountObjectPtr<MEDFileFields> _fs;
1136      int _iter_id;
1137      int _nb_iter;
1138   };
1139 }
1140
1141 #endif