13 #ifndef SIM_EXPLICIT_RK_H_
14 #define SIM_EXPLICIT_RK_H_
28 template<
class Solver>
45 else if (type ==
HEUN) {
54 else if (type ==
RK3) {
56 RK.
b.push_back(1.0/6.0);
57 RK.
b.push_back(2.0/3.0);
58 RK.
b.push_back(1.0/6.0);
67 else if (type ==
RK4) {
69 RK.
b.push_back(1.0/6.0);
70 RK.
b.push_back(1.0/3.0);
71 RK.
b.push_back(1.0/3.0);
72 RK.
b.push_back(1.0/6.0);
95 solver.getProcessAdm().cout <<
"\n step = "<< tp.
step <<
" time = "<< tp.
time.
t << std::endl;
98 return this->
solveRK(stages, tp);
111 for (
size_t i=0;i<stages.size();++i) {
113 for (
size_t j=0;j<i;++j)
116 solver.updateDirichlet(time.
t, &dum);
117 solver.applyDirichlet(tmp);
123 if (!
solver.solveSystem(stages[i]))
127 solver.setMode(SIM::RHS_ONLY);
132 for (
size_t i=0;i<
RK.
b.size();++i)
138 solver.getProblem()->getField1Name(1).c_str());
146 return solver.advanceStep(tp);
150 bool saveModel(
char* fileName,
int& geoBlk,
int& nBlock)
152 return solver.saveModel(fileName, geoBlk, nBlock);
158 return solver.saveStep(tp, nBlock);
164 solver.registerFields(exporter);
171 return solver.serialize(data);
178 return solver.deSerialize(data);
std::vector< Vector > Vectors
An array of real-valued vectors with algebraic operations.
Definition: MatVec.h:37
Various helpers for time integration.
Class for encapsulation of general time stepping parameters.
Administer and write data using DataWriters.
Definition: DataExporter.h:38
Class for administration of MPI processes in IFEM library.
Definition: ProcessAdm.h:33
Explicit Runge-Kutta based time stepping for SIM classes.
Definition: SIMExplicitRK.h:30
void setLinear(bool enable)
Mark operator as linear to avoid repeated assembly and factorization.
Definition: SIMExplicitRK.h:182
RKTableaux RK
Tableaux of Runge-Kutta coefficients.
Definition: SIMExplicitRK.h:186
bool deSerialize(const std::map< std::string, std::string > &data)
Set internal state from a serialized state.
Definition: SIMExplicitRK.h:176
const ProcessAdm & getProcessAdm() const
Returns the parallel process administrator.
Definition: SIMExplicitRK.h:89
virtual bool solveStep(TimeStep &tp)
Computes the solution for the current time step.
Definition: SIMExplicitRK.h:92
bool linear
If true mass matrix is constant.
Definition: SIMExplicitRK.h:188
bool saveStep(const TimeStep &tp, int &nBlock)
Saves the converged results of a given time step to VTF file.
Definition: SIMExplicitRK.h:156
bool serialize(std::map< std::string, std::string > &data)
Serialize internal state for restarting purposes.
Definition: SIMExplicitRK.h:169
SIMExplicitRK(Solver &solv, Method type, bool standalone=true)
Constructor.
Definition: SIMExplicitRK.h:36
Solver & solver
Reference to simulator.
Definition: SIMExplicitRK.h:185
bool solveRK(Vectors &stages, const TimeStep &tp)
Applies the Runge-Kutta scheme.
Definition: SIMExplicitRK.h:104
bool alone
If true, this is a standalone solver.
Definition: SIMExplicitRK.h:187
bool saveModel(char *fileName, int &geoBlk, int &nBlock)
Opens a new VTF-file and writes the model geometry to it.
Definition: SIMExplicitRK.h:150
bool advanceStep(TimeStep &tp)
Advances the time step one step forward.
Definition: SIMExplicitRK.h:144
void registerFields(DataExporter &exporter)
Registers fields for output to a data exporter.
Definition: SIMExplicitRK.h:162
Class for encapsulation of general time stepping parameters.
Definition: TimeStep.h:31
int step
Time step counter.
Definition: TimeStep.h:72
TimeDomain time
Time domain data.
Definition: TimeStep.h:74
void resize(size_t r, size_t c, bool forceClear=false)
Resize the matrix to dimension .
Definition: matrix.h:488
A vector class with some added algebraic operations.
Definition: matrix.h:64
vector< T > & add(const std::vector< T > &X, const T &alfa=T(1), unsigned int ofsx=0, int stridex=1, unsigned int ofsy=0, int stridey=1)
Add the given vector X scaled by alfa to *this.
Definition: matrix.h:1562
bool resize(size_t n, char forceClear=0)
Resize the vector to length n.
Definition: matrix.h:277
Utilities for time integration.
Definition: BDF.h:21
Method
Enum defining various solution methods.
Definition: TimeIntUtils.h:28
@ HEUN
Heun-Euler, explicit.
Definition: TimeIntUtils.h:33
@ RK3
Kutta's third order method, explicit.
Definition: TimeIntUtils.h:34
@ RK4
Kutta's fourth order method, explicit.
Definition: TimeIntUtils.h:35
@ EULER
Forward Euler, explicit.
Definition: TimeIntUtils.h:32
Struct representing the time domain.
Definition: TimeDomain.h:23
double dt
Current timestep (or load parameter) increment.
Definition: TimeDomain.h:25
double t
Current time (or pseudo time, load parameter)
Definition: TimeDomain.h:24
Struct holding a Runge-Kutta tableaux.
Definition: TimeIntUtils.h:59
RealArray c
Stage levels.
Definition: TimeIntUtils.h:63
Matrix A
Coefficient matrix.
Definition: TimeIntUtils.h:61
int order
Order of scheme.
Definition: TimeIntUtils.h:60
RealArray b
Stage weights.
Definition: TimeIntUtils.h:62