Skip to content

Commit

Permalink
Add MGSmootherPrecondition::initialize_matrices()
Browse files Browse the repository at this point in the history
  • Loading branch information
peterrum committed Feb 6, 2022
1 parent 1fe7920 commit 9359a70
Showing 1 changed file with 37 additions and 2 deletions.
39 changes: 37 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,15 @@ 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 setup manually by the user in the following. This
* is useful if one wants full flexibility in the choice of smoothers.
*/
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 +1042,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

0 comments on commit 9359a70

Please sign in to comment.