Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
IBackwardMng.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/* IBackwardMng.h (C) 2000-2025 */
9/* */
10/* Interface managing backward strategies. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_IBACKWARDMNG_H
13#define ARCANE_CORE_IBACKWARDMNG_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
18
19/*---------------------------------------------------------------------------*/
20/*---------------------------------------------------------------------------*/
21
22namespace Arcane
23{
24
25/*---------------------------------------------------------------------------*/
26/*---------------------------------------------------------------------------*/
27
28/*!
29 * \internal
30 * \brief Interface managing backward strategies.
31 *
32 * This interface is used by ITimeLoopMng to manage
33 * backward rollback. The principle of backward rollback is to save at a given
34 * iteration the values of the variables in order to be able to return to
35 * this iteration, for example, in case of a calculation problem.
36 *
37 * It is possible to set a specific instance via
38 * ITimeLoopMng::setBackwardMng();
39 *
40 * The sequence of operations, performed at the end of each iteration,
41 * is managed by the ITimeLoopMng instance. It is as follows:
42 *
43 * \code
44 * IBackwardMng bw = ...;
45 * bw->beginAction();
46 * if (bw->checkAndApplyRestore()){
47 * // Execution of restoration entry points.
48 * }
49 * bw->checkAndApplySave();
50 * bw->endAction();
51 * \endcode
52 */
53class ARCANE_CORE_EXPORT IBackwardMng
54{
55 public:
56
57 // Actions to perform
59 {
60 //! Save
62 //! Restore
64 };
65
66 public:
67
68 virtual ~IBackwardMng() = default;
69
70 public:
71
72 //! Initialization of the backward manager
73 virtual void init() = 0;
74
75 //! Indicates that the save/restore actions have started
76 virtual void beginAction() = 0;
77
78 /*!
79 * \brief Checks and applies restoration if necessary.
80 * \retval true if a restoration is performed.
81 */
82 virtual bool checkAndApplyRestore() = 0;
83
84 /*!
85 * \brief Checks and applies variable saving if necessary.
86 * If \a is_forced is true, forces the save.
87 * \retval true if a save is performed.
88 */
89 virtual bool checkAndApplySave(bool is_forced) = 0;
90
91 //! Indicates that the save/restore actions are finished
92 virtual void endAction() = 0;
93
94 // Save period
95 virtual void setSavePeriod(Integer n) = 0;
96
97 // Retrieves the save period
98 virtual Integer savePeriod() const = 0;
99
100 /*!
101 * \brief Signals that a backward rollback is desired.
102 *
103 * The backward rollback will occur when checkAndApplyRestore() is called.
104 *
105 * Generally, this method should not be called directly but
106 * rather ITimeLoopMng::goBackward().
107 *
108 * From the call to this method until the effective action of
109 * the backward rollback when calling checkAndApplyRestore(),
110 * isBackwardEnabled() returns \a true.
111 */
112 virtual void goBackward() = 0;
113
114 /*!
115 * \brief Indicates if the backward rollback saves are locked.
116 *
117 * isLocked() is true if it is not possible to perform a
118 * save. This is the case, for example, when a backward rollback has been performed at iteration
119 * \a M to iteration N and we have not yet
120 * returned to iteration \a M.
121 */
122 virtual bool isLocked() const = 0;
123
124 /*!
125 * \brief Indicates if a backward rollback is scheduled.
126 * \sa goBackward().
127 */
128 virtual bool isBackwardEnabled() const = 0;
129
130 /*!
131 * \brief Deletes resources associated with the backward rollback.
132 *
133 * This method is called to deallocate resources
134 * such as variable saves. This method is called
135 * among other things before a load balancing because it will not be
136 * possible to perform a backward rollback before this balancing.
137 */
138 virtual void clear() = 0;
139};
140
141/*---------------------------------------------------------------------------*/
142/*---------------------------------------------------------------------------*/
143
144} // namespace Arcane
145
146/*---------------------------------------------------------------------------*/
147/*---------------------------------------------------------------------------*/
148
149#endif
Declarations of Arcane's general types.
virtual void init()=0
Initialization of the backward manager.
virtual void clear()=0
Deletes resources associated with the backward rollback.
virtual bool checkAndApplySave(bool is_forced)=0
Checks and applies variable saving if necessary. If is_forced is true, forces the save.
virtual void endAction()=0
Indicates that the save/restore actions are finished.
virtual void goBackward()=0
Signals that a backward rollback is desired.
virtual bool isLocked() const =0
Indicates if the backward rollback saves are locked.
virtual bool isBackwardEnabled() const =0
Indicates if a backward rollback is scheduled.
virtual void beginAction()=0
Indicates that the save/restore actions have started.
virtual bool checkAndApplyRestore()=0
Checks and applies restoration if necessary.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.