From: Peter Munch Date: Sun, 6 Feb 2022 07:32:18 +0000 (+0100) Subject: Add MGSmootherPrecondition::initialize_matrices() X-Git-Tag: v9.4.0-rc1~517^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f016c1092f5765a6ddc974bc03af64386dbe8b2c;p=dealii.git Add MGSmootherPrecondition::initialize_matrices() --- diff --git a/include/deal.II/multigrid/mg_smoother.h b/include/deal.II/multigrid/mg_smoother.h index 7074658328..27bbbd6f33 100644 --- a/include/deal.II/multigrid/mg_smoother.h +++ b/include/deal.II/multigrid/mg_smoother.h @@ -467,6 +467,17 @@ public: 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 + void + initialize_matrices(const MGLevelObject &matrices); + /** * Initialize for matrices. This function stores pointers to the level * matrices and initializes the smoothing operator with the according @@ -1033,8 +1044,34 @@ MGSmootherPrecondition::initialize( // enough interface to populate reinit_(domain|range)_vector. Thus, // apply an empty LinearOperator exemplar. matrices[i] = - linear_operator(LinearOperator(), m[i]); - smoothers[i].initialize(m[i], data); + linear_operator(LinearOperator(), + Utilities::get_underlying_value(m[i])); + smoothers[i].initialize(Utilities::get_underlying_value(m[i]), data); + } +} + + + +template +template +inline void +MGSmootherPrecondition:: + initialize_matrices(const MGLevelObject &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(LinearOperator(), + Utilities::get_underlying_value(m[i])); } }