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 INCLUDE_EXADG_INCOMPRESSIBLE_NAVIER_STOKES_TIME_INTEGRATION_TIME_INT_BDF_H_
23#define INCLUDE_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
99 virtual void
100 print_iterations() const = 0;
101
102 bool
103 print_solver_info() const final;
104
105protected:
106 void
107 allocate_vectors() override;
108
109 void
110 setup_derived() override;
111
112 void
113 read_restart_vectors(BoostInputArchiveType & ia) override;
114
115 void
116 write_restart_vectors(BoostOutputArchiveType & oa) const override;
117
118 void
119 prepare_vectors_for_next_timestep() override;
120
121 Parameters const & param;
122
123 // number of refinement steps, where the time step size is reduced in
124 // factors of 2 with each refinement
125 unsigned int const refine_steps_time;
126
127 // global cfl number
128 double const cfl;
129
130 // spatial discretization operator
131 std::shared_ptr<SpatialOperatorBase<dim, Number>> operator_base;
132
133 // convective term formulated explicitly
134 bool needs_vector_convective_term;
135 std::vector<VectorType> vec_convective_term;
136 VectorType convective_term_np;
137
138 // required for strongly-coupled partitioned iteration
139 bool use_extrapolation;
140 bool store_solution;
141
142 // This object allows to access utility functions needed for ALE
143 std::shared_ptr<HelpersALE<dim, Number> const> helpers_ale;
144
145private:
146 void
147 get_quantities_and_times(
148 std::vector<VectorType const *> & quantities,
149 std::vector<double> & times,
150 std::function<VectorType const *(unsigned int const)> const & get_quantity) const;
151
152 void
153 get_quantities_and_times_np(
154 std::vector<VectorType const *> & quantities,
155 std::vector<double> & times,
156 std::function<VectorType const *(unsigned int const)> const & get_quantity,
157 std::function<VectorType const *()> const & get_quantity_np) const;
158
159 void
160 initialize_vec_convective_term();
161
162 double
163 calculate_time_step_size() final;
164
165 double
166 recalculate_time_step_size() const final;
167
168 virtual VectorType const &
169 get_velocity(unsigned int i /* t_{n-i} */) const = 0;
170
171 virtual VectorType const &
172 get_pressure(unsigned int i /* t_{n-i} */) const = 0;
173
174 virtual void
175 set_velocity(VectorType const & velocity, unsigned int const i /* t_{n-i} */) = 0;
176
177 virtual void
178 set_pressure(VectorType const & pressure, unsigned int const i /* t_{n-i} */) = 0;
179
180 void
181 postprocessing() const final;
182
183 // postprocessor
184 std::shared_ptr<PostProcessorInterface<Number>> postprocessor;
185
186 // ALE
187 VectorType grid_velocity;
188 std::vector<VectorType> vec_grid_coordinates;
189 VectorType grid_coordinates_np;
190};
191
192} // namespace IncNS
193} // namespace ExaDG
194
195#endif /* INCLUDE_EXADG_INCOMPRESSIBLE_NAVIER_STOKES_TIME_INTEGRATION_TIME_INT_BDF_H_ */
Definition lambda_functions_ale.h:40
Definition parameters.h:46
Definition postprocessor_interface.h:34
Definition spatial_operator_base.h:68
Definition driver.cpp:33