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