Salome HOME
Implemenatation of MEDFileFields::linearToQuadratic + Remapper is now dealing with...
[tools/medcoupling.git] / src / MEDLoader / MEDFileField1TS.hxx
1 // Copyright (C) 2007-2016  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Anthony Geay (EDF R&D)
20
21 #ifndef __MEDFILEFIELD1TS_HXX__
22 #define __MEDFILEFIELD1TS_HXX__
23
24 #include "MEDLoaderDefines.hxx"
25 #include "MEDFileFieldGlobs.hxx"
26 #include "MEDFileFieldInternal.hxx"
27 #include "MEDLoaderTraits.hxx"
28
29 #include "med.h"
30
31 namespace MEDCoupling
32 {
33   class TimeHolder;
34   class MEDFileMeshes;
35   
36   /*!
37    * SDA is for Shared Data Arrays such as profiles.
38    */
39   class MEDFileAnyTypeField1TSWithoutSDA : public RefCountObject, public MEDFileFieldNameScope
40   {
41   public:
42     MEDLOADER_EXPORT MEDFileAnyTypeField1TSWithoutSDA();
43     MEDLOADER_EXPORT MEDFileAnyTypeField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order);
44     MEDLOADER_EXPORT int getIteration() const { return _iteration; }
45     MEDLOADER_EXPORT int getOrder() const { return _order; }
46     MEDLOADER_EXPORT double getTime(int& iteration, int& order) const { iteration=_iteration; order=_order; return _dt; }
47     MEDLOADER_EXPORT void setTime(int iteration, int order, double val) { _dt=val; _iteration=iteration; _order=order; }
48     MEDLOADER_EXPORT int getDimension() const;
49     MEDLOADER_EXPORT bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab);
50     MEDLOADER_EXPORT int getMeshIteration() const;
51     MEDLOADER_EXPORT int getMeshOrder() const;
52     MEDLOADER_EXPORT bool isDealingTS(int iteration, int order) const;
53     MEDLOADER_EXPORT std::pair<int,int> getDtIt() const;
54     MEDLOADER_EXPORT void fillIteration(std::pair<int,int>& p) const;
55     MEDLOADER_EXPORT void fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const;
56     MEDLOADER_EXPORT std::vector<TypeOfField> getTypesOfFieldAvailable() const;
57     //
58     MEDLOADER_EXPORT std::vector<std::string> getPflsReallyUsed2() const;
59     MEDLOADER_EXPORT std::vector<std::string> getLocsReallyUsed2() const;
60     MEDLOADER_EXPORT std::vector<std::string> getPflsReallyUsedMulti2() const;
61     MEDLOADER_EXPORT std::vector<std::string> getLocsReallyUsedMulti2() const;
62     MEDLOADER_EXPORT void changePflsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
63     MEDLOADER_EXPORT void changeLocsRefsNamesGen2(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
64     //
65     MEDLOADER_EXPORT int getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const;
66     MEDLOADER_EXPORT void convertMedBallIntoClassic();
67     MEDLOADER_EXPORT void makeReduction(INTERP_KERNEL::NormalizedCellType ct, TypeOfField tof, const DataArrayInt *pfl);
68     MEDLOADER_EXPORT std::vector< std::vector<std::pair<int,int> > > getFieldSplitedByType(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const;
69     //
70     MEDLOADER_EXPORT MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId);
71     MEDLOADER_EXPORT const MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const;
72     MEDLOADER_EXPORT void deepCpyLeavesFrom(const MEDFileAnyTypeField1TSWithoutSDA& other);
73     MEDLOADER_EXPORT void accept(MEDFileFieldVisitor& visitor) const;
74   public:
75     MEDLOADER_EXPORT int getNumberOfComponents() const;
76     MEDLOADER_EXPORT const std::vector<std::string>& getInfo() const;
77     MEDLOADER_EXPORT std::vector<std::string>& getInfo();
78     MEDLOADER_EXPORT bool presenceOfMultiDiscPerGeoType() const;
79     MEDLOADER_EXPORT bool presenceOfStructureElements() const;
80     MEDLOADER_EXPORT bool onlyStructureElements() const;
81     MEDLOADER_EXPORT void killStructureElements();
82     MEDLOADER_EXPORT void keepOnlyStructureElements();
83     MEDLOADER_EXPORT void keepOnlyOnSE(const std::string& seName);
84     MEDLOADER_EXPORT void getMeshSENames(std::vector< std::pair<std::string,std::string> >& ps) const;
85     MEDLOADER_EXPORT void setInfo(const std::vector<std::string>& infos);
86     MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
87     MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
88     MEDLOADER_EXPORT int copyTinyInfoFrom(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arr);
89     MEDLOADER_EXPORT void setFieldNoProfileSBT(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arr, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc);
90     MEDLOADER_EXPORT void setFieldProfile(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arrOfVals, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile, MEDFileFieldGlobsReal& glob, const MEDFileFieldNameScope& nasc);
91     MEDLOADER_EXPORT virtual void simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const;
92     MEDLOADER_EXPORT virtual MEDFileAnyTypeField1TSWithoutSDA *deepCopy() const = 0;
93     MEDLOADER_EXPORT virtual MEDFileAnyTypeField1TSWithoutSDA *shallowCpy() const = 0;
94     MEDLOADER_EXPORT virtual std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > splitComponents() const;
95     MEDLOADER_EXPORT virtual const char *getTypeStr() const = 0;
96     MEDLOADER_EXPORT virtual DataArray *getUndergroundDataArray() const = 0;
97     MEDLOADER_EXPORT virtual DataArray *getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const = 0;
98     MEDLOADER_EXPORT virtual void setArray(DataArray *arr) = 0;
99     MEDLOADER_EXPORT virtual DataArray *createNewEmptyDataArrayInstance() const = 0;
100     MEDLOADER_EXPORT virtual DataArray *getOrCreateAndGetArray() = 0;
101     MEDLOADER_EXPORT virtual const DataArray *getOrCreateAndGetArray() const = 0;
102   public:
103     MEDLOADER_EXPORT MEDCouplingFieldDouble *fieldOnMesh(const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray>& arrOut, const MEDFileFieldNameScope& nasc) const;
104     MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray> &arrOut, const MEDFileFieldNameScope& nasc) const;
105     MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDFileMesh *mesh, MCAuto<DataArray> &arrOut, const MEDFileFieldNameScope& nasc) const;
106     MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldAtTopLevel(TypeOfField type, const std::string& mName, int renumPol, const MEDFileFieldGlobsReal *glob, MCAuto<DataArray> &arrOut, const MEDFileFieldNameScope& nasc) const;
107     MEDLOADER_EXPORT MEDCouplingFieldDouble *getFieldOnMeshAtLevel(TypeOfField type, int renumPol, const MEDFileFieldGlobsReal *glob, const MEDCouplingMesh *mesh, const DataArrayInt *cellRenum, const DataArrayInt *nodeRenum, MCAuto<DataArray> &arrOut, const MEDFileFieldNameScope& nasc) const;
108     DataArray *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl, const MEDFileFieldGlobsReal *glob, const MEDFileFieldNameScope& nasc) const;
109   public:
110     MEDLOADER_EXPORT bool renumberEntitiesLyingOnMesh(const std::string& meshName, const std::vector<int>& oldCode, const std::vector<int>& newCode, const DataArrayInt *renumO2N, MEDFileFieldGlobsReal& glob);
111     MEDLOADER_EXPORT std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > splitDiscretizations() const;
112     MEDLOADER_EXPORT std::vector< MCAuto<MEDFileAnyTypeField1TSWithoutSDA> > splitMultiDiscrPerGeoTypes() const;
113     MEDLOADER_EXPORT int keepOnlySpatialDiscretization(TypeOfField tof, std::vector< std::pair<int,int> >& its);
114     MEDLOADER_EXPORT int keepOnlyGaussDiscretization(std::size_t idOfDisc, std::vector< std::pair<int,int> >& its);
115   public:
116     MEDLOADER_EXPORT void allocNotFromFile(int newNbOfTuples);
117     MEDLOADER_EXPORT bool allocIfNecessaryTheArrayToReceiveDataFromFile();
118     MEDLOADER_EXPORT void loadOnlyStructureOfDataRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities);
119     MEDLOADER_EXPORT void loadBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc);
120     MEDLOADER_EXPORT void loadBigArraysRecursivelyIfNecessary(med_idt fid, const MEDFileFieldNameScope& nasc);
121     MEDLOADER_EXPORT void loadStructureAndBigArraysRecursively(med_idt fid, const MEDFileFieldNameScope& nasc, const MEDFileMeshes *ms, const MEDFileEntities *entities);
122     MEDLOADER_EXPORT void unloadArrays();
123     MEDLOADER_EXPORT void writeLL(med_idt fid, const MEDFileWritable& opts, const MEDFileFieldNameScope& nasc) const;
124     MEDLOADER_EXPORT static std::string FieldNameToMEDFileConvention(const std::string& nonCorrectFieldName);
125   protected:
126     int getMeshIdFromMeshName(const std::string& mName) const;
127     int addNewEntryIfNecessary(const MEDCouplingMesh *mesh);
128     void updateData(int newLgth, const std::vector< std::pair<int,int> >& oldStartStops);
129   protected:
130     std::vector< MCAuto< MEDFileFieldPerMesh > > _field_per_mesh;
131     int _iteration;
132     int _order;
133     double _dt;
134   public:
135     //! only useable on reading
136     mutable int _csit;
137     // -3 means allocated and build from scratch
138     // -2 means allocated and read from a file
139     // -1 means not allocated and build from scratch
140     // >=0 means not allocated and read from a file
141     mutable int _nb_of_tuples_to_be_allocated;
142   };
143
144   class MEDFileIntField1TSWithoutSDA;
145
146   template<class T>
147   class MEDFileField1TSTemplateWithoutSDA : public MEDFileAnyTypeField1TSWithoutSDA
148   {
149   protected:
150     MEDFileField1TSTemplateWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order):MEDFileAnyTypeField1TSWithoutSDA(fieldName,meshName,csit,iteration,order) { }
151     MEDFileField1TSTemplateWithoutSDA() { }
152   public:
153     MEDLOADER_EXPORT void setArray(DataArray *arr);
154     MEDLOADER_EXPORT DataArray *createNewEmptyDataArrayInstance() const;
155     MEDLOADER_EXPORT typename Traits<T>::ArrayType *getOrCreateAndGetArrayTemplate();
156     MEDLOADER_EXPORT typename Traits<T>::ArrayType const *getOrCreateAndGetArrayTemplate() const;
157     MEDLOADER_EXPORT typename Traits<T>::ArrayType *getUndergroundDataArrayTemplate() const;
158     MEDLOADER_EXPORT typename Traits<T>::ArrayType *getUndergroundDataArrayTemplateExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const;
159     MEDLOADER_EXPORT DataArray *getOrCreateAndGetArray();
160     MEDLOADER_EXPORT const DataArray *getOrCreateAndGetArray() const;
161     MEDLOADER_EXPORT DataArray *getUndergroundDataArray() const;
162     MEDLOADER_EXPORT void aggregate(const typename std::vector< typename MLFieldTraits<T>::F1TSWSDAType const * >& f1tss, const std::vector< std::vector< std::pair<int,int> > >& dts);
163     MEDLOADER_EXPORT void copyTimeInfoFrom(const typename Traits<T>::FieldType *mcf);
164   protected:
165     MCAuto< typename Traits<T>::ArrayType > _arr;
166   };
167
168   /*!
169    * SDA is for Shared Data Arrays such as profiles.
170    */
171   class MEDFileField1TSWithoutSDA : public MEDFileField1TSTemplateWithoutSDA<double>
172   {
173   public:
174     MEDLOADER_EXPORT const char *getTypeStr() const;
175     MEDLOADER_EXPORT DataArray *getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const;
176     MEDLOADER_EXPORT std::vector< std::vector<DataArrayDouble *> > getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF, std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const;
177     MEDLOADER_EXPORT static void CheckMeshDimRel(int meshDimRelToMax);
178     MEDLOADER_EXPORT static std::vector<int> CheckSBTMesh(const MEDCouplingMesh *mesh);
179     MEDLOADER_EXPORT static MEDFileField1TSWithoutSDA *New(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector<std::string>& infos);
180   public:
181     MEDLOADER_EXPORT MEDFileField1TSWithoutSDA();
182     MEDLOADER_EXPORT MEDFileField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector<std::string>& infos);
183     MEDLOADER_EXPORT MEDFileField1TSWithoutSDA *shallowCpy() const;
184     MEDLOADER_EXPORT MEDFileField1TSWithoutSDA *deepCopy() const;
185     MEDLOADER_EXPORT MEDFileIntField1TSWithoutSDA *convertToInt() const;
186   public:
187     static const char TYPE_STR[];
188   };
189
190   template<class T>
191   class MEDFileField1TSNDTemplateWithoutSDA : public MEDFileField1TSTemplateWithoutSDA<T>
192   {
193   public:
194     MEDLOADER_EXPORT MEDFileField1TSWithoutSDA *convertToDouble() const;
195   protected:
196     MEDFileField1TSNDTemplateWithoutSDA() { }
197     MEDFileField1TSNDTemplateWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector<std::string>& infos):MEDFileField1TSTemplateWithoutSDA<T>(fieldName,meshName,csit,iteration,order) { }
198   };
199   
200   /*!
201    * SDA is for Shared Data Arrays such as profiles.
202    */
203   class MEDFileIntField1TSWithoutSDA : public MEDFileField1TSNDTemplateWithoutSDA<int>
204   {
205   public:
206     MEDLOADER_EXPORT MEDFileIntField1TSWithoutSDA();
207     MEDLOADER_EXPORT static MEDFileIntField1TSWithoutSDA *New(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector<std::string>& infos);
208     MEDLOADER_EXPORT MEDFileIntField1TSWithoutSDA *deepCopy() const;
209     MEDLOADER_EXPORT MEDFileIntField1TSWithoutSDA *shallowCpy() const;
210     MEDLOADER_EXPORT const char *getTypeStr() const;
211     MEDLOADER_EXPORT DataArray *getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const;
212     MEDLOADER_EXPORT DataArrayInt *getUndergroundDataArrayIntExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const;
213   protected:
214     MEDFileIntField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector<std::string>& infos);
215   public:
216     MEDLOADER_EXPORT static const char TYPE_STR[];
217   };
218
219   /*!
220    * SDA is for Shared Data Arrays such as profiles.
221    */
222   class MEDFileFloatField1TSWithoutSDA : public MEDFileField1TSNDTemplateWithoutSDA<float>
223   {
224   public:
225     MEDLOADER_EXPORT MEDFileFloatField1TSWithoutSDA();
226     MEDLOADER_EXPORT static MEDFileFloatField1TSWithoutSDA *New(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector<std::string>& infos);
227     MEDLOADER_EXPORT MEDFileFloatField1TSWithoutSDA *deepCopy() const;
228     MEDLOADER_EXPORT MEDFileFloatField1TSWithoutSDA *shallowCpy() const;
229     MEDLOADER_EXPORT const char *getTypeStr() const;
230     MEDLOADER_EXPORT DataArray *getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const;
231     MEDLOADER_EXPORT DataArrayFloat *getUndergroundDataArrayFloatExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const;
232   protected:
233     MEDFileFloatField1TSWithoutSDA(const std::string& fieldName, const std::string& meshName, int csit, int iteration, int order, const std::vector<std::string>& infos);
234   public:
235     MEDLOADER_EXPORT static const char TYPE_STR[];
236   };
237
238   /*!
239    * User class.
240    */
241   class MEDFileAnyTypeField1TS : public RefCountObject, public MEDFileWritableStandAlone, public MEDFileFieldGlobsReal
242   {
243   protected:
244     MEDLOADER_EXPORT MEDFileAnyTypeField1TS();
245     MEDLOADER_EXPORT MEDFileAnyTypeField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities=0);
246     MEDLOADER_EXPORT MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities=0);
247     MEDLOADER_EXPORT MEDFileAnyTypeField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities=0);
248     MEDLOADER_EXPORT MEDFileAnyTypeField1TS(const MEDFileAnyTypeField1TSWithoutSDA& other, bool shallowCopyOfContent);
249     MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c);
250     MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *BuildNewInstanceFromContent(MEDFileAnyTypeField1TSWithoutSDA *c, med_idt fid);
251     MEDLOADER_EXPORT static MEDFileAnyTypeField1TSWithoutSDA *BuildContentFrom(med_idt fid, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities);
252     MEDLOADER_EXPORT static MEDFileAnyTypeField1TSWithoutSDA *BuildContentFrom(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities);
253     MEDLOADER_EXPORT static MEDFileAnyTypeField1TSWithoutSDA *BuildContentFrom(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms, const MEDFileEntities *entities);
254     MEDLOADER_EXPORT void writeLL(med_idt fid) const;
255     // direct forwarding to MEDFileAnyTypeField1TSWithoutSDA instance _content
256   public:
257     MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *New(const std::string& fileName, bool loadAll=true);
258     MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *New(med_idt fid, bool loadAll=true);
259     MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true);
260     MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *New(med_idt fid, const std::string& fieldName, bool loadAll=true);
261     MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll=true);
262     MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll=true);
263     MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *NewAdv(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileEntities *entities);
264     MEDLOADER_EXPORT static MEDFileAnyTypeField1TS *NewAdv(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileEntities *entities);
265     MEDLOADER_EXPORT int getDimension() const;
266     MEDLOADER_EXPORT int getIteration() const;
267     MEDLOADER_EXPORT int getOrder() const;
268     MEDLOADER_EXPORT double getTime(int& iteration, int& order) const;
269     MEDLOADER_EXPORT void setTime(int iteration, int order, double val);
270     MEDLOADER_EXPORT std::string getName() const;
271     MEDLOADER_EXPORT void setName(const std::string& name);
272     MEDLOADER_EXPORT std::string simpleRepr() const;
273     MEDLOADER_EXPORT void simpleRepr(int bkOffset, std::ostream& oss, int f1tsId) const;
274     MEDLOADER_EXPORT std::string getDtUnit() const;
275     MEDLOADER_EXPORT void setDtUnit(const std::string& dtUnit);
276     MEDLOADER_EXPORT std::string getMeshName() const;
277     MEDLOADER_EXPORT void setMeshName(const std::string& newMeshName);
278     MEDLOADER_EXPORT bool changeMeshNames(const std::vector< std::pair<std::string,std::string> >& modifTab);
279     MEDLOADER_EXPORT int getMeshIteration() const;
280     MEDLOADER_EXPORT int getMeshOrder() const;
281     MEDLOADER_EXPORT int getNumberOfComponents() const;
282     MEDLOADER_EXPORT bool isDealingTS(int iteration, int order) const;
283     MEDLOADER_EXPORT std::pair<int,int> getDtIt() const;
284     MEDLOADER_EXPORT void fillIteration(std::pair<int,int>& p) const;
285     MEDLOADER_EXPORT void fillTypesOfFieldAvailable(std::vector<TypeOfField>& types) const;
286     MEDLOADER_EXPORT void setInfo(const std::vector<std::string>& infos);
287     MEDLOADER_EXPORT const std::vector<std::string>& getInfo() const;
288     MEDLOADER_EXPORT std::vector<std::string>& getInfo();
289     MEDLOADER_EXPORT bool presenceOfMultiDiscPerGeoType() const;
290     MEDLOADER_EXPORT std::vector<TypeOfField> getTypesOfFieldAvailable() const;
291     MEDLOADER_EXPORT std::vector< std::vector<std::pair<int,int> > > getFieldSplitedByType(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
292         std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const;
293     MEDLOADER_EXPORT MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId);
294     MEDLOADER_EXPORT const MEDFileFieldPerMeshPerTypePerDisc *getLeafGivenMeshAndTypeAndLocId(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId) const;
295     MEDLOADER_EXPORT int getNonEmptyLevels(const std::string& mname, std::vector<int>& levs) const;
296     MEDLOADER_EXPORT void convertMedBallIntoClassic();
297     MEDLOADER_EXPORT void makeReduction(INTERP_KERNEL::NormalizedCellType ct, TypeOfField tof, const DataArrayInt *pfl);
298     MEDLOADER_EXPORT virtual MEDFileAnyTypeField1TS *extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const = 0;
299     MEDLOADER_EXPORT virtual MEDFileAnyTypeField1TS *shallowCpy() const = 0;
300   public:
301     MEDLOADER_EXPORT void loadArrays();
302     MEDLOADER_EXPORT void loadArraysIfNecessary();
303     MEDLOADER_EXPORT void unloadArrays();
304     MEDLOADER_EXPORT void unloadArraysWithoutDataLoss();
305     MEDLOADER_EXPORT std::vector< MCAuto< MEDFileAnyTypeField1TS > > splitComponents() const;
306     MEDLOADER_EXPORT std::vector< MCAuto< MEDFileAnyTypeField1TS > > splitDiscretizations() const;
307     MEDLOADER_EXPORT std::vector< MCAuto< MEDFileAnyTypeField1TS > > splitMultiDiscrPerGeoTypes() const;
308     MEDLOADER_EXPORT MEDFileAnyTypeField1TS *deepCopy() const;
309     MEDLOADER_EXPORT int copyTinyInfoFrom(const MEDCouplingFieldDouble *field, const DataArray *arr);
310     MEDLOADER_EXPORT int copyTinyInfoFrom(const TimeHolder *th, const MEDCouplingFieldTemplate *field, const DataArray *arr);
311   public:
312     //! underground method see MEDFileField1TSWithoutSDA::setProfileNameOnLeaf
313     MEDLOADER_EXPORT void setProfileNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newPflName, bool forceRenameOnGlob=false);
314     //! underground method see MEDFileField1TSWithoutSDA::setLocNameOnLeaf
315     MEDLOADER_EXPORT void setLocNameOnLeaf(const std::string& mName, INTERP_KERNEL::NormalizedCellType typ, int locId, const std::string& newLocName, bool forceRenameOnGlob=false);
316     MEDLOADER_EXPORT std::size_t getHeapMemorySizeWithoutChildren() const;
317     MEDLOADER_EXPORT std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
318     MEDLOADER_EXPORT std::vector<std::string> getPflsReallyUsed() const;
319     MEDLOADER_EXPORT std::vector<std::string> getLocsReallyUsed() const;
320     MEDLOADER_EXPORT std::vector<std::string> getPflsReallyUsedMulti() const;
321     MEDLOADER_EXPORT std::vector<std::string> getLocsReallyUsedMulti() const;
322     MEDLOADER_EXPORT void changePflsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
323     MEDLOADER_EXPORT void changeLocsRefsNamesGen(const std::vector< std::pair<std::vector<std::string>, std::string > >& mapOfModif);
324   public:
325     MEDLOADER_EXPORT static int LocateField2(med_idt fid, int fieldIdCFormat, bool checkFieldId, std::string& fieldName, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut, std::string& meshName);
326     MEDLOADER_EXPORT static int LocateField(med_idt fid, const std::string& fieldName, int& posCFormat, med_field_type& typcha, std::vector<std::string>& infos, std::string& dtunitOut, std::string& meshName);
327   public:
328     MEDLOADER_EXPORT virtual med_field_type getMEDFileFieldType() const = 0;
329     MEDLOADER_EXPORT MEDFileAnyTypeField1TSWithoutSDA *contentNotNullBase();
330     MEDLOADER_EXPORT const MEDFileAnyTypeField1TSWithoutSDA *contentNotNullBase() const;
331   protected:
332     MCAuto<MEDFileAnyTypeField1TSWithoutSDA> _content;
333   };
334
335   class MEDFileIntField1TS;
336
337   template<class T>
338   class MEDFileTemplateField1TS : public MEDFileAnyTypeField1TS
339   {
340   public:
341     MEDLOADER_EXPORT static typename MLFieldTraits<T>::F1TSType *New();
342     MEDLOADER_EXPORT static typename MLFieldTraits<T>::F1TSType *New(const std::string& fileName, bool loadAll=true);
343     MEDLOADER_EXPORT static typename MLFieldTraits<T>::F1TSType *New(med_idt fid, bool loadAll=true);
344     MEDLOADER_EXPORT static typename MLFieldTraits<T>::F1TSType *New(DataArrayByte *db) { return BuildFromMemoryChunk<typename MLFieldTraits<T>::F1TSType>(db); }
345     MEDLOADER_EXPORT static typename MLFieldTraits<T>::F1TSType *New(const std::string& fileName, const std::string& fieldName, bool loadAll=true);
346     MEDLOADER_EXPORT static typename MLFieldTraits<T>::F1TSType *New(med_idt fid, const std::string& fieldName, bool loadAll=true);
347     MEDLOADER_EXPORT static typename MLFieldTraits<T>::F1TSType *New(const std::string& fileName, const std::string& fieldName, int iteration, int order, bool loadAll=true);
348     MEDLOADER_EXPORT static typename MLFieldTraits<T>::F1TSType *New(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll=true);
349     MEDLOADER_EXPORT static typename MLFieldTraits<T>::F1TSType *New(const typename MLFieldTraits<T>::F1TSWSDAType& other, bool shallowCopyOfContent);
350   public:
351     MEDLOADER_EXPORT static typename Traits<T>::ArrayType *ReturnSafelyTypedDataArray(MCAuto<DataArray>& arr);
352     MEDLOADER_EXPORT typename Traits<T>::ArrayType *getFieldWithProfile(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, DataArrayInt *&pfl) const;
353     MEDLOADER_EXPORT void setArray(DataArray *arr);
354     MEDLOADER_EXPORT typename Traits<T>::ArrayType *getUndergroundDataArray() const;
355     MEDLOADER_EXPORT typename Traits<T>::ArrayType *getUndergroundDataArrayExt(std::vector< std::pair<std::pair<INTERP_KERNEL::NormalizedCellType,int>,std::pair<int,int> > >& entries) const;
356     MEDLOADER_EXPORT static MCAuto<typename Traits<T>::FieldType> SetDataArrayInField(MEDCouplingFieldDouble *f, MCAuto<DataArray>& arr);
357     MEDLOADER_EXPORT static MCAuto<MEDCouplingFieldDouble> ToFieldTemplateWithTime(const typename Traits<T>::FieldType *f);
358   public:
359     MEDLOADER_EXPORT void copyTimeInfoFrom(const typename Traits<T>::FieldType *mcf);
360     MEDLOADER_EXPORT typename Traits<T>::FieldType *field(const MEDFileMesh *mesh) const;
361     MEDLOADER_EXPORT typename Traits<T>::FieldType *getFieldAtLevel(TypeOfField type, int meshDimRelToMax, int renumPol=0) const;
362     MEDLOADER_EXPORT typename Traits<T>::FieldType *getFieldAtTopLevel(TypeOfField type, int renumPol=0) const;
363     MEDLOADER_EXPORT typename Traits<T>::FieldType *getFieldOnMeshAtLevel(TypeOfField type, int meshDimRelToMax, const MEDFileMesh *mesh, int renumPol=0) const;
364     MEDLOADER_EXPORT typename Traits<T>::FieldType *getFieldOnMeshAtLevel(TypeOfField type, const MEDCouplingMesh *mesh, int renumPol=0) const;
365     MEDLOADER_EXPORT typename Traits<T>::FieldType *getFieldAtLevelOld(TypeOfField type, const std::string& mname, int meshDimRelToMax, int renumPol=0) const;
366     MEDLOADER_EXPORT void setFieldNoProfileSBT(const typename Traits<T>::FieldType *field);
367     MEDLOADER_EXPORT void setFieldProfile(const typename Traits<T>::FieldType *field, const MEDFileMesh *mesh, int meshDimRelToMax, const DataArrayInt *profile);
368     MEDLOADER_EXPORT typename MLFieldTraits<T>::F1TSType *extractPartImpl(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const;
369     MEDLOADER_EXPORT MEDFileAnyTypeField1TS *extractPart(const std::map<int, MCAuto<DataArrayInt> >& extractDef, MEDFileMesh *mm) const { return this->extractPartImpl(extractDef,mm); }
370   protected:
371     ~MEDFileTemplateField1TS() { }
372     MEDFileTemplateField1TS();
373     MEDFileTemplateField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms):MEDFileAnyTypeField1TS(fid,loadAll,ms) { }
374     MEDFileTemplateField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms):MEDFileAnyTypeField1TS(fid,fieldName,loadAll,ms) { }
375     MEDFileTemplateField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms):MEDFileAnyTypeField1TS(fid,fieldName,iteration,order,loadAll,ms) { }
376     MEDFileTemplateField1TS(const typename MLFieldTraits<T>::F1TSWSDAType& other, bool shallowCopyOfContent):MEDFileAnyTypeField1TS(other,shallowCopyOfContent) { }
377     const typename MLFieldTraits<T>::F1TSWSDAType *contentNotNull() const;
378     typename MLFieldTraits<T>::F1TSWSDAType *contentNotNull();
379   };
380
381   /*!
382    * User class.
383    */
384   class MEDFileField1TS : public MEDFileTemplateField1TS<double>
385   {
386     friend class MEDFileTemplateField1TS<double>;
387   public:
388     MEDLOADER_EXPORT MEDFileIntField1TS *convertToInt(bool isDeepCpyGlobs=true) const;
389   public:
390     MEDLOADER_EXPORT MEDFileField1TS *shallowCpy() const;
391     MEDLOADER_EXPORT std::vector< std::vector<DataArrayDouble *> > getFieldSplitedByType2(const std::string& mname, std::vector<INTERP_KERNEL::NormalizedCellType>& types, std::vector< std::vector<TypeOfField> >& typesF,
392                                                                                           std::vector< std::vector<std::string> >& pfls, std::vector< std::vector<std::string> >& locs) const;
393   public:
394   private:
395     med_field_type getMEDFileFieldType() const { return MED_FLOAT64; }
396   private:
397     ~MEDFileField1TS() { }
398     MEDFileField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms);
399     MEDFileField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms);
400     MEDFileField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms);
401     MEDFileField1TS(const MEDFileField1TSWithoutSDA& other, bool shallowCopyOfContent);
402     MEDFileField1TS() { }
403   };
404
405   template<class T>
406   class MEDFileNDTemplateField1TS : public MEDFileTemplateField1TS<T>
407   {
408   public:
409     MEDLOADER_EXPORT MEDFileField1TS *convertToDouble(bool isDeepCpyGlobs=true) const;
410   protected:
411     ~MEDFileNDTemplateField1TS() { }
412     MEDFileNDTemplateField1TS() { }
413     MEDFileNDTemplateField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms):MEDFileTemplateField1TS<T>(fid,loadAll,ms) { }
414     MEDFileNDTemplateField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms):MEDFileTemplateField1TS<T>(fid,fieldName,loadAll,ms) { }
415     MEDFileNDTemplateField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms):MEDFileTemplateField1TS<T>(fid,fieldName,iteration,order,loadAll,ms) { }
416     MEDFileNDTemplateField1TS(const typename MLFieldTraits<T>::F1TSWSDAType& other, bool shallowCopyOfContent):MEDFileTemplateField1TS<T>(other,shallowCopyOfContent) { }
417   };
418
419   class MEDFileIntField1TS : public MEDFileNDTemplateField1TS<int>
420   {
421     friend class MEDFileTemplateField1TS<int>;
422   public:
423     MEDLOADER_EXPORT MEDFileIntField1TS *shallowCpy() const { return new MEDFileIntField1TS(*this); }
424   public:
425     MEDLOADER_EXPORT static MCAuto<MEDCouplingFieldDouble> ConvertFieldIntToFieldDouble(const MEDCouplingFieldInt *f);
426   private:
427     med_field_type getMEDFileFieldType() const { return MED_INT32; }
428   private:
429     ~MEDFileIntField1TS() { }
430     MEDFileIntField1TS() { }
431     MEDFileIntField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms):MEDFileNDTemplateField1TS<int>(fid,loadAll,ms) { }
432     MEDFileIntField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms):MEDFileNDTemplateField1TS<int>(fid,fieldName,loadAll,ms) { }
433     MEDFileIntField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms):MEDFileNDTemplateField1TS<int>(fid,fieldName,iteration,order,loadAll,ms) { }
434     /*!
435      * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
436      * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
437      *
438      * \warning this is a shallow copy constructor
439      */
440     MEDFileIntField1TS(const MEDFileIntField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileNDTemplateField1TS<int>(other,shallowCopyOfContent) { }
441   };
442
443   class MEDFileFloatField1TS : public MEDFileNDTemplateField1TS<float>
444   {
445     friend class MEDFileTemplateField1TS<float>;
446   private:
447     med_field_type getMEDFileFieldType() const { return MED_FLOAT32; }
448     MEDLOADER_EXPORT MEDFileFloatField1TS *shallowCpy() const { return new MEDFileFloatField1TS(*this); }
449   private:
450     ~MEDFileFloatField1TS() { }
451     MEDFileFloatField1TS() { }
452     MEDFileFloatField1TS(med_idt fid, bool loadAll, const MEDFileMeshes *ms):MEDFileNDTemplateField1TS<float>(fid,loadAll,ms) { }
453     MEDFileFloatField1TS(med_idt fid, const std::string& fieldName, bool loadAll, const MEDFileMeshes *ms):MEDFileNDTemplateField1TS<float>(fid,fieldName,loadAll,ms) { }
454     MEDFileFloatField1TS(med_idt fid, const std::string& fieldName, int iteration, int order, bool loadAll, const MEDFileMeshes *ms):MEDFileNDTemplateField1TS<float>(fid,fieldName,iteration,order,loadAll,ms) { }
455     /*!
456      * This constructor is a shallow copy constructor. If \a shallowCopyOfContent is true the content of \a other is shallow copied.
457      * If \a shallowCopyOfContent is false, \a other is taken to be the content of \a this.
458      *
459      * \warning this is a shallow copy constructor
460      */
461     MEDFileFloatField1TS(const MEDFileFloatField1TSWithoutSDA& other, bool shallowCopyOfContent):MEDFileNDTemplateField1TS<float>(other,shallowCopyOfContent) { }
462   };
463 }
464
465 #endif