Salome HOME
Merge from V6_main 15/03/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 #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, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
501     static MEDFileField1TS *New(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent);
502     static MEDFileField1TS *New();
503     std::string simpleRepr() const;
504     void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
505     MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
506     MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int renumPol=0) const throw(INTERP_KERNEL::Exception);
507     MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
508     MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
509     MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const char *mname, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
510     DataArrayDouble *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception);
511     //
512     void setFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception);
513     void setFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
514     // direct forwarding to MEDFileField1TSWithoutSDA instance _content
515   public:
516     std::size_t getHeapMemorySize() const;
517     MEDFileField1TS *deepCpy() const throw(INTERP_KERNEL::Exception);
518     int copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception);
519     int getDimension() const;
520     int getIteration() const;
521     int getOrder() const;
522     double getTime(int& iteration, int& order) const;
523     void setTime(int iteration, int order, double val);
524     std::string getName() const;
525     void setName(const char *name);
526     void simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const;
527     const std::string& getDtUnit() const;
528     std::string getMeshName() const throw(INTERP_KERNEL::Exception);
529     void setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception);
530     bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception);
531     int getMeshIteration() const throw(INTERP_KERNEL::Exception);
532     int getMeshOrder() const throw(INTERP_KERNEL::Exception);
533     int getNumberOfComponents() const;
534     bool isDealingTS(int iteration, int order) const;
535     std::pair<int,int> getDtIt() const;
536     void fillIteration(std::pair<int,int>& p) const;
537     void fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const throw(INTERP_KERNEL::Exception);
538     const std::vector<std::string>& getInfo() const;
539     std::vector<std::string>& getInfo();
540     DataArrayDouble *getUndergroundDataArray() const throw(INTERP_KERNEL::Exception);
541     DataArrayDouble *getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const throw(INTERP_KERNEL::Exception);
542     MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) throw(INTERP_KERNEL::Exception);
543     const MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const throw(INTERP_KERNEL::Exception);
544     int getNonEmptyLevels(const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception);
545     std::vector<TypeOfField> getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception);
546     std::vector< std::vector<std::pair<int,int> > > getFieldSplitedByType(const char *mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
547                                                                           std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const throw(INTERP_KERNEL::Exception);
548     std::vector< std::vector<DataArrayDouble *> > getFieldSplitedByType2(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   public:
551     //! underground method see MEDFileField1TSWithoutSDA::setProfileNameOnLeaf
552     void setProfileNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newPflName, bool forceRenameOnGlob=false) throw(INTERP_KERNEL::Exception);
553     //! underground method see MEDFileField1TSWithoutSDA::setLocNameOnLeaf
554     void setLocNameOnLeaf(const char *mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const char *newLocName, bool forceRenameOnGlob=false) throw(INTERP_KERNEL::Exception);
555     std::vector<std::string> getPflsReallyUsed() const;
556     std::vector<std::string> getLocsReallyUsed() const;
557     std::vector<std::string> getPflsReallyUsedMulti() const;
558     std::vector<std::string> getLocsReallyUsedMulti() const;
559     void changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
560     void changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
561   private:
562     void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
563     MEDFileField1TS(const char *fileName, const char *fieldName, int iteration, int order) throw(INTERP_KERNEL::Exception);
564     MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent);
565     MEDFileField1TS();
566   protected:
567     MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> _content;
568   };
569   
570   class MEDLOADER_EXPORT MEDFileFieldMultiTSWithoutSDA : public RefCountObject
571   {
572   public:
573     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);
574     MEDFileFieldMultiTSWithoutSDA(med_idt fid, int fieldId) throw(INTERP_KERNEL::Exception);
575     std::size_t getHeapMemorySize() const;
576     MEDFileFieldMultiTSWithoutSDA *deepCpy() const throw(INTERP_KERNEL::Exception);
577     int getNumberOfTS() const;
578     void eraseEmptyTS() throw(INTERP_KERNEL::Exception);
579     void eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception);
580     std::vector< std::pair<int,int> > getIterations() const;
581     int getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception);
582     int getPosGivenTime(double time, double eps=1e-8) const throw(INTERP_KERNEL::Exception);
583     int getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception);
584     std::vector< std::vector<TypeOfField> > getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception);
585     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);
586     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);
587     virtual void writeLL(med_idt fid, const MEDFileWritable& opts) const throw(INTERP_KERNEL::Exception);
588     std::string getName() const;
589     void setName(const char *name);
590     void simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const;
591     std::vector< std::pair<int,int> > getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception);
592     std::string getMeshName() const throw(INTERP_KERNEL::Exception);
593     void setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception);
594     bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception);
595     const std::vector<std::string>& getInfo() const throw(INTERP_KERNEL::Exception);
596     DataArrayDouble *getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception);
597     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);
598     bool renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
599     void appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
600     void appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob) throw(INTERP_KERNEL::Exception);
601   public:
602     const MEDFileField1TSWithoutSDA *getTimeStepAtPos2(int pos) const throw(INTERP_KERNEL::Exception);
603     MEDFileField1TSWithoutSDA *getTimeStepAtPos2(int pos) throw(INTERP_KERNEL::Exception);
604     const MEDFileField1TSWithoutSDA& getTimeStepEntry(int iteration, int order) const throw(INTERP_KERNEL::Exception);
605     std::vector<std::string> getPflsReallyUsed2() const;
606     std::vector<std::string> getLocsReallyUsed2() const;
607     std::vector<std::string> getPflsReallyUsedMulti2() const;
608     std::vector<std::string> getLocsReallyUsedMulti2() const;
609     void changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
610     void changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
611   protected:
612     MEDFileField1TSWithoutSDA& getTimeStepEntry(int iteration, int order) throw(INTERP_KERNEL::Exception);
613     std::string getDtUnit() const throw(INTERP_KERNEL::Exception);
614     MEDFileFieldMultiTSWithoutSDA(const char *fieldName);
615     MEDFileFieldMultiTSWithoutSDA(med_idt fid, const char *fieldName, int id, int ft, const std::vector<std::string>& infos, int nbOfStep) throw(INTERP_KERNEL::Exception);
616     void finishLoading(med_idt fid, int nbPdt) throw(INTERP_KERNEL::Exception);
617     void copyTinyInfoFrom(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception);
618     void checkCoherencyOfTinyInfo(const MEDCouplingFieldDouble *field) const throw(INTERP_KERNEL::Exception);
619   public:
620     MEDFileFieldMultiTSWithoutSDA();
621   protected:
622     std::string _name;
623     std::vector<std::string> _infos;
624     //! only useable on reading. 0 is for float, 1 for int32, 2 for int64
625     mutable int _field_type;
626     std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileField1TSWithoutSDA> > _time_steps;
627   };
628
629   class MEDFileFieldMultiTSIterator;
630
631   /*!
632    * User class.
633    */
634   class MEDLOADER_EXPORT MEDFileFieldMultiTS : public RefCountObject, public MEDFileWritable, public MEDFileFieldGlobsReal
635   {
636   public:
637     static MEDFileFieldMultiTS *New();
638     static MEDFileFieldMultiTS *New(const char *fileName) throw(INTERP_KERNEL::Exception);
639     static MEDFileFieldMultiTS *New(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
640     static MEDFileFieldMultiTS *New(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent);
641     std::size_t getHeapMemorySize() const;
642     MEDFileFieldMultiTS *deepCpy() const throw(INTERP_KERNEL::Exception);
643     //
644     MEDFileField1TS *getTimeStepAtPos(int pos) const throw(INTERP_KERNEL::Exception);
645     MEDFileField1TS *getTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception);
646     MEDFileField1TS *getTimeStepGivenTime(double time, double eps=1e-8) const throw(INTERP_KERNEL::Exception);
647     MEDFileFieldMultiTSIterator *iterator() throw(INTERP_KERNEL::Exception);
648     //
649     std::string simpleRepr() const;
650     void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
651     void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
652     MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
653     MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, int iteration, int order, int renumPol=0) const throw(INTERP_KERNEL::Exception);
654     MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
655     MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int iteration, int order, const MEDCouplingMesh *mesh, int renumPol=0) const throw(INTERP_KERNEL::Exception);
656     MEDCouplingFieldDouble *getFieldAtLevelOld(TypeOfField type, const char *mname, int iteration, int order, int meshDimRelToMax, int renumPol=0) const throw(INTERP_KERNEL::Exception);
657     DataArrayDouble *getFieldWithProfile(TypeOfField type, int iteration, int order, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const throw(INTERP_KERNEL::Exception);
658     //
659     void appendFieldNoProfileSBT(const MEDCouplingFieldDouble *field) throw(INTERP_KERNEL::Exception);
660     void appendFieldProfile(const MEDCouplingFieldDouble *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile) throw(INTERP_KERNEL::Exception);
661   public:// direct forwarding to MEDFileField1TSWithoutSDA instance _content
662     int getNumberOfTS() const;
663     void eraseEmptyTS() throw(INTERP_KERNEL::Exception);
664     void eraseTimeStepIds(const int *startIds, const int *endIds) throw(INTERP_KERNEL::Exception);
665     std::vector< std::pair<int,int> > getIterations() const;
666     int getPosOfTimeStep(int iteration, int order) const throw(INTERP_KERNEL::Exception);
667     int getPosGivenTime(double time, double eps=1e-8) const throw(INTERP_KERNEL::Exception);
668     int getNonEmptyLevels(int iteration, int order, const char *mname, std::vector<int>& levs) const throw(INTERP_KERNEL::Exception);
669     std::vector< std::vector<TypeOfField> > getTypesOfFieldAvailable() const throw(INTERP_KERNEL::Exception);
670     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);
671 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);
672     std::string getName() const;
673     void setName(const char *name);
674     void simpleRepr(int bkOffset, std::ostream& oss, int fmtsId) const;
675     std::vector< std::pair<int,int> > getTimeSteps(std::vector<double>& ret1) const throw(INTERP_KERNEL::Exception);
676     std::string getMeshName() const throw(INTERP_KERNEL::Exception);
677     void setMeshName(const char *newMeshName) throw(INTERP_KERNEL::Exception);
678     bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception);
679     const std::vector<std::string>& getInfo() const throw(INTERP_KERNEL::Exception);
680     DataArrayDouble *getUndergroundDataArray(int iteration, int order) const throw(INTERP_KERNEL::Exception);
681     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);
682   public:
683     std::vector<std::string> getPflsReallyUsed() const;
684     std::vector<std::string> getLocsReallyUsed() const;
685     std::vector<std::string> getPflsReallyUsedMulti() const;
686     std::vector<std::string> getLocsReallyUsedMulti() const;
687     void changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
688     void changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
689   public:
690     MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> getContent();
691   private:
692     MEDFileFieldMultiTS();
693     MEDFileFieldMultiTS(const MEDFileFieldMultiTSWithoutSDA& other, bool shallowCopyOfContent);
694     MEDFileFieldMultiTS(const char *fileName) throw(INTERP_KERNEL::Exception);
695     MEDFileFieldMultiTS(const char *fileName, const char *fieldName) throw(INTERP_KERNEL::Exception);
696   protected:
697     MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> _content;
698   };
699
700   class MEDCOUPLING_EXPORT MEDFileFieldMultiTSIterator
701   {
702   public:
703     MEDFileFieldMultiTSIterator(MEDFileFieldMultiTS *fmts);
704     ~MEDFileFieldMultiTSIterator();
705     MEDFileField1TS *nextt();
706   private:
707     MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTS> _fmts;
708      int _iter_id;
709      int _nb_iter;
710   };
711
712   class MEDFileFieldsIterator;
713
714   /*!
715    * Use class.
716    */
717   class MEDLOADER_EXPORT MEDFileFields : public RefCountObject, public MEDFileFieldGlobsReal, public MEDFileWritable
718   {
719   public:
720     static MEDFileFields *New();
721     static MEDFileFields *New(const char *fileName) throw(INTERP_KERNEL::Exception);
722     std::size_t getHeapMemorySize() const;
723     MEDFileFields *deepCpy() const throw(INTERP_KERNEL::Exception);
724     void write(const char *fileName, int mode) const throw(INTERP_KERNEL::Exception);
725     void writeLL(med_idt fid) const throw(INTERP_KERNEL::Exception);
726     int getNumberOfFields() const;
727     std::vector<std::string> getFieldsNames() const throw(INTERP_KERNEL::Exception);
728     std::vector<std::string> getMeshesNames() const throw(INTERP_KERNEL::Exception);
729     std::string simpleRepr() const;
730     void simpleRepr(int bkOffset, std::ostream& oss) const;
731     //
732     void resize(int newSize) throw(INTERP_KERNEL::Exception);
733     void pushField(MEDFileFieldMultiTS *field) throw(INTERP_KERNEL::Exception);
734     void setFieldAtPos(int i, MEDFileFieldMultiTS *field) throw(INTERP_KERNEL::Exception);
735     MEDFileFieldMultiTS *getFieldAtPos(int i) const throw(INTERP_KERNEL::Exception);
736     MEDFileFieldMultiTS *getFieldWithName(const char *fieldName) const throw(INTERP_KERNEL::Exception);
737     MEDFileFieldsIterator *iterator() throw(INTERP_KERNEL::Exception);
738     void destroyFieldAtPos(int i) throw(INTERP_KERNEL::Exception);
739     bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab) throw(INTERP_KERNEL::Exception);
740     bool renumberEntitiesLyingOnMesh(const char *meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N) throw(INTERP_KERNEL::Exception);
741   public:
742     int getPosFromFieldName(const char *fieldName) const throw(INTERP_KERNEL::Exception);
743     std::vector<std::string> getPflsReallyUsed() const;
744     std::vector<std::string> getLocsReallyUsed() const;
745     std::vector<std::string> getPflsReallyUsedMulti() const;
746     std::vector<std::string> getLocsReallyUsedMulti() const;
747     void changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
748     void changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif) throw(INTERP_KERNEL::Exception);
749   private:
750     MEDFileFields();
751     MEDFileFields(const char *fileName) throw(INTERP_KERNEL::Exception);
752   private:
753     std::vector< MEDCouplingAutoRefCountObjectPtr<MEDFileFieldMultiTSWithoutSDA> > _fields;
754   };
755
756   class MEDCOUPLING_EXPORT MEDFileFieldsIterator
757   {
758   public:
759     MEDFileFieldsIterator(MEDFileFields *fs);
760     ~MEDFileFieldsIterator();
761     MEDFileFieldMultiTS *nextt();
762   private:
763     MEDCouplingAutoRefCountObjectPtr<MEDFileFields> _fs;
764      int _iter_id;
765      int _nb_iter;
766   };
767 }
768
769 #endif