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 void
129 prepare_vectors_for_next_timestep() override;
130
131 Parameters const & param;
132
133 // number of refinement steps, where the time step size is reduced in
134 // factors of 2 with each refinement
135 unsigned int const refine_steps_time;
136
137 // global cfl number
138 double const cfl;
139
140 // spatial discretization operator
141 std::shared_ptr<SpatialOperatorBase<dim, Number>> operator_base;
142
143 // convective term formulated explicitly
144 bool needs_vector_convective_term;
145 std::vector<VectorType> vec_convective_term;
146 VectorType convective_term_np;
147
148 // required for strongly-coupled partitioned iteration
149 bool use_extrapolation;
150 bool store_solution;
151 bool update_velocity;
152 bool update_pressure;
153
154 // This object allows to access utility functions needed for ALE
155 std::shared_ptr<HelpersALE<dim, Number> const> helpers_ale;
156
157private:
158 void
159 get_quantities_and_times(
160 std::vector<VectorType const *> & quantities,
161 std::vector<double> & times,
162 std::function<VectorType const *(unsigned int const)> const & get_quantity) const;
163
164 void
165 get_quantities_and_times_np(
166 std::vector<VectorType const *> & quantities,
167 std::vector<double> & times,
168 std::function<VectorType const *(unsigned int const)> const & get_quantity,
169 std::function<VectorType const *()> const & get_quantity_np) const;
170
171 void
172 initialize_vec_convective_term();
173
174 double
175 calculate_time_step_size() final;
176
177 double
178 recalculate_time_step_size() const final;
179
180 virtual VectorType const &
181 get_velocity(unsigned int i /* t_{n-i} */) const = 0;
182
183 virtual VectorType const &
184 get_pressure(unsigned int i /* t_{n-i} */) const = 0;
185
186 virtual void
187 set_velocity(VectorType const & velocity, unsigned int const i /* t_{n-i} */) = 0;
188
189 virtual void
190 set_pressure(VectorType const & pressure, unsigned int const i /* t_{n-i} */) = 0;
191
192 void
193 postprocessing() const final;
194
195 // postprocessor
196 std::shared_ptr<PostProcessorInterface<Number>> postprocessor;
197
198 // ALE
199 VectorType grid_velocity;
200 std::vector<VectorType> vec_grid_coordinates;
201 VectorType grid_coordinates_np;
202};
203
204} // namespace IncNS
205} // namespace ExaDG
206
207#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