Salome HOME
Merge from V6_main 01/04/2013
[tools/medcoupling.git] / src / MEDCoupling / MEDCouplingTimeDiscretization.hxx
1 // Copyright (C) 2007-2013  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19 // Author : Anthony Geay (CEA/DEN)
20
21 #ifndef __PARAMEDMEM_MEDCOUPLINGTIMEDISCRETIZATION_HXX__
22 #define __PARAMEDMEM_MEDCOUPLINGTIMEDISCRETIZATION_HXX__
23
24 #include "MEDCoupling.hxx"
25 #include "MEDCouplingTimeLabel.hxx"
26 #include "MEDCouplingRefCountObject.hxx"
27 #include "InterpKernelException.hxx"
28
29 #include <vector>
30
31 namespace ParaMEDMEM
32 {
33   class MEDCouplingMesh;
34   class DataArrayDouble;
35   class TimeLabel;
36
37   class MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization : public TimeLabel
38   {
39   protected:
40     MEDCouplingTimeDiscretization();
41     MEDCouplingTimeDiscretization(const MEDCouplingTimeDiscretization& other, bool deepCpy);
42   public:
43     void updateTime() const;
44     virtual std::size_t getHeapMemorySize() const;
45     static MEDCouplingTimeDiscretization *New(TypeOfTimeDiscretization type);
46     void setTimeUnit(const char *unit) { _time_unit=unit; }
47     const char *getTimeUnit() const { return _time_unit.c_str(); }
48     virtual void copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other) throw(INTERP_KERNEL::Exception);
49     virtual void copyTinyStringsFrom(const MEDCouplingTimeDiscretization& other);
50     virtual void checkCoherency() const throw(INTERP_KERNEL::Exception);
51     virtual bool areCompatible(const MEDCouplingTimeDiscretization *other) const;
52     virtual bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const;
53     virtual bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const;
54     virtual bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const;
55     virtual bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const;
56     virtual bool isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const;
57     virtual bool isEqual(const MEDCouplingTimeDiscretization *other, double prec) const;
58     virtual bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const;
59     virtual MEDCouplingTimeDiscretization *buildNewTimeReprFromThis(TypeOfTimeDiscretization type, bool deepCpy) const;
60     virtual std::string getStringRepr() const = 0;
61     virtual TypeOfTimeDiscretization getEnum() const = 0;
62     virtual void synchronizeTimeWith(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception) = 0;
63     virtual MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const = 0;
64     virtual MEDCouplingTimeDiscretization *aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const = 0;
65     virtual MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const = 0;
66     virtual MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const = 0;
67     virtual MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const = 0;
68     virtual MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const = 0;
69     virtual MEDCouplingTimeDiscretization *min(const MEDCouplingTimeDiscretization *other) const = 0;
70     virtual MEDCouplingTimeDiscretization *add(const MEDCouplingTimeDiscretization *other) const = 0;
71     virtual void addEqual(const MEDCouplingTimeDiscretization *other) = 0;
72     virtual MEDCouplingTimeDiscretization *substract(const MEDCouplingTimeDiscretization *other) const = 0;
73     virtual void substractEqual(const MEDCouplingTimeDiscretization *other) = 0;
74     virtual MEDCouplingTimeDiscretization *multiply(const MEDCouplingTimeDiscretization *other) const = 0;
75     virtual void multiplyEqual(const MEDCouplingTimeDiscretization *other) = 0;
76     virtual MEDCouplingTimeDiscretization *divide(const MEDCouplingTimeDiscretization *other) const = 0;
77     virtual void divideEqual(const MEDCouplingTimeDiscretization *other) = 0;
78     virtual void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
79     virtual void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
80     virtual void getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const;
81     virtual void resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays);
82     virtual void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS);
83     virtual void getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const = 0;
84     virtual void getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const = 0;
85     virtual void finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD) = 0;
86     virtual MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const = 0;
87     void setTimeTolerance(double val) { _time_tolerance=val; }
88     double getTimeTolerance() const { return _time_tolerance; }
89     virtual void checkNoTimePresence() const throw(INTERP_KERNEL::Exception) = 0;
90     virtual void checkTimePresence(double time) const throw(INTERP_KERNEL::Exception) = 0;
91     virtual void setArray(DataArrayDouble *array, TimeLabel *owner);
92     virtual void setEndArray(DataArrayDouble *array, TimeLabel *owner);
93     virtual void setArrays(const std::vector<DataArrayDouble *>& arrays, TimeLabel *owner) throw(INTERP_KERNEL::Exception);
94     DataArrayDouble *getArray() { return _array; }
95     const DataArrayDouble *getArray() const { return _array; }
96     virtual const DataArrayDouble *getEndArray() const;
97     virtual DataArrayDouble *getEndArray();
98     virtual std::vector< const DataArrayDouble *> getArraysForTime(double time) const throw(INTERP_KERNEL::Exception) = 0;
99     virtual void getValueForTime(double time, const std::vector<double>& vals, double *res) const = 0; 
100     virtual void getArrays(std::vector<DataArrayDouble *>& arrays) const;
101     virtual bool isBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
102     virtual bool isStrictlyBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
103     double getTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { return getStartTime(iteration,order); }
104     virtual double getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) = 0;
105     virtual double getEndTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) = 0;
106     void setTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { setStartTime(time,iteration,order); }
107     void setIteration(int it) throw(INTERP_KERNEL::Exception) { setStartIteration(it); }
108     void setOrder(int order) throw(INTERP_KERNEL::Exception) { setStartOrder(order); }
109     void setTimeValue(double val) throw(INTERP_KERNEL::Exception) { setStartTimeValue(val); }
110     virtual void setStartIteration(int it) throw(INTERP_KERNEL::Exception) = 0;
111     virtual void setEndIteration(int it) throw(INTERP_KERNEL::Exception) = 0;
112     virtual void setStartOrder(int order) throw(INTERP_KERNEL::Exception) = 0;
113     virtual void setEndOrder(int order) throw(INTERP_KERNEL::Exception) = 0;
114     virtual void setStartTimeValue(double time) throw(INTERP_KERNEL::Exception) = 0;
115     virtual void setEndTimeValue(double time) throw(INTERP_KERNEL::Exception) = 0;
116     virtual void setStartTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) = 0;
117     virtual void setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) = 0;
118     virtual void getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception) = 0;
119     virtual void getValueOnDiscTime(int eltId, int iteration, int order, double *value) const throw(INTERP_KERNEL::Exception) = 0;
120     //
121     virtual MEDCouplingTimeDiscretization *doublyContractedProduct() const throw(INTERP_KERNEL::Exception);
122     virtual MEDCouplingTimeDiscretization *determinant() const throw(INTERP_KERNEL::Exception);
123     virtual MEDCouplingTimeDiscretization *eigenValues() const throw(INTERP_KERNEL::Exception);
124     virtual MEDCouplingTimeDiscretization *eigenVectors() const throw(INTERP_KERNEL::Exception);
125     virtual MEDCouplingTimeDiscretization *inverse() const throw(INTERP_KERNEL::Exception);
126     virtual MEDCouplingTimeDiscretization *trace() const throw(INTERP_KERNEL::Exception);
127     virtual MEDCouplingTimeDiscretization *deviator() const throw(INTERP_KERNEL::Exception);
128     virtual MEDCouplingTimeDiscretization *magnitude() const throw(INTERP_KERNEL::Exception);
129     virtual MEDCouplingTimeDiscretization *maxPerTuple() const throw(INTERP_KERNEL::Exception);
130     virtual MEDCouplingTimeDiscretization *keepSelectedComponents(const std::vector<int>& compoIds) const throw(INTERP_KERNEL::Exception);
131     virtual void setSelectedComponents(const MEDCouplingTimeDiscretization *other, const std::vector<int>& compoIds) throw(INTERP_KERNEL::Exception);
132     virtual void changeNbOfComponents(int newNbOfComp, double dftValue) throw(INTERP_KERNEL::Exception);
133     virtual void sortPerTuple(bool asc) throw(INTERP_KERNEL::Exception);
134     virtual void setUniformValue(int nbOfTuple, int nbOfCompo, double value);
135     virtual void applyLin(double a, double b, int compoId);
136     virtual void applyFunc(int nbOfComp, FunctionToEvaluate func);
137     virtual void applyFunc(int nbOfComp, const char *func);
138     virtual void applyFunc2(int nbOfComp, const char *func);
139     virtual void applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const char *func);
140     virtual void applyFunc(const char *func);
141     virtual void applyFuncFast32(const char *func);
142     virtual void applyFuncFast64(const char *func);
143     virtual void fillFromAnalytic(const DataArrayDouble *loc, int nbOfComp, FunctionToEvaluate func) throw(INTERP_KERNEL::Exception);
144     virtual void fillFromAnalytic(const DataArrayDouble *loc, int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception);
145     virtual void fillFromAnalytic2(const DataArrayDouble *loc, int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception);
146     virtual void fillFromAnalytic3(const DataArrayDouble *loc, int nbOfComp, const std::vector<std::string>& varsOrder, const char *func) throw(INTERP_KERNEL::Exception);
147     //
148     virtual ~MEDCouplingTimeDiscretization();
149   protected:
150     std::string _time_unit;
151     double _time_tolerance;
152     DataArrayDouble *_array;
153   protected:
154     static const double TIME_TOLERANCE_DFT;
155   };
156
157   class MEDCOUPLING_EXPORT MEDCouplingNoTimeLabel : public MEDCouplingTimeDiscretization
158   {
159   public:
160     MEDCouplingNoTimeLabel();
161     MEDCouplingNoTimeLabel(const MEDCouplingTimeDiscretization& other, bool deepCpy);
162     std::string getStringRepr() const;
163     TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; }
164     void synchronizeTimeWith(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception);
165     MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const;
166     MEDCouplingTimeDiscretization *aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const;
167     MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const;
168     MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const;
169     MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const;
170     MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const;
171     MEDCouplingTimeDiscretization *min(const MEDCouplingTimeDiscretization *other) const;
172     MEDCouplingTimeDiscretization *add(const MEDCouplingTimeDiscretization *other) const;
173     void addEqual(const MEDCouplingTimeDiscretization *other);
174     MEDCouplingTimeDiscretization *substract(const MEDCouplingTimeDiscretization *other) const;
175     void substractEqual(const MEDCouplingTimeDiscretization *other);
176     MEDCouplingTimeDiscretization *multiply(const MEDCouplingTimeDiscretization *other) const;
177     void multiplyEqual(const MEDCouplingTimeDiscretization *other);
178     MEDCouplingTimeDiscretization *divide(const MEDCouplingTimeDiscretization *other) const;
179     void divideEqual(const MEDCouplingTimeDiscretization *other);
180     bool isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const;
181     bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const;
182     bool areCompatible(const MEDCouplingTimeDiscretization *other) const;
183     bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const;
184     bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const;
185     bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const;
186     bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const;
187     MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const;
188     void checkNoTimePresence() const throw(INTERP_KERNEL::Exception) { }
189     void checkTimePresence(double time) const throw(INTERP_KERNEL::Exception);
190     std::vector< const DataArrayDouble *> getArraysForTime(double time) const throw(INTERP_KERNEL::Exception);
191     void getValueForTime(double time, const std::vector<double>& vals, double *res) const;
192     bool isBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
193     bool isStrictlyBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
194     double getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception);
195     double getEndTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception);
196     void setStartIteration(int it) throw(INTERP_KERNEL::Exception);
197     void setEndIteration(int it) throw(INTERP_KERNEL::Exception);
198     void setStartOrder(int order) throw(INTERP_KERNEL::Exception);
199     void setEndOrder(int order) throw(INTERP_KERNEL::Exception);
200     void setStartTimeValue(double time) throw(INTERP_KERNEL::Exception);
201     void setEndTimeValue(double time) throw(INTERP_KERNEL::Exception);
202     void setStartTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception);
203     void setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception);
204     void getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception);
205     void getValueOnDiscTime(int eltId, int iteration, int order, double *value) const throw(INTERP_KERNEL::Exception);
206     void getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const;
207     void getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const;
208     void finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD);
209   public:
210     static const TypeOfTimeDiscretization DISCRETIZATION=NO_TIME;
211     static const char REPR[];
212   private:
213     static const char EXCEPTION_MSG[];
214   };
215
216   class MEDCOUPLING_EXPORT MEDCouplingWithTimeStep : public MEDCouplingTimeDiscretization
217   {
218   protected:
219     MEDCouplingWithTimeStep(const MEDCouplingWithTimeStep& other, bool deepCpy);
220   public:
221     MEDCouplingWithTimeStep();
222     std::string getStringRepr() const;
223     void copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other) throw(INTERP_KERNEL::Exception);
224     TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; }
225     void synchronizeTimeWith(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception);
226     MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const;
227     MEDCouplingTimeDiscretization *aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const;
228     MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const;
229     MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const;
230     MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const;
231     MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const;
232     MEDCouplingTimeDiscretization *min(const MEDCouplingTimeDiscretization *other) const;
233     MEDCouplingTimeDiscretization *add(const MEDCouplingTimeDiscretization *other) const;
234     void addEqual(const MEDCouplingTimeDiscretization *other);
235     MEDCouplingTimeDiscretization *substract(const MEDCouplingTimeDiscretization *other) const;
236     void substractEqual(const MEDCouplingTimeDiscretization *other);
237     MEDCouplingTimeDiscretization *multiply(const MEDCouplingTimeDiscretization *other) const;
238     void multiplyEqual(const MEDCouplingTimeDiscretization *other);
239     MEDCouplingTimeDiscretization *divide(const MEDCouplingTimeDiscretization *other) const;
240     void divideEqual(const MEDCouplingTimeDiscretization *other);
241     bool isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const;
242     bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const;
243     bool areCompatible(const MEDCouplingTimeDiscretization *other) const;
244     bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const;
245     bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const;
246     bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const;
247     bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const;
248     void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
249     void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
250     void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS);
251     void getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const;
252     void getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const;
253     void finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD);
254     MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const;
255     void checkNoTimePresence() const throw(INTERP_KERNEL::Exception);
256     void checkTimePresence(double time) const throw(INTERP_KERNEL::Exception);
257     void setStartTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { _time=time; _iteration=iteration; _order=order; }
258     void setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { _time=time; _iteration=iteration; _order=order; }
259     double getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_iteration; order=_order; return _time; }
260     double getEndTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_iteration; order=_order; return _time; }
261     void setStartIteration(int it) throw(INTERP_KERNEL::Exception) { _iteration=it; }
262     void setEndIteration(int it) throw(INTERP_KERNEL::Exception) { _iteration=it; }
263     void setStartOrder(int order) throw(INTERP_KERNEL::Exception) { _order=order; }
264     void setEndOrder(int order) throw(INTERP_KERNEL::Exception) { _order=order; }
265     void setStartTimeValue(double time) throw(INTERP_KERNEL::Exception) { _time=time; }
266     void setEndTimeValue(double time) throw(INTERP_KERNEL::Exception) { _time=time; }
267     std::vector< const DataArrayDouble *> getArraysForTime(double time) const throw(INTERP_KERNEL::Exception);
268     void getValueForTime(double time, const std::vector<double>& vals, double *res) const;
269     void getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception);
270     void getValueOnDiscTime(int eltId, int iteration, int order, double *value) const throw(INTERP_KERNEL::Exception);
271   public:
272     static const TypeOfTimeDiscretization DISCRETIZATION=ONE_TIME;
273     static const char REPR[];
274   private:
275     static const char EXCEPTION_MSG[];
276   protected:
277     double _time;
278     int _iteration;
279     int _order;
280   };
281
282   class MEDCOUPLING_EXPORT MEDCouplingConstOnTimeInterval : public MEDCouplingTimeDiscretization
283   {
284   protected:
285     MEDCouplingConstOnTimeInterval(const MEDCouplingConstOnTimeInterval& other, bool deepCpy);
286   public:
287     MEDCouplingConstOnTimeInterval();
288     void copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other) throw(INTERP_KERNEL::Exception);
289     void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
290     void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
291     void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS);
292     void getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const;
293     void getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const;
294     void finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD);
295     MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const;
296     bool areCompatible(const MEDCouplingTimeDiscretization *other) const;
297     bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const;
298     bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const;
299     bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const;
300     bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const;
301     bool isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const;
302     bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const;
303     std::vector< const DataArrayDouble *> getArraysForTime(double time) const throw(INTERP_KERNEL::Exception);
304     void getValueForTime(double time, const std::vector<double>& vals, double *res) const;
305     void getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception);
306     void getValueOnDiscTime(int eltId, int iteration, int order, double *value) const throw(INTERP_KERNEL::Exception);
307     TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; }
308     void synchronizeTimeWith(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception);
309     std::string getStringRepr() const;
310     MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const;
311     MEDCouplingTimeDiscretization *aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const;
312     MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const;
313     MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const;
314     MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const;
315     MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const;
316     MEDCouplingTimeDiscretization *min(const MEDCouplingTimeDiscretization *other) const;
317     MEDCouplingTimeDiscretization *add(const MEDCouplingTimeDiscretization *other) const;
318     void addEqual(const MEDCouplingTimeDiscretization *other);
319     MEDCouplingTimeDiscretization *substract(const MEDCouplingTimeDiscretization *other) const;
320     void substractEqual(const MEDCouplingTimeDiscretization *other);
321     MEDCouplingTimeDiscretization *multiply(const MEDCouplingTimeDiscretization *other) const;
322     void multiplyEqual(const MEDCouplingTimeDiscretization *other);
323     MEDCouplingTimeDiscretization *divide(const MEDCouplingTimeDiscretization *other) const;
324     void divideEqual(const MEDCouplingTimeDiscretization *other);
325     void setStartTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { _start_time=time; _start_iteration=iteration; _start_order=order; }
326     void setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { _end_time=time; _end_iteration=iteration; _end_order=order; }
327     double getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_start_iteration; order=_start_order; return _start_time; }
328     double getEndTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_end_iteration; order=_end_order; return _end_time; }
329     void setStartIteration(int it) throw(INTERP_KERNEL::Exception) { _start_iteration=it; }
330     void setEndIteration(int it) throw(INTERP_KERNEL::Exception) { _end_iteration=it; }
331     void setStartOrder(int order) throw(INTERP_KERNEL::Exception) { _start_order=order; }
332     void setEndOrder(int order) throw(INTERP_KERNEL::Exception) { _end_order=order; }
333     void setStartTimeValue(double time) throw(INTERP_KERNEL::Exception) { _start_time=time; }
334     void setEndTimeValue(double time) throw(INTERP_KERNEL::Exception) { _end_time=time; }
335     void checkNoTimePresence() const throw(INTERP_KERNEL::Exception);
336     void checkTimePresence(double time) const throw(INTERP_KERNEL::Exception);
337   public:
338     static const TypeOfTimeDiscretization DISCRETIZATION=CONST_ON_TIME_INTERVAL;
339     static const char REPR[];
340   private:
341     static const char EXCEPTION_MSG[];
342   protected:
343     double _start_time;
344     double _end_time;
345     int _start_iteration;
346     int _end_iteration;
347     int _start_order;
348     int _end_order;
349   };
350
351   class MEDCOUPLING_EXPORT MEDCouplingTwoTimeSteps : public MEDCouplingTimeDiscretization
352   {
353   protected:
354     MEDCouplingTwoTimeSteps(const MEDCouplingTwoTimeSteps& other, bool deepCpy);
355     MEDCouplingTwoTimeSteps();
356     ~MEDCouplingTwoTimeSteps();
357   public:
358     void updateTime() const;
359     void synchronizeTimeWith(const MEDCouplingMesh *mesh) throw(INTERP_KERNEL::Exception);
360     std::size_t getHeapMemorySize() const;
361     void copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other) throw(INTERP_KERNEL::Exception);
362     void copyTinyStringsFrom(const MEDCouplingTimeDiscretization& other);
363     const DataArrayDouble *getEndArray() const;
364     DataArrayDouble *getEndArray();
365     void checkCoherency() const throw(INTERP_KERNEL::Exception);
366     bool isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const;
367     bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const;
368     void checkNoTimePresence() const throw(INTERP_KERNEL::Exception);
369     void checkTimePresence(double time) const throw(INTERP_KERNEL::Exception);
370     void getArrays(std::vector<DataArrayDouble *>& arrays) const;
371     void setEndArray(DataArrayDouble *array, TimeLabel *owner);
372     void setStartTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { _start_time=time; _start_iteration=iteration; _start_order=order; }
373     void setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { _end_time=time; _end_iteration=iteration; _end_order=order; }
374     double getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_start_iteration; order=_start_order; return _start_time; }
375     double getEndTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_end_iteration; order=_end_order; return _end_time; }
376     void setStartIteration(int it) throw(INTERP_KERNEL::Exception) { _start_iteration=it; }
377     void setEndIteration(int it) throw(INTERP_KERNEL::Exception) { _end_iteration=it; }
378     void setStartOrder(int order) throw(INTERP_KERNEL::Exception) { _start_order=order; }
379     void setEndOrder(int order) throw(INTERP_KERNEL::Exception) { _end_order=order; }
380     void setStartTimeValue(double time) throw(INTERP_KERNEL::Exception) { _start_time=time; }
381     void setEndTimeValue(double time) throw(INTERP_KERNEL::Exception) { _end_time=time; }
382     void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
383     void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
384     void getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const;
385     void resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays);
386     void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS);
387     void getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const;
388     void getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const;
389     void finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD);
390     std::vector< const DataArrayDouble *> getArraysForTime(double time) const throw(INTERP_KERNEL::Exception);
391     void setArrays(const std::vector<DataArrayDouble *>& arrays, TimeLabel *owner) throw(INTERP_KERNEL::Exception);
392   protected:
393     static const char EXCEPTION_MSG[];
394   protected:
395     double _start_time;
396     double _end_time;
397     int _start_iteration;
398     int _end_iteration;
399     int _start_order;
400     int _end_order;
401     DataArrayDouble *_end_array;
402   };
403
404   class MEDCOUPLING_EXPORT MEDCouplingLinearTime : public MEDCouplingTwoTimeSteps
405   {
406   protected:
407     MEDCouplingLinearTime(const MEDCouplingLinearTime& other, bool deepCpy);
408   public:
409     MEDCouplingLinearTime();
410     std::string getStringRepr() const;
411     TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; }
412     void checkCoherency() const throw(INTERP_KERNEL::Exception);
413     MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const;
414     bool areCompatible(const MEDCouplingTimeDiscretization *other) const;
415     bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const;
416     bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const;
417     bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const;
418     bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const;
419     void getValueForTime(double time, const std::vector<double>& vals, double *res) const;
420     void getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception);
421     void getValueOnDiscTime(int eltId, int iteration, int order, double *value) const throw(INTERP_KERNEL::Exception);
422     MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const;
423     MEDCouplingTimeDiscretization *aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const;
424     MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const;
425     MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const;
426     MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const;
427     MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const;
428     MEDCouplingTimeDiscretization *min(const MEDCouplingTimeDiscretization *other) const;
429     MEDCouplingTimeDiscretization *add(const MEDCouplingTimeDiscretization *other) const;
430     void addEqual(const MEDCouplingTimeDiscretization *other);
431     MEDCouplingTimeDiscretization *substract(const MEDCouplingTimeDiscretization *other) const;
432     void substractEqual(const MEDCouplingTimeDiscretization *other);
433     MEDCouplingTimeDiscretization *multiply(const MEDCouplingTimeDiscretization *other) const;
434     void multiplyEqual(const MEDCouplingTimeDiscretization *other);
435     MEDCouplingTimeDiscretization *divide(const MEDCouplingTimeDiscretization *other) const;
436     void divideEqual(const MEDCouplingTimeDiscretization *other);
437   public:
438     static const TypeOfTimeDiscretization DISCRETIZATION=LINEAR_TIME;
439     static const char REPR[];
440   };
441 }
442
443 #endif