From: Peter Munch Date: Thu, 22 Aug 2024 18:25:14 +0000 (+0200) Subject: Apply changes X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4b77cc4c460683923fe27f1fc40827abbc9fbd30;p=dealii.git Apply changes --- diff --git a/doc/news/changes/minor/20240810Munch b/doc/news/changes/minor/20240810Munch index 767fd3f103..870dac2924 100644 --- a/doc/news/changes/minor/20240810Munch +++ b/doc/news/changes/minor/20240810Munch @@ -1,5 +1,5 @@ -New: The new functions DoFTools::extract_elasticity_modes -and DoFTools::extract_level_elasticity_modes +New: The new functions DoFTools::extract_rigig_body_modes +and DoFTools::extract_level_rigig_body_modes allow you to extract translational and rotational modes, need to set up AMG for solving elasticity problems.
diff --git a/include/deal.II/dofs/dof_tools.h b/include/deal.II/dofs/dof_tools.h index a0722db5e3..bd03f0a980 100644 --- a/include/deal.II/dofs/dof_tools.h +++ b/include/deal.II/dofs/dof_tools.h @@ -1385,27 +1385,24 @@ namespace DoFTools /** * Same as the above but additional to the translational modes also - * the rotational modes are added, needed to set up AMG for solving + * the rotational modes are added, needed, e.g., to set up AMG for solving * elasticity problems. */ template - void - extract_elasticity_modes(const Mapping &mapping, - const DoFHandler &dof_handler, - const ComponentMask &component_mask, - std::vector> &elasticity_modes); + std::vector> + extract_rigid_body_modes(const Mapping &mapping, + const DoFHandler &dof_handler, + const ComponentMask &component_mask); /** * Same as above but for multigrid levels. */ template - void - extract_level_elasticity_modes( - const unsigned int level, - const Mapping &mapping, - const DoFHandler &dof_handler, - const ComponentMask &component_mask, - std::vector> &elasticity_modes); + std::vector> + extract_level_rigid_body_modes(const unsigned int level, + const Mapping &mapping, + const DoFHandler &dof_handler, + const ComponentMask &component_mask); /** @} */ /** diff --git a/include/deal.II/lac/trilinos_precondition.h b/include/deal.II/lac/trilinos_precondition.h index 7d3c88ef39..b3f11382d1 100644 --- a/include/deal.II/lac/trilinos_precondition.h +++ b/include/deal.II/lac/trilinos_precondition.h @@ -1501,10 +1501,10 @@ namespace TrilinosWrappers /** * Same as above, but with values instead of Booleans. This - * is usfule if you want to specifiy rotational modes + * is useful if you want to specify rotational modes * in addition to the translational modes. See also: - * DoFTools::extract_elasticity_modes - * and DoFTools::extract_level_elasticity_modes. + * DoFTools::extract_rigid_body_modes + * and DoFTools::extract_level_rigid_body_modes. */ std::vector> constant_modes_values; diff --git a/source/dofs/dof_tools.cc b/source/dofs/dof_tools.cc index 7bf4e2ea42..d44793b86a 100644 --- a/source/dofs/dof_tools.cc +++ b/source/dofs/dof_tools.cc @@ -43,7 +43,7 @@ #include #include -#include +#include #include #include @@ -1495,21 +1495,20 @@ namespace DoFTools template - void - extract_elasticity_modes(const Mapping &mapping, - const DoFHandler &dof_handler, - const ComponentMask &component_mask, - const unsigned int mg_level, - std::vector> &elasticity_modes) + std::vector> + extract_rigid_body_modes(const Mapping &mapping, + const DoFHandler &dof_handler, + const ComponentMask &component_mask, + const unsigned int mg_level) { AssertDimension(dim, spacedim); AssertDimension(component_mask.n_selected_components(), dim); - const unsigned int n_modes = RigidBodyMotion::n_modes; + constexpr unsigned int n_modes = RigidBodyMotion::n_modes; - elasticity_modes.resize(n_modes); + std::vector> rigid_body_modes(n_modes); - LinearAlgebra::distributed::Vector elasticity_modes_dealii( + LinearAlgebra::distributed::Vector rigid_body_modes_dealii( mg_level == numbers::invalid_unsigned_int ? dof_handler.locally_owned_dofs() : dof_handler.locally_owned_mg_dofs(mg_level), @@ -1523,14 +1522,16 @@ namespace DoFTools VectorTools::interpolate(mapping, dof_handler, RigidBodyMotion(i), - elasticity_modes_dealii, + rigid_body_modes_dealii, component_mask, mg_level); // copy to right format - elasticity_modes[i].assign(elasticity_modes_dealii.begin(), - elasticity_modes_dealii.end()); + rigid_body_modes[i].assign(rigid_body_modes_dealii.begin(), + rigid_body_modes_dealii.end()); } + + return rigid_body_modes; } } // namespace internal @@ -1567,32 +1568,30 @@ namespace DoFTools template - void - extract_elasticity_modes(const Mapping &mapping, - const DoFHandler &dof_handler, - const ComponentMask &component_mask, - std::vector> &constant_modes) + std::vector> + extract_rigid_body_modes(const Mapping &mapping, + const DoFHandler &dof_handler, + const ComponentMask &component_mask) { - internal::extract_elasticity_modes(mapping, - dof_handler, - component_mask, - numbers::invalid_unsigned_int, - constant_modes); + return internal::extract_rigid_body_modes(mapping, + dof_handler, + component_mask, + numbers::invalid_unsigned_int); } template - void - extract_level_elasticity_modes( - const unsigned int level, - const Mapping &mapping, - const DoFHandler &dof_handler, - const ComponentMask &component_mask, - std::vector> &constant_modes) + std::vector> + extract_level_rigid_body_modes(const unsigned int level, + const Mapping &mapping, + const DoFHandler &dof_handler, + const ComponentMask &component_mask) { - internal::extract_elasticity_modes( - mapping, dof_handler, component_mask, level, constant_modes); + return internal::extract_rigid_body_modes(mapping, + dof_handler, + component_mask, + level); } diff --git a/source/dofs/dof_tools.inst.in b/source/dofs/dof_tools.inst.in index 30732c63dd..d371037eb6 100644 --- a/source/dofs/dof_tools.inst.in +++ b/source/dofs/dof_tools.inst.in @@ -199,18 +199,18 @@ for (deal_II_dimension : DIMENSIONS) const ComponentMask &selected_components, std::vector> &constant_modes); - template void DoFTools::extract_elasticity_modes( + template std::vector> + DoFTools::extract_rigid_body_modes( const Mapping &mapping, const DoFHandler &dof_handler, - const ComponentMask &selected_components, - std::vector> &constant_modes); + const ComponentMask &selected_components); - template void DoFTools::extract_level_elasticity_modes( + template std::vector> + DoFTools::extract_level_rigid_body_modes( const unsigned int level, const Mapping &mapping, const DoFHandler &dof_handler, - const ComponentMask &selected_components, - std::vector> &constant_modes); + const ComponentMask &selected_components); template void DoFTools::get_active_fe_indices( const DoFHandler &dof_handler, diff --git a/tests/mpi/extract_constant_modes_05.cc b/tests/mpi/extract_rigid_body_modes_01.cc similarity index 92% rename from tests/mpi/extract_constant_modes_05.cc rename to tests/mpi/extract_rigid_body_modes_01.cc index 70b738e406..78e247c5cb 100644 --- a/tests/mpi/extract_constant_modes_05.cc +++ b/tests/mpi/extract_rigid_body_modes_01.cc @@ -14,7 +14,7 @@ -// test DoFTools::extract_elasticity_modes +// test DoFTools::rigid_body_modes #include @@ -59,8 +59,8 @@ test() // extract constant modes and print ComponentMask mask(fe.n_components(), true); - std::vector> constant_modes; - DoFTools::extract_elasticity_modes(mapping, dofh, mask, constant_modes); + std::vector> constant_modes = + DoFTools::extract_rigid_body_modes(mapping, dofh, mask); for (unsigned int i = 0; i < constant_modes.size(); ++i) { diff --git a/tests/mpi/extract_constant_modes_05.mpirun=4.with_p4est=true.output b/tests/mpi/extract_rigid_body_modes_01.mpirun=4.with_p4est=true.output similarity index 100% rename from tests/mpi/extract_constant_modes_05.mpirun=4.with_p4est=true.output rename to tests/mpi/extract_rigid_body_modes_01.mpirun=4.with_p4est=true.output diff --git a/tests/mpi/extract_constant_modes_06.cc b/tests/mpi/extract_rigid_body_modes_02.cc similarity index 92% rename from tests/mpi/extract_constant_modes_06.cc rename to tests/mpi/extract_rigid_body_modes_02.cc index 660eed0e95..831ff7023f 100644 --- a/tests/mpi/extract_constant_modes_06.cc +++ b/tests/mpi/extract_rigid_body_modes_02.cc @@ -14,7 +14,7 @@ -// test DoFTools::extract_level_elasticity_modes +// test DoFTools::extract_level_rigid_body_modes #include @@ -63,9 +63,8 @@ test() // extract constant modes and print ComponentMask mask(fe.n_components(), true); - std::vector> constant_modes; - DoFTools::extract_level_elasticity_modes( - 0, mapping, dofh, mask, constant_modes); + std::vector> constant_modes = + DoFTools::extract_level_rigid_body_modes(0, mapping, dofh, mask); for (unsigned int i = 0; i < constant_modes.size(); ++i) { diff --git a/tests/mpi/extract_constant_modes_06.mpirun=4.with_p4est=true.output b/tests/mpi/extract_rigid_body_modes_02.mpirun=4.with_p4est=true.output similarity index 100% rename from tests/mpi/extract_constant_modes_06.mpirun=4.with_p4est=true.output rename to tests/mpi/extract_rigid_body_modes_02.mpirun=4.with_p4est=true.output diff --git a/tests/simplex/step-31.cc b/tests/simplex/step-31.cc index c3dfdd47bc..a31f77acc3 100644 --- a/tests/simplex/step-31.cc +++ b/tests/simplex/step-31.cc @@ -606,8 +606,20 @@ namespace Step31 stokes_fe.component_mask( velocity_components), constant_modes); + + std::vector> constant_modes_values( + constant_modes.size()); + + for (unsigned int i = 0; i < constant_modes.size(); ++i) + { + constant_modes_values[i].resize(constant_modes[i].size()); + + for (unsigned int j = 0; j < constant_modes[i].size(); ++j) + constant_modes_values[i][j] = constant_modes[i][j]; + } + TrilinosWrappers::PreconditionAMG::AdditionalData amg_data; - amg_data.constant_modes = constant_modes; + amg_data.constant_modes_values = constant_modes_values; amg_data.elliptic = true; amg_data.higher_order_elements = true; amg_data.smoother_sweeps = 2;