Manual for OpenFLUID 2.1.10

Engine.hpp
Go to the documentation of this file.
1 /*
2 
3  This file is part of OpenFLUID software
4  Copyright(c) 2007, INRA - Montpellier SupAgro
5 
6 
7  == GNU General Public License Usage ==
8 
9  OpenFLUID is free software: you can redistribute it and/or modify
10  it under the terms of the GNU General Public License as published by
11  the Free Software Foundation, either version 3 of the License, or
12  (at your option) any later version.
13 
14  OpenFLUID is distributed in the hope that it will be useful,
15  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  GNU General Public License for more details.
18 
19  You should have received a copy of the GNU General Public License
20  along with OpenFLUID. If not, see <http://www.gnu.org/licenses/>.
21 
22 
23  == Other Usage ==
24 
25  Other Usage means a use of OpenFLUID that is inconsistent with the GPL
26  license, and requires a written agreement between You and INRA.
27  Licensees for Other Usage of OpenFLUID may use this file in accordance
28  with the terms contained in the written agreement between You and INRA.
29 
30 */
31 
32 
33 /**
34  @file Engine.hpp
35 
36  @author Jean-Christophe FABRE <jean-christophe.fabre@inra.fr>
37 */
38 
39 
40 #ifndef __OPENFLUID_MACHINE_ENGINE_HPP__
41 #define __OPENFLUID_MACHINE_ENGINE_HPP__
42 
43 
44 #include <openfluid/dllexport.hpp>
46 #include <openfluid/core/TypeDefs.hpp>
48 
49 
50 namespace openfluid {
51 namespace base {
52 class SimulationStatus;
53 }
54 namespace core {
55 class Value;
56 class DateTime;
57 }
58 }
59 
60 
61 namespace openfluid { namespace machine {
62 
63 class ModelInstance;
64 class MonitoringInstance;
65 class MachineListener;
66 class SimulationBlob;
67 
68 
69 // =====================================================================
70 // =====================================================================
71 
72 
73 /**
74  Computation engine class
75 */
77 {
78 
79  private:
80 
81  SimulationBlob& m_SimulationBlob;
82 
84 
85  MachineListener* mp_MachineListener;
86 
87  ModelInstance& m_ModelInstance;
88 
89  MonitoringInstance& m_MonitoringInstance;
90 
92 
93 
94  void checkSimulationVarsProduction(int ExpectedVarsCount);
95 
96  void checkParametersConsistency();
97 
98  void checkModelConsistency();
99 
100  void checkAttributesConsistency();
101 
102  void checkExtraFilesConsistency();
103 
104  void checkExistingVariable(const openfluid::core::VariableName_t& VarName,
105  const openfluid::core::Value::Type& VarType,
106  const openfluid::core::UnitsClass_t& ClassName,
107  const std::string& SimulatorID);
108 
109  void createVariable(const openfluid::core::VariableName_t& VarName,
110  const openfluid::core::Value::Type& VarType,
111  const openfluid::core::UnitsClass_t& ClassName,
112  bool UpdateMode,
113  const std::string& SimulatorID);
114 
115  void checkExistingAttribute(const openfluid::core::AttributeName_t AttrName,
116  const openfluid::core::UnitsClass_t ClassName,
117  const std::string& SimulatorID);
118 
119  void createAttribute(const openfluid::core::AttributeName_t AttrName,
120  const openfluid::core::UnitsClass_t ClassName,
121  const std::string& SimulatorID);
122 
123  void prepareOutputDir();
124 
125 
126  public:
127 
128  Engine() = delete;
129 
131  const openfluid::core::Duration_t DeltaT)
132  {
133  return (Duration/DeltaT)+2;
134  }
135 
136  /**
137  Constructor
138  */
139  Engine(SimulationBlob& SimBlob,
140  ModelInstance& MInstance, MonitoringInstance& OLInstance,
142 
143  /**
144  Destructor
145  */
146  ~Engine();
147 
148  /**
149  Initializes the simulation engine
150  */
151  void initialize();
152 
153  /**
154  Executes the initParams() method of each item of the model
155  */
156  void initParams();
157 
158  /**
159  Executes the prepareData() method of each item of the model
160  */
161  void prepareData();
162 
163  /**
164  Executes the checkConsistency() method of each item of the model
165  */
166  void checkConsistency();
167 
168  /**
169  Executes the initializeRun(), runStep() and finalizeRun() methods of each item of the model
170  */
171  void run();
172 
173  /**
174  Finalizes the simulation engine
175  */
176  void finalize();
177 
179  {
180  return mp_SimStatus;
181  }
182 
184  {
185  return &m_SimulationBlob;
186  }
187 
188  MachineListener* machineListener()
189  {
190  return mp_MachineListener;
191  }
192 
194  {
195  return &m_ModelInstance;
196  }
197 
198  unsigned int getWarningsCount() const
199  {
200  return mp_SimLogger->getWarningsCount();
201  }
202 };
203 
204 
205 } } //namespaces
206 
207 
208 #endif
209 
Definition: SimulationLogger.hpp:57
Definition: Engine.hpp:76
Definition: MachineListener.hpp:54
Definition: ApplicationException.hpp:47
Definition: MonitoringInstance.hpp:58
const openfluid::base::SimulationStatus * simulationStatus()
Definition: Engine.hpp:178
std::string VariableName_t
Definition: TypeDefs.hpp:131
std::string UnitsClass_t
Definition: TypeDefs.hpp:98
SimulationBlob * simulationBlob()
Definition: Engine.hpp:183
std::uint64_t Duration_t
Definition: TypeDefs.hpp:312
std::string AttributeName_t
Definition: TypeDefs.hpp:117
Definition: SimulationStatus.hpp:55
Type
Definition: Value.hpp:68
unsigned int getWarningsCount() const
Definition: Engine.hpp:198
static std::size_t computeValuesBuffersDefaultSize(const openfluid::core::Duration_t Duration, const openfluid::core::Duration_t DeltaT)
Definition: Engine.hpp:130
ModelInstance * modelInstance()
Definition: Engine.hpp:193
MachineListener * machineListener()
Definition: Engine.hpp:188
Definition: ModelInstance.hpp:65
#define OPENFLUID_API
Definition: dllexport.hpp:86
unsigned int getWarningsCount() const
Definition: FileLogger.hpp:93
Definition: SimulationBlob.hpp:53