From d505c0bec309117e5ed0a699d21542e664b5827a Mon Sep 17 00:00:00 2001 From: Timo Koch <timo.koch@iws.uni-stuttgart.de> Date: Thu, 28 Apr 2022 20:30:15 +0200 Subject: [PATCH] [bugfix][parallel][solver] Rebuild parallel helpers after grid adaption --- dumux/linear/amgbackend.hh | 15 +++++++++++++++ dumux/linear/istlsolverfactorybackend.hh | 15 +++++++++++++++ test/porousmediumflow/2p/adaptive/main.cc | 1 + 3 files changed, 31 insertions(+) diff --git a/dumux/linear/amgbackend.hh b/dumux/linear/amgbackend.hh index 468d4f7dd9..2e3ef24482 100644 --- a/dumux/linear/amgbackend.hh +++ b/dumux/linear/amgbackend.hh @@ -87,6 +87,21 @@ public: checkAvailabilityOfDirectSolver_(); } + /*! + * \brief Update the solver after grid adaption + * + * \param gridView the grid view on which we are performing the multi-grid + * \param dofMapper an index mapper for dof entities + */ + void updateAfterGridAdaption(const typename LinearSolverTraits::GridView& gridView, + const typename LinearSolverTraits::DofMapper& dofMapper) + { +#if HAVE_MPI + if (isParallel_) + phelper_ = std::make_unique<ParallelISTLHelper<LinearSolverTraits>>(gridView, dofMapper); +#endif + } + /*! * \brief Solve a linear system. * diff --git a/dumux/linear/istlsolverfactorybackend.hh b/dumux/linear/istlsolverfactorybackend.hh index 9c90f0f83e..a23c72613c 100644 --- a/dumux/linear/istlsolverfactorybackend.hh +++ b/dumux/linear/istlsolverfactorybackend.hh @@ -158,6 +158,21 @@ public: #endif } + /*! + * \brief Update the solver after grid adaption + * + * \param gridView the grid view on which we are performing the multi-grid + * \param dofMapper an index mapper for dof entities + */ + void updateAfterGridAdaption(const typename LinearSolverTraits::GridView& gridView, + const typename LinearSolverTraits::DofMapper& dofMapper) + { +#if HAVE_MPI + if (isParallel_) + parallelHelper_ = std::make_unique<ParallelISTLHelper<LinearSolverTraits>>(gridView, dofMapper); +#endif + } + /*! * \brief Solve a linear system. * diff --git a/test/porousmediumflow/2p/adaptive/main.cc b/test/porousmediumflow/2p/adaptive/main.cc index 5ee75e1e5a..b060c766fb 100644 --- a/test/porousmediumflow/2p/adaptive/main.cc +++ b/test/porousmediumflow/2p/adaptive/main.cc @@ -202,6 +202,7 @@ int main(int argc, char** argv) xOld = x; //!< Overwrite the old solution with the new (resized & interpolated) one gridVariables->updateAfterGridAdaption(x); //!< Initialize the secondary variables to the new (and "new old") solution assembler->updateAfterGridAdaption(); //!< Tell the assembler that the grid changed + linearSolver->updateAfterGridAdaption(leafGridView, gridGeometry->dofMapper()); //!< Tell the solver that the grid changed problem->computePointSourceMap(); //!< Update the point source map } } -- GitLab