From ff6499eaa74904fd34d872c695c2e6df105bdc4f Mon Sep 17 00:00:00 2001 From: Bernd Flemisch <bernd@iws.uni-stuttgart.de> Date: Thu, 7 Mar 2013 18:03:54 +0000 Subject: [PATCH] Bugfix: the implicit AMG tests now also compile with an unpatched PDELab. This is achieved by setting a corresponding macro in a PDELab header. This should be replaced by a proper configure test after the release. Reviewed by Christoph. git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/trunk@10350 2fb0f335-1f38-0410-981e-8018bf24f1b0 --- patches/pdelab-1.0.1.patch | 40 +++++++++++++++++++++------ test/implicit/1p/1ptestproblem.hh | 14 ++++++---- test/implicit/1p/Makefile.am | 5 ---- test/implicit/1p/test_box1pwithamg.cc | 26 +++++++++++++++-- test/implicit/1p/test_cc1pwithamg.cc | 26 +++++++++++++++-- 5 files changed, 86 insertions(+), 25 deletions(-) diff --git a/patches/pdelab-1.0.1.patch b/patches/pdelab-1.0.1.patch index b52635f510..44ddfcc776 100644 --- a/patches/pdelab-1.0.1.patch +++ b/patches/pdelab-1.0.1.patch @@ -1,8 +1,19 @@ Index: dune/pdelab/backend/istlvectorbackend.hh =================================================================== ---- dune/pdelab/backend/istlvectorbackend.hh (revision 2221) +--- dune/pdelab/backend/istlvectorbackend.hh (revision 2292) +++ dune/pdelab/backend/istlvectorbackend.hh (working copy) -@@ -30,6 +30,8 @@ +@@ -3,6 +3,10 @@ + #ifndef DUNE_ISTLVECTORBACKEND_HH + #define DUNE_ISTLVECTORBACKEND_HH + ++// Needed to detect in Dumux whether PDELab is patched. ++// TODO: this should be replaced by a proper configure test. ++#define DUNE_PDELAB_IS_PATCHED_FOR_DUMUX ++ + #include<vector> + + #include<dune/common/fvector.hh> +@@ -30,6 +34,8 @@ typedef typename ContainerType::size_type size_type; typedef ISTLVectorBackend<BLOCKSIZE> Backend; @@ -11,7 +22,7 @@ Index: dune/pdelab/backend/istlvectorbackend.hh ISTLBlockVectorContainer (const T& t_) : container(t_.globalSize()/BLOCKSIZE) {} ISTLBlockVectorContainer (const T& t_, const E& e) : container(t_.globalSize()/BLOCKSIZE) -@@ -89,6 +91,11 @@ +@@ -89,6 +95,11 @@ return container.two_norm(); } @@ -23,7 +34,7 @@ Index: dune/pdelab/backend/istlvectorbackend.hh typename Dune::template FieldTraits<E>::real_type one_norm() const { return container.one_norm(); -@@ -163,6 +170,16 @@ +@@ -163,6 +174,16 @@ return container.size()*BLOCKSIZE; } @@ -42,7 +53,7 @@ Index: dune/pdelab/backend/istlvectorbackend.hh { Index: dune/pdelab/backend/novlpistlsolverbackend.hh =================================================================== ---- dune/pdelab/backend/novlpistlsolverbackend.hh (revision 2221) +--- dune/pdelab/backend/novlpistlsolverbackend.hh (revision 2292) +++ dune/pdelab/backend/novlpistlsolverbackend.hh (working copy) @@ -1153,7 +1153,7 @@ int verbose_=1, bool reuse_=false, @@ -68,7 +79,7 @@ Index: dune/pdelab/backend/novlpistlsolverbackend.hh #if HAVE_MPI Index: dune/pdelab/backend/ovlpistlsolverbackend.hh =================================================================== ---- dune/pdelab/backend/ovlpistlsolverbackend.hh (revision 2221) +--- dune/pdelab/backend/ovlpistlsolverbackend.hh (revision 2292) +++ dune/pdelab/backend/ovlpistlsolverbackend.hh (working copy) @@ -794,7 +794,7 @@ ISTLBackend_AMG(const GFS& gfs_, unsigned maxiter_=5000, @@ -79,12 +90,13 @@ Index: dune/pdelab/backend/ovlpistlsolverbackend.hh verbose(verbose_), reuse(reuse_), firstapply(true), usesuperlu(usesuperlu_) { -@@ -855,11 +855,11 @@ +@@ -855,11 +855,12 @@ \param[in] r right hand side \param[in] reduction to be achieved */ - void apply(M& A, V& z, V& r, typename V::ElementType reduction) -+ void apply(MatrixType& A, V& z, V& r, typename V::ElementType reduction) ++ template <class Vector> ++ void apply(MatrixType& A, Vector& z, Vector& r, typename V::ElementType reduction) { Timer watch; Comm oocc(gfs.gridView().comm()); @@ -93,9 +105,19 @@ Index: dune/pdelab/backend/ovlpistlsolverbackend.hh typedef Dune::Amg::CoarsenCriterion<Dune::Amg::SymmetricCriterion<MatrixType, Dune::Amg::FirstDiagonal> > Criterion; #if HAVE_MPI +@@ -891,7 +892,8 @@ + Solver<VectorType> solver(oop,sp,*amg,reduction,maxiter,verb); + Dune::InverseOperatorResult stat; + +- solver.apply(BlockProcessor<GFS>::getVector(z),BlockProcessor<GFS>::getVector(r),stat); ++// solver.apply(BlockProcessor<GFS>::getVector(z),BlockProcessor<GFS>::getVector(r),stat); ++ solver.apply(z,r,stat); + stats.tsolve= watch.elapsed(); + res.converged = stat.converged; + res.iterations = stat.iterations; Index: dune/pdelab/backend/seqistlsolverbackend.hh =================================================================== ---- dune/pdelab/backend/seqistlsolverbackend.hh (revision 2221) +--- dune/pdelab/backend/seqistlsolverbackend.hh (revision 2292) +++ dune/pdelab/backend/seqistlsolverbackend.hh (working copy) @@ -542,10 +542,10 @@ \param[in] r right hand side diff --git a/test/implicit/1p/1ptestproblem.hh b/test/implicit/1p/1ptestproblem.hh index 8c8f60bd4e..540037396f 100644 --- a/test/implicit/1p/1ptestproblem.hh +++ b/test/implicit/1p/1ptestproblem.hh @@ -40,13 +40,17 @@ #include <dumux/material/components/simpleh2o.hh> #include <dumux/material/fluidsystems/liquidphase.hh> -#ifdef USE_AMGBACKEND #if HAVE_DUNE_PDELAB + +// Check if DUNE-PDELab has been patched for our needs. +// TODO: this should be replaced by a proper configure test. +#include <dune/pdelab/backend/istlvectorbackend.hh> + +#ifdef DUNE_PDELAB_IS_PATCHED_FOR_DUMUX #include <dumux/linear/amgbackend.hh> -#else // HAVE_DUNE_PDELAB -#warning You have to install dune-pdelab to use the AMG backend. +#endif // DUNE_PDELAB_IS_PATCHED_FOR_DUMUX + #endif // HAVE_DUNE_PDELAB -#endif //USE_AMGBACKEND #include "1ptestspatialparams.hh" @@ -92,7 +96,7 @@ SET_INT_PROP(OnePTestProblem, LinearSolverVerbosity, 0); SET_INT_PROP(OnePTestProblem, LinearSolverPreconditionerIterations, 1); SET_SCALAR_PROP(OnePTestProblem, LinearSolverPreconditionerRelaxation, 1.0); -#if defined(USE_AMGBACKEND) && HAVE_DUNE_PDELAB +#ifdef DUNE_PDELAB_IS_PATCHED_FOR_DUMUX NEW_TYPE_TAG(OnePTestBoxProblemWithAMG, INHERITS_FROM(OnePTestBoxProblem)); NEW_TYPE_TAG(OnePTestCCProblemWithAMG, INHERITS_FROM(OnePTestCCProblem)); // Solver settings for the tests using AMG diff --git a/test/implicit/1p/Makefile.am b/test/implicit/1p/Makefile.am index 2982eeba6a..7edde9a77b 100644 --- a/test/implicit/1p/Makefile.am +++ b/test/implicit/1p/Makefile.am @@ -4,13 +4,8 @@ noinst_HEADERS = *.hh EXTRA_DIST=*.input grids/*.dgf CMakeLists.txt test_box1p_SOURCES = test_box1p.cc - test_cc1p_SOURCES = test_cc1p.cc - test_box1pwithamg_SOURCES = test_box1pwithamg.cc -test_box1pwithamg_CXXFLAGS = -DUSE_AMGBACKEND - test_cc1pwithamg_SOURCES = test_cc1pwithamg.cc -test_cc1pwithamg_CXXFLAGS = -DUSE_AMGBACKEND include $(top_srcdir)/am/global-rules diff --git a/test/implicit/1p/test_box1pwithamg.cc b/test/implicit/1p/test_box1pwithamg.cc index 6d867b7870..5e706888c0 100644 --- a/test/implicit/1p/test_box1pwithamg.cc +++ b/test/implicit/1p/test_box1pwithamg.cc @@ -25,6 +25,11 @@ #if HAVE_DUNE_PDELAB +// Check if DUNE-PDELab has been patched for our needs. +// TODO: this should be replaced by a proper configure test. +#include <dune/pdelab/backend/istlvectorbackend.hh> +#ifdef DUNE_PDELAB_IS_PATCHED_FOR_DUMUX + #include "1ptestproblem.hh" #include <dumux/common/start.hh> @@ -65,15 +70,30 @@ int main(int argc, char** argv) typedef TTAG(OnePTestBoxProblemWithAMG) ProblemTypeTag; return Dumux::start<ProblemTypeTag>(argc, argv, usage); } -#else +#else // DUNE_PDELAB_IS_PATCHED_FOR_DUMUX + +#warning You need to have a patched dune-pdelab to run this test, see ../../../patches/README for details. + +#include <iostream> + +int main() +{ + std::cerr << "You need to have a patched dune-pdelab to run this test, " + "see ../../../patches/README for details." << std::endl;; + return 77; +} + +#endif // DUNE_PDELAB_IS_PATCHED_FOR_DUMUX + +#else // HAVE_DUNE_PDELAB -#warning You need to have dune-pdelab installed to run this test +#warning You need to have dune-pdelab installed and patched to run this test. #include <iostream> int main() { - std::cerr << "You need to have dune-pdelab installed to run this test\n"; + std::cerr << "You need to have dune-pdelab installed and patched to run this test.\n"; return 77; } #endif // HAVE_DUNE_PDELAB diff --git a/test/implicit/1p/test_cc1pwithamg.cc b/test/implicit/1p/test_cc1pwithamg.cc index 35ec850954..dd92e136bd 100644 --- a/test/implicit/1p/test_cc1pwithamg.cc +++ b/test/implicit/1p/test_cc1pwithamg.cc @@ -25,6 +25,11 @@ #if HAVE_DUNE_PDELAB +// Check if DUNE-PDELab has been patched for our needs. +// TODO: this should be replaced by a proper configure test. +#include <dune/pdelab/backend/istlvectorbackend.hh> +#ifdef DUNE_PDELAB_IS_PATCHED_FOR_DUMUX + #include "1ptestproblem.hh" #include <dumux/common/start.hh> @@ -65,15 +70,30 @@ int main(int argc, char** argv) typedef TTAG(OnePTestCCProblemWithAMG) ProblemTypeTag; return Dumux::start<ProblemTypeTag>(argc, argv, usage); } -#else +#else // DUNE_PDELAB_IS_PATCHED_FOR_DUMUX + +#warning You need to have a patched dune-pdelab to run this test, see ../../../patches/README for details. + +#include <iostream> + +int main() +{ + std::cerr << "You need to have a patched dune-pdelab to run this test, " + "see ../../../patches/README for details." << std::endl;; + return 77; +} + +#endif // DUNE_PDELAB_IS_PATCHED_FOR_DUMUX + +#else // HAVE_DUNE_PDELAB -#warning You need to have dune-pdelab installed to run this test +#warning You need to have dune-pdelab installed and patched to run this test. #include <iostream> int main() { - std::cerr << "You need to have dune-pdelab installed to run this test\n"; + std::cerr << "You need to have dune-pdelab installed and patched to run this test.\n"; return 77; } #endif // HAVE_DUNE_PDELAB -- GitLab