Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
IVariableMng.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/* IVariableMng.h (C) 2000-2023 */
9/* */
10/* Variable manager interface. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_IVARIABLEMNG_H
13#define ARCANE_CORE_IVARIABLEMNG_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
18
19/*---------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22namespace Arcane
23{
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28class IVariable;
29class IVariableFilter;
30class VariableInfo;
31class MeshVariable;
32class IModule;
33class IParallelMng;
34class IDataReader;
35class IDataWriter;
36class IObservable;
41class VariableRef;
42class IMesh;
45class IVariableMngInternal;
46
47/*---------------------------------------------------------------------------*/
48/*---------------------------------------------------------------------------*/
49
50/*!
51 * \brief Variable manager interface.
52 *
53 * This manager contains the list of variables declared in the
54 * associated sub-domain \a subDomain(). It maintains the list of variables
55 * and allows them to be read or written.
56 */
58{
59 public:
60
61 virtual ~IVariableMng() = default; //!< Frees resources.
62
63 public:
64
65 //! Sub-domain manager
66 ARCCORE_DEPRECATED_2020("Do not use this method. Try to get 'ISubDomain' from another way")
67 virtual ISubDomain* subDomain() = 0;
68
69 //! Associated parallelism manager
70 virtual IParallelMng* parallelMng() const = 0;
71
72 //! Message manager
73 virtual ITraceMng* traceMng() = 0;
74
75 /*!
76 * \brief Checks a variable.
77 *
78 * Checks that the variable named \a name characterized by \a infos
79 * is valid.
80 * This is true if and only if:
81 * - no variable named \a infos.name() already exists.
82 * - a variable named \a infos.name() exists and
83 * its type and kind match \a infos.
84 *
85 * If the variable is not valid, an exception is thrown.
86 *
87 * This operation is used when you want to create a
88 * new reference to a variable and ensure that it
89 * will be valid.
90 *
91 * \exception ExBadVariableKindType if the variable named \a infos.name() exists
92 * and its type and kind do not match those of \a infos.
93 *
94 * \return the variable named \a infos.name() if it exists, 0 otherwise
95 */
96 virtual IVariable* checkVariable(const VariableInfo& infos) = 0;
97 /*! \brief Generates a name for a temporary variable.
98 *
99 * To ensure the consistency of this name, all sub-domains
100 * must call this function.
101 */
103
104 //! Displays the list of variables managed by a module
105 virtual void dumpList(std::ostream&, IModule*) = 0;
106
107 //! Displays the list of all variables managed by the manager
108 virtual void dumpList(std::ostream&) = 0;
109
110 /*!
111 * \brief Estimated size for exporting variables.
112 *
113 This operation estimates the number of megabytes that the
114 exportation of variables \a vars will generate. If \a vars is empty, the estimation
115 is based on all referenced variables.
116
117 The estimation only takes into account the memory used
118 by the variables and not the writer used.
119
120 The estimation is local to the sub-domain. To obtain the total size
121 of an export, you must determine the size per sub-domain
122 and sum them up.
123
124 This method is collective
125
126 \todo use 8-byte integers or more...
127 */
128 virtual Real exportSize(const VariableCollection& vars) = 0;
129
130 /*!
131 * \brief Observable for variables being written.
132 *
133 * Observers registered in this observable are called
134 * before writing variables (operation writeCheckpoint(),
135 * writeVariables() or writePostProcessing()).
136 */
138
139 /*!
140 * \brief Observable for variables being read.
141 *
142 * Observers registered in this observable are called
143 * after reading variables (operation readVariables() or readCheckpoint()).
144 */
146
147 /*! \brief Writes the variables.
148 *
149 * Iterates through all variables managed by the manager and applies the writer
150 * \a writer to them. If \a filter is not null, it is applied to each variable and
151 * a variable is written only if the filter is true for that variable.
152 *
153 * This method is collective
154 */
155 virtual void writeVariables(IDataWriter* writer, IVariableFilter* filter = 0) = 0;
156
157 /*!
158 * \brief Exports the variables.
159 *
160 * Exports the variables in the list \a vars. If \a vars is
161 * empty, it exports all variables in the base that are used.
162 */
163 virtual void writeVariables(IDataWriter* writer, const VariableCollection& vars) = 0;
164
165 /*!
166 * \internal
167 * \brief Writes variables for a checkpoint.
168 *
169 * Uses the protection service \a writer to write the variables.
170 *
171 * This method is collective.
172 *
173 * This method is internal to Arcane. Generally, writing
174 * a checkpoint is done via an instance of ICheckpointMng,
175 * accessible via ISubDomain::checkpointMng().
176 */
177 virtual void writeCheckpoint(ICheckpointWriter* writer) = 0;
178
179 /*! \brief Writes variables for post-processing.
180 *
181 * Uses the post-processing service \a writer to write the variables.
182 * The caller must have positioned the fields of \a writer before this call,
183 * notably the list of variables to be post-processed. This method
184 * calls IPostProcessorWriter::notifyBeginWrite() before writing
185 * and IPostProcessorWriter::notifyEndWriter() at the end.
186 *
187 * This method is collective.
188 */
189 virtual void writePostProcessing(IPostProcessorWriter* writer) = 0;
190
191 /*!
192 *\brief Reads all variables.
193 *
194 * Iterates through all variables managed by the manager and applies the reader
195 * \a reader to them. If \a filter is not null, it is applied to each variable and
196 * a variable is read only if the filter is true for that variable. Variables
197 * that are not read are not modified by this operation.
198 *
199 * \deprecated Use readVariable(IDataReader*)
200 *
201 * This method is collective.
202 */
203 virtual void readVariables(IDataReader* reader, IVariableFilter* filter = 0) = 0;
204
205 /*!
206 * \internal
207 * \brief Reads all variables from a checkpoint.
208 *
209 * Reads a checkpoint using the service \a reader on all
210 * variables.
211 *
212 * This method is collective.
213 *
214 * This method is internal to Arcane. Generally, reading
215 * a checkpoint is done via an instance of ICheckpointMng,
216 * accessible via ISubDomain::checkpointMng().
217 */
218 virtual void readCheckpoint(ICheckpointReader* reader) = 0;
219
220 /*!
221 * \internal
222 * \brief Reads all variables from a checkpoint.
223 *
224 * Reads a checkpoint using the information contained
225 * in \a infos.
226 *
227 * This method is collective.
228 *
229 * This method is internal to Arcane. Generally, reading
230 * a checkpoint is done via an instance of ICheckpointMng,
231 * accessible via ISubDomain::checkpointMng().
232 */
233 virtual void readCheckpoint(const CheckpointReadInfo& infos) = 0;
234
235 //! Gets all variables of module \a i
236 virtual void variables(VariableRefCollection v, IModule* i) = 0;
237
238 //! List of variables
240
241 //! List of used variables
243
244 //! Notifies the manager that a variable's state has changed
245 virtual void notifyUsedVariableChanged() = 0;
246
247 //! Returns the variable named \a name or 0 if no such name exists.
248 virtual IVariable* findVariable(const String& name) = 0;
249
250 //! Returns the mesh variable named \a name or 0 if no such name exists.
251 virtual IVariable* findMeshVariable(IMesh* mesh, const String& name) = 0;
252
253 //! Returns the fully qualified variable named \a name or 0 if no such name exists.
254 virtual IVariable* findVariableFullyQualified(const String& name) = 0;
255
256 //! Writes statistics about variables to the stream \a ostr
257 virtual void dumpStats(std::ostream& ostr, bool is_verbose) = 0;
258
259 //! Writes statistics with the writer \a writer.
260 virtual void dumpStatsJSON(JSONWriter& writer) = 0;
261
262 //! Interface of associated utility functions
263 virtual IVariableUtilities* utilities() const = 0;
264
265 //! Interface of the variable synchronization manager.
267
268 public:
269
270 //! \name Events
271 //@{
272 //! Event sent when a variable is created
274
275 //! Event sent when a variable is destroyed
277 //@}
278
279 public:
280
281 /*!
282 * \brief Constructs the instance members.
283 *
284 * The instance is not usable until this method has been
285 * called. This method must be called before initialize().
286 * \warning This method must only be called once.
287 */
288 ARCANE_DEPRECATED_REASON("Y2023: This method is internal to Arcane")
289 virtual void build() = 0;
290
291 /*!
292 * \brief Initializes the instance.
293 * The instance is not usable until this method has been
294 * called.
295 * \warning This method must only be called once.
296 */
297 ARCANE_DEPRECATED_REASON("Y2023: This method is internal to Arcane")
298 virtual void initialize() = 0;
299
300 //! Removes and destroys the variables managed by this manager
301 ARCANE_DEPRECATED_REASON("Y2023: This method is internal to Arcane")
302 virtual void removeAllVariables() = 0;
303
304 //! Detaches variables associated with the mesh \a mesh.
305 ARCANE_DEPRECATED_REASON("Y2023: This method is internal to Arcane")
306 virtual void detachMeshVariables(IMesh* mesh) = 0;
307
308 /*!
309 * \brief Adds a reference to a variable.
310 *
311 * Adds the reference \a var to the manager.
312 *
313 * \pre var != 0
314 * \pre var must not already be referenced.
315 * \return the implementation associated with \a var.
316 */
317 ARCANE_DEPRECATED_REASON("Y2023: This method is internal to Arcane")
318 virtual void addVariableRef(VariableRef* var) = 0;
319
320 /*!
321 * \brief Removes a reference to a variable.
322 *
323 * Removes the reference \a var from the manager.
324 *
325 * If \a var is not referenced by the manager, nothing is done.
326 * \pre var != 0
327 */
328 ARCANE_DEPRECATED_REASON("Y2023: This method is internal to Arcane")
329 virtual void removeVariableRef(VariableRef* var) = 0;
330
331 /*!
332 * \brief Adds a variable.
333 *
334 * Adds the variable \a var.
335 *
336 * The validity of the variable is not checked (void checkVariable()).
337 *
338 * \pre var != 0
339 * \pre var must not already be referenced.
340 * \return the implementation associated with \a var.
341 */
342 ARCANE_DEPRECATED_REASON("Y2023: This method is internal to Arcane")
343 virtual void addVariable(IVariable* var) = 0;
344
345 /*!
346 * \brief Removes a variable.
347 *
348 * Removes the variable \a var.
349 *
350 * After calling this method, the variable must no longer be used.
351 *
352 * \pre var != 0
353 * \pre var must have a single reference.
354 */
355 ARCANE_DEPRECATED_REASON("Y2023: This method is internal to Arcane")
356 virtual void removeVariable(IVariable* var) = 0;
357
358 /*!
359 * \brief Initializes the variables.
360 *
361 * Iterates through the list of variables and initializes them.
362 * Only variables of a used module are initialized.
363 *
364 * \param is_continue \a true if resuming.
365 */
366 ARCANE_DEPRECATED_REASON("Y2023: This method is internal to Arcane")
367 virtual void initializeVariables(bool is_continue) = 0;
368
369 public:
370
371 /*!
372 * \internal
373 * Temporary internal function to retrieve the sub-domain.
374 */
375 ARCANE_DEPRECATED_REASON("Y2023: This method is internal to Arcane")
376 virtual ISubDomain* _internalSubDomain() const = 0;
377
378 public:
379
380 //! Internal Arcane API
381 virtual IVariableMngInternal* _internalApi() = 0;
382};
383
384/*---------------------------------------------------------------------------*/
385/*---------------------------------------------------------------------------*/
386
387} // End namespace Arcane
388
389/*---------------------------------------------------------------------------*/
390/*---------------------------------------------------------------------------*/
391
392#endif
Declarations of Arcane's general types.
Checkpoint reading information.
Interface for the protection/recovery reading service.
Interface of the checkpoint/recovery write service.
Interface for reading variable data.
Definition IDataReader.h:35
Interface for writing variable data.
Definition IDataWriter.h:45
Interface of a module.
Definition IModule.h:40
Interface of the parallelism manager for a subdomain.
Interface for a writer for post-processing information.
Interface of the subdomain manager.
Definition ISubDomain.h:75
Functor of a filter applicable to variables.
Variable manager interface.
virtual EventObservable< const VariableStatusChangedEventArgs & > & onVariableRemoved()=0
Event sent when a variable is destroyed.
virtual IVariableUtilities * utilities() const =0
Interface of associated utility functions.
virtual void notifyUsedVariableChanged()=0
Notifies the manager that a variable's state has changed.
virtual void readVariables(IDataReader *reader, IVariableFilter *filter=0)=0
Reads all variables.
virtual void variables(VariableRefCollection v, IModule *i)=0
Gets all variables of module i.
virtual void removeVariableRef(VariableRef *var)=0
Removes a reference to a variable.
virtual void addVariable(IVariable *var)=0
Adds a variable.
virtual ~IVariableMng()=default
Frees resources.
virtual IParallelMng * parallelMng() const =0
Associated parallelism manager.
virtual EventObservable< const VariableStatusChangedEventArgs & > & onVariableAdded()=0
Event sent when a variable is created.
virtual void dumpStatsJSON(JSONWriter &writer)=0
Writes statistics with the writer writer.
virtual VariableCollection usedVariables()=0
List of used variables.
virtual void writeVariables(IDataWriter *writer, IVariableFilter *filter=0)=0
Writes the variables.
virtual IVariable * findMeshVariable(IMesh *mesh, const String &name)=0
Returns the mesh variable named name or 0 if no such name exists.
virtual IObservable * writeObservable()=0
Observable for variables being written.
virtual IVariable * checkVariable(const VariableInfo &infos)=0
Checks a variable.
virtual void detachMeshVariables(IMesh *mesh)=0
Detaches variables associated with the mesh mesh.
virtual void writePostProcessing(IPostProcessorWriter *writer)=0
Writes variables for post-processing.
virtual void build()=0
Constructs the instance members.
virtual IVariableSynchronizerMng * synchronizerMng() const =0
Interface of the variable synchronization manager.
virtual IVariableMngInternal * _internalApi()=0
Internal Arcane API.
virtual IVariable * findVariable(const String &name)=0
Returns the variable named name or 0 if no such name exists.
virtual ISubDomain * subDomain()=0
Sub-domain manager.
virtual void initializeVariables(bool is_continue)=0
Initializes the variables.
virtual void initialize()=0
Initializes the instance. The instance is not usable until this method has been called.
virtual ITraceMng * traceMng()=0
Message manager.
virtual IObservable * readObservable()=0
Observable for variables being read.
virtual Real exportSize(const VariableCollection &vars)=0
Estimated size for exporting variables.
virtual IVariable * findVariableFullyQualified(const String &name)=0
Returns the fully qualified variable named name or 0 if no such name exists.
virtual void addVariableRef(VariableRef *var)=0
Adds a reference to a variable.
virtual void dumpStats(std::ostream &ostr, bool is_verbose)=0
Writes statistics about variables to the stream ostr.
virtual void removeVariable(IVariable *var)=0
Removes a variable.
virtual void removeAllVariables()=0
Removes and destroys the variables managed by this manager.
virtual String generateTemporaryVariableName()=0
Generates a name for a temporary variable.
virtual void dumpList(std::ostream &, IModule *)=0
Displays the list of variables managed by a module.
Interface of the variable synchronization manager.
Interface providing utility functions on variables.
Interface of a variable.
Definition IVariable.h:40
Information characterizing a variable.
Reference to a variable.
Definition VariableRef.h:56
Arguments of the event notifying a change in the state of a variable.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Collection< VariableRef * > VariableRefCollection
Collection of variables.
double Real
Type representing a real number.