From: Peter Munch Date: Thu, 3 Dec 2020 17:24:32 +0000 (+0100) Subject: MatrixFreeTools::compute_diagonal: accept class and function pointer X-Git-Tag: v9.3.0-rc1~768^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0f91b30619329de40569daf12f9f49b35143afa1;p=dealii.git MatrixFreeTools::compute_diagonal: accept class and function pointer --- diff --git a/include/deal.II/matrix_free/tools.h b/include/deal.II/matrix_free/tools.h index 4d46c108c7..1cd9540ab9 100644 --- a/include/deal.II/matrix_free/tools.h +++ b/include/deal.II/matrix_free/tools.h @@ -71,6 +71,31 @@ namespace MatrixFreeTools const unsigned int quad_no = 0, const unsigned int first_selected_component = 0); + /** + * Same as above but with a class and a function pointer. + */ + template + void + compute_diagonal( + const MatrixFree &matrix_free, + LinearAlgebra::distributed::Vector & diagonal_global, + void (CLASS::*cell_operation)(FEEvaluation &) const, + CLASS * owning_class, + const unsigned int dof_no = 0, + const unsigned int quad_no = 0, + const unsigned int first_selected_component = 0); + /** * Compute the matrix representation of a linear operator (@p matrix), given @@ -567,6 +592,42 @@ namespace MatrixFreeTools false); } + template + void + compute_diagonal( + const MatrixFree &matrix_free, + LinearAlgebra::distributed::Vector & diagonal_global, + void (CLASS::*cell_operation)(FEEvaluation &) const, + CLASS * owning_class, + const unsigned int dof_no, + const unsigned int quad_no, + const unsigned int first_selected_component) + { + compute_diagonal( + matrix_free, + diagonal_global, + [&](auto &feeval) { (owning_class->*cell_operation)(feeval); }, + dof_no, + quad_no, + first_selected_component); + } + template