ryujin 2.1.1 revision 0348cbb53a3e4b1da2a4c037e81f88f2d21ce219
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 "mpi_ensemble.h"
13#include "patterns_conversion.h"
14
15#include <deal.II/base/parameter_acceptor.h>
16#include <deal.II/base/quadrature.h>
17#include <deal.II/distributed/shared_tria.h>
18#include <deal.II/distributed/tria.h>
19#include <deal.II/fe/fe.h>
20#include <deal.II/fe/mapping.h>
21
22#include <memory>
23#include <set>
24
25namespace ryujin
26{
52 enum Boundary : dealii::types::boundary_id {
62
69
79 slip = 2,
80
90
102
118
127 };
128
129
135 enum class Ansatz {
137 cg_q1,
138
140 cg_q2,
141
143 cg_q3,
144
146 dg_q0,
147
149 dg_q1,
150
152 dg_q2,
153
155 dg_q3
156 };
157} // namespace ryujin
158
159#ifndef DOXYGEN
160DECLARE_ENUM(ryujin::Boundary,
161 LIST({ryujin::Boundary::do_nothing, "do nothing"},
162 {ryujin::Boundary::periodic, "periodic"},
163 {ryujin::Boundary::slip, "slip"},
164 {ryujin::Boundary::no_slip, "no slip"},
165 {ryujin::Boundary::dirichlet, "dirichlet"},
166 {ryujin::Boundary::dynamic, "dynamic"},
168 "dirichlet momentum"}));
169
170DECLARE_ENUM(ryujin::Ansatz,
171 LIST({ryujin::Ansatz::cg_q1, "cG Q1"},
172 {ryujin::Ansatz::cg_q2, "cG Q2"},
173 {ryujin::Ansatz::cg_q3, "cG Q3"},
174 {ryujin::Ansatz::dg_q0, "dG Q0"},
175 {ryujin::Ansatz::dg_q1, "dG Q1"},
176 {ryujin::Ansatz::dg_q2, "dG Q2"},
177 {ryujin::Ansatz::dg_q3, "dG Q3"}));
178#endif
179
180namespace ryujin
181{
182 namespace
183 {
184 template <int dim>
185 struct Proxy {
186 using Triangulation = dealii::parallel::distributed::Triangulation<dim>;
187 };
188
189 template <>
190 struct Proxy<1> {
191 using Triangulation = dealii::parallel::shared::Triangulation<1>;
192 };
193
194 } // namespace
195
196
212 template <int dim>
213 class Discretization : public dealii::ParameterAcceptor
214 {
215 public:
223 using Triangulation = typename Proxy<dim>::Triangulation;
224
228 Discretization(const MPIEnsemble &mpi_ensemble,
229 const std::string &subsection = "/Discretization");
230
235 void prepare(const std::string &base_name);
236
241
246
247
252 {
253 switch (ansatz_) {
254 /* Continous Ansatz: */
255 case Ansatz::cg_q1:
256 [[fallthrough]];
257 case Ansatz::cg_q2:
258 [[fallthrough]];
259 case Ansatz::cg_q3:
260 return false;
261
262 /* Discontinuous Ansatz: */
263 case Ansatz::dg_q0:
264 [[fallthrough]];
265 case Ansatz::dg_q1:
266 [[fallthrough]];
267 case Ansatz::dg_q2:
268 [[fallthrough]];
269 case Ansatz::dg_q3:
270 return true;
271 }
272 __builtin_unreachable();
273 return false;
274 }
275
279 ACCESSOR(refinement)
280
281
285
286
290
295
300
305
310
315
321
322 protected:
324
326 std::unique_ptr<const dealii::Mapping<dim>> mapping_;
327 std::unique_ptr<const dealii::FiniteElement<dim>> finite_element_;
328 std::unique_ptr<const dealii::Quadrature<dim>> quadrature_;
329 std::unique_ptr<const dealii::Quadrature<1>> quadrature_1d_;
330 std::unique_ptr<const dealii::Quadrature<dim - 1>> face_quadrature_;
331 std::unique_ptr<const dealii::Quadrature<dim - 1>> face_nodal_quadrature_;
332
333 private:
335
339
340 Ansatz ansatz_;
341
342 std::string geometry_;
343
344 unsigned int refinement_;
345
346 bool mesh_writeout_;
347 double mesh_distortion_;
348
350
354
355 std::set<std::unique_ptr<Geometry<dim>>> geometry_list_;
356
358 };
359
360
365 template <int dim>
367 std::is_same<typename Discretization<dim>::Triangulation,
368 dealii::parallel::distributed::Triangulation<dim>>::value;
369} /* 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_
Discretization(const MPIEnsemble &mpi_ensemble, const std::string &subsection="/Discretization")
const MPIEnsemble & mpi_ensemble_
void prepare(const std::string &base_name)
auto & mapping() const
bool have_discontinuous_ansatz() const
auto & quadrature() const
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