111would yield periodicity constraints such that @f$u(0,y)=u(1,y)@f$
for all
114If we instead consider the
parallelogram given by the convex hull of
115@f$(0,0)@f$, @f$(1,1)@f$, @f$(1,2)@f$, @f$(0,1)@f$ we can achieve the constraints
116@f$u(0,y)=u(1,y+1)@f$ by specifying an @p offset:
134Here, again, the assignment of boundary indicators 0 and 1 stems from
137The resulting @p matched_pairs can be used in
139object with periodicity constraints:
141DoFTools::make_periodicity_constraints(matched_pairs, constraints);
144Apart from this high
level interface there are also variants of
145DoFTools::make_periodicity_constraints available that combine those two
146steps (see the variants of DofTools::make_periodicity_constraints).
148There is also a low
level interface to
149DoFTools::make_periodicity_constraints if more flexibility is needed. The
150low
level variant allows to directly specify two faces that shall be
154make_periodicity_constraints(face_1,
157 component_mask = <default value>;
158 face_orientation = <default value>,
159 face_flip = <default value>,
160 face_rotation = <default value>,
161 matrix = <default value>);
163Here, we need to specify the orientation of the two faces using
164@p face_orientation, @p face_flip and @p face_orientation. For a closer description
165have a look at the documentation of
DoFTools::make_periodicity_constraints.
166The remaining parameters are the same as for the high
level interface apart
167from the self-explaining @p component_mask and @p affine_constraints.
170<a name="step-45-problem"></a>
171<a name="step_45-Apracticalexample"></a><h1>A practical example</h1>
174In the following, we show how to use the above functions in a more involved
175example. The task is to enforce rotated periodicity constraints for the
176velocity component of a Stokes flow.
178On a quarter-circle defined by @f$\Omega=\{{\bf x}\in(0,1)^2:\|{\bf x}\|\in (0.5,1)\}@f$ we are
179going to solve the Stokes problem
181 -\Delta \; \textbf{u} + \nabla p &=& (\exp(-100\|{\bf x}-(.75,0.1)^T\|^2),0)^T, \\
182 -\textrm{div}\; \textbf{u}&=&0,\\
183 \textbf{u}|_{\Gamma_1}&=&{\bf 0},
185where the boundary @f$\Gamma_1@f$ is defined as @f$\Gamma_1 \dealcoloneq \{x\in \partial\Omega: \|x\|\in\{0.5,1\}\}@f$.
186For the remaining parts of the boundary we are going to use periodic boundary conditions, i.e.
188 u_x(0,\nu)&=-u_y(\nu,0)&\nu&\in[0,1]\\
189 u_y(0,\nu)&=u_x(\nu,0)&\nu&\in[0,1].
193which also documents how it assigns boundary indicators to its various
194boundaries
if its `
colorize` argument is
set to `
true`.
197 * <a name=
"step_45-CommProg"></a>
198 * <h1> The commented program</h1>
200 * This example program is a slight modification of @ref step_22
"step-22" running in
parallel
201 *
using Trilinos to demonstrate the usage of periodic boundary conditions in
202 * deal.II. We thus omit to discuss the majority of the source code and only
203 * comment on the parts that deal with periodicity constraints. For the rest
204 * have a look at @ref step_22
"step-22" and the full source code at the bottom.
208 * In order to implement periodic boundary conditions only two
functions
209 * have to be modified:
210 * - <code>StokesProblem<dim>::setup_dofs()</code>:
212 * - <code>StokesProblem<dim>::create_mesh()</code>:
213 * To supply a distributed
triangulation with periodicity information.
217 * The rest of the program is identical to @ref step_22
"step-22", so let us skip
this part
218 * and only show these two
functions in the following. (The full program can be
219 * found in the
"Plain program" section below, though.)
230 * <a name=
"step_45-Settingupperiodicityconstraintsondistributedtriangulations"></a>
231 * <h3>Setting up periodicity constraints on distributed triangulations</h3>
235 *
void StokesProblem<dim>::create_mesh()
238 *
const double inner_radius = .5;
239 *
const double outer_radius = 1.;
246 * Before we can prescribe periodicity constraints, we need to ensure that
247 * cells on opposite sides of the domain but connected by periodic faces are
248 * part of the ghost layer
if one of them is stored on the local processor.
249 * At
this point we need to think about how we want to prescribe
251 * boundary should be matched to the
vertices @f$\text{
vertices}_1@f$ of a face
252 * on the lower boundary given by @f$\text{
vertices}_2=R\cdot
253 * \text{
vertices}_1+
b@f$ where the rotation
matrix @f$R@f$ and the offset @f$b@f$ are
262 * The data structure we are saving the resulting information into is here
268 * periodicity_vector;
271 * rotation_matrix[0][1] = 1.;
272 * rotation_matrix[1][0] = -1.;
278 * periodicity_vector,
284 * Now telling the
triangulation about the desired periodicity is
285 * particularly easy by just calling
296 *
void StokesProblem<dim>::setup_dofs()
298 * dof_handler.distribute_dofs(fe);
300 * std::vector<unsigned int> block_component(dim + 1, 0);
301 * block_component[dim] = 1;
304 *
const std::vector<types::global_dof_index> dofs_per_block =
306 *
const unsigned int n_u = dofs_per_block[0], n_p = dofs_per_block[1];
309 * owned_partitioning.clear();
310 *
const IndexSet &locally_owned_dofs = dof_handler.locally_owned_dofs();
311 * owned_partitioning.push_back(locally_owned_dofs.get_view(0, n_u));
312 * owned_partitioning.push_back(locally_owned_dofs.get_view(n_u, n_u + n_p));
314 * relevant_partitioning.
clear();
315 *
const IndexSet locally_relevant_dofs =
317 * relevant_partitioning.push_back(locally_relevant_dofs.get_view(0, n_u));
318 * relevant_partitioning.push_back(
319 * locally_relevant_dofs.get_view(n_u, n_u + n_p));
321 * constraints.clear();
322 * constraints.reinit(locally_owned_dofs, locally_relevant_dofs);
330 * BoundaryValues<dim>(),
332 * fe.component_mask(velocities));
336 * BoundaryValues<dim>(),
338 * fe.component_mask(velocities));
342 * After we provided the mesh with the necessary information
for the
343 * periodicity constraints, we are now able to actual create them. For
344 * describing the
matching we are
using the same approach as before, i.e.,
345 * the @f$\text{
vertices}_2@f$ of a face on the left boundary should be
347 * @f$\text{
vertices}_1@f$ of a face on the lower boundary given by
349 *
matrix @f$R@f$ and the offset @f$b@f$ are given by
357 * These two objects not only describe how faces should be matched but
358 * also in which sense the solution should be transformed from
359 * @f$\text{face}_2@f$ to
360 * @f$\text{face}_1@f$.
364 * rotation_matrix[0][1] = 1.;
365 * rotation_matrix[1][0] = -1.;
371 * For setting up the constraints, we
first store the periodicity
372 * information in an auxiliary
object of type
374 *
DoFHandler@<dim@>::%cell_iterator@> </code>. The periodic boundaries
375 * have the boundary indicators 2 (x=0) and 3 (y=0). All the other
376 * parameters we have
set up before. In
this case the direction does not
378 * exactly what we want.
383 * periodicity_vector;
385 *
const unsigned int direction = 1;
391 * periodicity_vector,
397 * Next, we need to provide information on which vector valued components
398 * of the solution should be rotated. Since we choose here to just
399 * constraint the velocity and
this starts at the
first component of the
400 * solution vector, we simply
insert a 0:
403 * std::vector<unsigned int> first_vector_components;
404 * first_vector_components.push_back(0);
408 * After setting up all the information in periodicity_vector all we have
417 * first_vector_components);
420 * constraints.close();
424 * owned_partitioning,
425 * relevant_partitioning,
429 *
for (
unsigned int c = 0; c < dim + 1; ++c)
430 *
for (
unsigned int d = 0;
d < dim + 1; ++
d)
431 *
if (!((c == dim) && (d == dim)))
442 * mpi_communicator));
446 * system_matrix.reinit(bsp);
451 * owned_partitioning,
452 * owned_partitioning,
453 * relevant_partitioning,
457 *
for (
unsigned int c = 0; c < dim + 1; ++c)
458 *
for (
unsigned int d = 0;
d < dim + 1; ++
d)
459 *
if ((c == dim) && (d == dim))
465 * preconditioner_coupling,
466 * preconditioner_bsp,
470 * mpi_communicator));
472 * preconditioner_bsp.compress();
474 * preconditioner_matrix.reinit(preconditioner_bsp);
477 * system_rhs.reinit(owned_partitioning, mpi_communicator);
478 * solution.reinit(owned_partitioning,
479 * relevant_partitioning,
485 * The rest of the program is then again identical to @ref step_22
"step-22". We will omit
486 * it here now, but as before, you can find these parts in the
"Plain program"
491<a name=
"step_45-Results"></a><h1>Results</h1>
494The created output is not very surprising. We simply see that the solution is
495periodic with respect to the left and lower boundary:
497<img src=
"https://www.dealii.org/images/steps/developer/step-45.periodic.png" alt=
"">
499Without the periodicity constraints we would have ended up with the following solution:
501<img src=
"https://www.dealii.org/images/steps/developer/step-45.non_periodic.png" alt=
"">
504<a name=
"step_45-PlainProg"></a>
505<h1> The plain program</h1>
void refine_global(const unsigned int times=1)
virtual void add_periodicity(const std::vector<::GridTools::PeriodicFacePair< cell_iterator > > &) override
__global__ void set(Number *val, const Number s, const size_type N)
typename ::Triangulation< dim, spacedim >::cell_iterator cell_iterator
void make_hanging_node_constraints(const DoFHandler< dim, spacedim > &dof_handler, AffineConstraints< number > &constraints)
void make_sparsity_pattern(const DoFHandler< dim, spacedim > &dof_handler, SparsityPatternBase &sparsity_pattern, const AffineConstraints< number > &constraints={}, const bool keep_constrained_dofs=true, const types::subdomain_id subdomain_id=numbers::invalid_subdomain_id)
void component_wise(DoFHandler< dim, spacedim > &dof_handler, const std::vector< unsigned int > &target_component=std::vector< unsigned int >())
void parallelogram(Triangulation< dim > &tria, const Point< dim >(&corners)[dim], const bool colorize=false)
void quarter_hyper_shell(Triangulation< dim > &tria, const Point< dim > ¢er, const double inner_radius, const double outer_radius, const unsigned int n_cells=0, const bool colorize=false)
@ matrix
Contents is actually a matrix.
Point< spacedim > point(const gp_Pnt &p, const double tolerance=1e-10)
SymmetricTensor< 2, dim, Number > b(const Tensor< 2, dim, Number > &F)
SymmetricTensor< 2, dim, Number > d(const Tensor< 2, dim, Number > &F, const Tensor< 2, dim, Number > &dF_dt)
VectorType::value_type * end(VectorType &V)
VectorType::value_type * begin(VectorType &V)
unsigned int this_mpi_process(const MPI_Comm mpi_communicator)
int(& functions)(const void *v1, const void *v2)
const ::parallel::distributed::Triangulation< dim, spacedim > * triangulation