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