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