ryujin 2.1.1 revision fd1a8e8ebb4535655802e400781bce67403e1e49
discretization.h
Go to the documentation of this file.
1//
2// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
3// Copyright (C) 2020 - 2024 by the ryujin authors
4//
5
6#pragma once
7
8#include <compile_time_options.h>
9
10#include "convenience_macros.h"
11#include "geometry.h"
12#include "patterns_conversion.h"
13
14#include <deal.II/base/parameter_acceptor.h>
15#include <deal.II/base/quadrature.h>
16#include <deal.II/distributed/shared_tria.h>
17#include <deal.II/distributed/tria.h>
18#include <deal.II/fe/fe.h>
19#include <deal.II/fe/mapping.h>
20
21#include <memory>
22#include <set>
23
24namespace ryujin
25{
48 enum Boundary : dealii::types::boundary_id {
58
65
75 slip = 2,
76
86
98
114
123 };
124
125
131 enum class Ansatz {
133 cg_q1,
134
136 cg_q2,
137
139 cg_q3,
140
142 dg_q0,
143
145 dg_q1,
146
148 dg_q2,
149
151 dg_q3
152 };
153} // namespace ryujin
154
155#ifndef DOXYGEN
156DECLARE_ENUM(ryujin::Boundary,
157 LIST({ryujin::Boundary::do_nothing, "do nothing"},
158 {ryujin::Boundary::periodic, "periodic"},
159 {ryujin::Boundary::slip, "slip"},
160 {ryujin::Boundary::no_slip, "no slip"},
161 {ryujin::Boundary::dirichlet, "dirichlet"},
162 {ryujin::Boundary::dynamic, "dynamic"},
164 "dirichlet momentum"}));
165
166DECLARE_ENUM(ryujin::Ansatz,
167 LIST({ryujin::Ansatz::cg_q1, "cG Q1"},
168 {ryujin::Ansatz::cg_q2, "cG Q2"},
169 {ryujin::Ansatz::cg_q3, "cG Q3"},
170 {ryujin::Ansatz::dg_q0, "dG Q0"},
171 {ryujin::Ansatz::dg_q1, "dG Q1"},
172 {ryujin::Ansatz::dg_q2, "dG Q2"},
173 {ryujin::Ansatz::dg_q3, "dG Q3"}));
174#endif
175
176namespace ryujin
177{
178 namespace
179 {
180 template <int dim>
181 struct Proxy {
182 using Triangulation = dealii::parallel::distributed::Triangulation<dim>;
183 };
184
185 template <>
186 struct Proxy<1> {
187 using Triangulation = dealii::parallel::shared::Triangulation<1>;
188 };
189
190 } // namespace
191
192#ifndef DOXYGEN
193 /* forward declaration */
194 template <int dim>
195 class Discretization;
196#endif
197
202 template <int dim>
204 std::is_same<typename Discretization<dim>::Triangulation,
205 dealii::parallel::distributed::Triangulation<dim>>::value;
206
207
223 template <int dim>
224 class Discretization : public dealii::ParameterAcceptor
225 {
226 public:
234 using Triangulation = typename Proxy<dim>::Triangulation;
235
236 static_assert(dim == 1 || have_distributed_triangulation<dim>);
237
241 Discretization(const MPI_Comm &mpi_communicator,
242 const std::string &subsection = "/Discretization");
243
248 void prepare(const std::string &base_name);
249
254
259
260
265 {
266 switch (ansatz_) {
267 /* Continous Ansatz: */
268 case Ansatz::cg_q1:
269 [[fallthrough]];
270 case Ansatz::cg_q2:
271 [[fallthrough]];
272 case Ansatz::cg_q3:
273 return false;
274
275 /* Discontinuous Ansatz: */
276 case Ansatz::dg_q0:
277 [[fallthrough]];
278 case Ansatz::dg_q1:
279 [[fallthrough]];
280 case Ansatz::dg_q2:
281 [[fallthrough]];
282 case Ansatz::dg_q3:
283 return true;
284 }
285 __builtin_unreachable();
286 return false;
287 }
288
292 ACCESSOR(refinement)
293
294
298
299
303
308
313
318
323
328
334
335 protected:
336 const MPI_Comm &mpi_communicator_;
337
339 std::unique_ptr<const dealii::Mapping<dim>> mapping_;
340 std::unique_ptr<const dealii::FiniteElement<dim>> finite_element_;
341 std::unique_ptr<const dealii::Quadrature<dim>> quadrature_;
342 std::unique_ptr<const dealii::Quadrature<1>> quadrature_1d_;
343 std::unique_ptr<const dealii::Quadrature<dim - 1>> face_quadrature_;
344 std::unique_ptr<const dealii::Quadrature<dim - 1>> face_nodal_quadrature_;
345
346 private:
348
352
353 Ansatz ansatz_;
354
355 std::string geometry_;
356
357 unsigned int refinement_;
358
359 bool mesh_writeout_;
360 double mesh_distortion_;
361 bool mesh_repartitioning_;
362
364
368
369 std::set<std::unique_ptr<Geometry<dim>>> geometry_list_;
370
372 };
373} /* namespace ryujin */
auto & finite_element() const
std::unique_ptr< const dealii::Quadrature< dim - 1 > > face_quadrature_
typename Proxy< dim >::Triangulation Triangulation
std::unique_ptr< Triangulation > triangulation_
auto & triangulation() const
std::unique_ptr< const dealii::Quadrature< 1 > > quadrature_1d_
std::unique_ptr< const dealii::Quadrature< dim - 1 > > face_nodal_quadrature_
std::unique_ptr< const dealii::Mapping< dim > > mapping_
void prepare(const std::string &base_name)
auto & mapping() const
bool have_discontinuous_ansatz() const
auto & quadrature() const
Discretization(const MPI_Comm &mpi_communicator, const std::string &subsection="/Discretization")
const MPI_Comm & mpi_communicator_
auto & quadrature_1d() const
auto & face_quadrature() const
std::unique_ptr< const dealii::FiniteElement< dim > > finite_element_
std::unique_ptr< const dealii::Quadrature< dim > > quadrature_
auto & face_nodal_quadrature() const
@ dirichlet_momentum
#define ACCESSOR(member)
#define ACCESSOR_READ_ONLY(member)
constexpr bool have_distributed_triangulation