1 // Copyright (C) 2007-2012 CEA/DEN, EDF R&D
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.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
20 #ifndef __PARAMEDMEM_MEDCOUPLINGTIMEDISCRETIZATION_HXX__
21 #define __PARAMEDMEM_MEDCOUPLINGTIMEDISCRETIZATION_HXX__
23 #include "MEDCoupling.hxx"
24 #include "MEDCouplingTimeLabel.hxx"
25 #include "MEDCouplingRefCountObject.hxx"
26 #include "InterpKernelException.hxx"
32 class DataArrayDouble;
35 class MEDCOUPLING_EXPORT MEDCouplingTimeDiscretization : public TimeLabel
38 MEDCouplingTimeDiscretization();
39 MEDCouplingTimeDiscretization(const MEDCouplingTimeDiscretization& other, bool deepCpy);
41 void updateTime() const;
42 static MEDCouplingTimeDiscretization *New(TypeOfTimeDiscretization type);
43 void setTimeUnit(const char *unit) { _time_unit=unit; }
44 const char *getTimeUnit() const { return _time_unit.c_str(); }
45 virtual void copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other) throw(INTERP_KERNEL::Exception);
46 virtual void copyTinyStringsFrom(const MEDCouplingTimeDiscretization& other);
47 virtual void checkCoherency() const throw(INTERP_KERNEL::Exception);
48 virtual bool areCompatible(const MEDCouplingTimeDiscretization *other) const;
49 virtual bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const;
50 virtual bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const;
51 virtual bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const;
52 virtual bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const;
53 virtual bool isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const;
54 virtual bool isEqual(const MEDCouplingTimeDiscretization *other, double prec) const;
55 virtual bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const;
56 virtual MEDCouplingTimeDiscretization *buildNewTimeReprFromThis(TypeOfTimeDiscretization type, bool deepCpy) const;
57 virtual std::string getStringRepr() const = 0;
58 virtual TypeOfTimeDiscretization getEnum() const = 0;
59 virtual MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const = 0;
60 virtual MEDCouplingTimeDiscretization *aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const = 0;
61 virtual MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const = 0;
62 virtual MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const = 0;
63 virtual MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const = 0;
64 virtual MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const = 0;
65 virtual MEDCouplingTimeDiscretization *min(const MEDCouplingTimeDiscretization *other) const = 0;
66 virtual MEDCouplingTimeDiscretization *add(const MEDCouplingTimeDiscretization *other) const = 0;
67 virtual void addEqual(const MEDCouplingTimeDiscretization *other) = 0;
68 virtual MEDCouplingTimeDiscretization *substract(const MEDCouplingTimeDiscretization *other) const = 0;
69 virtual void substractEqual(const MEDCouplingTimeDiscretization *other) = 0;
70 virtual MEDCouplingTimeDiscretization *multiply(const MEDCouplingTimeDiscretization *other) const = 0;
71 virtual void multiplyEqual(const MEDCouplingTimeDiscretization *other) = 0;
72 virtual MEDCouplingTimeDiscretization *divide(const MEDCouplingTimeDiscretization *other) const = 0;
73 virtual void divideEqual(const MEDCouplingTimeDiscretization *other) = 0;
74 virtual void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
75 virtual void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
76 virtual void getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const;
77 virtual void resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays);
78 virtual void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS);
79 virtual void getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const = 0;
80 virtual void getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const = 0;
81 virtual void finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD) = 0;
82 virtual MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const = 0;
83 void setTimeTolerance(double val) { _time_tolerance=val; }
84 double getTimeTolerance() const { return _time_tolerance; }
85 virtual void checkNoTimePresence() const throw(INTERP_KERNEL::Exception) = 0;
86 virtual void checkTimePresence(double time) const throw(INTERP_KERNEL::Exception) = 0;
87 virtual void setArray(DataArrayDouble *array, TimeLabel *owner);
88 virtual void setEndArray(DataArrayDouble *array, TimeLabel *owner);
89 virtual void setArrays(const std::vector<DataArrayDouble *>& arrays, TimeLabel *owner) throw(INTERP_KERNEL::Exception);
90 DataArrayDouble *getArray() { return _array; }
91 const DataArrayDouble *getArray() const { return _array; }
92 virtual const DataArrayDouble *getEndArray() const;
93 virtual DataArrayDouble *getEndArray();
94 virtual std::vector< const DataArrayDouble *> getArraysForTime(double time) const throw(INTERP_KERNEL::Exception) = 0;
95 virtual void getValueForTime(double time, const std::vector<double>& vals, double *res) const = 0;
96 virtual void getArrays(std::vector<DataArrayDouble *>& arrays) const;
97 virtual bool isBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
98 virtual bool isStrictlyBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
99 double getTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { return getStartTime(iteration,order); }
100 virtual double getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) = 0;
101 virtual double getEndTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) = 0;
102 void setTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { setStartTime(time,iteration,order); }
103 void setIteration(int it) throw(INTERP_KERNEL::Exception) { setStartIteration(it); }
104 void setOrder(int order) throw(INTERP_KERNEL::Exception) { setStartOrder(order); }
105 void setTimeValue(double val) throw(INTERP_KERNEL::Exception) { setStartTimeValue(val); }
106 virtual void setStartIteration(int it) throw(INTERP_KERNEL::Exception) = 0;
107 virtual void setEndIteration(int it) throw(INTERP_KERNEL::Exception) = 0;
108 virtual void setStartOrder(int order) throw(INTERP_KERNEL::Exception) = 0;
109 virtual void setEndOrder(int order) throw(INTERP_KERNEL::Exception) = 0;
110 virtual void setStartTimeValue(double time) throw(INTERP_KERNEL::Exception) = 0;
111 virtual void setEndTimeValue(double time) throw(INTERP_KERNEL::Exception) = 0;
112 virtual void setStartTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) = 0;
113 virtual void setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) = 0;
114 virtual void getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception) = 0;
115 virtual void getValueOnDiscTime(int eltId, int iteration, int order, double *value) const throw(INTERP_KERNEL::Exception) = 0;
117 virtual MEDCouplingTimeDiscretization *doublyContractedProduct() const throw(INTERP_KERNEL::Exception);
118 virtual MEDCouplingTimeDiscretization *determinant() const throw(INTERP_KERNEL::Exception);
119 virtual MEDCouplingTimeDiscretization *eigenValues() const throw(INTERP_KERNEL::Exception);
120 virtual MEDCouplingTimeDiscretization *eigenVectors() const throw(INTERP_KERNEL::Exception);
121 virtual MEDCouplingTimeDiscretization *inverse() const throw(INTERP_KERNEL::Exception);
122 virtual MEDCouplingTimeDiscretization *trace() const throw(INTERP_KERNEL::Exception);
123 virtual MEDCouplingTimeDiscretization *deviator() const throw(INTERP_KERNEL::Exception);
124 virtual MEDCouplingTimeDiscretization *magnitude() const throw(INTERP_KERNEL::Exception);
125 virtual MEDCouplingTimeDiscretization *maxPerTuple() const throw(INTERP_KERNEL::Exception);
126 virtual MEDCouplingTimeDiscretization *keepSelectedComponents(const std::vector<int>& compoIds) const throw(INTERP_KERNEL::Exception);
127 virtual void setSelectedComponents(const MEDCouplingTimeDiscretization *other, const std::vector<int>& compoIds) throw(INTERP_KERNEL::Exception);
128 virtual void changeNbOfComponents(int newNbOfComp, double dftValue) throw(INTERP_KERNEL::Exception);
129 virtual void sortPerTuple(bool asc) throw(INTERP_KERNEL::Exception);
130 virtual void setUniformValue(int nbOfTuple, int nbOfCompo, double value);
131 virtual void applyLin(double a, double b, int compoId);
132 virtual void applyFunc(int nbOfComp, FunctionToEvaluate func);
133 virtual void applyFunc(int nbOfComp, const char *func);
134 virtual void applyFunc2(int nbOfComp, const char *func);
135 virtual void applyFunc3(int nbOfComp, const std::vector<std::string>& varsOrder, const char *func);
136 virtual void applyFunc(const char *func);
137 virtual void applyFuncFast32(const char *func);
138 virtual void applyFuncFast64(const char *func);
139 virtual void fillFromAnalytic(const DataArrayDouble *loc, int nbOfComp, FunctionToEvaluate func) throw(INTERP_KERNEL::Exception);
140 virtual void fillFromAnalytic(const DataArrayDouble *loc, int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception);
141 virtual void fillFromAnalytic2(const DataArrayDouble *loc, int nbOfComp, const char *func) throw(INTERP_KERNEL::Exception);
142 virtual void fillFromAnalytic3(const DataArrayDouble *loc, int nbOfComp, const std::vector<std::string>& varsOrder, const char *func) throw(INTERP_KERNEL::Exception);
144 virtual ~MEDCouplingTimeDiscretization();
146 std::string _time_unit;
147 double _time_tolerance;
148 DataArrayDouble *_array;
150 static const double TIME_TOLERANCE_DFT;
153 class MEDCOUPLING_EXPORT MEDCouplingNoTimeLabel : public MEDCouplingTimeDiscretization
156 MEDCouplingNoTimeLabel();
157 MEDCouplingNoTimeLabel(const MEDCouplingTimeDiscretization& other, bool deepCpy);
158 std::string getStringRepr() const;
159 TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; }
160 MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const;
161 MEDCouplingTimeDiscretization *aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const;
162 MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const;
163 MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const;
164 MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const;
165 MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const;
166 MEDCouplingTimeDiscretization *min(const MEDCouplingTimeDiscretization *other) const;
167 MEDCouplingTimeDiscretization *add(const MEDCouplingTimeDiscretization *other) const;
168 void addEqual(const MEDCouplingTimeDiscretization *other);
169 MEDCouplingTimeDiscretization *substract(const MEDCouplingTimeDiscretization *other) const;
170 void substractEqual(const MEDCouplingTimeDiscretization *other);
171 MEDCouplingTimeDiscretization *multiply(const MEDCouplingTimeDiscretization *other) const;
172 void multiplyEqual(const MEDCouplingTimeDiscretization *other);
173 MEDCouplingTimeDiscretization *divide(const MEDCouplingTimeDiscretization *other) const;
174 void divideEqual(const MEDCouplingTimeDiscretization *other);
175 bool isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const;
176 bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const;
177 bool areCompatible(const MEDCouplingTimeDiscretization *other) const;
178 bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const;
179 bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const;
180 bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const;
181 bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const;
182 MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const;
183 void checkNoTimePresence() const throw(INTERP_KERNEL::Exception) { }
184 void checkTimePresence(double time) const throw(INTERP_KERNEL::Exception);
185 std::vector< const DataArrayDouble *> getArraysForTime(double time) const throw(INTERP_KERNEL::Exception);
186 void getValueForTime(double time, const std::vector<double>& vals, double *res) const;
187 bool isBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
188 bool isStrictlyBefore(const MEDCouplingTimeDiscretization *other) const throw(INTERP_KERNEL::Exception);
189 double getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception);
190 double getEndTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception);
191 void setStartIteration(int it) throw(INTERP_KERNEL::Exception);
192 void setEndIteration(int it) throw(INTERP_KERNEL::Exception);
193 void setStartOrder(int order) throw(INTERP_KERNEL::Exception);
194 void setEndOrder(int order) throw(INTERP_KERNEL::Exception);
195 void setStartTimeValue(double time) throw(INTERP_KERNEL::Exception);
196 void setEndTimeValue(double time) throw(INTERP_KERNEL::Exception);
197 void setStartTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception);
198 void setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception);
199 void getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception);
200 void getValueOnDiscTime(int eltId, int iteration, int order, double *value) const throw(INTERP_KERNEL::Exception);
201 void getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const;
202 void getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const;
203 void finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD);
205 static const TypeOfTimeDiscretization DISCRETIZATION=NO_TIME;
206 static const char REPR[];
208 static const char EXCEPTION_MSG[];
211 class MEDCOUPLING_EXPORT MEDCouplingWithTimeStep : public MEDCouplingTimeDiscretization
214 MEDCouplingWithTimeStep(const MEDCouplingWithTimeStep& other, bool deepCpy);
216 MEDCouplingWithTimeStep();
217 std::string getStringRepr() const;
218 void copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other) throw(INTERP_KERNEL::Exception);
219 TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; }
220 MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const;
221 MEDCouplingTimeDiscretization *aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const;
222 MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const;
223 MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const;
224 MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const;
225 MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const;
226 MEDCouplingTimeDiscretization *min(const MEDCouplingTimeDiscretization *other) const;
227 MEDCouplingTimeDiscretization *add(const MEDCouplingTimeDiscretization *other) const;
228 void addEqual(const MEDCouplingTimeDiscretization *other);
229 MEDCouplingTimeDiscretization *substract(const MEDCouplingTimeDiscretization *other) const;
230 void substractEqual(const MEDCouplingTimeDiscretization *other);
231 MEDCouplingTimeDiscretization *multiply(const MEDCouplingTimeDiscretization *other) const;
232 void multiplyEqual(const MEDCouplingTimeDiscretization *other);
233 MEDCouplingTimeDiscretization *divide(const MEDCouplingTimeDiscretization *other) const;
234 void divideEqual(const MEDCouplingTimeDiscretization *other);
235 bool isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const;
236 bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const;
237 bool areCompatible(const MEDCouplingTimeDiscretization *other) const;
238 bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const;
239 bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const;
240 bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const;
241 bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const;
242 void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
243 void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
244 void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS);
245 void getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const;
246 void getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const;
247 void finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD);
248 MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const;
249 void checkNoTimePresence() const throw(INTERP_KERNEL::Exception);
250 void checkTimePresence(double time) const throw(INTERP_KERNEL::Exception);
251 void setStartTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { _time=time; _iteration=iteration; _order=order; }
252 void setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { _time=time; _iteration=iteration; _order=order; }
253 double getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_iteration; order=_order; return _time; }
254 double getEndTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_iteration; order=_order; return _time; }
255 void setStartIteration(int it) throw(INTERP_KERNEL::Exception) { _iteration=it; }
256 void setEndIteration(int it) throw(INTERP_KERNEL::Exception) { _iteration=it; }
257 void setStartOrder(int order) throw(INTERP_KERNEL::Exception) { _order=order; }
258 void setEndOrder(int order) throw(INTERP_KERNEL::Exception) { _order=order; }
259 void setStartTimeValue(double time) throw(INTERP_KERNEL::Exception) { _time=time; }
260 void setEndTimeValue(double time) throw(INTERP_KERNEL::Exception) { _time=time; }
261 std::vector< const DataArrayDouble *> getArraysForTime(double time) const throw(INTERP_KERNEL::Exception);
262 void getValueForTime(double time, const std::vector<double>& vals, double *res) const;
263 void getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception);
264 void getValueOnDiscTime(int eltId, int iteration, int order, double *value) const throw(INTERP_KERNEL::Exception);
266 static const TypeOfTimeDiscretization DISCRETIZATION=ONE_TIME;
267 static const char REPR[];
269 static const char EXCEPTION_MSG[];
276 class MEDCOUPLING_EXPORT MEDCouplingConstOnTimeInterval : public MEDCouplingTimeDiscretization
279 MEDCouplingConstOnTimeInterval(const MEDCouplingConstOnTimeInterval& other, bool deepCpy);
281 MEDCouplingConstOnTimeInterval();
282 void copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other) throw(INTERP_KERNEL::Exception);
283 void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
284 void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
285 void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS);
286 void getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const;
287 void getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const;
288 void finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD);
289 MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const;
290 bool areCompatible(const MEDCouplingTimeDiscretization *other) const;
291 bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const;
292 bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const;
293 bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const;
294 bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const;
295 bool isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const;
296 bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const;
297 std::vector< const DataArrayDouble *> getArraysForTime(double time) const throw(INTERP_KERNEL::Exception);
298 void getValueForTime(double time, const std::vector<double>& vals, double *res) const;
299 void getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception);
300 void getValueOnDiscTime(int eltId, int iteration, int order, double *value) const throw(INTERP_KERNEL::Exception);
301 TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; }
302 std::string getStringRepr() const;
303 MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const;
304 MEDCouplingTimeDiscretization *aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const;
305 MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const;
306 MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const;
307 MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const;
308 MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const;
309 MEDCouplingTimeDiscretization *min(const MEDCouplingTimeDiscretization *other) const;
310 MEDCouplingTimeDiscretization *add(const MEDCouplingTimeDiscretization *other) const;
311 void addEqual(const MEDCouplingTimeDiscretization *other);
312 MEDCouplingTimeDiscretization *substract(const MEDCouplingTimeDiscretization *other) const;
313 void substractEqual(const MEDCouplingTimeDiscretization *other);
314 MEDCouplingTimeDiscretization *multiply(const MEDCouplingTimeDiscretization *other) const;
315 void multiplyEqual(const MEDCouplingTimeDiscretization *other);
316 MEDCouplingTimeDiscretization *divide(const MEDCouplingTimeDiscretization *other) const;
317 void divideEqual(const MEDCouplingTimeDiscretization *other);
318 void setStartTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { _start_time=time; _start_iteration=iteration; _start_order=order; }
319 void setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { _end_time=time; _end_iteration=iteration; _end_order=order; }
320 double getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_start_iteration; order=_start_order; return _start_time; }
321 double getEndTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_end_iteration; order=_end_order; return _end_time; }
322 void setStartIteration(int it) throw(INTERP_KERNEL::Exception) { _start_iteration=it; }
323 void setEndIteration(int it) throw(INTERP_KERNEL::Exception) { _end_iteration=it; }
324 void setStartOrder(int order) throw(INTERP_KERNEL::Exception) { _start_order=order; }
325 void setEndOrder(int order) throw(INTERP_KERNEL::Exception) { _end_order=order; }
326 void setStartTimeValue(double time) throw(INTERP_KERNEL::Exception) { _start_time=time; }
327 void setEndTimeValue(double time) throw(INTERP_KERNEL::Exception) { _end_time=time; }
328 void checkNoTimePresence() const throw(INTERP_KERNEL::Exception);
329 void checkTimePresence(double time) const throw(INTERP_KERNEL::Exception);
331 static const TypeOfTimeDiscretization DISCRETIZATION=CONST_ON_TIME_INTERVAL;
332 static const char REPR[];
334 static const char EXCEPTION_MSG[];
338 int _start_iteration;
344 class MEDCOUPLING_EXPORT MEDCouplingTwoTimeSteps : public MEDCouplingTimeDiscretization
347 MEDCouplingTwoTimeSteps(const MEDCouplingTwoTimeSteps& other, bool deepCpy);
348 MEDCouplingTwoTimeSteps();
349 ~MEDCouplingTwoTimeSteps();
351 void updateTime() const;
352 void copyTinyAttrFrom(const MEDCouplingTimeDiscretization& other) throw(INTERP_KERNEL::Exception);
353 void copyTinyStringsFrom(const MEDCouplingTimeDiscretization& other);
354 const DataArrayDouble *getEndArray() const;
355 DataArrayDouble *getEndArray();
356 void checkCoherency() const throw(INTERP_KERNEL::Exception);
357 bool isEqualIfNotWhy(const MEDCouplingTimeDiscretization *other, double prec, std::string& reason) const;
358 bool isEqualWithoutConsideringStr(const MEDCouplingTimeDiscretization *other, double prec) const;
359 void checkNoTimePresence() const throw(INTERP_KERNEL::Exception);
360 void checkTimePresence(double time) const throw(INTERP_KERNEL::Exception);
361 void getArrays(std::vector<DataArrayDouble *>& arrays) const;
362 void setEndArray(DataArrayDouble *array, TimeLabel *owner);
363 void setStartTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { _start_time=time; _start_iteration=iteration; _start_order=order; }
364 void setEndTime(double time, int iteration, int order) throw(INTERP_KERNEL::Exception) { _end_time=time; _end_iteration=iteration; _end_order=order; }
365 double getStartTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_start_iteration; order=_start_order; return _start_time; }
366 double getEndTime(int& iteration, int& order) const throw(INTERP_KERNEL::Exception) { iteration=_end_iteration; order=_end_order; return _end_time; }
367 void setStartIteration(int it) throw(INTERP_KERNEL::Exception) { _start_iteration=it; }
368 void setEndIteration(int it) throw(INTERP_KERNEL::Exception) { _end_iteration=it; }
369 void setStartOrder(int order) throw(INTERP_KERNEL::Exception) { _start_order=order; }
370 void setEndOrder(int order) throw(INTERP_KERNEL::Exception) { _end_order=order; }
371 void setStartTimeValue(double time) throw(INTERP_KERNEL::Exception) { _start_time=time; }
372 void setEndTimeValue(double time) throw(INTERP_KERNEL::Exception) { _end_time=time; }
373 void getTinySerializationIntInformation(std::vector<int>& tinyInfo) const;
374 void getTinySerializationDbleInformation(std::vector<double>& tinyInfo) const;
375 void getTinySerializationStrInformation(std::vector<std::string>& tinyInfo) const;
376 void resizeForUnserialization(const std::vector<int>& tinyInfoI, std::vector<DataArrayDouble *>& arrays);
377 void finishUnserialization(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD, const std::vector<std::string>& tinyInfoS);
378 void getTinySerializationIntInformation2(std::vector<int>& tinyInfo) const;
379 void getTinySerializationDbleInformation2(std::vector<double>& tinyInfo) const;
380 void finishUnserialization2(const std::vector<int>& tinyInfoI, const std::vector<double>& tinyInfoD);
381 std::vector< const DataArrayDouble *> getArraysForTime(double time) const throw(INTERP_KERNEL::Exception);
382 void setArrays(const std::vector<DataArrayDouble *>& arrays, TimeLabel *owner) throw(INTERP_KERNEL::Exception);
384 static const char EXCEPTION_MSG[];
388 int _start_iteration;
392 DataArrayDouble *_end_array;
395 class MEDCOUPLING_EXPORT MEDCouplingLinearTime : public MEDCouplingTwoTimeSteps
398 MEDCouplingLinearTime(const MEDCouplingLinearTime& other, bool deepCpy);
400 MEDCouplingLinearTime();
401 std::string getStringRepr() const;
402 TypeOfTimeDiscretization getEnum() const { return DISCRETIZATION; }
403 void checkCoherency() const throw(INTERP_KERNEL::Exception);
404 MEDCouplingTimeDiscretization *performCpy(bool deepCpy) const;
405 bool areCompatible(const MEDCouplingTimeDiscretization *other) const;
406 bool areStrictlyCompatible(const MEDCouplingTimeDiscretization *other, std::string& reason) const;
407 bool areStrictlyCompatibleForMul(const MEDCouplingTimeDiscretization *other) const;
408 bool areStrictlyCompatibleForDiv(const MEDCouplingTimeDiscretization *other) const;
409 bool areCompatibleForMeld(const MEDCouplingTimeDiscretization *other) const;
410 void getValueForTime(double time, const std::vector<double>& vals, double *res) const;
411 void getValueOnTime(int eltId, double time, double *value) const throw(INTERP_KERNEL::Exception);
412 void getValueOnDiscTime(int eltId, int iteration, int order, double *value) const throw(INTERP_KERNEL::Exception);
413 MEDCouplingTimeDiscretization *aggregate(const MEDCouplingTimeDiscretization *other) const;
414 MEDCouplingTimeDiscretization *aggregate(const std::vector<const MEDCouplingTimeDiscretization *>& other) const;
415 MEDCouplingTimeDiscretization *meld(const MEDCouplingTimeDiscretization *other) const;
416 MEDCouplingTimeDiscretization *dot(const MEDCouplingTimeDiscretization *other) const;
417 MEDCouplingTimeDiscretization *crossProduct(const MEDCouplingTimeDiscretization *other) const;
418 MEDCouplingTimeDiscretization *max(const MEDCouplingTimeDiscretization *other) const;
419 MEDCouplingTimeDiscretization *min(const MEDCouplingTimeDiscretization *other) const;
420 MEDCouplingTimeDiscretization *add(const MEDCouplingTimeDiscretization *other) const;
421 void addEqual(const MEDCouplingTimeDiscretization *other);
422 MEDCouplingTimeDiscretization *substract(const MEDCouplingTimeDiscretization *other) const;
423 void substractEqual(const MEDCouplingTimeDiscretization *other);
424 MEDCouplingTimeDiscretization *multiply(const MEDCouplingTimeDiscretization *other) const;
425 void multiplyEqual(const MEDCouplingTimeDiscretization *other);
426 MEDCouplingTimeDiscretization *divide(const MEDCouplingTimeDiscretization *other) const;
427 void divideEqual(const MEDCouplingTimeDiscretization *other);
429 static const TypeOfTimeDiscretization DISCRETIZATION=LINEAR_TIME;
430 static const char REPR[];