IFEM 90A354
TimeStep.h
Go to the documentation of this file.
1// $Id$
2//==============================================================================
12//==============================================================================
13
14#ifndef TIME_STEP_H_
15#define TIME_STEP_H_
16
17#include "TimeDomain.h"
18#include <iostream>
19#include <vector>
20#include <map>
21#include <string>
22
23namespace tinyxml2 { class XMLElement; }
24
25
31{
32public:
34 TimeStep();
36 TimeStep(const TimeStep& ts) : iter(time.it) { *this = ts; }
38 TimeStep& operator=(const TimeStep& ts);
39
43 bool parse(char* keyWord, std::istream& is);
46 bool parse(const tinyxml2::XMLElement* elem);
47
49 bool multiSteps() const;
51 bool hasReached(double t) const;
52
55 bool reset(int istep = 0);
58 bool increment();
61 bool cutback();
63 bool finished() const;
64
67 bool serialize(std::map<std::string,std::string>& data) const;
70 bool deSerialize(const std::map<std::string,std::string>& data);
71
72 int step;
73 int& iter;
75
76 double starTime;
77 double stopTime;
78 double maxCFL;
79
80private:
81 int niter;
83 int maxStep;
84
85 double dtMin;
86 double dtMax;
87 double f1;
88 double f2;
89
90 typedef std::pair<std::vector<double>,double> Step;
91 typedef std::vector<Step> TimeSteps;
92
94 TimeSteps::iterator stepIt;
95
96 size_t lstep;
97};
98
99#endif
Time domain representation for time-dependent and nonlinear solvers.
Class for encapsulation of general time stepping parameters.
Definition TimeStep.h:31
int step
Time step counter.
Definition TimeStep.h:72
bool serialize(std::map< std::string, std::string > &data) const
Serialize internal state for restarting purposes.
Definition TimeStep.C:355
TimeStep & operator=(const TimeStep &ts)
Assigment operator.
Definition TimeStep.C:39
bool reset(int istep=0)
Resets the time step to the specified step.
Definition TimeStep.C:203
bool hasReached(double t) const
Returns true if the given time t has been reached.
Definition TimeStep.C:191
double stopTime
Stop time of simulation.
Definition TimeStep.h:77
TimeSteps::iterator stepIt
Running iterator over the time steps.
Definition TimeStep.h:94
double f2
Scale factor for reduced time step size.
Definition TimeStep.h:88
double f1
Scale factor for increased time step size.
Definition TimeStep.h:87
bool multiSteps() const
Returns true if the simulation consists of several time steps.
Definition TimeStep.C:184
double starTime
Start time of simulation.
Definition TimeStep.h:76
size_t lstep
Local step counter, i.e., within current *stepIt.
Definition TimeStep.h:96
bool finished() const
Returns true if the end of the simulation has been reached.
Definition TimeStep.C:331
int niter
Number of iterations in previous time step.
Definition TimeStep.h:81
TimeStep(const TimeStep &ts)
Copy constructor.
Definition TimeStep.h:36
std::pair< std::vector< double >, double > Step
Time step definition.
Definition TimeStep.h:90
double dtMax
Maximun time increment size.
Definition TimeStep.h:86
bool increment()
Advances the time increments one step further.
Definition TimeStep.C:223
std::vector< Step > TimeSteps
Time step container.
Definition TimeStep.h:91
int nInitStep
Number of fixed timesteps in the beginning.
Definition TimeStep.h:82
TimeSteps mySteps
Time step definitions.
Definition TimeStep.h:93
double dtMin
Minimum time increment size.
Definition TimeStep.h:85
TimeStep()
The constructor initializes the counters to zero.
Definition TimeStep.C:25
bool parse(char *keyWord, std::istream &is)
Parses a data section from an input stream.
Definition TimeStep.C:62
bool deSerialize(const std::map< std::string, std::string > &data)
Set internal state from a serialized state.
Definition TimeStep.C:371
TimeDomain time
Time domain data.
Definition TimeStep.h:74
int & iter
Iteration counter.
Definition TimeStep.h:73
int maxStep
Maximum number of time steps.
Definition TimeStep.h:83
bool cutback()
Restarts current increment with a smaller step size on divergence.
Definition TimeStep.C:303
double maxCFL
CFL restriction on time step size (0.0: no restriction)
Definition TimeStep.h:78
Struct representing the time domain.
Definition TimeDomain.h:23