Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
ModuleMaster.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/* ModuleMaster.h (C) 2000-2025 */
9/* */
10/* Master Module. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_CORE_MODULEMASTER_H
13#define ARCANE_CORE_MODULEMASTER_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/VersionInfo.h"
18
19#include "arcane/core/IModuleMaster.h"
20#include "arcane/core/AbstractModule.h"
22#include "arcane/core/CommonVariables.h"
23
24/*---------------------------------------------------------------------------*/
25/*---------------------------------------------------------------------------*/
26
27namespace Arcane
28{
29
30/*---------------------------------------------------------------------------*/
31/*---------------------------------------------------------------------------*/
32
33/*!
34 * \internal
35 * \brief Main module.
36 *
37 * This module is always loaded first so that these entry points encompass
38 * all those of other modules.
39 * It contains the global case variables, such as the filename or the
40 * iteration number.
41 */
42class ARCANE_CORE_EXPORT ModuleMaster
43: public AbstractModule
44, public CommonVariables
45, public IModuleMaster
46{
47 public:
48
49 //! Constructor
50 explicit ModuleMaster(const ModuleBuildInfo&);
51
52 //! Destructor
53 ~ModuleMaster() override;
54
55 public:
56
57 //! Module version
58 VersionInfo versionInfo() const override { return VersionInfo(1, 0, 0); }
59
60 //! Access to module options
62
63 //! Conversion to \a IModule
64 IModule* toModule() override { return this; }
65
66 //! Access to 'common' variables shared between all services and modules
67 CommonVariables* commonVariables() override { return this; }
68
69 void addTimeLoopService(ITimeLoopService* tls) override;
70
71 //! Dumps standard curves (CPUTime, ElapsedTime, ...)
72 void dumpStandardCurves() override;
73
74 public:
75
76 //! Auto-loaded entry point at the beginning of the calculation loop iteration
77 /*!
78 <ul>
79 <li>If the current time is strictly greater than the limit time, requests the termination of the calculation</li>
80 <li>Adds the delta calculated in the previous time step to the current time</li>
81 </ul>
82 */
83 void timeLoopBegin();
84
85 //! Auto-loaded entry point at the end of the calculation loop iteration
86 /*!
87 <ul>
88 <li>Increments the iteration counter</li>
89 </ul>
90 */
91 void timeLoopEnd();
92
93 //! Auto-loaded entry point at the beginning of initialization
94 void masterInit();
95
96 //! Auto-loaded entry point at the beginning of a new case initialization
97 /*! Is not called in case of initialization on a restart */
98 void masterStartInit();
99
100 //! Auto-loaded entry point at the beginning of a new case restart
101 void masterContinueInit();
102
103 protected:
104
105 //! Overridable time step incrementation
106 // note: IFPEN has a notion of event. We can know the next
107 // time and time step. If we apply the default incrementation,
108 // we get rounding errors...
109 virtual void timeIncrementation();
110
111 //! Overridable display of time step information
112 // note: IFPEN desires displays configurable per application
113 virtual void timeStepInformation();
114
115 void _masterBeginLoop();
116 void _masterEndLoop();
117 void _masterStartInit();
118 void _masterContinueInit();
119 void _masterLoopExit();
120 void _masterMeshChanged();
121 void _masterRestore();
122
123 protected:
124
125 //! Instance of module options
127
128 //! Number of calculation loops performed
130
131 //! CPU time value at the last iteration
133
134 //! Clock time value at the last iteration
136
137 //! List of time loop services
139
140 //! Indicates if we are in the first execution loop
141 bool m_is_first_loop = true;
142
143 Real m_thm_mem_used = 0.0;
144 Real m_thm_diff_cpu = 0.0;
145 Real m_thm_global_cpu_time = 0.0;
146 Real m_thm_diff_elapsed = 0.0;
147 Real m_thm_global_elapsed_time = 0.0;
148 Real m_thm_global_time = 0.0;
149
150 bool m_has_thm_dump_at_iteration = false;
151
152 private:
153
154 void _dumpTimeInfo();
155};
156
157/*---------------------------------------------------------------------------*/
158/*---------------------------------------------------------------------------*/
159
160} // namespace Arcane
161
162/*---------------------------------------------------------------------------*/
163/*---------------------------------------------------------------------------*/
164
165#endif
AbstractModule(const ModuleBuildInfo &)
Constructor from a ModuleBuildInfo.
CommonVariables(IModule *c)
Constructs the references of the common variables for the module c.
Interface of a module.
Definition IModule.h:40
Interface of a service operating during the time loop.
Information for building a module.
CaseOptionsMain * m_case_options_main
Instance of module options.
bool m_is_first_loop
Indicates if we are in the first execution loop.
Real m_old_cpu_time
CPU time value at the last iteration.
ModuleMaster(const ModuleBuildInfo &)
Constructor.
IModule * toModule() override
Conversion to IModule.
Real m_old_elapsed_time
Clock time value at the last iteration.
CommonVariables * commonVariables() override
Access to 'common' variables shared between all services and modules.
VersionInfo versionInfo() const override
Module version.
CaseOptionsMain * caseoptions() override
Access to module options.
UniqueArray< ITimeLoopService * > m_timeloop_services
List of time loop services.
Integer m_nb_loop
Number of calculation loops performed.
1D data vector with value semantics (STL style).
Information about a version.
Definition VersionInfo.h:47
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.
double Real
Type representing a real number.