Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add MGSmootherPrecondition::initialize_matrices() #13343

Merged
merged 1 commit into from
Feb 9, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 39 additions & 2 deletions include/deal.II/multigrid/mg_smoother.h
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,17 @@ class MGSmootherPrecondition : public MGSmoother<VectorType>
const typename PreconditionerType::AdditionalData &
additional_data = typename PreconditionerType::AdditionalData());

/**
* In contrast to the function above, only initialize the matrices. The
* smoothers need to be set up manually by the user as a subsequent step
* in the code. For this purpose, the public field @p smoothers
* can be directly modified. This is useful if one wants full flexibility in
* the choice of smoothers, e.g., use different smoothers on the levels.
*/
template <typename MatrixType2>
void
initialize_matrices(const MGLevelObject<MatrixType2> &matrices);

/**
* Initialize for matrices. This function stores pointers to the level
* matrices and initializes the smoothing operator with the according
Expand Down Expand Up @@ -1033,8 +1044,34 @@ MGSmootherPrecondition<MatrixType, PreconditionerType, VectorType>::initialize(
// enough interface to populate reinit_(domain|range)_vector. Thus,
// apply an empty LinearOperator exemplar.
matrices[i] =
linear_operator<VectorType>(LinearOperator<VectorType>(), m[i]);
smoothers[i].initialize(m[i], data);
linear_operator<VectorType>(LinearOperator<VectorType>(),
Utilities::get_underlying_value(m[i]));
smoothers[i].initialize(Utilities::get_underlying_value(m[i]), data);
}
}



template <typename MatrixType, typename PreconditionerType, typename VectorType>
template <typename MatrixType2>
inline void
MGSmootherPrecondition<MatrixType, PreconditionerType, VectorType>::
initialize_matrices(const MGLevelObject<MatrixType2> &m)
{
const unsigned int min = m.min_level();
const unsigned int max = m.max_level();

matrices.resize(min, max);
smoothers.resize(min, max);

for (unsigned int i = min; i <= max; ++i)
{
// Workaround: Unfortunately, not every "m[i]" object has a rich
// enough interface to populate reinit_(domain|range)_vector. Thus,
// apply an empty LinearOperator exemplar.
matrices[i] =
linear_operator<VectorType>(LinearOperator<VectorType>(),
Utilities::get_underlying_value(m[i]));
}
}

Expand Down