8#include <compile_time_options.h>
13#include <deal.II/base/quadrature_lib.h>
14#include <deal.II/fe/fe_dgq.h>
15#include <deal.II/fe/fe_q.h>
16#include <deal.II/fe/mapping_q.h>
17#include <deal.II/grid/grid_out.h>
23 using namespace dealii;
27 const std::string &subsection)
28 : ParameterAcceptor(subsection)
29 , mpi_ensemble_(mpi_ensemble)
34 add_parameter(
"finite element ansatz",
36 "The finite element ansatz used for discretization. valid "
37 "choices are cG Q1, cG Q2, cG Q3.");
39 geometry_ =
"cylinder";
40 add_parameter(
"geometry",
42 "Name of the geometry used to create the mesh. Valid names "
43 "are given by any of the subsections defined below.");
46 add_parameter(
"mesh refinement",
48 "number of refinement of global refinement steps");
50 mesh_writeout_ =
true;
51 add_parameter(
"mesh writeout",
53 "Write out shared coarse mesh to a GMSH *.msh file.");
55 mesh_distortion_ = 0.;
57 "mesh distortion", mesh_distortion_,
"Strength of mesh distortion");
59 Geometries::populate_geometry_list<dim>(geometry_list_, subsection);
67 std::cout <<
"Discretization<dim>::prepare()" << std::endl;
70 const auto smoothing =
71 dealii::Triangulation<dim>::limit_level_difference_at_vertices;
73 if constexpr (have_distributed_triangulation<dim>) {
75 Triangulation::Settings::construct_multigrid_hierarchy;
76 triangulation_ = std::make_unique<Triangulation>(
77 mpi_ensemble_.ensemble_communicator(), smoothing, settings);
80 const auto settings =
static_cast<typename Triangulation::Settings
>(
81 Triangulation::partition_auto |
82 Triangulation::construct_multigrid_hierarchy);
85 std::make_unique<Triangulation>(mpi_ensemble_.ensemble_communicator(),
91 auto &triangulation = *triangulation_;
94 bool initialized =
false;
95 for (
auto &it : geometry_list_)
96 if (it->name() == geometry_) {
97 it->create_triangulation(triangulation);
104 ExcMessage(
"Could not find a geometry description with name \"" +
108 if (mesh_writeout_ && dealii::Utilities::MPI::this_mpi_process(
109 mpi_ensemble_.ensemble_communicator()) == 0) {
110#ifdef DEAL_II_GMSH_WITH_API
112 grid_out.write_msh(triangulation, base_name +
"-coarse_grid.msh");
115 GridOutFlags::Msh flags(
true,
true);
116 grid_out.set_flags(flags);
117 std::ofstream file(base_name +
"-coarse_grid.msh");
118 grid_out.write_msh(triangulation, file);
122 triangulation.refine_global(refinement_);
124 if (std::abs(mesh_distortion_) > 1.0e-10)
125 GridTools::distort_random(
126 mesh_distortion_, triangulation,
false, std::random_device()());
130 finite_element_ = std::make_unique<FE_Q<dim>>(1);
133 finite_element_ = std::make_unique<FE_Q<dim>>(2);
136 finite_element_ = std::make_unique<FE_Q<dim>>(3);
139 finite_element_ = std::make_unique<FE_DGQ<dim>>(0);
142 finite_element_ = std::make_unique<FE_DGQ<dim>>(1);
145 finite_element_ = std::make_unique<FE_DGQ<dim>>(2);
148 finite_element_ = std::make_unique<FE_DGQ<dim>>(3);
154 mapping_ = std::make_unique<MappingQ<dim>>(1);
155 quadrature_ = std::make_unique<QGauss<dim>>(1);
156 quadrature_1d_ = std::make_unique<QGauss<1>>(1);
157 face_quadrature_ = std::make_unique<QGauss<dim - 1>>(1);
159 face_nodal_quadrature_ = std::make_unique<dealii::QMidpoint<dim - 1>>();
161 face_nodal_quadrature_ = std::make_unique<QGauss<dim - 1>>(1);
166 mapping_ = std::make_unique<MappingQ<dim>>(1);
167 quadrature_ = std::make_unique<QGauss<dim>>(2);
168 quadrature_1d_ = std::make_unique<QGauss<1>>(2);
169 face_quadrature_ = std::make_unique<QGauss<dim - 1>>(2);
170 face_nodal_quadrature_ =
171 std::make_unique<dealii::QGaussLobatto<dim - 1>>(2);
176 mapping_ = std::make_unique<MappingQ<dim>>(2);
177 quadrature_ = std::make_unique<QGauss<dim>>(3);
178 quadrature_1d_ = std::make_unique<QGauss<1>>(3);
179 face_quadrature_ = std::make_unique<QGauss<dim - 1>>(3);
180 face_nodal_quadrature_ =
181 std::make_unique<dealii::QGaussLobatto<dim - 1>>(3);
186 mapping_ = std::make_unique<MappingQ<dim>>(3);
187 quadrature_ = std::make_unique<QGauss<dim>>(4);
188 quadrature_1d_ = std::make_unique<QGauss<1>>(4);
189 face_quadrature_ = std::make_unique<QGauss<dim - 1>>(4);
190 face_nodal_quadrature_ =
191 std::make_unique<dealii::QGaussLobatto<dim - 1>>(4);
Discretization(const MPIEnsemble &mpi_ensemble, const std::string &subsection="/Discretization")
void prepare(const std::string &base_name)