Salome HOME
Merge from V6_main 01/04/2013
[modules/med.git] / src / MEDLoader / MEDFileField.hxx
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Anthony Geay (CEA/DEN)
20
21 #ifndef __MEDFILEFIELD_HXX__
22 #define __MEDFILEFIELD_HXX__
23
24 #include "MEDLoaderDefines.hxx"
25
26 #include "MEDFileUtilities.hxx"
27
28 #include "MEDCouplingAutoRefCountObjectPtr.hxx"
29 #include "MEDCouplingRefCountObject.hxx"
30 #include "MEDCouplingMemArray.hxx"
31
32 #include "NormalizedUnstructuredMesh.hxx"
33 #include "InterpKernelException.hxx"
34
35 #include <vector>
36 #include <string>
37 #include <list>
38 #include <set>
39
40 #include "med.h"
41
42 namespace ParaMEDMEM
43 {
44   class MEDFileFieldGlobs;
45   class MEDCouplingMesh;
46   class MEDCouplingFieldDouble;
47   class MEDFileMesh;
48
49   class MEDFileFieldLoc : public RefCountObject
50   {
51   public:
52     void MEDLOADER_EXPORT simpleRepr(std::ostream& oss) const;
53     const MEDLOADER_EXPORT std::string& getName() const { return _name; }
54     void MEDLOADER_EXPORT setName(const char *name);
55     static MEDFileFieldLoc *New(med_idt fid, const char *locName);
56     static MEDFileFieldLoc *New(med_idt fid, int id);
57     static MEDFileFieldLoc *New(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w);
58     std::size_t getHeapMemorySize() const;
59     MEDFileFieldLoc *deepCpy() const;
60     int MEDLOADER_EXPORT getNbOfGaussPtPerCell() const { return _nb_gauss_pt; }
61     void MEDLOADER_EXPORT writeLL(med_idt fid) const;
62     std::string MEDLOADER_EXPORT repr() const;
63     bool MEDLOADER_EXPORT isName(const char *name) const { return _name==name; }
64     int MEDLOADER_EXPORT getDimension() const { return _dim; }
65     int MEDLOADER_EXPORT getNumberOfGaussPoints() const { return _nb_gauss_pt; }
66     int MEDLOADER_EXPORT getNumberOfPointsInCells() const { return _nb_node_per_cell; }
67     const MEDLOADER_EXPORT std::vector<double>& getRefCoords() const { return _ref_coo; }
68     const MEDLOADER_EXPORT std::vector<double>& getGaussCoords() const { return _gs_coo; }
69     const MEDLOADER_EXPORT std::vector<double>& getGaussWeights() const { return _w; }
70     bool MEDLOADER_EXPORT isEqual(const MEDFileFieldLoc& other, double eps) const;
71   private:
72     MEDFileFieldLoc(med_idt fid, const char *locName);
73     MEDFileFieldLoc(med_idt fid, int id);
74     MEDFileFieldLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w);
75   private:
76     int _dim;
77     int _nb_gauss_pt;
78     int _nb_node_per_cell;
79     std::string _name;
80     INTERP_KERNEL::NormalizedCellType _geo_type;
81     std::vector<double> _ref_coo;
82     std::vector<double> _gs_coo;
83     std::vector<double> _w;
84   };
85
86 /// @cond INTERNAL
87   class MEDFileFieldPerMeshPerType;
88   class MEDFileField1TSWithoutSDA;
89   class MEDFileFieldGlobsReal;
90   class MEDFileFieldPerMesh;
91
92   class MEDFileFieldPerMeshPerTypePerDisc : public RefCountObject, public MEDFileWritable
93   {
94   public:
95     static MEDFileFieldPerMeshPerTypePerDisc *NewOnRead(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt) throw(INTERP_KERNEL::Exception);
96     static MEDFileFieldPerMeshPerTypePerDisc *New(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int locId);
97     static MEDFileFieldPerMeshPerTypePerDisc *New(const MEDFileFieldPerMeshPerTypePerDisc& other);
98     std::size_t getHeapMemorySize() const;
99     MEDFileFieldPerMeshPerTypePerDisc *deepCpy(MEDFileFieldPerMeshPerType *father) const throw(INTERP_KERNEL::Exception);
100     void assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
101     void assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
102     void assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
103     void getCoarseData(TypeOfField& type, std::pair<int,int>& dad, std::string& pfl, std::string& loc) const throw(INTERP_KERNEL::Exception);
104     void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
105     const MEDFileFieldPerMeshPerType *getFather() const;
106     void prepareLoading(med_idt fid, int profileIt, int& start) throw(INTERP_KERNEL::Exception);
107     void finishLoading(med_idt fid, int profileIt, int ft) throw(INTERP_KERNEL::Exception);
108     void setNewStart(int newValueOfStart) throw(INTERP_KERNEL::Exception);
109     int getIteration() const;
110     int getOrder() const;
111     double getTime() const;
112     std::string getName() const;
113     std::string getMeshName() const;
114     TypeOfField getType() const;
115     void simpleRepr(int bkOffset, std::ostream& oss, int id) const;
116     void fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception);
117     void setType(TypeOfField newType);
118     INTERP_KERNEL::NormalizedCellType getGeoType() const;
119     int getNumberOfComponents() const;
120     int getNumberOfTuples() const;
121     int getStart() const { return _start; }
122     DataArrayDouble *getArray();
123     const DataArrayDouble *getArray() const;
124     const std::vector<std::string>& getInfo() const;
125     std::string getProfile() const;
126     void setProfile(const char *newPflName);
127     std::string getLocalization() const;
128     void setLocalization(const char *newLocName);
129     int getLocId() const { return _loc_id; }
130     void setLocId(int newId) const { _loc_id=newId; }
131     void setFather(MEDFileFieldPerMeshPerType *newFather) { _father=newFather; }
132     void changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
133     void changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
134     void getFieldAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, std::vector< std::pair<int,int> >& dads, std::vector<const DataArrayInt *>& pfls, std::vector<int>& locs,
135                          std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes) const;
136     void fillValues(int discId, int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const;
137     int fillEltIdsFromCode(int offset, const std::vector<int>& codeOfMesh, const MEDFileFieldGlobsReal& glob, int *ptToFill) const throw(INTERP_KERNEL::Exception);
138     int fillTupleIds(int *ptToFill) const throw(INTERP_KERNEL::Exception);
139     static int ConvertType(TypeOfField type, int locId) throw(INTERP_KERNEL::Exception);
140     static std::vector< std::vector< const MEDFileFieldPerMeshPerTypePerDisc *> > SplitPerDiscretization(const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entries);
141     static bool RenumberChunks(int offset, const std::vector< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
142                                const DataArrayInt *explicitIdsInMesh, const std::vector<int>& newCode,
143                                MEDFileFieldGlobsReal& glob, DataArrayDouble *arr, std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> >& result);
144     static MEDFileFieldPerMeshPerTypePerDisc *NewObjectOnSameDiscThanPool(TypeOfField typeF, INTERP_KERNEL::NormalizedCellType geoType, DataArrayInt *idsOfMeshElt,
145                                                                           bool isPfl, int nbi, int offset, std::list< const MEDFileFieldPerMeshPerTypePerDisc *>& entriesOnSameDisc,
146                                                                           MEDFileFieldGlobsReal& glob, bool &notInExisting) throw(INTERP_KERNEL::Exception);
147   private:
148     MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt) throw(INTERP_KERNEL::Exception);
149     MEDFileFieldPerMeshPerTypePerDisc(MEDFileFieldPerMeshPerType *fath, TypeOfField type, int profileIt, const std::string& dummy);
150     MEDFileFieldPerMeshPerTypePerDisc(const MEDFileFieldPerMeshPerTypePerDisc& other);
151     MEDFileFieldPerMeshPerTypePerDisc();
152   private:
153     TypeOfField _type;
154     MEDFileFieldPerMeshPerType *_father;
155     int _start;
156     int _end;
157     //! _nval is different than end-start in case of ON_GAUSS_PT and ON_GAUSS_NE ! (_nval=(_end-_start)/nbi)
158     int _nval;
159     std::string _profile;
160     std::string _localization;
161     //! only on assignement -3 : ON_NODES, -2 : ON_CELLS, -1 : ON_GAUSS_NE, 0..* : ON_GAUSS_PT
162     mutable int _loc_id;
163   public:
164     mutable int _tmp_work1;
165   };
166
167   class MEDFileFieldPerMeshPerType : public RefCountObject, public MEDFileWritable
168   {
169   public:
170     static MEDFileFieldPerMeshPerType *New(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception);
171     static MEDFileFieldPerMeshPerType *NewOnRead(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception);
172     std::size_t getHeapMemorySize() const;
173     MEDFileFieldPerMeshPerType *deepCpy(MEDFileFieldPerMesh *father) const throw(INTERP_KERNEL::Exception);
174     void assignFieldNoProfile(int& start, int offset, int nbOfCells, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
175     void assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const DataArrayInt *idsInPfl, DataArrayInt *locIds, int nbOfEltsInWholeMesh, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
176     void assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
177     void assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
178     const MEDFileFieldPerMesh *getFather() const;
179     void prepareLoading(med_idt fid, int &start) throw(INTERP_KERNEL::Exception);
180     void finishLoading(med_idt fid, int ft) throw(INTERP_KERNEL::Exception);
181     void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
182     void getDimension(int& dim) const;
183     void fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception);
184     void fillFieldSplitedByType(std::vector< std::pair<int,int> >& dads, std::vector<TypeOfField>& types, std::vector<std::string>& pfls, std::vector<std::string>& locs) const throw(INTERP_KERNEL::Exception);
185     int getIteration() const;
186     int getOrder() const;
187     double getTime() const;
188     std::string getName() const;
189     std::string getMeshName() const;
190     void simpleRepr(int bkOffset, std::ostream& oss, int id) const;
191     void getSizes(int& globalSz, int& nbOfEntries) const;
192     INTERP_KERNEL::NormalizedCellType getGeoType() const;
193     int getNumberOfComponents() const;
194     DataArrayDouble *getArray();
195     const DataArrayDouble *getArray() const;
196     const std::vector<std::string>& getInfo() const;
197     std::vector<std::string> getPflsReallyUsed() const;
198     std::vector<std::string> getLocsReallyUsed() const;
199     std::vector<std::string> getPflsReallyUsedMulti() const;
200     std::vector<std::string> getLocsReallyUsedMulti() const;
201     void changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
202     void changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
203     MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenLocId(int locId) throw(INTERP_KERNEL::Exception);
204     const MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenLocId(int locId) const throw(INTERP_KERNEL::Exception);
205     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;
206     void fillValues(int& startEntryId, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const;
207     void setLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) throw(INTERP_KERNEL::Exception);
208     static med_entity_type ConvertIntoMEDFileType(TypeOfField ikType, INTERP_KERNEL::NormalizedCellType ikGeoType, med_geometry_type& medfGeoType);
209   private:
210     std::vector<int> addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception);
211     std::vector<int> addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, int offset, int nbOfCells) throw(INTERP_KERNEL::Exception);
212     std::vector<int> addNewEntryIfNecessary(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception);
213     std::vector<int> addNewEntryIfNecessaryGauss(const MEDCouplingFieldDouble *field, const DataArrayInt *subCells) throw(INTERP_KERNEL::Exception);
214     MEDFileFieldPerMeshPerType(med_idt fid, MEDFileFieldPerMesh *fath, TypeOfField type, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception);
215     MEDFileFieldPerMeshPerType(MEDFileFieldPerMesh *fath, INTERP_KERNEL::NormalizedCellType geoType) throw(INTERP_KERNEL::Exception);
216   private:
217     MEDFileFieldPerMesh *_father;
218     std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldPerMeshPerTypePerDisc> > _field_pm_pt_pd;
219     INTERP_KERNEL::NormalizedCellType _geo_type;
220   };
221
222   class MEDFileFieldPerMesh : public RefCountObject, public MEDFileWritable
223   {
224   public:
225     static MEDFileFieldPerMesh *New(MEDFileField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh);
226     static MEDFileFieldPerMesh *NewOnRead(med_idt fid, MEDFileField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder) throw(INTERP_KERNEL::Exception);
227     std::size_t getHeapMemorySize() const;
228     MEDFileFieldPerMesh *deepCpy(MEDFileField1TSWithoutSDA *_father) const throw(INTERP_KERNEL::Exception);
229     void simpleRepr(int bkOffset,std::ostream& oss, int id) const;
230     void copyTinyInfoFrom(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception);
231     void assignFieldProfile(int& start, const DataArrayInt *multiTypePfl, const std::vector<int>& code, const std::vector<int>& code2, const std::vector<DataArrayInt *>& idsInPflPerType, const std::vector<DataArrayInt *>& idsPerType, const MEDCouplingFieldDouble *field, const MEDCouplingMesh *mesh, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
232     void assignFieldNoProfileNoRenum(int& start, const std::vector<int>& code, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
233     void assignNodeFieldNoProfile(int& start, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
234     void assignNodeFieldProfile(int& start, const DataArrayInt *pfl, const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
235     void prepareLoading(med_idt fid, int &start) throw(INTERP_KERNEL::Exception);
236     void finishLoading(med_idt fid, int ft) throw(INTERP_KERNEL::Exception);
237     void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
238     void fillTypesOfFieldAvailable(std::set<TypeOfField>& types) const throw(INTERP_KERNEL::Exception);
239     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 throw(INTERP_KERNEL::Exception);
240     void getDimension(int& dim) const;
241     double getTime() const;
242     int getIteration() const;
243     int getOrder() const;
244     int getMeshIteration() const { return _mesh_iteration; }
245     int getMeshOrder() const { return _mesh_order; }
246     const std::string& getDtUnit() const;
247     std::string getName() const;
248     std::string getMeshName() const { return _mesh_name; }
249     int getNumberOfComponents() const;
250     DataArrayDouble *getArray();
251     const DataArrayDouble *getArray() const;
252     const std::vector<std::string>& getInfo() const;
253     std::vector<std::string> getPflsReallyUsed() const;
254     std::vector<std::string> getLocsReallyUsed() const;
255     std::vector<std::string> getPflsReallyUsedMulti() const;
256     std::vector<std::string> getLocsReallyUsedMulti() const;
257     bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception);
258     bool renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
259     void changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
260     void changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
261     MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, bool& isPfl) const throw(INTERP_KERNEL::Exception);
262     DataArrayDouble *getFieldOnMeshAtLevelWithPfl(TypeOfField type, const MEDCouplingMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception);
263     DataArrayDouble *getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception);
264     MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception);
265     const MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenTypeAndLocId(INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception);
266   private:
267     int addNewEntryIfNecessary(INTERP_KERNEL::NormalizedCellType type);
268     MEDCouplingFieldDouble *finishField(TypeOfField type, const MEDFileFieldGlobsReal *glob,
269                                         const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs, const MEDCouplingMesh *mesh, bool& isPfl) const throw(INTERP_KERNEL::Exception);
270     MEDCouplingFieldDouble *finishField2(TypeOfField type, const MEDFileFieldGlobsReal *glob,
271                                          const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
272                                          const std::vector<INTERP_KERNEL::NormalizedCellType>& geoTypes,
273                                          const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl) const throw(INTERP_KERNEL::Exception);
274     MEDCouplingFieldDouble *finishFieldNode2(const MEDFileFieldGlobsReal *glob,
275                                              const std::vector< std::pair<int,int> >& dads, const std::vector<int>& locs,
276                                              const MEDCouplingMesh *mesh, const DataArrayInt *da, bool& isPfl) const throw(INTERP_KERNEL::Exception);
277     DataArrayDouble *finishField4(const std::vector< std::pair<int,int> >& dads, const DataArrayInt *pflIn, int nbOfElems, DataArrayInt *&pflOut) const throw(INTERP_KERNEL::Exception);
278     void assignNewLeaves(const std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerTypePerDisc > >& leaves) throw(INTERP_KERNEL::Exception);
279     static void SortArraysPerType(const MEDFileFieldGlobsReal *glob, TypeOfField type, 
280                                   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,
281                                   std::vector<int>& code, std::vector<DataArrayInt *>& notNullPfls);
282     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) throw(INTERP_KERNEL::Exception);
283     MEDFileFieldPerMesh(med_idt fid, MEDFileField1TSWithoutSDA *fath, int meshCsit, int meshIteration, int meshOrder) throw(INTERP_KERNEL::Exception);
284     MEDFileFieldPerMesh(MEDFileField1TSWithoutSDA *fath, const MEDCouplingMesh *mesh);
285   private:
286     std::string _mesh_name;
287     int _mesh_iteration;
288     int _mesh_order;
289     int _mesh_csit;
290     MEDFileField1TSWithoutSDA *_father;
291     std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMeshPerType > > _field_pm_pt;
292   };
293
294   class MEDFileFieldGlobsReal;
295
296   class MEDFileFieldGlobs : public RefCountObject
297   {
298   public:
299     static MEDFileFieldGlobs *New(const char *fname);
300     static MEDFileFieldGlobs *New();
301     std::size_t getHeapMemorySize() const;
302     MEDFileFieldGlobs *deepCpy() const throw(INTERP_KERNEL::Exception);
303     void simpleRepr(std::ostream& oss) const;
304     void appendGlobs(const MEDFileFieldGlobs& other, double eps) throw(INTERP_KERNEL::Exception);
305     void loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception);
306     void loadProfileInFile(med_idt fid, int id);
307     void loadGlobals(med_idt fid, const MEDFileFieldGlobsReal& real) throw(INTERP_KERNEL::Exception);
308     void loadAllGlobals(med_idt fid) throw(INTERP_KERNEL::Exception);
309     void writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception);
310     std::vector<std::string> getPfls() const;
311     std::vector<std::string> getLocs() const;
312     bool existsPfl(const char *pflName) const;
313     bool existsLoc(const char *locName) const;
314     std::string createNewNameOfPfl() const throw(INTERP_KERNEL::Exception);
315     std::string createNewNameOfLoc() const throw(INTERP_KERNEL::Exception);
316     std::vector< std::vector<int> > whichAreEqualProfiles() const;
317     std::vector< std::vector<int> > whichAreEqualLocs(double eps) const;
318     void setFileName(const char *fileName);
319     void changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
320     void changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
321     int getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception);
322     int getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception);
323     const char *getFileName() const { return _file_name.c_str(); }
324     std::string getFileName2() const { return _file_name; }
325     const MEDFileFieldLoc& getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception);
326     const MEDFileFieldLoc& getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception);
327     const DataArrayInt *getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception);
328     const DataArrayInt *getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception);
329     MEDFileFieldLoc& getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception);
330     MEDFileFieldLoc& getLocalization(const char *locName) throw(INTERP_KERNEL::Exception);
331     DataArrayInt *getProfile(const char *pflName) throw(INTERP_KERNEL::Exception);
332     DataArrayInt *getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception);
333     void killProfileIds(const std::vector<int>& pflIds) throw(INTERP_KERNEL::Exception);
334     void killLocalizationIds(const std::vector<int>& locIds) throw(INTERP_KERNEL::Exception);
335     //
336     void appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception);
337     void appendLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w) throw(INTERP_KERNEL::Exception);
338     //
339     static std::string CreateNewNameNotIn(const char *prefix, const std::vector<std::string>& namesToAvoid) throw(INTERP_KERNEL::Exception);
340   protected:
341     MEDFileFieldGlobs(const char *fname);
342     MEDFileFieldGlobs();
343     ~MEDFileFieldGlobs();
344   protected:
345     std::vector< MEDCouplingAutoRefCountObjectPtr<DataArrayInt> > _pfls;
346     std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldLoc> > _locs;
347     std::string _file_name;
348   };
349
350 /// @endcond INTERNAL
351
352   class MEDLOADER_EXPORT MEDFileFieldGlobsReal
353   {
354   public:
355     MEDFileFieldGlobsReal(const char *fname);
356     MEDFileFieldGlobsReal();
357     std::size_t getHeapMemorySize() const;
358     void simpleRepr(std::ostream& oss) const;
359     void shallowCpyGlobs(const MEDFileFieldGlobsReal& other);
360     void deepCpyGlobs(const MEDFileFieldGlobsReal& other);
361     void appendGlobs(const MEDFileFieldGlobsReal& other, double eps) throw(INTERP_KERNEL::Exception);
362     virtual std::vector<std::string> getPflsReallyUsed() const = 0;
363     virtual std::vector<std::string> getLocsReallyUsed() const = 0;
364     virtual std::vector<std::string> getPflsReallyUsedMulti() const = 0;
365     virtual std::vector<std::string> getLocsReallyUsedMulti() const = 0;
366     virtual void changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception) = 0;
367     virtual void changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception) = 0;
368     virtual ~MEDFileFieldGlobsReal();
369     //
370     void loadProfileInFile(med_idt fid, int id, const char *pflName) throw(INTERP_KERNEL::Exception);
371     void loadProfileInFile(med_idt fid, int id);
372     void loadGlobals(med_idt fid) throw(INTERP_KERNEL::Exception);
373     void loadAllGlobals(med_idt fid) throw(INTERP_KERNEL::Exception);
374     void writeGlobals(med_idt fid, const MEDFileWritable& opt) const throw(INTERP_KERNEL::Exception);
375     std::vector<std::string> getPfls() const;
376     std::vector<std::string> getLocs() const;
377     bool existsPfl(const char *pflName) const;
378     bool existsLoc(const char *locName) const;
379     std::string createNewNameOfPfl() const throw(INTERP_KERNEL::Exception);
380     std::string createNewNameOfLoc() const throw(INTERP_KERNEL::Exception);
381     std::vector< std::vector<int> > whichAreEqualProfiles() const;
382     std::vector< std::vector<int> > whichAreEqualLocs(double eps) const;
383     void setFileName(const char *fileName);
384     void changePflsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
385     void changeLocsNamesInStruct(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
386     void changePflsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
387     void changeLocsNames(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
388     void changePflName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception);
389     void changeLocName(const char *oldName, const char *newName) throw(INTERP_KERNEL::Exception);
390     std::vector< std::pair<std::vector<std::string>, std::string > > zipPflsNames() throw(INTERP_KERNEL::Exception);
391     std::vector< std::pair<std::vector<std::string>, std::string > > zipLocsNames(double eps) throw(INTERP_KERNEL::Exception);
392     int getNbOfGaussPtPerCell(int locId) const throw(INTERP_KERNEL::Exception);
393     int getLocalizationId(const char *loc) const throw(INTERP_KERNEL::Exception);
394     const char *getFileName() const;
395     std::string getFileName2() const;
396     const MEDFileFieldLoc& getLocalizationFromId(int locId) const throw(INTERP_KERNEL::Exception);
397     const MEDFileFieldLoc& getLocalization(const char *locName) const throw(INTERP_KERNEL::Exception);
398     MEDFileFieldLoc& getLocalizationFromId(int locId) throw(INTERP_KERNEL::Exception);
399     MEDFileFieldLoc& getLocalization(const char *locName) throw(INTERP_KERNEL::Exception);
400     const DataArrayInt *getProfile(const char *pflName) const throw(INTERP_KERNEL::Exception);
401     const DataArrayInt *getProfileFromId(int pflId) const throw(INTERP_KERNEL::Exception);
402     DataArrayInt *getProfile(const char *pflName) throw(INTERP_KERNEL::Exception);
403     DataArrayInt *getProfileFromId(int pflId) throw(INTERP_KERNEL::Exception);
404     void killProfileIds(const std::vector<int>& pflIds) throw(INTERP_KERNEL::Exception);
405     void killLocalizationIds(const std::vector<int>& locIds) throw(INTERP_KERNEL::Exception);
406     //
407     void appendProfile(DataArrayInt *pfl) throw(INTERP_KERNEL::Exception);
408     void appendLoc(const char *locName, INTERP_KERNEL::NormalizedCellType geoType, const std::vector<double>& refCoo, const std::vector<double>& gsCoo, const std::vector<double>& w) throw(INTERP_KERNEL::Exception);
409   protected:
410     MEDCouplingAutoRefCountObjectPtr< MEDFileFieldGlobs > _globals;
411   };
412
413   /*!
414    * SDA is for Shared Data Arrays such as profiles.
415    */
416   class MEDLOADER_EXPORT MEDFileField1TSWithoutSDA : public RefCountObject
417   {
418   public:
419     int copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception);
420     int getDimension() const;
421     int getIteration() const { return _iteration; }
422     int getOrder() const { return _order; }
423     double getTime(int& iteration, int& order) const { iteration=_iteration; order=_order; return _dt; }
424     void setTime(int iteration, int order, double val) { _dt=val; _iteration=iteration; _order=order; }
425     std::string getName() const;
426     void setName(const char *name);
427     void simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const;
428     const std::string& getDtUnit() const { return _dt_unit; }
429     std::string getMeshName() const throw(INTERP_KERNEL::Exception);
430     void setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception);
431     bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception);
432     int getMeshIteration() const throw(INTERP_KERNEL::Exception);
433     int getMeshOrder() const throw(INTERP_KERNEL::Exception);
434     int getNumberOfComponents() const;
435     bool isDealingTS(int iteration, int order) const;
436     std::pair<int,int> getDtIt() const;
437     void fillIteration(std::pair<int,int>& p) const;
438     void fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception);
439     const std::vector<std::string>& getInfo() const;
440     std::vector<std::string>& getInfo();
441     //
442     std::vector<std::string> getPflsReallyUsed2() const;
443     std::vector<std::string> getLocsReallyUsed2() const;
444     std::vector<std::string> getPflsReallyUsedMulti2() const;
445     std::vector<std::string> getLocsReallyUsedMulti2() const;
446     void changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
447     void changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
448     DataArrayDouble *getUndergroundDataArray() const throw(INTERP_KERNEL::Exception);
449     DataArrayDouble *getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception);
450     int getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception);
451     std::vector<TypeOfField> getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception);
452     std::vector< std::vector<std::pair<int,int> > > getFieldSplitedByType(const char *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 throw(INTERP_KERNEL::Exception);
453      std::vector< std::vector<DataArrayDouble *> > getFieldSplitedByType2(const char *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 throw(INTERP_KERNEL::Exception);
454      MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception);
455      const MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception);
456     static void CheckMeshDimRel(int meshDimRelToMax) throw(INTERP_KERNEL::Exception);
457     static std::vector<int> CheckSBTMesh(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception);
458     static MEDFileField1TSWithoutSDA *New(const char *fieldName, int csit, int fieldtype, int iteration, int order, const std::vector<std::string>& infos);
459   public:
460     void finishLoading(med_idt fid) throw(INTERP_KERNEL::Exception);
461     virtual void writeLL(med_idt fid, const MEDFileWritable& opts) const throw(INTERP_KERNEL::Exception);
462     void setFieldNoProfileSBT(const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
463     void setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
464     bool renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
465     MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception);
466     MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh) const throw(INTERP_KERNEL::Exception);
467     MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, const char *mName, int renumPol, const MEDFileFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception);
468     MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, const DataArrayInt *cellRenum, const DataArrayInt *nodeRenum) const throw(INTERP_KERNEL::Exception);
469     DataArrayDouble *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob) const throw(INTERP_KERNEL::Exception);
470   protected:
471     int addNewEntryIfNecessary(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception);
472     int getMeshIdFromMeshName(const char *mName) const throw(INTERP_KERNEL::Exception);
473   public:
474     MEDFileField1TSWithoutSDA();
475     MEDFileField1TSWithoutSDA(const char *fieldName, int csit, int fieldtype, int iteration, int order, const std::vector<std::string>& infos);
476     MEDFileField1TSWithoutSDA *deepCpy() const throw(INTERP_KERNEL::Exception);
477     std::size_t getHeapMemorySize() const;
478     DataArrayDouble *getOrCreateAndGetArray();
479     const DataArrayDouble *getOrCreateAndGetArray() const;
480   protected:
481     std::string _dt_unit;
482     MEDCouplingAutoRefCountObjectPtr< DataArrayDouble > _arr;
483     std::vector< MEDCouplingAutoRefCountObjectPtr< MEDFileFieldPerMesh > > _field_per_mesh;
484     int _iteration;
485     int _order;
486     double _dt;
487   public:
488     //! only useable on reading
489     mutable int _csit;
490     //! only useable on reading. 0 is for float, 1 for int32, 2 for int64
491     mutable int _field_type;
492   };
493
494   /*!
495    * User class.
496    */
497   class MEDLOADER_EXPORT MEDFileField1TS : public RefCountObject, public MEDFileWritable, public MEDFileFieldGlobsReal
498   {
499   public:
500     static MEDFileField1TS *New(const char *fileName) throw(INTERP_KERNEL::Exception);
501     static MEDFileField1TS *New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
502     static MEDFileField1TS *New(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
503     static MEDFileField1TS *New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent);
504     static MEDFileField1TS *New();
505     std::string simpleRepr() const;
506     void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
507     MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
508     MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int renumPol=0) const throw(INTERP_KERNEL::Exception);
509     MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
510     MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
511     MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
512     DataArrayDouble *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception);
513     //
514     void setFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception);
515     void setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
516     // direct forwarding to MEDFileField1TSWithoutSDA instance _content
517   public:
518     std::size_t getHeapMemorySize() const;
519     MEDFileField1TS *deepCpy() const throw(INTERP_KERNEL::Exception);
520     int copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception);
521     int getDimension() const;
522     int getIteration() const;
523     int getOrder() const;
524     double getTime(int& iteration, int& order) const;
525     void setTime(int iteration, int order, double val);
526     std::string getName() const;
527     void setName(const char *name);
528     void simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const;
529     const std::string& getDtUnit() const;
530     std::string getMeshName() const throw(INTERP_KERNEL::Exception);
531     void setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception);
532     bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception);
533     int getMeshIteration() const throw(INTERP_KERNEL::Exception);
534     int getMeshOrder() const throw(INTERP_KERNEL::Exception);
535     int getNumberOfComponents() const;
536     bool isDealingTS(int iteration, int order) const;
537     std::pair<int,int> getDtIt() const;
538     void fillIteration(std::pair<int,int>& p) const;
539     void fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception);
540     const std::vector<std::string>& getInfo() const;
541     std::vector<std::string>& getInfo();
542     DataArrayDouble *getUndergroundDataArray() const throw(INTERP_KERNEL::Exception);
543     DataArrayDouble *getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception);
544     MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception);
545     const MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception);
546     int getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception);
547     std::vector<TypeOfField> getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception);
548     std::vector< std::vector<std::pair<int,int> > > getFieldSplitedByType(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
549                                                                           std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception);
550     std::vector< std::vector<DataArrayDouble *> > getFieldSplitedByType2(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
551                                                                          std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception);
552   public:
553     //! underground method see MEDFileField1TSWithoutSDA::setProfileNameOnLeaf
554     void setProfileNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newPflName, bool forceRenameOnGlob=false) throw(INTERP_KERNEL::Exception);
555     //! underground method see MEDFileField1TSWithoutSDA::setLocNameOnLeaf
556     void setLocNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newLocName, bool forceRenameOnGlob=false) throw(INTERP_KERNEL::Exception);
557     std::vector<std::string> getPflsReallyUsed() const;
558     std::vector<std::string> getLocsReallyUsed() const;
559     std::vector<std::string> getPflsReallyUsedMulti() const;
560     std::vector<std::string> getLocsReallyUsedMulti() const;
561     void changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
562     void changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
563   private:
564     void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
565     MEDFileField1TS(const char *fileName) throw(INTERP_KERNEL::Exception);
566     MEDFileField1TS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
567     MEDFileField1TS(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
568     MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent);
569     MEDFileField1TS();
570     int locateField(med_idt fid, const char *fileName, const char *fieldName, med_field_type& typcha) throw(INTERP_KERNEL::Exception);
571   protected:
572     MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> _content;
573   };
574   
575   class MEDLOADER_EXPORT MEDFileFieldMultiTSWithoutSDA : public RefCountObject
576   {
577   public:
578     static MEDFileFieldMultiTSWithoutSDA *New(med_idt fid, const char *fieldName, int id, int ft, const std::vector<std::string>& infos, int nbOfStep) throw(INTERP_KERNEL::Exception);
579     MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId) throw(INTERP_KERNEL::Exception);
580     std::size_t getHeapMemorySize() const;
581     MEDFileFieldMultiTSWithoutSDA *deepCpy() const throw(INTERP_KERNEL::Exception);
582     int getNumberOfTS() const;
583     void eraseEmptyTS() throw(INTERP_KERNEL::Exception);
584     void eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception);
585     std::vector< std::pair<int,int> > getIterations() const;
586     int getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception);
587     int getPosGivenTime(double time, double eps=1e-8) const throw(INTERP_KERNEL::Exception);
588     int getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception);
589     std::vector< std::vector<TypeOfField> > getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception);
590     std::vector< std::vector< std::pair<int,int> > > getFieldSplitedByType(int iteration, int order, const char *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 throw(INTERP_KERNEL::Exception);
591     std::vector< std::vector<DataArrayDouble *> > getFieldSplitedByType2(int iteration, int order, const char *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 throw(INTERP_KERNEL::Exception);
592     virtual void writeLL(med_idt fid, const MEDFileWritable& opts) const throw(INTERP_KERNEL::Exception);
593     std::string getName() const;
594     void setName(const char *name);
595     void simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const;
596     std::vector< std::pair<int,int> > getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception);
597     std::string getMeshName() const throw(INTERP_KERNEL::Exception);
598     void setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception);
599     bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception);
600     const std::vector<std::string>& getInfo() const throw(INTERP_KERNEL::Exception);
601     DataArrayDouble *getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception);
602     DataArrayDouble *getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception);
603     bool renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
604     void appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
605     void appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
606   public:
607     const MEDFileField1TSWithoutSDA *getTimeStepAtPos2(int pos) const throw(INTERP_KERNEL::Exception);
608     MEDFileField1TSWithoutSDA *getTimeStepAtPos2(int pos) throw(INTERP_KERNEL::Exception);
609     const MEDFileField1TSWithoutSDA& getTimeStepEntry(int iteration, int order) const throw(INTERP_KERNEL::Exception);
610     std::vector<std::string> getPflsReallyUsed2() const;
611     std::vector<std::string> getLocsReallyUsed2() const;
612     std::vector<std::string> getPflsReallyUsedMulti2() const;
613     std::vector<std::string> getLocsReallyUsedMulti2() const;
614     void changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
615     void changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
616   protected:
617     MEDFileField1TSWithoutSDA& getTimeStepEntry(int iteration, int order) throw(INTERP_KERNEL::Exception);
618     std::string getDtUnit() const throw(INTERP_KERNEL::Exception);
619     MEDFileFieldMultiTSWithoutSDA(const char *fieldName);
620     MEDFileFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, int id, int ft, const std::vector<std::string>& infos, int nbOfStep) throw(INTERP_KERNEL::Exception);
621     void finishLoading(med_idt fid, int nbPdt) throw(INTERP_KERNEL::Exception);
622     void copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception);
623     void checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field) const throw(INTERP_KERNEL::Exception);
624   public:
625     MEDFileFieldMultiTSWithoutSDA();
626   protected:
627     std::string _name;
628     std::vector<std::string> _infos;
629     //! only useable on reading. 0 is for float, 1 for int32, 2 for int64
630     mutable int _field_type;
631     std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> > _time_steps;
632   };
633
634   class MEDFileFieldMultiTSIterator;
635
636   /*!
637    * User class.
638    */
639   class MEDLOADER_EXPORT MEDFileFieldMultiTS : public RefCountObject, public MEDFileWritable, public MEDFileFieldGlobsReal
640   {
641   public:
642     static MEDFileFieldMultiTS *New();
643     static MEDFileFieldMultiTS *New(const char *fileName) throw(INTERP_KERNEL::Exception);
644     static MEDFileFieldMultiTS *New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
645     static MEDFileFieldMultiTS *New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent);
646     std::size_t getHeapMemorySize() const;
647     MEDFileFieldMultiTS *deepCpy() const throw(INTERP_KERNEL::Exception);
648     //
649     MEDFileField1TS *getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception);
650     MEDFileField1TS *getTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception);
651     MEDFileField1TS *getTimeStepGivenTime(double time, double eps=1e-8) const throw(INTERP_KERNEL::Exception);
652     MEDFileFieldMultiTSIterator *iterator() throw(INTERP_KERNEL::Exception);
653     //
654     std::string simpleRepr() const;
655     void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
656     void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
657     MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
658     MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol=0) const throw(INTERP_KERNEL::Exception);
659     MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
660     MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
661     MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const char *mname, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
662     DataArrayDouble *getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception);
663     //
664     void appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception);
665     void appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
666   public:// direct forwarding to MEDFileField1TSWithoutSDA instance _content
667     int getNumberOfTS() const;
668     void eraseEmptyTS() throw(INTERP_KERNEL::Exception);
669     void eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception);
670     std::vector< std::pair<int,int> > getIterations() const;
671     int getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception);
672     int getPosGivenTime(double time, double eps=1e-8) const throw(INTERP_KERNEL::Exception);
673     int getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception);
674     std::vector< std::vector<TypeOfField> > getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception);
675     std::vector< std::vector< std::pair<int,int> > > getFieldSplitedByType(int iteration, int order, const char *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 throw(INTERP_KERNEL::Exception);
676 std::vector< std::vector<DataArrayDouble *> > getFieldSplitedByType2(int iteration, int order, const char *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 throw(INTERP_KERNEL::Exception);
677     std::string getName() const;
678     void setName(const char *name);
679     void simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const;
680     std::vector< std::pair<int,int> > getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception);
681     std::string getMeshName() const throw(INTERP_KERNEL::Exception);
682     void setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception);
683     bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception);
684     const std::vector<std::string>& getInfo() const throw(INTERP_KERNEL::Exception);
685     DataArrayDouble *getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception);
686     DataArrayDouble *getUndergroundDataArrayExt(int iteration, int order, std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception);
687   public:
688     std::vector<std::string> getPflsReallyUsed() const;
689     std::vector<std::string> getLocsReallyUsed() const;
690     std::vector<std::string> getPflsReallyUsedMulti() const;
691     std::vector<std::string> getLocsReallyUsedMulti() const;
692     void changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
693     void changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
694   public:
695     MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> getContent();
696   private:
697     MEDFileFieldMultiTS();
698     MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent);
699     MEDFileFieldMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception);
700     MEDFileFieldMultiTS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
701   protected:
702     MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> _content;
703   };
704
705   class MEDCOUPLING_EXPORT MEDFileFieldMultiTSIterator
706   {
707   public:
708     MEDFileFieldMultiTSIterator(MEDFileFieldMultiTS *fmts);
709     ~MEDFileFieldMultiTSIterator();
710     MEDFileField1TS *nextt();
711   private:
712     MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> _fmts;
713      int _iter_id;
714      int _nb_iter;
715   };
716
717   class MEDFileFieldsIterator;
718
719   /*!
720    * Use class.
721    */
722   class MEDLOADER_EXPORT MEDFileFields : public RefCountObject, public MEDFileFieldGlobsReal, public MEDFileWritable
723   {
724   public:
725     static MEDFileFields *New();
726     static MEDFileFields *New(const char *fileName) throw(INTERP_KERNEL::Exception);
727     std::size_t getHeapMemorySize() const;
728     MEDFileFields *deepCpy() const throw(INTERP_KERNEL::Exception);
729     void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
730     void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
731     int getNumberOfFields() const;
732     std::vector<std::string> getFieldsNames() const throw(INTERP_KERNEL::Exception);
733     std::vector<std::string> getMeshesNames() const throw(INTERP_KERNEL::Exception);
734     std::string simpleRepr() const;
735     void simpleRepr(int bkOffset, std::ostream& oss) const;
736     //
737     void resize(int newSize) throw(INTERP_KERNEL::Exception);
738     void pushField(MEDFileFieldMultiTS *field) throw(INTERP_KERNEL::Exception);
739     void setFieldAtPos(int i, MEDFileFieldMultiTS *field) throw(INTERP_KERNEL::Exception);
740     MEDFileFieldMultiTS *getFieldAtPos(int i) const throw(INTERP_KERNEL::Exception);
741     MEDFileFieldMultiTS *getFieldWithName(const char *fieldName) const throw(INTERP_KERNEL::Exception);
742     MEDFileFieldsIterator *iterator() throw(INTERP_KERNEL::Exception);
743     void destroyFieldAtPos(int i) throw(INTERP_KERNEL::Exception);
744     bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception);
745     bool renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N) throw(INTERP_KERNEL::Exception);
746   public:
747     int getPosFromFieldName(const char *fieldName) const throw(INTERP_KERNEL::Exception);
748     std::vector<std::string> getPflsReallyUsed() const;
749     std::vector<std::string> getLocsReallyUsed() const;
750     std::vector<std::string> getPflsReallyUsedMulti() const;
751     std::vector<std::string> getLocsReallyUsedMulti() const;
752     void changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
753     void changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
754   private:
755     MEDFileFields();
756     MEDFileFields(const char *fileName) throw(INTERP_KERNEL::Exception);
757   private:
758     std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> > _fields;
759   };
760
761   class MEDCOUPLING_EXPORT MEDFileFieldsIterator
762   {
763   public:
764     MEDFileFieldsIterator(MEDFileFields *fs);
765     ~MEDFileFieldsIterator();
766     MEDFileFieldMultiTS *nextt();
767   private:
768     MEDCouplingAutoRefCountObjectPtr<MEDFileFields> _fs;
769      int _iter_id;
770      int _nb_iter;
771   };
772 }
773
774 #endif