ExaDG
Loading...
Searching...
No Matches
time_int_bdf.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 EXADG_INCOMPRESSIBLE_NAVIER_STOKES_TIME_INTEGRATION_TIME_INT_BDF_H_
23#define EXADG_INCOMPRESSIBLE_NAVIER_STOKES_TIME_INTEGRATION_TIME_INT_BDF_H_
24
25// deal.II
26#include <deal.II/lac/la_parallel_vector.h>
27
28// ExaDG
29#include <exadg/time_integration/lambda_functions_ale.h>
30#include <exadg/time_integration/time_int_bdf_base.h>
31
32namespace ExaDG
33{
34namespace IncNS
35{
36class Parameters;
37
38template<int dim, typename Number>
40
41template<typename Number>
43
44template<int dim, typename Number>
45class TimeIntBDF : public TimeIntBDFBase
46{
47public:
48 using Base = TimeIntBDFBase;
49 using VectorType = dealii::LinearAlgebra::distributed::Vector<Number>;
50 using BlockVectorType = dealii::LinearAlgebra::distributed::BlockVector<Number>;
51 using BoostInputArchiveType = TimeIntBase::BoostInputArchiveType;
52 using BoostOutputArchiveType = TimeIntBase::BoostOutputArchiveType;
53
54 TimeIntBDF(std::shared_ptr<SpatialOperatorBase<dim, Number>> operator_in,
55 std::shared_ptr<HelpersALE<dim, Number> const> helpers_ale_in,
56 std::shared_ptr<PostProcessorInterface<Number>> postprocessor_in,
57 Parameters const & param_in,
58 MPI_Comm const & mpi_comm_in,
59 bool const is_test_in);
60
61 virtual ~TimeIntBDF()
62 {
63 }
64
65 virtual VectorType const &
66 get_velocity() const = 0;
67
68 virtual VectorType const &
69 get_velocity_np() const = 0;
70
71 virtual VectorType const &
72 get_pressure() const = 0;
73
74 virtual VectorType const &
75 get_pressure_np() const = 0;
76
77 void
78 get_velocities_and_times(std::vector<VectorType const *> & velocities,
79 std::vector<double> & times) const;
80
81 void
82 get_velocities_and_times_np(std::vector<VectorType const *> & velocities,
83 std::vector<double> & times) const;
84
85 void
86 get_pressures_and_times(std::vector<VectorType const *> & pressures,
87 std::vector<double> & times) const;
88
89 void
90 get_pressures_and_times_np(std::vector<VectorType const *> & pressures,
91 std::vector<double> & times) const;
92
93 void
94 ale_update();
95
96 void
97 advance_one_timestep_partitioned_solve(bool const use_extrapolation,
98 bool const update_velocity,
99 bool const update_pressure);
100
101 virtual void
102 print_iterations() const = 0;
103
104 bool
105 print_solver_info() const final;
106
107protected:
108 void
109 allocate_vectors() override;
110
111 void
112 setup_derived() override;
113
114 void
115 read_restart_vectors() final;
116
117 void
118 write_restart_vectors() const final;
119
120 virtual void
121 get_vectors_serialization(std::vector<VectorType const *> & vectors_velocity,
122 std::vector<VectorType const *> & vectors_pressure) const;
123
124 virtual void
125 set_vectors_deserialization(std::vector<VectorType> const & vectors_velocity,
126 std::vector<VectorType> const & vectors_pressure);
127
128 virtual void
129 update_after_deserialization();
130
131 void
132 prepare_vectors_for_next_timestep() override;
133
134 Parameters const & param;
135
136 // number of refinement steps, where the time step size is reduced in
137 // factors of 2 with each refinement
138 unsigned int const refine_steps_time;
139
140 // global cfl number
141 double const cfl;
142
143 // spatial discretization operator
144 std::shared_ptr<SpatialOperatorBase<dim, Number>> operator_base;
145
146 // convective term formulated explicitly
147 bool needs_vector_convective_term;
148 std::vector<VectorType> vec_convective_term;
149 VectorType convective_term_np;
150
151 // required for strongly-coupled partitioned iteration
152 bool use_extrapolation;
153 bool store_solution;
154 bool update_velocity;
155 bool update_pressure;
156
157 // This object allows to access utility functions needed for ALE
158 std::shared_ptr<HelpersALE<dim, Number> const> helpers_ale;
159
160private:
161 void
162 get_quantities_and_times(
163 std::vector<VectorType const *> & quantities,
164 std::vector<double> & times,
165 std::function<VectorType const *(unsigned int const)> const & get_quantity) const;
166
167 void
168 get_quantities_and_times_np(
169 std::vector<VectorType const *> & quantities,
170 std::vector<double> & times,
171 std::function<VectorType const *(unsigned int const)> const & get_quantity,
172 std::function<VectorType const *()> const & get_quantity_np) const;
173
174 void
175 initialize_vec_convective_term();
176
177 double
178 calculate_time_step_size() final;
179
180 double
181 recalculate_time_step_size() const final;
182
183 virtual VectorType const &
184 get_velocity(unsigned int i /* t_{n-i} */) const = 0;
185
186 virtual VectorType const &
187 get_pressure(unsigned int i /* t_{n-i} */) const = 0;
188
189 virtual void
190 set_velocity(VectorType const & velocity, unsigned int const i /* t_{n-i} */) = 0;
191
192 virtual void
193 set_pressure(VectorType const & pressure, unsigned int const i /* t_{n-i} */) = 0;
194
195 void
196 postprocessing() const final;
197
198 // postprocessor
199 std::shared_ptr<PostProcessorInterface<Number>> postprocessor;
200
201 // ALE
202 VectorType grid_velocity;
203 std::vector<VectorType> vec_grid_coordinates;
204 VectorType grid_coordinates_np;
205};
206
207} // namespace IncNS
208} // namespace ExaDG
209
210#endif /* EXADG_INCOMPRESSIBLE_NAVIER_STOKES_TIME_INTEGRATION_TIME_INT_BDF_H_ */
Definition lambda_functions_ale.h:40
Definition parameters.h:46
Definition postprocessor_interface.h:37
Definition spatial_operator_base.h:68
Definition driver.cpp:33