ryujin 2.1.1 revision 7b33fa74945ccba789651fca714670471a34aef7
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
208 template <int dim>
209 class Discretization : public dealii::ParameterAcceptor
210 {
211 public:
219 using Triangulation = typename Proxy<dim>::Triangulation;
220
224 Discretization(const MPI_Comm &mpi_communicator,
225 const std::string &subsection = "/Discretization");
226
231 void prepare(const std::string &base_name);
232
237
242
243
248 {
249 switch (ansatz_) {
250 /* Continous Ansatz: */
251 case Ansatz::cg_q1:
252 [[fallthrough]];
253 case Ansatz::cg_q2:
254 [[fallthrough]];
255 case Ansatz::cg_q3:
256 return false;
257
258 /* Discontinuous Ansatz: */
259 case Ansatz::dg_q0:
260 [[fallthrough]];
261 case Ansatz::dg_q1:
262 [[fallthrough]];
263 case Ansatz::dg_q2:
264 [[fallthrough]];
265 case Ansatz::dg_q3:
266 return true;
267 }
268 __builtin_unreachable();
269 return false;
270 }
271
275 ACCESSOR(refinement)
276
277
281
282
286
291
296
301
306
311
317
318 protected:
319 const MPI_Comm &mpi_communicator_;
320
322 std::unique_ptr<const dealii::Mapping<dim>> mapping_;
323 std::unique_ptr<const dealii::FiniteElement<dim>> finite_element_;
324 std::unique_ptr<const dealii::Quadrature<dim>> quadrature_;
325 std::unique_ptr<const dealii::Quadrature<1>> quadrature_1d_;
326 std::unique_ptr<const dealii::Quadrature<dim - 1>> face_quadrature_;
327 std::unique_ptr<const dealii::Quadrature<dim - 1>> face_nodal_quadrature_;
328
329 private:
331
335
336 Ansatz ansatz_;
337
338 std::string geometry_;
339
340 unsigned int refinement_;
341
342 bool mesh_writeout_;
343 double mesh_distortion_;
344
346
350
351 std::set<std::unique_ptr<Geometry<dim>>> geometry_list_;
352
354 };
355
356
361 template <int dim>
363 std::is_same<typename Discretization<dim>::Triangulation,
364 dealii::parallel::distributed::Triangulation<dim>>::value;
365} /* 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