OGS
TimeLoop.h
Go to the documentation of this file.
1
11#pragma once
12
13#include <functional>
14#include <memory>
15
18#include "Process.h"
20
21namespace NumLib
22{
23class ConvergenceCriterion;
24}
25
26namespace ChemistryLib
27{
28class ChemicalSolverInterface;
29}
30
31namespace ProcessLib
32{
33struct ProcessData;
34
37{
38public:
39 TimeLoop(std::unique_ptr<Output>&& output,
40 std::vector<std::unique_ptr<ProcessData>>&& per_process_data,
41 const int global_coupling_max_iterations,
42 std::vector<std::unique_ptr<NumLib::ConvergenceCriterion>>&&
43 global_coupling_conv_crit,
44 const double start_time, const double end_time);
45
46 void initialize();
47 void outputLastTimeStep() const;
48
49 ~TimeLoop();
50
51 bool executeTimeStep();
53 double endTime() const { return _end_time; }
54 double currentTime() const { return _current_time; }
56
57private:
58 bool doNonlinearIteration(double const t, double const dt,
59 std::size_t const timesteps);
67
80 const double t, const double dt, const std::size_t timestep_id);
81
93 const double t, const double dt, const std::size_t timestep_id);
94
110 std::pair<double, bool> computeTimeStepping(
111 const double prev_dt, double& t, std::size_t& accepted_steps,
112 std::size_t& rejected_steps,
113 std::vector<std::function<double(double, double)>> const&
114 time_step_constraints);
115
116 template <typename OutputClass, typename OutputClassMember>
117 void outputSolutions(bool const output_initial_condition, unsigned timestep,
118 const double t, OutputClass& output_object,
119 OutputClassMember output_class_member) const;
120
121private:
122 std::vector<GlobalVector*> _process_solutions;
123 std::vector<GlobalVector*> _process_solutions_prev;
124 std::unique_ptr<Output> _output;
125 std::vector<std::unique_ptr<ProcessData>> _per_process_data;
126
127 const double _start_time;
128 const double _end_time;
130 std::size_t _accepted_steps = 0;
131 std::size_t _rejected_steps = 0;
132 double _dt = 0;
135
139 std::vector<std::unique_ptr<NumLib::ConvergenceCriterion>>
141
144 std::vector<GlobalVector*> _solutions_of_last_cpl_iteration;
145
149 std::vector<std::size_t> _xdot_vector_ids;
150};
151} // namespace ProcessLib
Time loop capable of time-integrating several processes at once.
Definition: TimeLoop.h:37
std::pair< double, bool > computeTimeStepping(const double prev_dt, double &t, std::size_t &accepted_steps, std::size_t &rejected_steps, std::vector< std::function< double(double, double)> > const &time_step_constraints)
Definition: TimeLoop.cpp:306
void outputSolutions(bool const output_initial_condition, unsigned timestep, const double t, OutputClass &output_object, OutputClassMember output_class_member) const
Definition: TimeLoop.cpp:851
bool doNonlinearIteration(double const t, double const dt, std::size_t const timesteps)
Definition: TimeLoop.cpp:633
TimeLoop(std::unique_ptr< Output > &&output, std::vector< std::unique_ptr< ProcessData > > &&per_process_data, const int global_coupling_max_iterations, std::vector< std::unique_ptr< NumLib::ConvergenceCriterion > > &&global_coupling_conv_crit, const double start_time, const double end_time)
Definition: TimeLoop.cpp:276
void outputLastTimeStep() const
Definition: TimeLoop.cpp:616
std::vector< GlobalVector * > _solutions_of_last_cpl_iteration
Definition: TimeLoop.h:144
const double _start_time
Definition: TimeLoop.h:127
std::vector< std::size_t > _xdot_vector_ids
Definition: TimeLoop.h:149
double currentTime() const
Definition: TimeLoop.h:54
NumLib::NonlinearSolverStatus solveUncoupledEquationSystems(const double t, const double dt, const std::size_t timestep_id)
Member to solver non coupled systems of equations, which can be a single system of equations,...
Definition: TimeLoop.cpp:687
std::vector< std::unique_ptr< ProcessData > > _per_process_data
Definition: TimeLoop.h:125
const double _end_time
Definition: TimeLoop.h:128
std::size_t _accepted_steps
Definition: TimeLoop.h:130
bool successful_time_step
Definition: TimeLoop.h:55
std::vector< std::unique_ptr< NumLib::ConvergenceCriterion > > _global_coupling_conv_crit
Convergence criteria of processes for the global coupling iterations.
Definition: TimeLoop.h:140
void setCoupledSolutions()
Definition: TimeLoop.cpp:291
const int _global_coupling_max_iterations
Maximum iterations of the global coupling.
Definition: TimeLoop.h:137
std::vector< GlobalVector * > _process_solutions
Definition: TimeLoop.h:122
std::unique_ptr< Output > _output
Definition: TimeLoop.h:124
void initialize()
initialize output, convergence criterion, etc.
Definition: TimeLoop.cpp:485
int _repeating_times_of_rejected_step
Definition: TimeLoop.h:133
std::size_t _rejected_steps
Definition: TimeLoop.h:131
bool calculateNextTimeStep()
Definition: TimeLoop.cpp:565
std::vector< GlobalVector * > _process_solutions_prev
Definition: TimeLoop.h:123
double endTime() const
Definition: TimeLoop.h:53
NumLib::NonlinearSolverStatus solveCoupledEquationSystemsByStaggeredScheme(const double t, const double dt, const std::size_t timestep_id)
Member to solver coupled systems of equations by the staggered scheme.
Definition: TimeLoop.cpp:730
static const double t
Status of the non-linear solver.