ExaDG
Loading...
Searching...
No Matches
application_base.h
1/* ______________________________________________________________________
2 *
3 * ExaDG - High-Order Discontinuous Galerkin for the Exa-Scale
4 *
5 * Copyright (C) 2023 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_ACOUSTIC_CONSERVATION_EQUATIONS_USER_INTERFACE_APPLICATION_BASE_H_
23#define EXADG_ACOUSTIC_CONSERVATION_EQUATIONS_USER_INTERFACE_APPLICATION_BASE_H_
24
25// deal.II
26#include <deal.II/distributed/fully_distributed_tria.h>
27#include <deal.II/distributed/tria.h>
28#include <deal.II/grid/grid_generator.h>
29#include <deal.II/grid/grid_tools.h>
30#include <deal.II/grid/manifold_lib.h>
31
32// ExaDG
33#include <exadg/acoustic_conservation_equations/postprocessor/postprocessor.h>
34#include <exadg/acoustic_conservation_equations/user_interface/boundary_descriptor.h>
35#include <exadg/acoustic_conservation_equations/user_interface/field_functions.h>
36#include <exadg/acoustic_conservation_equations/user_interface/parameters.h>
37#include <exadg/grid/grid.h>
38#include <exadg/grid/grid_utilities.h>
39#include <exadg/operators/resolution_parameters.h>
40#include <exadg/postprocessor/output_parameters.h>
41
42namespace ExaDG
43{
44namespace Acoustics
45{
46template<int dim, typename Number>
48{
49public:
50 virtual void
51 add_parameters(dealii::ParameterHandler & prm)
52 {
53 output_parameters.add_parameters(prm);
54 }
55
56 ApplicationBase(std::string parameter_file, MPI_Comm const & comm)
57 : mpi_comm(comm),
58 pcout(std::cout, dealii::Utilities::MPI::this_mpi_process(mpi_comm) == 0),
59 parameter_file(parameter_file),
60 n_subdivisions_1d_hypercube(1)
61 {
62 }
63
64 virtual ~ApplicationBase() = default;
65
66 void
67 set_parameters_throughput_study(unsigned int const degree,
68 unsigned int const refine_space,
69 unsigned int const n_subdivisions_1d_hypercube)
70 {
71 this->param.degree_u = degree;
72 this->param.grid.n_refine_global = refine_space;
73 this->n_subdivisions_1d_hypercube = n_subdivisions_1d_hypercube;
74 }
75
76 void
77 set_parameters_convergence_study(unsigned int const degree,
78 unsigned int const refine_space,
79 unsigned int const refine_time)
80 {
81 this->param.degree_u = degree;
82 this->param.grid.n_refine_global = refine_space;
83 this->param.n_refine_time = refine_time;
84 }
85
86 virtual void
87 setup(std::shared_ptr<Grid<dim>> & grid, std::shared_ptr<dealii::Mapping<dim>> & mapping)
88 {
89 parse_parameters();
90
91 set_parameters();
92 param.check();
93 param.print(pcout, "List of parameters:");
94
95 // grid
96 grid = std::make_shared<Grid<dim>>();
97 create_grid(*grid, mapping);
98 print_grid_info(pcout, *grid);
99
100 // boundary conditions
101 boundary_descriptor = std::make_shared<BoundaryDescriptor<dim>>();
102 set_boundary_descriptor();
103 ExaDG::verify_boundary_conditions<dim>(*boundary_descriptor, *grid);
104
105 // field functions
106 field_functions = std::make_shared<FieldFunctions<dim>>();
107 set_field_functions();
108 }
109
110 virtual std::shared_ptr<PostProcessorBase<dim, Number>>
111 create_postprocessor() = 0;
112
113 Parameters const &
114 get_parameters() const
115 {
116 return param;
117 }
118
119 std::shared_ptr<BoundaryDescriptor<dim> const>
120 get_boundary_descriptor() const
121 {
122 return boundary_descriptor;
123 }
124
125 std::shared_ptr<FieldFunctions<dim> const>
126 get_field_functions() const
127 {
128 return field_functions;
129 }
130
131 // Analytical mesh motion
132 virtual std::shared_ptr<dealii::Function<dim>>
133 create_mesh_movement_function()
134 {
135 std::shared_ptr<dealii::Function<dim>> mesh_motion =
136 std::make_shared<dealii::Functions::ZeroFunction<dim>>(dim);
137
138 return mesh_motion;
139 }
140
141protected:
142 virtual void
143 parse_parameters()
144 {
145 dealii::ParameterHandler prm;
146 this->add_parameters(prm);
147 prm.parse_input(parameter_file, "", true, true);
148 }
149
150 MPI_Comm const mpi_comm;
151
152 dealii::ConditionalOStream pcout;
153
154 Parameters param;
155
156 std::shared_ptr<FieldFunctions<dim>> field_functions;
157 std::shared_ptr<BoundaryDescriptor<dim>> boundary_descriptor;
158
159 std::string parameter_file;
160
161 unsigned int n_subdivisions_1d_hypercube;
162
163 OutputParameters output_parameters;
164
165private:
166 virtual void
167 set_parameters() = 0;
168
169 virtual void
170 create_grid(Grid<dim> & grid, std::shared_ptr<dealii::Mapping<dim>> & mapping) = 0;
171
172 virtual void
173 set_boundary_descriptor() = 0;
174
175 virtual void
176 set_field_functions() = 0;
177};
178
179
180} // namespace Acoustics
181} // namespace ExaDG
182
183
184#endif /* EXADG_ACOUSTIC_CONSERVATION_EQUATIONS_USER_INTERFACE_APPLICATION_BASE_H_ */
Definition application_base.h:48
Definition parameters.h:41
Definition grid.h:40
Definition driver.cpp:33
Definition output_parameters.h:32