From: Matthias Maier Date: Fri, 14 Jul 2017 21:56:51 +0000 (-0500) Subject: Bugfix: Add overload for linear_operator that takes a LinearOperator exemplar X-Git-Tag: v9.0.0-rc1~1416^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5d6d4679993d1d6d0185fcb23bbf71c290404af5;p=dealii.git Bugfix: Add overload for linear_operator that takes a LinearOperator exemplar This allows to copy the reinit functions from a LinearOperator directly. --- diff --git a/include/deal.II/lac/linear_operator.h b/include/deal.II/lac/linear_operator.h index 22d37c2fbc..7f00ad0020 100644 --- a/include/deal.II/lac/linear_operator.h +++ b/include/deal.II/lac/linear_operator.h @@ -1291,6 +1291,45 @@ linear_operator(const OperatorExemplar &operator_exemplar, const Matrix &matrix) } + +/** + * @relates LinearOperator + * + * Variant of above function that takes a LinearOperator @p + * operator_exemplar as an additional reference. + * The reinit_domain_vector and reinit_range_vector function are copied + * from the @p operator_exemplar object. + * + * The reference @p matrix is used to construct vmult, Tvmult, etc. + * + * This variant can, for example, be used to encapsulate preconditioners (that + * typically do not expose any information about the underlying matrix). + * + * @author Matthias Maier, 2017 + * + * @ingroup LAOperators + */ +template +LinearOperator +linear_operator(const LinearOperator &operator_exemplar, + const Matrix &matrix) +{ + // Initialise the payload based on the LinearOperator exemplar + auto return_op = operator_exemplar; + + typename std::conditional< + has_vmult_add_and_Tvmult_add::type::value, + MatrixInterfaceWithVmultAdd, + MatrixInterfaceWithoutVmultAdd>::type(). + operator()(return_op, matrix); + + return return_op; +} + + //@}