WARPXM v1.10.0
Loading...
Searching...
No Matches
wmsolver.h
Go to the documentation of this file.
1#ifndef wmsolver_h
2#define wmsolver_h
3
4// WarpX solver includes
6#include "timestep_status.h"
7#include "wmsolverbase.h"
8
9// WarpX lib includes
11#include "lib/wmdomain.h"
12
14
15// std includes
16#include <map>
17#include <string>
18
23// forward declarations
24class WmTaskGraphProcessor;
25class WmSimulation;
26class WmDomain;
27class WmSubSolver;
29class WmHostAction;
30
35class WmSolver : public WmSolverBase
36{
37public:
44 WmSolver(const WmSimulation* parentSim);
45
49 virtual ~WmSolver();
50
56 void setStartFrame(unsigned frame)
57 {
58 _startFrame = frame;
59 }
60
66 virtual void setup(const WxCryptSet& wxc);
67
73 const WmDomain& getDomain() const;
74
83 WmSubSolver* getSubSolver(const std::string& name) const;
84
91 const wxm::variable::variable_t& getConstVar(const std::string& name) const
92 {
93 VariableMap_t::const_iterator i;
94 i = _variables.find(name);
95 if (i != _variables.end())
96 {
97 return (*i->second);
98 }
99 else
100 {
101 WxExcept wxe;
102 wxe << "Variable " << name << " not found";
103 throw wxe;
104 }
105 }
106
116 wxm::variable::variable_t& getVar(const std::string& name) const
117 {
118 VariableMap_t::iterator i;
119 VariableMap_t* p_variables = const_cast<VariableMap_t*>(
120 &_variables); // TODO:: revisit this interface decision to const_cast.
121 // Originated from choice to make parent pointers in host
122 // actions const.
123 i = p_variables->find(name);
124 if (i != p_variables->end())
125 {
126 return (*i->second);
127 }
128 else
129 {
130 WxExcept wxe("WmSolver::getVar : ");
131 wxe << "Variable " << name << " not found";
132 throw wxe;
133 }
134 }
135
142 const std::type_info& getVarType(const std::string& name) const;
143
151 {
152 SequencedGroupMap_t::iterator i;
153 i = _sequencedGroups.find(name);
154 if (i != _sequencedGroups.end())
155 {
156 return *i->second;
157 }
158 else
159 {
160 WxExcept wxe;
161 wxe << "WmSequencedGroup " << name << " not found";
162 throw wxe;
163 }
164 }
165
169 virtual void solve();
170
174 void presolve();
175
180 void step_dt(real limit_dt = 0);
181
189 {
190 return _solverParameters;
191 }
192
193 const std::vector<WmHostAction*>& getStartOnlyGroup() const
194 {
195 return _startOnlyG;
196 }
197
198 const std::vector<WmHostAction*>& getPerStepGroup() const
199 {
200 return _perStepG;
201 }
202
203private:
205 WmSolver& operator=(const WmSolver& s);
206 WmSolver(const WmSolver& s);
207
211 void startOnly();
212
216 void restart();
217
221 void endOnly();
222
226 void preRedoPerStep();
227
231 void init()
232 {
233 }
234
238 void finishBuild()
239 {
240 }
241
245 void load(WxIoBase& io, const WxIoNodeType& grpNode)
246 {
247 }
248
252 void dump(WxIoBase& io, WxIoNodeType& grpNode) const
253 {
254 }
255
259 virtual WxStepperStatus step()
260 {
261 return WxStepperStatus();
262 }
263
270 std::pair<TimestepConstraint, TimestepDecision> advance(real tend);
271
273 typedef std::map<std::string, wxm::variable::variable_t*> VariableMap_t;
274 typedef std::pair<std::string, wxm::variable::variable_t*> VariablePair_t;
275
277 typedef std::map<std::string, WmSubSolver*> SubSolverMap_t;
278 typedef std::pair<std::string, WmSubSolver*> SubSolverPair_t;
279
281 typedef std::map<std::string, WmHostAction*> HostActionMap_t;
282 typedef std::pair<std::string, WmHostAction*> HostActionPair_t;
283
285 typedef std::map<std::string, WmSequencedGroup*> SequencedGroupMap_t;
286 typedef std::pair<std::string, WmSequencedGroup*> SequencedGroupPair_t;
287
289 solverParameters_t _solverParameters;
290
292 TimestepStatus _timestep_status;
293
295 bool flexible_writeout;
296
298 real _tstart, _tend;
299 unsigned _startFrame;
301 unsigned _nout;
302
304 VariableMap_t _variables;
306 SubSolverMap_t _subSolvers;
307
309 HostActionMap_t _hostActions;
310
312 SequencedGroupMap_t _sequencedGroups;
313
315 WmDomain* _domain;
316
322 bool enable_fpe;
323
329 void add_host_actions(std::vector<WmHostAction*>& g, const std::string& name);
330
332 std::vector<WmHostAction*> _startOnlyG;
334 std::vector<WmHostAction*> _endOnlyG;
336 std::vector<WmHostAction*> _perStepG;
338 std::vector<WmHostAction*> _preRedoPerStepG;
340 std::vector<WmHostAction*> _restartG;
341 // what's used to calculate dt
342 wxm::dt_calc::time_stepper_base* _dt_calc = nullptr;
343};
346#endif // wmsolver_h
Manages information about dt tried first, dt actually taken, and dt suggested for the next timestep,...
Definition: timestep_status.h:21
Definition: wmdomain.h:35
The WmHostAction class is a base class for sub-solvers in the WARPXM system.
Definition: wmhostaction.h:35
Represents a set of events that must be executed serially in the specified sequence.
Definition: wmsequencedgroup.h:23
Top level class for WARPXM simulations.
Definition: wmsimulation.h:28
A base class for solvers in WARPM.
Definition: wmsolverbase.h:35
Provides many vital functionality to building and executing a sequence of simulation code.
Definition: wmsolver.h:36
WmSubSolver * getSubSolver(const std::string &name) const
Return pointer to subsolver.
virtual void setup(const WxCryptSet &wxc)
Setup the subsolver using cryptset.
WmSolver(const WmSimulation *parentSim)
Create solver Subsequent setup() call still required.
const wxm::variable::variable_t & getConstVar(const std::string &name) const
Return constant reference to a read variable.
Definition: wmsolver.h:91
wxm::variable::variable_t & getVar(const std::string &name) const
Return reference to a variable.
Definition: wmsolver.h:116
const solverParameters_t & getSolverParameters() const
Return the solver parameters.
Definition: wmsolver.h:188
void setStartFrame(unsigned frame)
Set frame from which to start the simulation.
Definition: wmsolver.h:56
virtual void solve()
Run solver.
void presolve()
Run any pre-solve initialization.
void step_dt(real limit_dt=0)
Tries to steps a single time step dt.
const std::type_info & getVarType(const std::string &name) const
Return a type_info reference for a variable known to the solver.
const WmDomain & getDomain() const
Return unstructured multi-subdomain domain.
WmSequencedGroup & getSequencedGroup(const std::string &name)
Return reference WmSequencedGroup.
Definition: wmsolver.h:150
virtual ~WmSolver()
Destroy solver.
const std::vector< WmHostAction * > & getPerStepGroup() const
Definition: wmsolver.h:198
const std::vector< WmHostAction * > & getStartOnlyGroup() const
Definition: wmsolver.h:193
Base class for sub-solvers in WARPXM compute kernel system.
Definition: wmsubsolver.h:40
WxCryptSet extends WxCrypt by providing, in addition to name-value pairs, an set of named WxCryptSets...
Definition: wxcryptset.h:35
Provides an abstract interface for access to hierachical datasets.
Definition: wxiobase.h:25
virtual std::string name() const
Get name of object.
Represents important parameters for the efficacy of a completing simulation step.
Definition: wxstepperstatus.h:19
Definition: time_stepper_base.h:12
wxm::lib::Except is the class to use for creating and throwing exceptions.
Definition: wxexcept.h:31
Definition: variable.h:22
Definition: wmsolverbase.h:38
Provides a means for derived messengers to return implimentation specific message status flags and da...
Definition: wxiotmpl.h:23
#define real
Definition: wmoclunstructuredreconstruction.h:11