Amg_preconditioner = std::make_shared<TrilinosWrappers::PreconditionAMG>();
- std::vector<std::vector<bool>> constant_modes;
- const FEValuesExtractors::Vector velocity_components(0);
- DoFTools::extract_constant_modes(stokes_dof_handler,
- stokes_fe.component_mask(
- velocity_components),
- constant_modes);
+ const FEValuesExtractors::Vector velocity_components(0);
+ const std::vector<std::vector<bool>> constant_modes =
+ DoFTools::extract_constant_modes(
+ stokes_dof_handler, stokes_fe.component_mask(velocity_components));
TrilinosWrappers::PreconditionAMG::AdditionalData amg_data;
amg_data.constant_modes = constant_modes;
assemble_stokes_preconditioner();
- std::vector<std::vector<bool>> constant_modes;
- const FEValuesExtractors::Vector velocity_components(0);
- DoFTools::extract_constant_modes(stokes_dof_handler,
- stokes_fe.component_mask(
- velocity_components),
- constant_modes);
+ const FEValuesExtractors::Vector velocity_components(0);
+ const std::vector<std::vector<bool>> constant_modes =
+ DoFTools::extract_constant_modes(
+ stokes_dof_handler, stokes_fe.component_mask(velocity_components));
Mp_preconditioner =
std::make_shared<TrilinosWrappers::PreconditionJacobi>();
{
TimerOutput::Scope t(computing_timer, "Solve: setup preconditioner");
- std::vector<std::vector<bool>> constant_modes;
- DoFTools::extract_constant_modes(dof_handler,
- ComponentMask(),
- constant_modes);
+ const std::vector<std::vector<bool>> constant_modes =
+ DoFTools::extract_constant_modes(dof_handler, ComponentMask());
TrilinosWrappers::PreconditionAMG::AdditionalData additional_data;
additional_data.constant_modes = constant_modes;
<< std::flush;
const unsigned int max_iterations = 500;
SolverControl solver_control(max_iterations, relative_error);
- std::vector<std::vector<bool>> constant_modes;
- DoFTools::extract_constant_modes(dof_handler,
- ComponentMask(),
- constant_modes);
+ const std::vector<std::vector<bool>> constant_modes =
+ DoFTools::extract_constant_modes(dof_handler, ComponentMask());
TrilinosWrappers::PreconditionAMG preconditioner_stiffness;
TrilinosWrappers::PreconditionAMG::AdditionalData Amg_data;
Amg_data.constant_modes = constant_modes;
* This function is used in step-31, step-32, and step-42, for example.
*/
template <int dim, int spacedim>
- void
+ std::vector<std::vector<bool>>
extract_constant_modes(const DoFHandler<dim, spacedim> &dof_handler,
- const ComponentMask &component_mask,
- std::vector<std::vector<bool>> &constant_modes);
+ const ComponentMask &component_mask);
+
+ /**
+ * Same as above.
+ *
+ * @deprecated
+ */
+ template <int dim, int spacedim>
+ DEAL_II_DEPRECATED_EARLY_WITH_COMMENT(
+ "Use the other function that returns the constant modes by value, rather than via an argument.")
+ void extract_constant_modes(const DoFHandler<dim, spacedim> &dof_handler,
+ const ComponentMask &component_mask,
+ std::vector<std::vector<bool>> &constant_modes);
/**
* Same as above but for multigrid levels.
*/
template <int dim, int spacedim>
- void
+ std::vector<std::vector<bool>>
extract_level_constant_modes(const unsigned int level,
const DoFHandler<dim, spacedim> &dof_handler,
- const ComponentMask &component_mask,
- std::vector<std::vector<bool>> &constant_modes);
+ const ComponentMask &component_mask);
+
+ /**
+ * Same as above.
+ *
+ * @deprecated
+ */
+ template <int dim, int spacedim>
+ DEAL_II_DEPRECATED_EARLY_WITH_COMMENT(
+ "Use the other function that returns the constant modes by value, rather than via an argument.")
+ void extract_level_constant_modes(
+ const unsigned int level,
+ const DoFHandler<dim, spacedim> &dof_handler,
+ const ComponentMask &component_mask,
+ std::vector<std::vector<bool>> &constant_modes);
/**
* Same as the above but additional to the translational modes also
namespace internal
{
template <int dim, int spacedim>
- void
+ std::vector<std::vector<bool>>
extract_constant_modes(const DoFHandler<dim, spacedim> &dof_handler,
const ComponentMask &component_mask,
- const unsigned int mg_level,
- std::vector<std::vector<bool>> &constant_modes)
+ const unsigned int mg_level)
{
+ std::vector<std::vector<bool>> constant_modes;
+
const auto &locally_owned_dofs =
(mg_level == numbers::invalid_unsigned_int) ?
dof_handler.locally_owned_dofs() :
// constant_modes object:
if (locally_owned_dofs.n_elements() == 0)
{
- constant_modes = std::vector<std::vector<bool>>(0);
- return;
+ return std::vector<std::vector<bool>>(0);
}
const unsigned int n_components = dof_handler.get_fe(0).n_components();
indices.second, i);
}
});
+
+ return constant_modes;
}
+ template <int dim, int spacedim>
+ std::vector<std::vector<bool>>
+ extract_constant_modes(const DoFHandler<dim, spacedim> &dof_handler,
+ const ComponentMask &component_mask)
+ {
+ return internal::extract_constant_modes(dof_handler,
+ component_mask,
+ numbers::invalid_unsigned_int);
+ }
+
+
+
template <int dim, int spacedim>
void
extract_constant_modes(const DoFHandler<dim, spacedim> &dof_handler,
const ComponentMask &component_mask,
std::vector<std::vector<bool>> &constant_modes)
{
- internal::extract_constant_modes(dof_handler,
- component_mask,
- numbers::invalid_unsigned_int,
- constant_modes);
+ const auto temp =
+ internal::extract_constant_modes(dof_handler,
+ component_mask,
+ numbers::invalid_unsigned_int);
+ constant_modes = temp;
+ }
+
+
+
+ template <int dim, int spacedim>
+ std::vector<std::vector<bool>>
+ extract_level_constant_modes(const unsigned int level,
+ const DoFHandler<dim, spacedim> &dof_handler,
+ const ComponentMask &component_mask)
+ {
+ return internal::extract_constant_modes(dof_handler, component_mask, level);
}
const ComponentMask &component_mask,
std::vector<std::vector<bool>> &constant_modes)
{
- internal::extract_constant_modes(dof_handler,
- component_mask,
- level,
- constant_modes);
+ const auto temp =
+ internal::extract_constant_modes(dof_handler, component_mask, level);
+ constant_modes = temp;
}
const types::subdomain_id subdomain_id,
std::vector<bool> &selected_dofs);
+ template std::vector<std::vector<bool>> DoFTools::extract_constant_modes<
+ deal_II_dimension>(const DoFHandler<deal_II_dimension> &dof_handler,
+ const ComponentMask &selected_components);
+
template void DoFTools::extract_constant_modes<deal_II_dimension>(
const DoFHandler<deal_II_dimension> &dof_handler,
const ComponentMask &selected_components,
std::vector<std::vector<bool>> &constant_modes);
+ template std::vector<std::vector<bool>>
+ DoFTools::extract_level_constant_modes<deal_II_dimension>(
+ const unsigned int level,
+ const DoFHandler<deal_II_dimension> &dof_handler,
+ const ComponentMask &selected_components);
+
template void DoFTools::extract_level_constant_modes<deal_II_dimension>(
const unsigned int level,
const DoFHandler<deal_II_dimension> &dof_handler,
for (unsigned int c = 0; c < element.n_components(); ++c)
component_mask.set(c, (int_mask & (1 << c)));
- std::vector<std::vector<bool>> constant_modes;
- DoFTools::extract_constant_modes(dof, component_mask, constant_modes);
+ const auto constant_modes =
+ DoFTools::extract_constant_modes(dof, component_mask);
for (unsigned int d = 0; d < constant_modes.size(); ++d)
{
ComponentMask mask(fe.n_components(), false);
mask.set(c, true);
- std::vector<std::vector<bool>> constant_modes;
- DoFTools::extract_constant_modes(dofh, mask, constant_modes);
+ const auto constant_modes =
+ DoFTools::extract_constant_modes(dofh, mask);
for (unsigned int i = 0; i < constant_modes.size(); ++i)
{
ComponentMask mask(fe.n_components(), false);
mask.set(c, true);
- std::vector<std::vector<bool>> constant_modes;
- DoFTools::extract_constant_modes(dofh, mask, constant_modes);
+ const auto constant_modes =
+ DoFTools::extract_constant_modes(dofh, mask);
for (unsigned int i = 0; i < constant_modes.size(); ++i)
{
{
ComponentMask mask(fe.n_components(), true);
- std::vector<std::vector<bool>> constant_modes;
- DoFTools::extract_constant_modes(dofh, mask, constant_modes);
+ const auto constant_modes = DoFTools::extract_constant_modes(dofh, mask);
for (unsigned int i = 0; i < constant_modes.size(); ++i)
{
{
ComponentMask mask(1, true);
- std::vector<std::vector<bool>> constant_modes;
- DoFTools::extract_constant_modes(dofh, mask, constant_modes);
+ const auto constant_modes = DoFTools::extract_constant_modes(dofh, mask);
for (unsigned int i = 0; i < constant_modes.size(); ++i)
{
ComponentMask mask(fe.n_components(), false);
mask.set(c, true);
- std::vector<std::vector<bool>> constant_modes;
- DoFTools::extract_level_constant_modes(0, dofh, mask, constant_modes);
+ const auto constant_modes =
+ DoFTools::extract_level_constant_modes(0, dofh, mask);
for (unsigned int i = 0; i < constant_modes.size(); ++i)
{
ComponentMask mask(fe.n_components(), false);
mask.set(c, true);
- std::vector<std::vector<bool>> constant_modes;
- DoFTools::extract_level_constant_modes(0, dofh, mask, constant_modes);
+ const auto constant_modes =
+ DoFTools::extract_level_constant_modes(0, dofh, mask);
for (unsigned int i = 0; i < constant_modes.size(); ++i)
{
deallog << " Rebuilding Stokes preconditioner..." << std::flush;
assemble_stokes_preconditioner();
Amg_preconditioner = std::make_shared<TrilinosWrappers::PreconditionAMG>();
- std::vector<std::vector<bool>> constant_modes;
const FEValuesExtractors::Vector velocity_components(0);
- DoFTools::extract_constant_modes(stokes_dof_handler,
- stokes_fe.component_mask(
- velocity_components),
- constant_modes);
+ const auto constant_modes = DoFTools::extract_constant_modes(
+ stokes_dof_handler, stokes_fe.component_mask(velocity_components));
std::vector<std::vector<double>> constant_modes_values(
constant_modes.size());
deallog.push(Utilities::int_to_string(dof_handler.n_dofs(), 5));
TrilinosWrappers::PreconditionAMG preconditioner;
TrilinosWrappers::PreconditionAMG::AdditionalData data;
- DoFTools::extract_constant_modes(dof_handler,
- ComponentMask(1, true),
- data.constant_modes);
+ data.constant_modes =
+ DoFTools::extract_constant_modes(dof_handler, ComponentMask(1, true));
data.smoother_sweeps = 2;
{
solution = 0;
deallog.push(Utilities::int_to_string(dof_handler.n_dofs(), 5));
TrilinosWrappers::PreconditionAMGMueLu preconditioner;
TrilinosWrappers::PreconditionAMGMueLu::AdditionalData data;
- DoFTools::extract_constant_modes(dof_handler,
- std::vector<bool>(1, true),
- data.constant_modes);
+ data.constant_modes =
+ DoFTools::extract_constant_modes(dof_handler, std::vector<bool>(1, true));
data.smoother_sweeps = 2;
{
solution = 0;