33 #ifndef __H__UG__LIB_DISC__TIME_DISC__THETA_TIME_STEP__
34 #define __H__UG__LIB_DISC__TIME_DISC__THETA_TIME_STEP__
54 template <
typename TAlgebra>
137 std::vector<number>& vSA,
164 template <
typename TAlgebra>
218 else if (
m_scheme ==
"Alexander")
return 2;
219 else if (
m_scheme ==
"FracStep")
return 3;
220 else UG_THROW(
"Step Scheme not recognized.");
231 std::vector<number>& vSA,
245 return currentTime + dt;
250 const number gamma = 1 - 1. / sqrt(2.);
256 return currentTime + gamma * dt;
259 vSA[1] = (1.- 2*gamma) * dt;
260 return currentTime + (1 - gamma) * dt;
262 UG_THROW(
"Alexander scheme has only 2 stages")
271 vSA[0] = (2.-sqrt(2.)) * (1-1./sqrt(2.)) * dt;
272 vSA[1] = (1.- (2.-sqrt(2.)))* (1-1./sqrt(2.)) * dt;
273 return currentTime + (1-1./sqrt(2.)) * dt;
275 vSA[0] = (sqrt(2.)-1) * (sqrt(2.)-1) * dt;
276 vSA[1] = (1.- (sqrt(2.)-1)) * (sqrt(2.)-1) * dt;
277 return currentTime + (sqrt(2.)-1) * dt;
279 vSA[0] = (2.-sqrt(2.)) * (1-1./sqrt(2.)) * dt;
280 vSA[1] = (1.- (2.-sqrt(2.)))* (1-1./sqrt(2.)) * dt;
281 return currentTime + (1-1./sqrt(2.)) * dt;
283 UG_THROW(
"FracStep scheme has only 3 stages")
299 template <
typename TAlgebra>
342 if(stage!=1)
UG_THROW(
"BDF has only one stage.");
347 std::vector<number>& vSA,
356 const number futureTime = currentTime + dt;
361 " previous solutions, but only "<<prevSol->size()<<
"passed.");
363 std::vector<number> vTimePoint(
m_order+1);
364 vTimePoint[0] = futureTime;
365 for(
size_t i = 1; i <=
m_order; ++i)
366 vTimePoint[i] = prevSol->time(i-1);
369 for(
size_t i = 0; i <=
m_order; ++i)
373 for(
size_t j = 0; j < vTimePoint.size(); ++j)
378 for(
size_t k = 0; k < vTimePoint.size(); ++k)
383 prod *= (vTimePoint[0]-vTimePoint[k])/
384 (vTimePoint[i]-vTimePoint[k]);
386 prod *= 1./(vTimePoint[i]-vTimePoint[j]);
393 const number scale = 1.0 / vSM[0];
395 for(
size_t i = 1; i <=
m_order; ++i) vSA[i] = 0;
398 for(
int i =
m_order; i >= 0; --i) vSM[i] *= scale;
408 template <
typename TAlgebra>
447 if(order > 4)
UG_THROW(
"DIRK: Only up to order 4.");
458 default:
UG_THROW(
"DIRK: Only up to order 4.")
491 std::vector<number>& vSA,
495 std::vector<number>& vSA,
Definition: smart_pointer.h:296
Definition: smart_pointer.h:108
Definition: theta_time_step.h:302
BDF(SmartPtr< IDomainDiscretization< TAlgebra > > spDD, size_t order)
theta = 0 -> Backward Euler
Definition: theta_time_step.h:325
virtual ~BDF()
Definition: theta_time_step.h:331
algebra_type::vector_type vector_type
Type of algebra vector.
Definition: theta_time_step.h:314
algebra_type::matrix_type matrix_type
Type of algebra matrix.
Definition: theta_time_step.h:311
virtual void set_stage(size_t stage)
sets the stage
Definition: theta_time_step.h:340
BDF(SmartPtr< IDomainDiscretization< TAlgebra > > spDD)
constructor
Definition: theta_time_step.h:318
TAlgebra algebra_type
Type of algebra.
Definition: theta_time_step.h:308
size_t m_order
Definition: theta_time_step.h:403
virtual number update_scaling(std::vector< number > &vSM, std::vector< number > &vSA, number dt, number currentTime, ConstSmartPtr< VectorTimeSeries< vector_type > > prevSol)
Error estimator ///.
Definition: theta_time_step.h:346
void set_order(size_t order)
sets the theta value
Definition: theta_time_step.h:334
virtual size_t num_stages() const
returns the number of stages
Definition: theta_time_step.h:337
IDomainDiscretization< TAlgebra > domain_discretization_type
Domain Discretization type.
Definition: theta_time_step.h:305
Definition: grid_level.h:42
TAlgebra::vector_type vector_type
Type of algebra vector.
Definition: assemble_interface.h:119
Interface for domain discretization.
Definition: domain_disc_interface.h:136
Time Discretization Interface.
Definition: time_disc_interface.h:65
SmartPtr< IDomainDiscretization< TAlgebra > > m_spDomDisc
Domain Discretization.
Definition: time_disc_interface.h:173
multi step time stepping scheme
Definition: theta_time_step.h:57
std::vector< number > m_vScaleStiff
Scaling for stiffness part.
Definition: theta_time_step.h:143
algebra_type::vector_type vector_type
Type of algebra vector.
Definition: theta_time_step.h:66
virtual size_t num_prev_steps() const
returns number of previous time steps needed
Definition: theta_time_step.h:84
virtual number update_scaling(std::vector< number > &vSM, std::vector< number > &vSA, number dt, number currentTime, ConstSmartPtr< VectorTimeSeries< vector_type > > prevSol)=0
Error estimator ///.
void assemble_jacobian(matrix_type &J, const vector_type &u, const GridLevel &gl)
assembles Jacobian (or Approximation of Jacobian)
Definition: theta_time_step_impl.h:113
bool is_error_valid()
returns whether error indicators are valid
Definition: theta_time_step.h:129
TAlgebra algebra_type
Type of algebra.
Definition: theta_time_step.h:60
virtual void finish_step(SmartPtr< VectorTimeSeries< vector_type > > currSol)
Definition: theta_time_step_impl.h:295
number m_dt
Time Step size.
Definition: theta_time_step.h:146
virtual void finish_step_elem(SmartPtr< VectorTimeSeries< vector_type > > currSol, const GridLevel &gl)
Definition: theta_time_step_impl.h:313
virtual void prepare_step_elem(SmartPtr< VectorTimeSeries< vector_type > > prevSol, number dt, const GridLevel &gl)
prepares the assembling of Defect/Jacobian for a time step
Definition: theta_time_step_impl.h:77
virtual void prepare_step(SmartPtr< VectorTimeSeries< vector_type > > prevSol, number dt)
prepares the assembling of Defect/Jacobian for a time step
Definition: theta_time_step_impl.h:46
void adjust_solution(vector_type &u, const GridLevel &gl)
sets dirichlet values in solution vector
Definition: theta_time_step_impl.h:173
SmartPtr< VectorTimeSeries< vector_type > > m_pPrevSol
Previous solutions.
Definition: theta_time_step.h:145
CPUAlgebra::vector_type error_vector_type
Type of algebra vector.
Definition: theta_time_step.h:69
IDomainDiscretization< algebra_type > domain_discretization_type
Domain Discretization type.
Definition: theta_time_step.h:72
void assemble_defect(vector_type &d, const vector_type &u, const GridLevel &gl)
assembles Defect
Definition: theta_time_step_impl.h:143
void calc_error(const vector_type &u, error_vector_type &u_vtk)
Definition: theta_time_step.h:122
void invalidate_error()
Definition: theta_time_step.h:126
virtual ~MultiStepTimeDiscretization()
Definition: theta_time_step.h:81
void calc_error(const vector_type &u, error_vector_type *u_vtk)
Error estimator ///.
Definition: theta_time_step_impl.h:261
void calc_error(const vector_type &u)
Definition: theta_time_step.h:121
algebra_type::matrix_type matrix_type
Type of algebra matrix.
Definition: theta_time_step.h:63
number m_futureTime
Future Time.
Definition: theta_time_step.h:147
virtual number future_time() const
returns the future time point (i.e. the one that will be computed)
Definition: theta_time_step.h:101
MultiStepTimeDiscretization(SmartPtr< IDomainDiscretization< algebra_type > > spDD)
constructor
Definition: theta_time_step.h:76
std::vector< number > m_vScaleMass
Scaling for mass part.
Definition: theta_time_step.h:142
void assemble_linear(matrix_type &A, vector_type &b, const GridLevel &gl)
Assembles Matrix and Right-Hand-Side for a linear problem.
Definition: theta_time_step_impl.h:184
size_t m_prevSteps
number of previous steps needed.
Definition: theta_time_step.h:141
void assemble_rhs(vector_type &b, const vector_type &u, const GridLevel &gl)
assembles rhs
Definition: theta_time_step_impl.h:231
Wrapper for sequential matrices to handle them in parallel.
Definition: parallel_matrix.h:65
Singly Diagonal Implicit Runge Kutta Method.
Definition: theta_time_step.h:411
number m_lastTime
Definition: theta_time_step.h:504
TAlgebra algebra_type
Type of algebra.
Definition: theta_time_step.h:417
number m_Time0
Definition: theta_time_step.h:503
void assemble_jacobian(matrix_type &J, const vector_type &u, const GridLevel &gl)
assembles Jacobian (or Approximation of Jacobian)
Definition: theta_time_step_impl.h:643
algebra_type::vector_type vector_type
Type of algebra vector.
Definition: theta_time_step.h:423
SDIRK(SmartPtr< IDomainDiscretization< TAlgebra > > spDD)
default constructor (implicit Euler)
Definition: theta_time_step.h:427
void assemble_linear(matrix_type &A, vector_type &b, const GridLevel &gl)
Assembles Matrix and Right-Hand-Side for a linear problem.
Definition: theta_time_step_impl.h:708
void assemble_rhs(vector_type &b, const vector_type &u, const GridLevel &gl)
assembles rhs
Definition: theta_time_step_impl.h:722
virtual void prepare_step(SmartPtr< VectorTimeSeries< vector_type > > prevSol, number dt)
prepares the assembling of Defect/Jacobian for a time step
Definition: theta_time_step_impl.h:612
virtual void set_stage(size_t stage)
sets the stage
Definition: theta_time_step_impl.h:339
SDIRK(SmartPtr< IDomainDiscretization< TAlgebra > > spDD, int order)
theta = 1.0 -> Implicit Euler, 0.0 -> Explicit Euler
Definition: theta_time_step.h:435
int m_order
Definition: theta_time_step.h:502
IDomainDiscretization< TAlgebra > domain_discretization_type
Domain Discretization type.
Definition: theta_time_step.h:414
void assemble_defect(vector_type &d, const vector_type &u, const GridLevel &gl)
assembles Defect
Definition: theta_time_step_impl.h:670
virtual ~SDIRK()
Definition: theta_time_step.h:443
void adjust_solution(vector_type &u, const GridLevel &gl)
sets dirichlet values in solution vector
Definition: theta_time_step_impl.h:697
size_t m_stage
Definition: theta_time_step.h:501
virtual number update_scaling(std::vector< number > &vSM, std::vector< number > &vSA, number dt)
Definition: theta_time_step_impl.h:345
virtual number update_scaling(std::vector< number > &vSM, std::vector< number > &vSA, number dt, number currentTime, ConstSmartPtr< VectorTimeSeries< vector_type > > prevSol)
Error estimator ///.
Definition: theta_time_step.h:494
void set_order(int order)
sets the scheme
Definition: theta_time_step.h:446
virtual size_t num_stages() const
returns number of stages
Definition: theta_time_step.h:452
algebra_type::matrix_type matrix_type
Type of algebra matrix.
Definition: theta_time_step.h:420
theta time stepping scheme
Definition: theta_time_step.h:167
TAlgebra algebra_type
Type of algebra.
Definition: theta_time_step.h:173
virtual void set_stage(size_t stage)
sets the stage
Definition: theta_time_step.h:224
IDomainDiscretization< TAlgebra > domain_discretization_type
Domain Discretization type.
Definition: theta_time_step.h:170
virtual size_t num_stages() const
returns number of stages
Definition: theta_time_step.h:215
algebra_type::matrix_type matrix_type
Type of algebra matrix.
Definition: theta_time_step.h:176
algebra_type::vector_type vector_type
Type of algebra vector.
Definition: theta_time_step.h:179
number m_theta
Definition: theta_time_step.h:291
void set_scheme(const char *scheme)
sets the scheme
Definition: theta_time_step.h:212
virtual ~ThetaTimeStep()
Definition: theta_time_step.h:209
ThetaTimeStep(SmartPtr< IDomainDiscretization< TAlgebra > > spDD, number theta)
theta = 1.0 -> Implicit Euler, 0.0 -> Explicit Euler
Definition: theta_time_step.h:192
virtual number update_scaling(std::vector< number > &vSM, std::vector< number > &vSA, number dt, number currentTime, ConstSmartPtr< VectorTimeSeries< vector_type > > prevSol)
Error estimator ///.
Definition: theta_time_step.h:230
ThetaTimeStep(SmartPtr< IDomainDiscretization< TAlgebra > > spDD)
default constructor (implicit Euler)
Definition: theta_time_step.h:183
ThetaTimeStep(SmartPtr< IDomainDiscretization< TAlgebra > > spDD, const char *scheme)
theta = 1.0 -> Implicit Euler, 0.0 -> Explicit Euler
Definition: theta_time_step.h:201
void set_theta(number theta)
sets the theta value
Definition: theta_time_step.h:227
std::string m_scheme
Definition: theta_time_step.h:295
size_t m_stage
Definition: theta_time_step.h:293
time series of solutions and corresponding time point
Definition: solution_time_series.h:59
#define UG_THROW(msg)
Definition: error.h:57
double number
Definition: types.h:124
CPUAlgebra::vector_type vector_type