-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>
/**
* 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);
/** @} */
/**
/**
* 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;
#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>
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),
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
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);
}
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,
-// test DoFTools::extract_elasticity_modes
+// test DoFTools::rigid_body_modes
#include <deal.II/base/tensor.h>
// 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)
{
-// test DoFTools::extract_level_elasticity_modes
+// test DoFTools::extract_level_rigid_body_modes
#include <deal.II/base/tensor.h>
// 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)
{
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;