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