diff --git a/dumux/linear/amgbackend.hh b/dumux/linear/amgbackend.hh index 468d4f7dd941eb746d0bf9508b3dc2bafacd3a97..2e3ef244828f67259c27d671e87b885f5832f5e5 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 9c90f0f83e1e5a90242d406f92296a558260fb1c..a23c72613c768189600c3102a98ee5402aede1ce 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 5ee75e1e5ad1d17facee8d2e9de6b8656b5ea508..b060c766fbda4ab9efd6244bce316536c60eabf8 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 } }