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