]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Apply changes 17477/head
authorPeter Munch <peterrmuench@gmail.com>
Thu, 22 Aug 2024 18:25:14 +0000 (20:25 +0200)
committerPeter Munch <peterrmuench@gmail.com>
Fri, 23 Aug 2024 12:58:13 +0000 (14:58 +0200)
doc/news/changes/minor/20240810Munch
include/deal.II/dofs/dof_tools.h
include/deal.II/lac/trilinos_precondition.h
source/dofs/dof_tools.cc
source/dofs/dof_tools.inst.in
tests/mpi/extract_rigid_body_modes_01.cc [moved from tests/mpi/extract_constant_modes_05.cc with 92% similarity]
tests/mpi/extract_rigid_body_modes_01.mpirun=4.with_p4est=true.output [moved from tests/mpi/extract_constant_modes_05.mpirun=4.with_p4est=true.output with 100% similarity]
tests/mpi/extract_rigid_body_modes_02.cc [moved from tests/mpi/extract_constant_modes_06.cc with 92% similarity]
tests/mpi/extract_rigid_body_modes_02.mpirun=4.with_p4est=true.output [moved from tests/mpi/extract_constant_modes_06.mpirun=4.with_p4est=true.output with 100% similarity]
tests/simplex/step-31.cc

index 767fd3f103b36bfad7082a8e11288c26ad022c45..870dac292442459b6976cd2d203f11ba6070426c 100644 (file)
@@ -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.
 <br>
index a0722db5e37effe05913d8252a6ac2558717af4e..bd03f0a980ca62251ecb45ecbadb78d016e2faef 100644 (file)
@@ -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 <int dim, int spacedim>
-  void
-  extract_elasticity_modes(const Mapping<dim, spacedim>     &mapping,
-                           const DoFHandler<dim, spacedim>  &dof_handler,
-                           const ComponentMask              &component_mask,
-                           std::vector<std::vector<double>> &elasticity_modes);
+  std::vector<std::vector<double>>
+  extract_rigid_body_modes(const Mapping<dim, spacedim>    &mapping,
+                           const DoFHandler<dim, spacedim> &dof_handler,
+                           const ComponentMask             &component_mask);
 
   /**
    * Same as above but for multigrid levels.
    */
   template <int dim, int spacedim>
