ExaDG
Loading...
Searching...
No Matches
driver.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_DRIVER_H_
23#define EXADG_INCOMPRESSIBLE_NAVIER_STOKES_DRIVER_H_
24
25// ExaDG
26#include <exadg/functions_and_boundary_conditions/verify_boundary_conditions.h>
27#include <exadg/grid/mapping_deformation_function.h>
28#include <exadg/grid/mapping_deformation_poisson.h>
29#include <exadg/incompressible_navier_stokes/postprocessor/postprocessor_base.h>
30#include <exadg/incompressible_navier_stokes/spatial_discretization/operator_consistent_splitting.h>
31#include <exadg/incompressible_navier_stokes/spatial_discretization/operator_coupled.h>
32#include <exadg/incompressible_navier_stokes/spatial_discretization/operator_dual_splitting.h>
33#include <exadg/incompressible_navier_stokes/spatial_discretization/operator_pressure_correction.h>
34#include <exadg/incompressible_navier_stokes/time_integration/driver_steady_problems.h>
35#include <exadg/incompressible_navier_stokes/time_integration/time_int_bdf_consistent_splitting.h>
36#include <exadg/incompressible_navier_stokes/time_integration/time_int_bdf_coupled_solver.h>
37#include <exadg/incompressible_navier_stokes/time_integration/time_int_bdf_dual_splitting.h>
38#include <exadg/incompressible_navier_stokes/time_integration/time_int_bdf_pressure_correction.h>
39#include <exadg/incompressible_navier_stokes/user_interface/application_base.h>
40#include <exadg/matrix_free/matrix_free_data.h>
41#include <exadg/operators/finite_element.h>
42#include <exadg/utilities/print_general_infos.h>
43
44namespace ExaDG
45{
46namespace IncNS
47{
48// Note: Make sure that the correct time integration scheme is selected in the input file that is
49// compatible with the OperatorType specified here. This also includes the treatment of the
50// convective term (explicit/implicit), e.g., specifying VelocityConvDiffOperator together
51// with an explicit treatment of the convective term will only apply the Helmholtz-like
52// operator.
53
54// clang-format off
55enum class OperatorType{
56 CoupledNonlinearResidual, // nonlinear residual of coupled system of equations
57 CoupledLinearized, // linearized system of equations for coupled solution approach
58 PressurePoissonOperator, // negative Laplace operator (scalar quantity, pressure)
59 ConvectiveOperator, // convective term (vectorial quantity, velocity)
60 HelmholtzOperator, // mass + viscous (vectorial quantity, velocity)
61 ProjectionOperator, // mass + divergence penalty + continuity penalty (vectorial quantity, velocity)
62 VelocityConvDiffOperator, // mass + convective + viscous (vectorial quantity, velocity)
63 InverseMassOperator // inverse mass operator (vectorial quantity, velocity)
64};
65// clang-format on
66
67enum class PressureDegree
68{
69 MixedOrder,
70 EqualOrder
71};
72
73inline unsigned int
74get_dofs_per_element(OperatorType const & operator_type,
75 PressureDegree const & pressure_degree,
76 unsigned int const dim,
77 unsigned int const degree,
78 ExaDG::ElementType const element_type)
79{
80 unsigned int degree_p = 1;
81 if(pressure_degree == PressureDegree::MixedOrder)
82 degree_p = degree - 1;
83 else if(pressure_degree == PressureDegree::EqualOrder)
84 degree_p = degree;
85 else
86 AssertThrow(false, dealii::ExcMessage("Not implemented."));
87
88 double const velocity_dofs_per_element = ExaDG::get_dofs_per_element(
89 element_type, true /* is_dg */, dim /* n_components */, degree, dim);
90
91 double const pressure_dofs_per_element = ExaDG::get_dofs_per_element(
92 element_type, true /* is_dg */, 1 /* n_components */, degree_p, dim);
93
94 // coupled/monolithic problem
95 if(operator_type == OperatorType::CoupledNonlinearResidual or
96 operator_type == OperatorType::CoupledLinearized)
97 {
98 return static_cast<unsigned int>(velocity_dofs_per_element + pressure_dofs_per_element);
99 }
100 // velocity only
101 else if(operator_type == OperatorType::ConvectiveOperator or
102 operator_type == OperatorType::VelocityConvDiffOperator or
103 operator_type == OperatorType::HelmholtzOperator or
104 operator_type == OperatorType::ProjectionOperator or
105 operator_type == OperatorType::InverseMassOperator)
106 {
107 return static_cast<unsigned int>(velocity_dofs_per_element);
108 }
109 // pressure only
110 else if(operator_type == OperatorType::PressurePoissonOperator)
111 {
112 return static_cast<unsigned int>(pressure_dofs_per_element);
113 }
114 else
115 {
116 AssertThrow(false, dealii::ExcMessage("Not implemented."));
117 }
118
119 return 0;
120}
121
122template<int dim, typename Number>
123class Driver
124{
125public:
126 Driver(MPI_Comm const & comm,
127 std::shared_ptr<ApplicationBase<dim, Number>> application,
128 bool const is_test,
129 bool const is_throughput_study);
130
131 void
132 setup();
133
134 void
135 solve() const;
136
137 void
138 print_performance_results(double const total_time) const;
139
140 /*
141 * Throughput study
142 */
143 std::tuple<unsigned int, dealii::types::global_dof_index, double>
144 apply_operator(OperatorType const & operator_type,
145 unsigned int const n_repetitions_inner,
146 unsigned int const n_repetitions_outer) const;
147
148private:
149 using VectorType = dealii::LinearAlgebra::distributed::Vector<Number>;
150
151 void
152 ale_update() const;
153
154 // MPI communicator
155 MPI_Comm const mpi_comm;
156
157 // output to std::cout
158 dealii::ConditionalOStream pcout;
159
160 // do not print wall times if is_test
161 bool const is_test;
162
163 // do not set up certain data structures (solver, postprocessor) in case of throughput study
164 bool const is_throughput_study;
165
166 // application
167 std::shared_ptr<ApplicationBase<dim, Number>> application;
168
169 // Grid and mapping
170 std::shared_ptr<Grid<dim>> grid;
171
172 std::shared_ptr<dealii::Mapping<dim>> mapping;
173
174 std::shared_ptr<MultigridMappings<dim, Number>> multigrid_mappings;
175
176 // ALE mapping
177 std::shared_ptr<DeformedMappingBase<dim, Number>> ale_mapping;
178
179 std::shared_ptr<MultigridMappings<dim, Number>> ale_multigrid_mappings;
180
181 // ALE helper functions required by time integrator
182 std::shared_ptr<HelpersALE<dim, Number>> helpers_ale;
183
184 /*
185 * Spatial discretization
186 */
187 std::shared_ptr<SpatialOperatorBase<dim, Number>> pde_operator;
188
189 /*
190 * Postprocessor
191 */
192 typedef PostProcessorBase<dim, Number> Postprocessor;
193
194 std::shared_ptr<Postprocessor> postprocessor;
195
196 /*
197 * Temporal discretization
198 */
199
200 // unsteady solver
201 std::shared_ptr<TimeIntBDF<dim, Number>> time_integrator;
202
203 // steady solver
204 std::shared_ptr<DriverSteadyProblems<dim, Number>> driver_steady;
205
206 /*
207 * Computation time (wall clock time).
208 */
209 mutable TimerTree timer_tree;
210};
211
212} // namespace IncNS
213} // namespace ExaDG
214
215#endif /* EXADG_INCOMPRESSIBLE_NAVIER_STOKES_DRIVER_H_ */
Definition application_base.h:51
Definition postprocessor_base.h:40
Definition timer_tree.h:36
Definition driver.cpp:33