From: Matthias Maier Date: Thu, 3 May 2018 02:46:57 +0000 (-0500) Subject: LinearOperator: Implement a mean value filter operator X-Git-Tag: v9.0.0-rc1~28^2~7 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e67fdbfadc85d274711720fbf4276841fb6be73d;p=dealii.git LinearOperator: Implement a mean value filter operator --- diff --git a/include/deal.II/lac/linear_operator.h b/include/deal.II/lac/linear_operator.h index ed3d14812c..a08b89cb76 100644 --- a/include/deal.II/lac/linear_operator.h +++ b/include/deal.II/lac/linear_operator.h @@ -851,6 +851,72 @@ null_operator(const LinearOperator &op) } +/** + * @relatesalso LinearOperator + * + * Return a LinearOperator that acts as a mean value filter. The vmult() + * functions of this matrix subtract the mean values of the vector. + * + * The function takes an std::function object @p reinit_vector as + * an argument to initialize the reinit_range_vector and + * reinit_domain_vector objects of the LinearOperator object. + * + * @ingroup LAOperators + */ +template +LinearOperator +mean_value_filter(const std::function &reinit_vector) +{ + LinearOperator return_op ((Payload())); + + return_op.reinit_range_vector = reinit_vector; + return_op.reinit_domain_vector = reinit_vector; + + return_op.vmult = [](Range &v, const Range &u) + { + const auto mean = u.mean_value(); + for (types::global_dof_index i = 0; i +LinearOperator +mean_value_filter(const LinearOperator &op) +{ + auto return_op = mean_value_operator(op.reinit_range_vector); + static_cast(return_op) = op.identity_payload(); + + return return_op; +} + + namespace internal { namespace LinearOperatorImplementation