-  void
-  extract_level_elasticity_modes(
-    const unsigned int                level,
-    const Mapping<dim, spacedim>     &mapping,
-    const DoFHandler<dim, spacedim>  &dof_handler,
-    const ComponentMask              &component_mask,
-    std::vector<std::vector<double>> &elasticity_modes);
+  std::vector<std::vector<double>>
+  extract_level_rigid_body_modes(const unsigned int               level,
+                                 const Mapping<dim, spacedim>    &mapping,
+                                 const DoFHandler<dim, spacedim> &dof_handler,
+                                 const ComponentMask &component_mask);
   /** @} */
 
   /**
index 7d3c88ef392270303dc294c2a4a311e4f8fda474..b3f11382d1f5ab636d4eb8e5485161edbb721225 100644 (file)
@@ -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<std::vector<double>> constant_modes_values;
 
index 7bf4e2ea424876106e7aa631d01f01348ac80045..d44793b86a9807c4b9f5992c76a0cb07670112d4 100644 (file)
@@ -43,7 +43,7 @@
 #include <deal.II/lac/sparsity_pattern_base.h>
 #include <deal.II/lac/vector.h>
 
-#include <deal.II/numerics/vector_tools.h>
+#include <deal.II/numerics/vector_tools_interpolate.h>
 
 #include <algorithm>
 #include <numeric>
@@ -1495,21 +1495,20 @@ namespace DoFTools
 
 
     template <int dim, int spacedim>
-    void
-    extract_elasticity_modes(const Mapping<dim, spacedim>     &mapping,
-                             const DoFHandler<dim, spacedim>  &dof_handler,
-                             const ComponentMask              &component_mask,
-                             const unsigned int                mg_level,
-                             std::vector<std::vector<double>> &elasticity_modes)
+    std::vector<std::vector<double>>
+    extract_rigid_body_modes(const Mapping<dim, spacedim>    &mapping,
+                             const DoFHandler<dim, spacedim> &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<dim>::n_modes;
+      constexpr unsigned int n_modes = RigidBodyMotion<dim>::n_modes;
 
-      elasticity_modes.resize(n_modes);
+      std::vector<std::vector<double>> rigid_body_modes(n_modes);
 
-      LinearAlgebra::distributed::Vector<double> elasticity_modes_dealii(
+      LinearAlgebra::distributed::Vector<double> 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<dim>(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 <int dim, int spacedim>
-  void
-  extract_elasticity_modes(const Mapping<dim, spacedim>     &mapping,
-                           const DoFHandler<dim, spacedim>  &dof_handler,
-                           const ComponentMask              &component_mask,
-                           std::vector<std::vector<double>> &constant_modes)
+  std::vector<std::vector<double>>
+  extract_rigid_body_modes(const Mapping<dim, spacedim>    &mapping,
+                           const DoFHandler<dim, spacedim> &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 <int dim, int spacedim>
-  void
-  extract_level_elasticity_modes(
-    const unsigned int                level,
-    const Mapping<dim, spacedim>     &mapping,
-    const DoFHandler<dim, spacedim>  &dof_handler,
-    const ComponentMask              &component_mask,
-    std::vector<std::vector<double>> &constant_modes)
+  std::vector<std::vector<double>>
+  extract_level_rigid_body_modes(const unsigned int               level,
+                                 const Mapping<dim, spacedim>    &mapping,
+                                 const DoFHandler<dim, spacedim> &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);
   }
 
 
index 30732c63dd3121879cc27aab823498acb8c351ce..d371037eb6f834a6398abebe150a4632394782d6 100644 (file)
@@ -199,18 +199,18 @@ for (deal_II_dimension : DIMENSIONS)
       const ComponentMask                 &selected_components,
       std::vector<std::vector<bool>>      &constant_modes);
 
-    template void DoFTools::extract_elasticity_modes<deal_II_dimension>(
+    template std::vector<std::vector<double>>
+    DoFTools::extract_rigid_body_modes<deal_II_dimension>(
       const Mapping<deal_II_dimension>    &mapping,
       const DoFHandler<deal_II_dimension> &dof_handler,
-      const ComponentMask                 &selected_components,
-      std::vector<std::vector<double>>    &constant_modes);
+      const ComponentMask                 &selected_components);
 
-    template void DoFTools::extract_level_elasticity_modes<deal_II_dimension>(
+    template std::vector<std::vector<double>>
+    DoFTools::extract_level_rigid_body_modes<deal_II_dimension>(
       const unsigned int                   level,
       const Mapping<deal_II_dimension>    &mapping,
       const DoFHandler<deal_II_dimension> &dof_handler,
-      const ComponentMask                 &selected_components,
-      std::vector<std::vector<double>>    &constant_modes);
+      const ComponentMask                 &selected_components);
 
     template void DoFTools::get_active_fe_indices<deal_II_dimension>(
       const DoFHandler<deal_II_dimension> &dof_handler,
similarity index 92%
rename from tests/mpi/extract_constant_modes_05.cc
rename to tests/mpi/extract_rigid_body_modes_01.cc
index 70b738e406f5c5332e3da400e7397b5caed0ae4c..78e247c5cb3e78ea684d4f805f7e584309337670 100644 (file)
@@ -14,7 +14,7 @@
 
 
 
-// test DoFTools::extract_elasticity_modes
+// test DoFTools::rigid_body_modes
 
 #include <deal.II/base/tensor.h>
 
@@ -59,8 +59,8 @@ test()
   // extract constant modes and print
   ComponentMask mask(fe.n_components(), true);
 
-  std::vector<std::vector<double>> constant_modes;
-  DoFTools::extract_elasticity_modes(mapping, dofh, mask, constant_modes);
+  std::vector<std::vector<double>> constant_modes =
+    DoFTools::extract_rigid_body_modes(mapping, dofh, mask);
 
   for (unsigned int i = 0; i < constant_modes.size(); ++i)
     {
similarity index 92%
rename from tests/mpi/extract_constant_modes_06.cc
rename to tests/mpi/extract_rigid_body_modes_02.cc
index 660eed0e9589a114a957ae34719f652495500f26..831ff7023f2e0132be63c93906e0fca71a2ab5d3 100644 (file)
@@ -14,7 +14,7 @@
 
 
 
-// test DoFTools::extract_level_elasticity_modes
+// test DoFTools::extract_level_rigid_body_modes
 
 #include <deal.II/base/tensor.h>
 
@@ -63,9 +63,8 @@ test()
   // extract constant modes and print
   ComponentMask mask(fe.n_components(), true);
 
-  std::vector<std::vector<double>> constant_modes;
-  DoFTools::extract_level_elasticity_modes(
-    0, mapping, dofh, mask, constant_modes);
+  std::vector<std::vector<double>> constant_modes =
+    DoFTools::extract_level_rigid_body_modes(0, mapping, dofh, mask);
 
   for (unsigned int i = 0; i < constant_modes.size(); ++i)
     {
index c3dfdd47bc61b89ad731a7515329d8526a05c08e..a31f77acc3eeb7dded6628ff536125ec1a1d7f69 100644 (file)
@@ -606,8 +606,20 @@ namespace Step31
                                      stokes_fe.component_mask(
                                        velocity_components),
                                      constant_modes);
+
+    std::vector<std::vector<double>> 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;

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.