ExaDG
Loading...
Searching...
No Matches
time_integration_constants_base.h
1/* ______________________________________________________________________
2 *
3 * ExaDG - High-Order Discontinuous Galerkin for the Exa-Scale
4 *
5 * Copyright (C) 2021 by the ExaDG authors
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <https://www.gnu.org/licenses/>.
19 * ______________________________________________________________________
20 */
21
22#ifndef INCLUDE_EXADG_TIME_INTEGRATION_TIME_INTEGRATION_CONSTANTS_BASE_H_
23#define INCLUDE_EXADG_TIME_INTEGRATION_TIME_INTEGRATION_CONSTANTS_BASE_H_
24
25#include <vector>
26
27namespace ExaDG
28{
30{
31public:
32 TimeIntegratorConstantsBase(unsigned int const order, bool const start_with_low_order)
33 : order(order), start_with_low_order(start_with_low_order)
34 {
35 }
36
38 {
39 }
40
41 /*
42 * This function updates the time integrator constants. The argument time_steps is only used in
43 * case of adaptive time stepping.
44 */
45 void
46 update(unsigned int const current_order,
47 bool const adaptive_time_stepping,
48 std::vector<double> const & time_steps)
49 {
50 // when starting the time integrator with a low order method, ensure that
51 // the time integrator constants are set properly
52 unsigned int const update_order =
53 (current_order <= order and start_with_low_order == true) ? current_order : order;
54
55 if(adaptive_time_stepping)
56 set_adaptive_time_step(update_order, time_steps);
57 else
58 set_constant_time_step(update_order);
59 }
60
61 unsigned int
62 get_order() const
63 {
64 return order;
65 }
66
67 /*
68 * This function prints the time integrator constants
69 */
70 virtual void
71 print(dealii::ConditionalOStream & pcout) const = 0;
72
73protected:
79 void
80 disable_high_order_constants(unsigned int const current_order, std::vector<double> & constants)
81 {
82 for(unsigned int i = current_order; i < constants.size(); ++i)
83 constants[i] = 0.0;
84 }
85
86
87 // order of time integrator
88 unsigned int const order;
89
90 // use a low order time integration scheme to start the time integrator?
91 bool const start_with_low_order;
92
93private:
94 /*
95 * This function calculates the time integrator constants in case of constant time step sizes.
96 */
97 virtual void
98 set_constant_time_step(unsigned int const current_order) = 0;
99
100 /*
101 * This function calculates time integrator constants in case of varying time step sizes
102 * (adaptive time stepping).
103 */
104 virtual void
105 set_adaptive_time_step(unsigned int const current_order,
106 std::vector<double> const & time_steps) = 0;
107};
108} // namespace ExaDG
109
110
111#endif /* INCLUDE_EXADG_TIME_INTEGRATION_TIME_INTEGRATION_CONSTANTS_BASE_H_ */
Definition time_integration_constants_base.h:30
void disable_high_order_constants(unsigned int const current_order, std::vector< double > &constants)
Definition time_integration_constants_base.h:80
Definition driver.cpp:33