From: Matthias Maier Date: Fri, 14 Jul 2017 03:08:36 +0000 (-0500) Subject: Bugfix: Use operator exemplars for preconditioners X-Git-Tag: v9.0.0-rc1~1423^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=14304c0e4568a58c82d6b6a1dcc93110d99de7ce;p=dealii.git Bugfix: Use operator exemplars for preconditioners Further, work around an issue with MG wrappers not exposing vector space information. --- diff --git a/include/deal.II/multigrid/mg_coarse.h b/include/deal.II/multigrid/mg_coarse.h index ea6d8981ac..ab62a4aca2 100644 --- a/include/deal.II/multigrid/mg_coarse.h +++ b/include/deal.II/multigrid/mg_coarse.h @@ -377,7 +377,7 @@ MGCoarseGridLACIteration solver(&s, typeid(*this).name()) { matrix = linear_operator(m); - precondition = linear_operator(p); + precondition = linear_operator(m, p); } @@ -398,12 +398,8 @@ MGCoarseGridLACIteration const PreconditionerType &p) { solver = &s; - if (matrix) - delete matrix; matrix = linear_operator(m); - if (precondition) - delete precondition; - precondition = linear_operator(p); + precondition = linear_operator(m, p); } @@ -437,8 +433,6 @@ void MGCoarseGridLACIteration ::set_matrix(const MatrixType &m) { - if (matrix) - delete matrix; matrix = linear_operator(m); } diff --git a/include/deal.II/multigrid/mg_matrix.h b/include/deal.II/multigrid/mg_matrix.h index 3d01770e18..8333cf21e8 100644 --- a/include/deal.II/multigrid/mg_matrix.h +++ b/include/deal.II/multigrid/mg_matrix.h @@ -183,8 +183,23 @@ namespace mg Matrix::initialize (const MGLevelObject &p) { matrices.resize(p.min_level(), p.max_level()); - for (unsigned int level=p.min_level(); level <= p.max_level(); ++level) - matrices[level] = linear_operator(p[level]); + for (unsigned int level = p.min_level(); level <= p.max_level(); ++level) + { + // Workaround: The matrix objects supplied to this class do not + // expose information how to reinitialize a vector. Therefore, + // populate vmult and Tvmult by hand... + matrices[level] = LinearOperator(); + matrices[level].vmult = [&p, level]( + VectorType &v, const VectorType &u) + { + p[level].vmult(v, u); + }; + matrices[level].Tvmult = [&p, level]( + VectorType &v, const VectorType &u) + { + p[level].Tvmult(v, u); + }; + } }