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