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