From e67fdbfadc85d274711720fbf4276841fb6be73d Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Wed, 2 May 2018 21:46:57 -0500 Subject: [PATCH] LinearOperator: Implement a mean value filter operator --- include/deal.II/lac/linear_operator.h | 66 +++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) 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 -- 2.39.5