13#ifndef SIM_EXPLICIT_RK_H_
14#define SIM_EXPLICIT_RK_H_
46 else if (type ==
HEUN) {
53 else if (type ==
RK3) {
55 RK.
b = {1.0/6.0, 2.0/3.0, 1.0/6.0};
56 RK.
c = {0.0, 0.5, 1.0};
62 else if (type ==
RK4) {
64 RK.
b = {1.0/6.0, 1.0/3.0, 1.0/3.0, 1.0/6.0};
65 RK.
c = {0.0, 0.5, 0.5, 1.0};
84 solver.getProcessAdm().cout <<
"\n step = "<< tp.
step <<
" time = "<< tp.
time.
t << std::endl;
92 return this->
solveRK(stages, tp);
105 for (
size_t i = 0; i < stages.size(); ++i) {
107 for (
size_t j = 0; j < i; ++j)
113 if (!
solver.updateDirichlet(time.
t, &dum))
116 if (!
solver.applyDirichlet(tmp))
121 if (!
solver.updateDirichlet(time.
t, &zeroRef,
true))
129 if (!
solver.solveSystem(stages[i]))
133 solver.setMode(SIM::RHS_ONLY);
139 for (
size_t i = 0; i <
RK.
b.size(); ++i)
150 solver.getProblem()->getField1Name(1).c_str());
158 return solver.advanceStep(tp);
162 bool saveModel(
char* fileName,
int& geoBlk,
int& nBlock)
164 return solver.saveModel(fileName, geoBlk, nBlock);
170 return solver.saveStep(tp, nBlock);
176 solver.registerFields(exporter);
183 return solver.serialize(data);
190 return solver.deSerialize(data);
std::vector< Vector > Vectors
An array of real-valued vectors with algebraic operations.
Definition MatVec.h:37
Class for administration MPI processes used by the IFEM library, in particular parallel linear algebr...
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:31
void setLinear(bool enable)
Mark operator as linear to avoid repeated assembly and factorization.
Definition SIMExplicitRK.h:194
RKTableaux RK
Tableaux of Runge-Kutta coefficients.
Definition SIMExplicitRK.h:198
const ProcessAdm & getProcessAdm() const
Returns the parallel process administrator.
Definition SIMExplicitRK.h:78
bool deSerialize(const std::map< std::string, std::string > &data)
Set internal state from a serialized state.
Definition SIMExplicitRK.h:188
virtual bool solveStep(TimeStep &tp)
Computes the solution for the current time step.
Definition SIMExplicitRK.h:81
bool linear
If true operators are constant.
Definition SIMExplicitRK.h:200
bool saveStep(const TimeStep &tp, int &nBlock)
Saves the converged results of a given time step to VTF file.
Definition SIMExplicitRK.h:168
bool serialize(std::map< std::string, std::string > &data)
Serialize internal state for restarting purposes.
Definition SIMExplicitRK.h:181
SIMExplicitRK(Solver &solv, Method type, bool standalone=true)
Constructor.
Definition SIMExplicitRK.h:37
Solver & solver
Reference to simulator.
Definition SIMExplicitRK.h:197
bool solveRK(Vectors &stages, const TimeStep &tp)
Applies the Runge-Kutta scheme.
Definition SIMExplicitRK.h:98
bool alone
If true, this is a standalone solver.
Definition SIMExplicitRK.h:199
bool saveModel(char *fileName, int &geoBlk, int &nBlock)
Opens a new VTF-file and writes the model geometry to it.
Definition SIMExplicitRK.h:162
bool advanceStep(TimeStep &tp)
Advances the time step one step forward.
Definition SIMExplicitRK.h:156
bool assemble
If true, assemble operators.
Definition SIMExplicitRK.h:201
void registerFields(DataExporter &exporter)
Registers fields for output to a data exporter.
Definition SIMExplicitRK.h:174
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:1619
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