39 :
Geometry<dim>(
"rectangular domain", subsection)
41 this->add_parameter(
"position bottom left",
43 "Position of bottom left corner");
45 for (
unsigned int d = 0; d < dim; ++d)
46 point_right_[d] = 20.0;
48 "position top right", point_right_,
"Position of top right corner");
50 grading_push_forward_ = dim == 1 ?
"x" : (dim == 2 ?
"x;y" :
"x;y;z;");
51 this->add_parameter(
"grading push forward",
52 grading_push_forward_,
53 "push forward of grading manifold");
55 grading_pull_back_ = grading_push_forward_;
56 this->add_parameter(
"grading pull back",
58 "pull back of grading manifold");
70 this->add_parameter(
"subdivisions x",
72 "number of subdivisions in x direction");
74 "boundary condition left",
76 "Type of boundary condition enforced on the left side of the "
77 "domain (faces with normal in negative x direction)");
79 "boundary condition right",
81 "Type of boundary condition enforced on the right side of the "
82 "domain (faces with normal in positive x direction)");
84 if constexpr (dim >= 2) {
85 this->add_parameter(
"subdivisions y",
87 "number of subdivisions in y direction");
89 "boundary condition bottom",
91 "Type of boundary condition enforced on the bottom side of the "
92 "domain (faces with normal in negative y direction)");
94 "boundary condition top",
96 "Type of boundary condition enforced on the top side of the "
97 "domain (faces with normal in positive y direction)");
100 if constexpr (dim == 3) {
101 this->add_parameter(
"subdivisions z",
103 "number of subdivisions in z direction");
105 "boundary condition back",
107 "Type of boundary condition enforced on the back side of the "
108 "domain (faces with normal in negative z direction)");
110 "boundary condition front",
112 "Type of boundary condition enforced on the front side of the "
113 "domain (faces with normal in positive z direction)");
123 dealii::Triangulation<dim, dim> tria1;
124 tria1.set_mesh_smoothing(triangulation.get_mesh_smoothing());
126 if constexpr (dim == 1) {
127 dealii::GridGenerator::subdivided_hyper_rectangle<dim, dim>(
128 tria1, {subdivisions_x_}, point_left_, point_right_);
129 }
else if constexpr (dim == 2) {
130 dealii::GridGenerator::subdivided_hyper_rectangle(
132 {subdivisions_x_, subdivisions_y_},
135 }
else if constexpr (dim == 3) {
136 dealii::GridGenerator::subdivided_hyper_rectangle(
138 {subdivisions_x_, subdivisions_y_, subdivisions_z_},
143 triangulation.copy_triangulation(tria1);
149 if (grading_push_forward_ != grading_pull_back_) {
150 dealii::FunctionManifold<dim> grading(grading_push_forward_,
152 triangulation.set_all_manifold_ids(1);
153 triangulation.set_manifold(1, grading);
158 for (
auto cell : triangulation.active_cell_iterators()) {
159 for (
auto f : cell->face_indices()) {
160 auto face = cell->face(f);
161 if (!face->at_boundary())
163 const auto position = face->center();
165 if (position[0] < point_left_[0] + 1.e-8)
166 face->set_boundary_id(boundary_left_);
167 if (position[0] > point_right_[0] - 1.e-8)
168 face->set_boundary_id(boundary_right_);
170 if constexpr (dim >= 2) {
171 if (position[1] < point_left_[1] + 1.e-8)
172 face->set_boundary_id(boundary_bottom_);
173 if (position[1] > point_right_[1] - 1.e-8)
174 face->set_boundary_id(boundary_top_);
177 if constexpr (dim == 3) {
178 if (position[2] < point_left_[2] + 1.e-8)
179 face->set_boundary_id(boundary_back_);
180 if (position[2] > point_right_[2] - 1.e-8)
181 face->set_boundary_id(boundary_front_);
186 std::vector<int> directions;
190 AssertThrow(boundary_left_ == boundary_right_,
192 "For prescribing periodic boundaries in x-direction, "
193 "both, the left and right boundary conditions must "
194 "be set to periodic"));
195 directions.push_back(0);
200 AssertThrow(boundary_bottom_ == boundary_top_,
202 "For prescribing periodic boundaries in y-direction, "
203 "both, the bottom and top boundary conditions must "
204 "be set to periodic"));
205 directions.push_back(1);
210 AssertThrow(boundary_back_ == boundary_front_,
212 "For prescribing periodic boundaries in z-direction, "
213 "both, the back and front boundary conditions must "
214 "be set to periodic"));
215 directions.push_back(2);
218#if DEAL_II_VERSION_GTE(9, 5, 0)
219 if (!directions.empty()) {
220 std::vector<dealii::GridTools::PeriodicFacePair<
221 typename dealii::Triangulation<dim>::cell_iterator>>
224 for (
const auto direction : directions)
225 dealii::GridTools::collect_periodic_faces(
231 triangulation.add_periodicity(periodic_faces);
237 dealii::Point<dim> point_left_;
238 dealii::Point<dim> point_right_;
240 unsigned int subdivisions_x_;
241 unsigned int subdivisions_y_;
242 unsigned int subdivisions_z_;
244 std::string grading_push_forward_;
245 std::string grading_pull_back_;
void create_triangulation(typename Geometry< dim >::Triangulation &triangulation) final
RectangularDomain(const std::string subsection)
typename Discretization< dim >::Triangulation Triangulation