Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
ITimeHistoryMng.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* ITimeHistoryMng.h (C) 2000-2025 */
9/* */
10/* Interface of the class managing a history of values. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_ITIMEHISTORYMNG_H
13#define ARCANE_CORE_ITIMEHISTORYMNG_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
19#include "arcane/utils/FatalErrorException.h"
20
21/*---------------------------------------------------------------------------*/
22/*---------------------------------------------------------------------------*/
23
24namespace Arcane
25{
26
27/*---------------------------------------------------------------------------*/
28/*---------------------------------------------------------------------------*/
29
30/*!
31 * Class containing the arguments for the user methods 'addValue'.
32 */
34{
35 public:
36
37 /*!
38 * \brief Constructor with three parameters.
39 *
40 * \param name The name of the curve.
41 * \param end_time Should the value be written at our iteration or at our iteration-1?
42 * \param subdomain_id The ID of the subdomain that must save the value (-1 for global).
43 */
44 TimeHistoryAddValueArg(const String& name, bool end_time, Integer subdomain_id)
45 : m_name(name)
46 , m_end_time(end_time)
47 , m_subdomain_id(subdomain_id)
48 {}
49
50 /*!
51 * \brief Constructor with two parameters.
52 *
53 * The value will be saved globally, and not on a specific subdomain.
54 *
55 * \param name The name of the curve.
56 * \param end_time Should the value be written at our iteration or at our iteration-1?
57 */
58 TimeHistoryAddValueArg(const String& name, bool end_time)
59 : TimeHistoryAddValueArg(name, end_time, NULL_SUB_DOMAIN_ID)
60 {}
61
62 /*!
63 * \brief Constructor with one parameter.
64 *
65 * The value will be saved globally, and not on a specific subdomain.
66 * The value will be saved at our iteration.
67 *
68 * \param name The name of the curve.
69 */
70 explicit TimeHistoryAddValueArg(const String& name)
71 : TimeHistoryAddValueArg(name, true)
72 {}
73
74 public:
75
76 const String& name() const { return m_name; }
77 bool endTime() const { return m_end_time; }
78 bool isLocal() const { return m_subdomain_id != NULL_SUB_DOMAIN_ID; }
79 Integer localSubDomainId() const { return m_subdomain_id; }
80
81 private:
82
83 String m_name;
84 bool m_end_time;
85 Integer m_subdomain_id;
86};
87
88/*---------------------------------------------------------------------------*/
89/*---------------------------------------------------------------------------*/
90
94class ITimeHistoryMngInternal;
96
97/*---------------------------------------------------------------------------*/
98/*---------------------------------------------------------------------------*/
99/*!
100 * \brief Class managing a history of values.
101 *
102 The history manager manages the history of a set of values over time.
103
104 The history is based on iterations (VariablesCommon::globalIteration()).
105 For each iteration, it is possible to save a value using the addValue()
106 methods. It is not mandatory to have a value for every iteration. When
107 several addValue() calls are made for the same history at the same
108 iteration, only the last value is taken into account.
109
110 Each history is associated with a name, which is the name of the file
111 where the list of values will be saved.
112
113 Only the instance associated with the subdomain where
114 parallelMng()->isMasterIO() is true saves the values. For others, calls
115 to addValue() have no effect.
116
117 Values are only saved if active() is true. It is possible to change the
118 activation status by calling isActive().
119
120 In debug mode, all histories are saved at every time step.
121 In normal execution, this set is saved every \a n iterations, \a n being
122 given by the dataset option <module-main/time-history-iteration-step>.
123 In any case, an output is performed at the end of the execution.
124
125 The format of these files depends on the implementation.
126
127 \since 0.4.38
128 */
130{
131 public:
132
133 virtual ~ITimeHistoryMng() = default; //!< Frees resources
134
135 public:
136
137 // TODO Deprecated
138 /*! \brief Adds the value \a value to the history \a name.
139 *
140 * \deprecated This method is deprecated and is replaced by using the
141 * GlobalTimeHistoryAdder object.
142 *
143 * The value is that at the end time of the iteration if \a end_time is true,
144 * at the beginning otherwise.
145 * the boolean is_local indicates whether the curve is specific to the
146 * process or not, in order to be able to write curves even by non io_master
147 * procs when the ARCANE_ENABLE_NON_IO_MASTER_CURVES variable is set.
148 */
149 virtual void addValue(const String& name, Real value, bool end_time = true, bool is_local = false) = 0;
150 /*! \brief Adds the value \a value to the history \a name.
151 *
152 * \deprecated This method is deprecated and is replaced by using the
153 * GlobalTimeHistoryAdder object.
154 *
155 * The value is that at the end time of the iteration if \a end_time is true,
156 * at the beginning otherwise.
157 * the boolean is_local indicates whether the curve is specific to the
158 * process or not, in order to be able to write curves even by non io_master
159 * procs when the ARCANE_ENABLE_NON_IO_MASTER_CURVES variable is set.
160 */
161 virtual void addValue(const String& name, Int32 value, bool end_time = true, bool is_local = false) = 0;
162 /*! Adds the value \a value to the history \a name.
163 *
164 * \deprecated This method is deprecated and is replaced by using the
165 * GlobalTimeHistoryAdder object.
166 *
167 * The value is that at the end time of the iteration if \a end_time is true,
168 * at the beginning otherwise.
169 * the boolean is_local indicates whether the curve is specific to the process
170 * or not, in order to be able to write curves even by non io_master procs
171 * when the ARCANE_ENABLE_NON_IO_MASTER_CURVES variable is set.
172 */
173 virtual void addValue(const String& name, Int64 value, bool end_time = true, bool is_local = false) = 0;
174 /*! \brief Adds the value \a value to the history \a name.
175 *
176 * \deprecated This method is deprecated and is replaced by using the
177 * GlobalTimeHistoryAdder object.
178 *
179 * The number of elements of \a value must be constant over time.
180 * The value is that at the end time of the iteration if \a end_time is true,
181 * at the beginning otherwise.
182 * the boolean is_local indicates whether the curve is specific to the process
183 * or not, in order to be able to write curves even by non io_master procs when
184 * the ARCANE_ENABLE_NON_IO_MASTER_CURVES variable is set.
185 */
186 virtual void addValue(const String& name, RealConstArrayView value, bool end_time = true, bool is_local = false) = 0;
187 /*! \brief Adds the value \a value to the history \a name.
188 *
189 * \deprecated This method is deprecated and is replaced by using the
190 * GlobalTimeHistoryAdder object.
191 *
192 * The number of elements of \a value must be constant over time.
193 * The value is that at the end time of the iteration if \a end_time is true,
194 * at the beginning otherwise.
195 * the boolean is_local indicates whether the curve is specific to the process
196 * or not, in order to be able to write curves even by non io_master procs when
197 * the ARCANE_ENABLE_NON_IO_MASTER_CURVES variable is set.
198 */
199 virtual void addValue(const String& name, Int32ConstArrayView value, bool end_time = true, bool is_local = false) = 0;
200 /*! Adds the value \a value to the history \a name.
201 *
202 * \deprecated This method is deprecated and is replaced by using the
203 * GlobalTimeHistoryAdder object.
204 *
205 * The number of elements of \a value must be constant over time.
206 * The value is that at the end time of the iteration if \a end_time is true,
207 * at the beginning otherwise.
208 * the boolean is_local indicates whether the curve is specific to the process
209 * or not, in order to be able to write curves even by non io_master procs when
210 * the ARCANE_ENABLE_NON_IO_MASTER_CURVES variable is set.
211 */
212 virtual void addValue(const String& name, Int64ConstArrayView value, bool end_time = true, bool is_local = false) = 0;
213
214 public:
215
216 virtual void timeHistoryBegin() = 0;
217 virtual void timeHistoryEnd() = 0;
218 virtual void timeHistoryInit() = 0;
219 virtual void timeHistoryStartInit() = 0;
220 virtual void timeHistoryContinueInit() = 0;
221 virtual void timeHistoryRestore() = 0;
222
223 public:
224
225 //! Adds a writer
226 virtual ARCANE_DEPRECATED void addCurveWriter(ITimeHistoryCurveWriter* writer)
227 {
228 ARCANE_UNUSED(writer);
229 ARCANE_FATAL("No longer supported. Use 'ITimeHistoryCurveWriter2' interface");
230 }
231
232 //! Removes a writer
233 virtual ARCANE_DEPRECATED void removeCurveWriter(ITimeHistoryCurveWriter* writer)
234 {
235 ARCANE_UNUSED(writer);
236 ARCANE_FATAL("No longer supported. Use 'ITimeHistoryCurveWriter2' interface");
237 }
238
239 //! Adds a writer
240 virtual void addCurveWriter(ITimeHistoryCurveWriter2* writer) = 0;
241
242 //! Removes a writer
244
245 //! Removes the writer with name \a name
246 virtual void removeCurveWriter(const String& name) = 0;
247
248 public:
249
250 /*!
251 * \internal
252 * \brief Saves the history.
253 *
254 * This consists of calling dumpCurves() for each registered writer.
255 */
256 virtual void dumpHistory(bool is_verbose) = 0;
257
258 /*!
259 * \brief Uses the writer \a writer to output all curves.
260 *
261 * The output path is the current directory.
262 */
263 virtual void dumpCurves(ITimeHistoryCurveWriter2* writer) = 0;
264
265 /*!
266 * \brief Indicates the activation status.
267 *
268 * The addValue() functions are only considered if the instance
269 * is active. Otherwise, calls to addValue() are
270 * ignored.
271 */
272 virtual bool active() const = 0;
273
274 /*!
275 * \brief Sets the activation status.
276 * \sa active().
277 */
278 virtual void setActive(bool is_active) = 0;
279
280 /*!
281 * \brief Applies the transformation \a v to all curves.
282 */
284
285 /*!
286 * \brief Indicates the output activation status.
287 *
288 * The dumpHistory() function is inactive
289 * if isDumpActive() is false.
290 */
291 virtual bool isDumpActive() const = 0;
292
293 /*!
294 * \brief Sets the output activation status.
295 */
296 virtual void setDumpActive(bool is_active) = 0;
297
298 /*!
299 * \brief Returns a boolean indicating if the history is compressed
300 */
301 virtual bool isShrinkActive() const = 0;
302
303 /*!
304 * \brief Sets the boolean indicating if the history is compressed
305 */
306 virtual void setShrinkActive(bool is_active) = 0;
307
308 public:
309
310 //! Internal Arcane API
311 virtual ITimeHistoryMngInternal* _internalApi() { ARCANE_FATAL("Invalid usage"); };
312};
313
314/*---------------------------------------------------------------------------*/
315/*---------------------------------------------------------------------------*/
316
317} // namespace Arcane
318
319/*---------------------------------------------------------------------------*/
320/*---------------------------------------------------------------------------*/
321
322#endif
#define ARCANE_FATAL(...)
Macro throwing a FatalErrorException.
Declarations of Arcane's general types.
Declarations of types used in Arcane.
Class interface allowing the addition of one or more values to a value history.
Class managing a history of values.
virtual void removeCurveWriter(ITimeHistoryCurveWriter2 *writer)=0
Removes a writer.
virtual void dumpCurves(ITimeHistoryCurveWriter2 *writer)=0
Uses the writer writer to output all curves.
virtual bool isDumpActive() const =0
Indicates the output activation status.
virtual void setShrinkActive(bool is_active)=0
Sets the boolean indicating if the history is compressed.
virtual void addValue(const String &name, Real value, bool end_time=true, bool is_local=false)=0
Adds the value value to the history name.
virtual void addValue(const String &name, RealConstArrayView value, bool end_time=true, bool is_local=false)=0
Adds the value value to the history name.
virtual ARCANE_DEPRECATED void removeCurveWriter(ITimeHistoryCurveWriter *writer)
Removes a writer.
virtual void addValue(const String &name, Int64ConstArrayView value, bool end_time=true, bool is_local=false)=0
virtual void setDumpActive(bool is_active)=0
Sets the output activation status.
virtual bool isShrinkActive() const =0
Returns a boolean indicating if the history is compressed.
virtual ~ITimeHistoryMng()=default
Frees resources.
virtual void setActive(bool is_active)=0
Sets the activation status.
virtual void addCurveWriter(ITimeHistoryCurveWriter2 *writer)=0
Adds a writer.
virtual void addValue(const String &name, Int64 value, bool end_time=true, bool is_local=false)=0
virtual void applyTransformation(ITimeHistoryTransformer *v)=0
Applies the transformation v to all curves.
virtual void removeCurveWriter(const String &name)=0
Removes the writer with name name.
virtual void addValue(const String &name, Int32ConstArrayView value, bool end_time=true, bool is_local=false)=0
Adds the value value to the history name.
virtual void addValue(const String &name, Int32 value, bool end_time=true, bool is_local=false)=0
Adds the value value to the history name.
virtual ARCANE_DEPRECATED void addCurveWriter(ITimeHistoryCurveWriter *writer)
Adds a writer.
virtual bool active() const =0
Indicates the activation status.
virtual ITimeHistoryMngInternal * _internalApi()
Internal Arcane API.
Interface of an object transforming history curves.
TimeHistoryAddValueArg(const String &name, bool end_time, Integer subdomain_id)
Constructor with three parameters.
TimeHistoryAddValueArg(const String &name)
Constructor with one parameter.
TimeHistoryAddValueArg(const String &name, bool end_time)
Constructor with two parameters.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
std::int64_t Int64
Signed integer type of 64 bits.
Int32 Integer
Type representing an integer.
ConstArrayView< Int32 > Int32ConstArrayView
C equivalent of a 1D array of 32-bit integers.
Definition UtilsTypes.h:482
ConstArrayView< Int64 > Int64ConstArrayView
C equivalent of a 1D array of 64-bit integers.
Definition UtilsTypes.h:480
double Real
Type representing a real number.
std::int32_t Int32
Signed integer type of 32 bits.
ConstArrayView< Real > RealConstArrayView
C equivalent of a 1D array of reals.
Definition UtilsTypes.h:488