ExaDG
Loading...
Searching...
No Matches
application_base.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_COMPRESSIBLE_NAVIER_STOKES_USER_INTERFACE_APPLICATION_BASE_H_
23#define INCLUDE_EXADG_COMPRESSIBLE_NAVIER_STOKES_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#include <deal.II/grid/tria_description.h>
32
33// ExaDG
34#include <exadg/compressible_navier_stokes/postprocessor/postprocessor.h>
35#include <exadg/compressible_navier_stokes/user_interface/boundary_descriptor.h>
36#include <exadg/compressible_navier_stokes/user_interface/field_functions.h>
37#include <exadg/compressible_navier_stokes/user_interface/parameters.h>
38#include <exadg/grid/grid.h>
39#include <exadg/grid/grid_utilities.h>
40#include <exadg/postprocessor/output_parameters.h>
41
42namespace ExaDG
43{
44namespace CompNS
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()
65 {
66 }
67
68 void
69 set_parameters_throughput_study(unsigned int const degree,
70 unsigned int const refine_space,
71 unsigned int const n_subdivisions_1d_hypercube)
72 {
73 this->param.degree = degree;
74 this->param.grid.n_refine_global = refine_space;
75 this->n_subdivisions_1d_hypercube = n_subdivisions_1d_hypercube;
76 }
77
78 void
79 set_parameters_convergence_study(unsigned int const degree,
80 unsigned int const refine_space,
81 unsigned int const refine_time)
82 {
83 this->param.degree = degree;
84 this->param.grid.n_refine_global = refine_space;
85 this->param.n_refine_time = refine_time;
86 }
87
88 void
89 setup(std::shared_ptr<Grid<dim>> & grid, std::shared_ptr<dealii::Mapping<dim>> & mapping)
90 {
91 parse_parameters();
92
93 // parameters
94 set_parameters();
95 param.check();
96 param.print(pcout, "List of parameters:");
97
98 // grid
99 grid = std::make_shared<Grid<dim>>();
100 create_grid(*grid, mapping);
101 print_grid_info(pcout, *grid);
102
103 // boundary conditions
104 boundary_descriptor = std::make_shared<BoundaryDescriptor<dim>>();
105 set_boundary_descriptor();
106 verify_boundary_conditions<dim>(*boundary_descriptor, *grid);
107
108 // field functions
109 field_functions = std::make_shared<FieldFunctions<dim>>();
110 set_field_functions();
111 }
112
113 virtual std::shared_ptr<PostProcessorBase<dim, Number>>
114 create_postprocessor() = 0;
115
116 Parameters const &
117 get_parameters() const
118 {
119 return param;
120 }
121
122 std::shared_ptr<BoundaryDescriptor<dim> const>
123 get_boundary_descriptor() const
124 {
125 return boundary_descriptor;
126 }
127
128 std::shared_ptr<FieldFunctions<dim> const>
129 get_field_functions() const
130 {
131 return field_functions;
132 }
133
134protected:
135 virtual void
136 parse_parameters()
137 {
138 dealii::ParameterHandler prm;
139 this->add_parameters(prm);
140 prm.parse_input(parameter_file, "", true, true);
141 }
142
143 MPI_Comm const mpi_comm;
144
145 dealii::ConditionalOStream pcout;
146
147 Parameters param;
148
149 std::shared_ptr<BoundaryDescriptor<dim>> boundary_descriptor;
150 std::shared_ptr<FieldFunctions<dim>> field_functions;
151
152 std::string parameter_file;
153
154 unsigned int n_subdivisions_1d_hypercube;
155
156 OutputParameters output_parameters;
157
158private:
159 virtual void
160 set_parameters() = 0;
161
162 virtual void
163 create_grid(Grid<dim> & grid, std::shared_ptr<dealii::Mapping<dim>> & mapping) = 0;
164
165 virtual void
166 set_boundary_descriptor() = 0;
167
168 virtual void
169 set_field_functions() = 0;
170};
171
172} // namespace CompNS
173} // namespace ExaDG
174
175
176#endif /* INCLUDE_EXADG_COMPRESSIBLE_NAVIER_STOKES_USER_INTERFACE_APPLICATION_BASE_H_ */
Definition application_base.h:48
Definition parameters.h:36
Definition grid.h:40
Definition driver.cpp:33
Definition output_parameters.h:32