Skip to content

Commit b6644a3

Browse files
authored
Merge pull request #6843 from gassmoeller/improve_documentation_mesh_diffusion
Improve mesh diffusion code documentation
2 parents ac19c42 + e53d44a commit b6644a3

File tree

1 file changed

+67
-32
lines changed

1 file changed

+67
-32
lines changed

source/mesh_deformation/diffusion.cc

Lines changed: 67 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -132,35 +132,62 @@ namespace aspect
132132
const std::set<types::boundary_id> tangential_velocity_boundary_indicators =
133133
this->get_boundary_velocity_manager().get_tangential_boundary_velocity_indicators();
134134

135-
// The list of all tangential mesh deformation boundary indicators.
136-
std::set<types::boundary_id> tmp_tangential_boundaries, tmp2_tangential_boundaries, all_tangential_boundaries;
137-
std::set_union(tangential_velocity_boundary_indicators.begin(),tangential_velocity_boundary_indicators.end(),
138-
additional_tangential_mesh_boundary_indicators.begin(),additional_tangential_mesh_boundary_indicators.end(),
139-
std::inserter(tmp_tangential_boundaries, tmp_tangential_boundaries.end()));
140-
std::set_union(tmp_tangential_boundaries.begin(),tmp_tangential_boundaries.end(),
141-
periodic_boundary_indicators.begin(),periodic_boundary_indicators.end(),
142-
std::inserter(tmp2_tangential_boundaries, tmp2_tangential_boundaries.end()));
143-
// Tangential Stokes velocity boundaries can also be mesh deformation boundaries,
144-
// so correct for that.
145-
std::set_difference(tmp2_tangential_boundaries.begin(),tmp2_tangential_boundaries.end(),
146-
boundary_ids.begin(),boundary_ids.end(),
147-
std::inserter(all_tangential_boundaries, all_tangential_boundaries.end()));
148-
149-
// The list of mesh deformation boundary indicators of boundaries that are allowed to move either
150-
// tangentially or in all directions.
151-
std::set<types::boundary_id> all_deformable_boundaries;
152-
std::set_union(all_tangential_boundaries.begin(),all_tangential_boundaries.end(),
153-
boundary_ids.begin(),boundary_ids.end(),
154-
std::inserter(all_deformable_boundaries, all_deformable_boundaries.end()));
155-
156-
// The list of mesh deformation boundary indicators of boundaries that are not allowed to move.
157-
std::set<types::boundary_id> all_fixed_boundaries;
158-
std::set_difference(all_boundaries.begin(),all_boundaries.end(),
159-
all_deformable_boundaries.begin(),all_deformable_boundaries.end(),
160-
std::inserter(all_fixed_boundaries, all_fixed_boundaries.end()));
161-
162-
// Make the no flux boundary constraints
163-
for (const types::boundary_id &boundary_id : all_fixed_boundaries)
135+
// Here we start to construct the list of all
136+
// tangential mesh deformation boundary indicators.
137+
std::set<types::boundary_id> tangential_stokes_and_mesh_boundaries;
138+
std::set<types::boundary_id> tangential_stokes_and_mesh_and_periodic_boundaries;
139+
std::set<types::boundary_id> all_tangential_mesh_deformation_boundaries;
140+
141+
// tangential_stokes_and_mesh_boundaries contains both the tangential Stokes velocity boundaries
142+
// and the additional tangential mesh boundaries.
143+
std::set_union(tangential_velocity_boundary_indicators.begin(),
144+
tangential_velocity_boundary_indicators.end(),
145+
additional_tangential_mesh_boundary_indicators.begin(),
146+
additional_tangential_mesh_boundary_indicators.end(),
147+
std::inserter(tangential_stokes_and_mesh_boundaries,
148+
tangential_stokes_and_mesh_boundaries.end()));
149+
150+
// tangential_stokes_and_mesh_and_periodic_boundaries contains also the periodic boundaries.
151+
std::set_union(tangential_stokes_and_mesh_boundaries.begin(),
152+
tangential_stokes_and_mesh_boundaries.end(),
153+
periodic_boundary_indicators.begin(),
154+
periodic_boundary_indicators.end(),
155+
std::inserter(tangential_stokes_and_mesh_and_periodic_boundaries,
156+
tangential_stokes_and_mesh_and_periodic_boundaries.end()));
157+
158+
// The set of tangential_velocity_boundary_indicators might already contain the
159+
// diffusion boundaries (i.e. those boundaries contained in the set boundary_ids).
160+
// These are not boundaries on which the mesh deforms tangentially,
161+
// so we here create a new set containing only tangential_mesh_deformation_boundaries
162+
std::set_difference(tangential_stokes_and_mesh_and_periodic_boundaries.begin(),
163+
tangential_stokes_and_mesh_and_periodic_boundaries.end(),
164+
boundary_ids.begin(),
165+
boundary_ids.end(),
166+
std::inserter(all_tangential_mesh_deformation_boundaries,
167+
all_tangential_mesh_deformation_boundaries.end()));
168+
169+
// We now add the diffusion boundaries to the list of tangential mesh deformation boundaries
170+
// to create a set of all boundaries on which the mesh is allowed to deform in some way.
171+
std::set<types::boundary_id> all_deformable_mesh_boundaries;
172+
std::set_union(all_tangential_mesh_deformation_boundaries.begin(),
173+
all_tangential_mesh_deformation_boundaries.end(),
174+
boundary_ids.begin(),
175+
boundary_ids.end(),
176+
std::inserter(all_deformable_mesh_boundaries,
177+
all_deformable_mesh_boundaries.end()));
178+
179+
// Finally, we get the set of all fixed mesh boundaries by
180+
// subtracting the deformable mesh boundaries from all boundaries.
181+
std::set<types::boundary_id> all_fixed_mesh_boundaries;
182+
std::set_difference(all_boundaries.begin(),
183+
all_boundaries.end(),
184+
all_deformable_mesh_boundaries.begin(),
185+
all_deformable_mesh_boundaries.end(),
186+
std::inserter(all_fixed_mesh_boundaries,
187+
all_fixed_mesh_boundaries.end()));
188+
189+
// Make the no flux boundary constraints for boundaries on which the mesh is fixed
190+
for (const types::boundary_id &boundary_id : all_fixed_mesh_boundaries)
164191
{
165192
VectorTools::interpolate_boundary_values (this->get_mapping(),
166193
mesh_deformation_dof_handler,
@@ -169,12 +196,20 @@ namespace aspect
169196
matrix_constraints);
170197
}
171198

172-
// Make the no normal flux boundary constraints
199+
// Make the no normal flux boundary constraints for boundaries on which the mesh is
200+
// allowed to move tangentially. We can use the manifold information to
201+
// compute the normal vector because these boundaries do not move normal to themselves.
173202
VectorTools::compute_no_normal_flux_constraints (mesh_deformation_dof_handler,
174203
/* first_vector_component= */
175204
0,
176-
all_tangential_boundaries,
177-
matrix_constraints, this->get_mapping());
205+
all_tangential_mesh_deformation_boundaries,
206+
matrix_constraints,
207+
this->get_mapping(),
208+
/* use_manifold_for_normal= */
209+
true);
210+
211+
// Note that we do not apply any constraints on the mesh of the diffusing boundaries
212+
// listed in boundary_ids. Their displacement is governed by the diffusion equation.
178213

179214
matrix_constraints.close();
180215

0 commit comments

Comments
 (0)