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