From c18317784888b3fb535faae43e6e432b74fa0037 Mon Sep 17 00:00:00 2001 From: Timo Koch Date: Wed, 29 Nov 2017 14:17:38 +0100 Subject: [PATCH 1/4] [box][scv,scvf] Make backwards compatible with dune 2.5 --- dumux/discretization/box/subcontrolvolume.hh | 4 ++++ dumux/discretization/box/subcontrolvolumeface.hh | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/dumux/discretization/box/subcontrolvolume.hh b/dumux/discretization/box/subcontrolvolume.hh index b29f786ed3..238ec13cb5 100644 --- a/dumux/discretization/box/subcontrolvolume.hh +++ b/dumux/discretization/box/subcontrolvolume.hh @@ -83,7 +83,11 @@ public: // e.g. for integration Geometry geometry() const { +#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6) return Geometry(Dune::GeometryTypes::cube(dim), corners_); +#else + return Geometry(Dune::GeometryType(Dune::GeometryType::cube, dim), corners_); +#endif } //! The global index of this scv diff --git a/dumux/discretization/box/subcontrolvolumeface.hh b/dumux/discretization/box/subcontrolvolumeface.hh index 77af3b7ec4..fe6066dc60 100644 --- a/dumux/discretization/box/subcontrolvolumeface.hh +++ b/dumux/discretization/box/subcontrolvolumeface.hh @@ -154,7 +154,11 @@ public: //! The geometry of the sub control volume face Geometry geometry() const { +#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6) return Geometry(Dune::GeometryTypes::cube(Geometry::mydimension), corners_); +#else + return Geometry(Dune::GeometryType(Dune::GeometryType::cube, Geometry::mydimension), corners_); +#endif } private: -- GitLab From 11002fa377e1f04657c2025feb96b190fa864934 Mon Sep 17 00:00:00 2001 From: Timo Koch Date: Wed, 29 Nov 2017 14:18:09 +0100 Subject: [PATCH 2/4] [mpfa][scvf] Make backwards compatible with dune 2.5 --- .../discretization/cellcentered/mpfa/subcontrolvolumeface.hh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dumux/discretization/cellcentered/mpfa/subcontrolvolumeface.hh b/dumux/discretization/cellcentered/mpfa/subcontrolvolumeface.hh index 03bbd2356a..bb13446711 100644 --- a/dumux/discretization/cellcentered/mpfa/subcontrolvolumeface.hh +++ b/dumux/discretization/cellcentered/mpfa/subcontrolvolumeface.hh @@ -23,6 +23,7 @@ #ifndef DUMUX_DISCRETIZATION_CC_MPFA_SUBCONTROLVOLUMEFACE_HH #define DUMUX_DISCRETIZATION_CC_MPFA_SUBCONTROLVOLUMEFACE_HH +#include #include "methods.hh" namespace Dumux @@ -144,7 +145,11 @@ public: const GlobalPosition& unitOuterNormal() const { return unitOuterNormal_; } //! The geometry of the sub control volume face +#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6) Geometry geometry() const { return Geometry(Dune::GeometryTypes::cube(Geometry::mydimension), corners_); } +#else + Geometry geometry() const { return Geometry(Dune::GeometryType(Dune::GeometryType::cube, Geometry::mydimension), corners_); } +#endif private: bool boundary_; -- GitLab From 0822dd8b16f06db752ccf92c42254d2532f838df Mon Sep 17 00:00:00 2001 From: Timo Koch Date: Wed, 29 Nov 2017 14:18:29 +0100 Subject: [PATCH 3/4] [mpfa][helper] Make backwards compatible with dune 2.5 --- .../cellcentered/mpfa/helper.hh | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/dumux/discretization/cellcentered/mpfa/helper.hh b/dumux/discretization/cellcentered/mpfa/helper.hh index 26fe069a77..84e0248bab 100644 --- a/dumux/discretization/cellcentered/mpfa/helper.hh +++ b/dumux/discretization/cellcentered/mpfa/helper.hh @@ -23,6 +23,7 @@ #ifndef DUMUX_DISCRETIZATION_CC_MPFA_HELPER_HH #define DUMUX_DISCRETIZATION_CC_MPFA_HELPER_HH +#include #include #include "methods.hh" @@ -112,11 +113,19 @@ public: */ static std::size_t getGlobalNumScvf(const GridView& gridView) { +#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6) assert(gridView.size(Dune::GeometryTypes::triangle) + gridView.size(Dune::GeometryTypes::quadrilateral) == gridView.size(0)); return gridView.size(Dune::GeometryTypes::triangle)*6 + gridView.size(Dune::GeometryTypes::quadrilateral)*8; +#else + assert(gridView.size(Dune::GeometryType(Dune::GeometryType::simplex, 2)) + + gridView.size(Dune::GeometryType(Dune::GeometryType::cube, 2)) == gridView.size(0)); + + return gridView.size(Dune::GeometryType(Dune::GeometryType::simplex, 2))*6 + + gridView.size(Dune::GeometryType(Dune::GeometryType::cube, 2))*8; +#endif } /*! @@ -194,12 +203,21 @@ public: */ static std::size_t getNumLocalScvfs(const Dune::GeometryType gt) { +#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6) if (gt == Dune::GeometryTypes::triangle) return 6; else if (gt == Dune::GeometryTypes::quadrilateral) return 8; else DUNE_THROW(Dune::NotImplemented, "Mpfa for 2d geometry type " << gt); +#else + if (gt.isTriangle()) + return 6; + else if (gt.isQuadrilateral()) + return 8; + else + DUNE_THROW(Dune::NotImplemented, "Mpfa for 2d geometry type " << gt); +#endif } }; @@ -334,6 +352,7 @@ public: */ static std::size_t getGlobalNumScvf(const GridView& gridView) { +#if DUNE_VERSION_NEWER(DUNE_COMMON,2,6) assert(gridView.size(Dune::GeometryTypes::tetrahedron) + gridView.size(Dune::GeometryTypes::pyramid) + gridView.size(Dune::GeometryTypes::prism) @@ -343,6 +362,17 @@ public: + gridView.size(Dune::GeometryTypes::pyramid)*16 + gridView.size(Dune::GeometryTypes::prism)*18 + gridView.size(Dune::GeometryTypes::cube)*24; +#else + assert(gridView.size(Dune::GeometryType(Dune::GeometryType::simplex, 3)) + + gridView.size(Dune::GeometryType(Dune::GeometryType::pyramid, 3)) + + gridView.size(Dune::GeometryType(Dune::GeometryType::prism, 3)) + + gridView.size(Dune::GeometryType(Dune::GeometryType::cube, 3)) == gridView.size(0)); + + return gridView.size(Dune::GeometryType(Dune::GeometryType::simplex, 3))*12 + + gridView.size(Dune::GeometryType(Dune::GeometryType::pyramid, 3))*16 + + gridView.size(Dune::GeometryType(Dune::GeometryType::prism, 3))*18 + + gridView.size(Dune::GeometryType(Dune::GeometryType::cube, 3))*24; +#endif } /*! -- GitLab From 69c8da6aeb360ea334d985e1c839918925f0d6a1 Mon Sep 17 00:00:00 2001 From: Timo Koch Date: Wed, 29 Nov 2017 14:42:51 +0100 Subject: [PATCH 4/4] [3p] Unify main files --- .../3p/implicit/3pniconductionproblem.hh | 18 +- .../3p/implicit/3pniconvectionproblem.hh | 16 +- .../3p/implicit/CMakeLists.txt | 34 ++- .../3p/implicit/infiltration3pproblem.hh | 12 +- .../implicit/{test_cc3p.cc => test_3p_fv.cc} | 10 +- .../{test_cc3p.input => test_3p_fv.input} | 0 ...nduction.cc => test_3pni_fv_conduction.cc} | 6 +- ...on.input => test_3pni_fv_conduction.input} | 6 +- ...nvection.cc => test_3pni_fv_convection.cc} | 6 +- ...on.input => test_3pni_fv_convection.input} | 6 +- .../3p/implicit/test_box3p.cc | 252 ----------------- .../3p/implicit/test_box3p.input | 22 -- .../3p/implicit/test_box3pniconduction.cc | 259 ------------------ .../3p/implicit/test_box3pniconduction.input | 16 -- .../3p/implicit/test_box3pniconvection.cc | 257 ----------------- .../3p/implicit/test_cc3pniconvection.input | 18 -- 16 files changed, 59 insertions(+), 879 deletions(-) rename test/porousmediumflow/3p/implicit/{test_cc3p.cc => test_3p_fv.cc} (97%) rename test/porousmediumflow/3p/implicit/{test_cc3p.input => test_3p_fv.input} (100%) rename test/porousmediumflow/3p/implicit/{test_cc3pniconduction.cc => test_3pni_fv_conduction.cc} (98%) rename test/porousmediumflow/3p/implicit/{test_cc3pniconduction.input => test_3pni_fv_conduction.input} (56%) rename test/porousmediumflow/3p/implicit/{test_cc3pniconvection.cc => test_3pni_fv_convection.cc} (98%) rename test/porousmediumflow/3p/implicit/{test_box3pniconvection.input => test_3pni_fv_convection.input} (62%) delete mode 100644 test/porousmediumflow/3p/implicit/test_box3p.cc delete mode 100644 test/porousmediumflow/3p/implicit/test_box3p.input delete mode 100644 test/porousmediumflow/3p/implicit/test_box3pniconduction.cc delete mode 100644 test/porousmediumflow/3p/implicit/test_box3pniconduction.input delete mode 100644 test/porousmediumflow/3p/implicit/test_box3pniconvection.cc delete mode 100644 test/porousmediumflow/3p/implicit/test_cc3pniconvection.input diff --git a/test/porousmediumflow/3p/implicit/3pniconductionproblem.hh b/test/porousmediumflow/3p/implicit/3pniconductionproblem.hh index c9c3fbf618..48568447d9 100644 --- a/test/porousmediumflow/3p/implicit/3pniconductionproblem.hh +++ b/test/porousmediumflow/3p/implicit/3pniconductionproblem.hh @@ -47,27 +47,25 @@ class ThreePNIConductionProblem; namespace Properties { -NEW_PROP_TAG(FVGridGeometry); - -NEW_TYPE_TAG(ThreePNIConductionProblem, INHERITS_FROM(ThreePNI)); -NEW_TYPE_TAG(ThreePNIConductionBoxProblem, INHERITS_FROM(BoxModel, ThreePNIConductionProblem, ThreePNISpatialParams)); -NEW_TYPE_TAG(ThreePNIConductionCCProblem, INHERITS_FROM(CCTpfaModel, ThreePNIConductionProblem, ThreePNISpatialParams)); -NEW_TYPE_TAG(ThreePNIConductionCCMpfaProblem, INHERITS_FROM(CCMpfaModel, ThreePNIConductionProblem, ThreePNISpatialParams)); +NEW_TYPE_TAG(ThreePNIConductionTypeTag, INHERITS_FROM(ThreePNI)); +NEW_TYPE_TAG(ThreePNIConductionBoxTypeTag, INHERITS_FROM(BoxModel, ThreePNIConductionTypeTag, ThreePNISpatialParams)); +NEW_TYPE_TAG(ThreePNIConductionCCTpfaTypeTag, INHERITS_FROM(CCTpfaModel, ThreePNIConductionTypeTag, ThreePNISpatialParams)); +NEW_TYPE_TAG(ThreePNIConductionCCMpfaTypeTag, INHERITS_FROM(CCMpfaModel, ThreePNIConductionTypeTag, ThreePNISpatialParams)); // Set the grid type -SET_TYPE_PROP(ThreePNIConductionProblem, Grid, Dune::YaspGrid<2>); +SET_TYPE_PROP(ThreePNIConductionTypeTag, Grid, Dune::YaspGrid<2>); // Set the problem property -SET_TYPE_PROP(ThreePNIConductionProblem, Problem, ThreePNIConductionProblem); +SET_TYPE_PROP(ThreePNIConductionTypeTag, Problem, ThreePNIConductionProblem); // Set the fluid system -SET_TYPE_PROP(ThreePNIConductionProblem, +SET_TYPE_PROP(ThreePNIConductionTypeTag, FluidSystem, FluidSystems::H2OAirMesitylene); // Set the spatial parameters -SET_TYPE_PROP(ThreePNIConductionProblem, +SET_TYPE_PROP(ThreePNIConductionTypeTag, SpatialParams, ThreePNISpatialParams); diff --git a/test/porousmediumflow/3p/implicit/3pniconvectionproblem.hh b/test/porousmediumflow/3p/implicit/3pniconvectionproblem.hh index 1178f4d46e..bed0617a8d 100644 --- a/test/porousmediumflow/3p/implicit/3pniconvectionproblem.hh +++ b/test/porousmediumflow/3p/implicit/3pniconvectionproblem.hh @@ -45,25 +45,25 @@ class ThreePNIConvectionProblem; namespace Properties { -NEW_TYPE_TAG(ThreePNIConvectionProblem, INHERITS_FROM(ThreePNI, ThreePNISpatialParams)); -NEW_TYPE_TAG(ThreePNIConvectionBoxProblem, INHERITS_FROM(BoxModel, ThreePNIConvectionProblem)); -NEW_TYPE_TAG(ThreePNIConvectionCCProblem, INHERITS_FROM(CCTpfaModel, ThreePNIConvectionProblem)); -NEW_TYPE_TAG(ThreePNIConvectionCCMpfaProblem, INHERITS_FROM(CCMpfaModel, ThreePNIConvectionProblem)); +NEW_TYPE_TAG(ThreePNIConvectionTypeTag, INHERITS_FROM(ThreePNI, ThreePNISpatialParams)); +NEW_TYPE_TAG(ThreePNIConvectionBoxTypeTag, INHERITS_FROM(BoxModel, ThreePNIConvectionTypeTag)); +NEW_TYPE_TAG(ThreePNIConvectionCCTpfaTypeTag, INHERITS_FROM(CCTpfaModel, ThreePNIConvectionTypeTag)); +NEW_TYPE_TAG(ThreePNIConvectionCCMpfaTypeTag, INHERITS_FROM(CCMpfaModel, ThreePNIConvectionTypeTag)); // Set the grid type -SET_TYPE_PROP(ThreePNIConvectionProblem, Grid, Dune::YaspGrid<2>); +SET_TYPE_PROP(ThreePNIConvectionTypeTag, Grid, Dune::YaspGrid<2>); // Set the problem property -SET_TYPE_PROP(ThreePNIConvectionProblem, Problem, ThreePNIConvectionProblem); +SET_TYPE_PROP(ThreePNIConvectionTypeTag, Problem, ThreePNIConvectionProblem); // Set the fluid system -SET_TYPE_PROP(ThreePNIConvectionProblem, +SET_TYPE_PROP(ThreePNIConvectionTypeTag, FluidSystem, FluidSystems::H2OAirMesitylene); // Set the spatial parameters -SET_TYPE_PROP(ThreePNIConvectionProblem, +SET_TYPE_PROP(ThreePNIConvectionTypeTag, SpatialParams, ThreePNISpatialParams); } diff --git a/test/porousmediumflow/3p/implicit/CMakeLists.txt b/test/porousmediumflow/3p/implicit/CMakeLists.txt index deeff68155..4c3385dfdc 100644 --- a/test/porousmediumflow/3p/implicit/CMakeLists.txt +++ b/test/porousmediumflow/3p/implicit/CMakeLists.txt @@ -2,56 +2,62 @@ add_input_file_links() # isothermal tests dune_add_test(NAME test_box3p - SOURCES test_box3p.cc + SOURCES test_3p_fv.cc + COMPILE_DEFINITIONS TYPETAG=InfiltrationThreePBoxTypeTag COMMAND ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py CMD_ARGS --script fuzzy --files ${CMAKE_SOURCE_DIR}/test/references/infiltration3pbox-reference.vtu - ${CMAKE_CURRENT_BINARY_DIR}/infiltration3pbox-00008.vtu - --command "${CMAKE_CURRENT_BINARY_DIR}/test_box3p") + ${CMAKE_CURRENT_BINARY_DIR}/infiltration3pbox-00008.vtu + --command "${CMAKE_CURRENT_BINARY_DIR}/test_box3p test_3p_fv.input -Problem.Name infiltration3pbox") dune_add_test(NAME test_cc3p - SOURCES test_cc3p.cc + SOURCES test_3p_fv.cc + COMPILE_DEFINITIONS TYPETAG=InfiltrationThreePCCTpfaTypeTag COMMAND ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py CMD_ARGS --script fuzzy --files ${CMAKE_SOURCE_DIR}/test/references/infiltration3pcc-reference.vtu - ${CMAKE_CURRENT_BINARY_DIR}/infiltration3pcc-00008.vtu - --command "${CMAKE_CURRENT_BINARY_DIR}/test_cc3p") + ${CMAKE_CURRENT_BINARY_DIR}/infiltration3pcc-00008.vtu + --command "${CMAKE_CURRENT_BINARY_DIR}/test_cc3p test_3p_fv.input -Problem.Name infiltration3pcc") # non-isothermal tests dune_add_test(NAME test_box3pniconvection - SOURCES test_box3pniconvection.cc + SOURCES test_3pni_fv_convection.cc + COMPILE_DEFINITIONS TYPETAG=ThreePNIConvectionBoxTypeTag COMMAND ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py CMD_ARGS --script fuzzy --files ${CMAKE_SOURCE_DIR}/test/references/3pniconvectionbox-reference.vtu ${CMAKE_CURRENT_BINARY_DIR}/test_box3pniconvection-00010.vtu - --command "${CMAKE_CURRENT_BINARY_DIR}/test_box3pniconvection" + --command "${CMAKE_CURRENT_BINARY_DIR}/test_box3pniconvection test_3pni_fv_convection.input -Problem.Name test_box3pniconvection" --zeroThreshold {"velocity_w \(m/s\)_1":1e-8}) dune_add_test(NAME test_cc3pniconvection - SOURCES test_cc3pniconvection.cc + SOURCES test_3pni_fv_convection.cc + COMPILE_DEFINITIONS TYPETAG=ThreePNIConvectionCCTpfaTypeTag COMMAND ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py CMD_ARGS --script fuzzy --files ${CMAKE_SOURCE_DIR}/test/references/3pniconvectioncc-reference.vtu ${CMAKE_CURRENT_BINARY_DIR}/test_cc3pniconvection-00010.vtu - --command "${CMAKE_CURRENT_BINARY_DIR}/test_cc3pniconvection" + --command "${CMAKE_CURRENT_BINARY_DIR}/test_cc3pniconvection test_3pni_fv_convection.input -Problem.Name test_cc3pniconvection" --zeroThreshold {"velocity_w \(m/s\)_1":1e-8}) dune_add_test(NAME test_box3pniconduction - SOURCES test_box3pniconduction.cc + SOURCES test_3pni_fv_conduction.cc + COMPILE_DEFINITIONS TYPETAG=ThreePNIConductionBoxTypeTag COMMAND ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py CMD_ARGS --script fuzzy --files ${CMAKE_SOURCE_DIR}/test/references/3pniconductionbox-reference.vtu ${CMAKE_CURRENT_BINARY_DIR}/test_box3pniconduction-00006.vtu - --command "${CMAKE_CURRENT_BINARY_DIR}/test_box3pniconduction" + --command "${CMAKE_CURRENT_BINARY_DIR}/test_box3pniconduction test_3pni_fv_conduction.input -Problem.Name test_box3pniconduction" --zeroThreshold {"velocity_w \(m/s\)_1":1e-8}) dune_add_test(NAME test_cc3pniconduction - SOURCES test_cc3pniconduction.cc + SOURCES test_3pni_fv_conduction.cc + COMPILE_DEFINITIONS TYPETAG=ThreePNIConductionCCTpfaTypeTag COMMAND ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py CMD_ARGS --script fuzzy --files ${CMAKE_SOURCE_DIR}/test/references/3pniconductioncc-reference.vtu ${CMAKE_CURRENT_BINARY_DIR}/test_cc3pniconduction-00006.vtu - --command "${CMAKE_CURRENT_BINARY_DIR}/test_cc3pniconduction" + --command "${CMAKE_CURRENT_BINARY_DIR}/test_cc3pniconduction test_3pni_fv_conduction.input -Problem.Name test_cc3pniconduction" --zeroThreshold {"velocity_w \(m/s\)_1":1e-8}) #install sources diff --git a/test/porousmediumflow/3p/implicit/infiltration3pproblem.hh b/test/porousmediumflow/3p/implicit/infiltration3pproblem.hh index 5948e370ba..18a4f6c27a 100644 --- a/test/porousmediumflow/3p/implicit/infiltration3pproblem.hh +++ b/test/porousmediumflow/3p/implicit/infiltration3pproblem.hh @@ -42,18 +42,18 @@ class InfiltrationThreePProblem; namespace Properties { -NEW_TYPE_TAG(InfiltrationThreePProblem, INHERITS_FROM(ThreeP, InfiltrationThreePSpatialParams)); -NEW_TYPE_TAG(InfiltrationThreePBoxProblem, INHERITS_FROM(BoxModel, InfiltrationThreePProblem)); -NEW_TYPE_TAG(InfiltrationThreePCCProblem, INHERITS_FROM(CCTpfaModel, InfiltrationThreePProblem)); +NEW_TYPE_TAG(InfiltrationThreePTypeTag, INHERITS_FROM(ThreeP, InfiltrationThreePSpatialParams)); +NEW_TYPE_TAG(InfiltrationThreePBoxTypeTag, INHERITS_FROM(BoxModel, InfiltrationThreePTypeTag)); +NEW_TYPE_TAG(InfiltrationThreePCCTpfaTypeTag, INHERITS_FROM(CCTpfaModel, InfiltrationThreePTypeTag)); // Set the grid type -SET_TYPE_PROP(InfiltrationThreePProblem, Grid, Dune::YaspGrid<2>); +SET_TYPE_PROP(InfiltrationThreePTypeTag, Grid, Dune::YaspGrid<2>); // Set the problem property -SET_TYPE_PROP(InfiltrationThreePProblem, Problem, InfiltrationThreePProblem); +SET_TYPE_PROP(InfiltrationThreePTypeTag, Problem, InfiltrationThreePProblem); // Set the fluid system -SET_TYPE_PROP(InfiltrationThreePProblem, +SET_TYPE_PROP(InfiltrationThreePTypeTag, FluidSystem, FluidSystems::H2OAirMesitylene); diff --git a/test/porousmediumflow/3p/implicit/test_cc3p.cc b/test/porousmediumflow/3p/implicit/test_3p_fv.cc similarity index 97% rename from test/porousmediumflow/3p/implicit/test_cc3p.cc rename to test/porousmediumflow/3p/implicit/test_3p_fv.cc index 5f09e831f7..f8bcf36e9a 100644 --- a/test/porousmediumflow/3p/implicit/test_cc3p.cc +++ b/test/porousmediumflow/3p/implicit/test_3p_fv.cc @@ -38,7 +38,7 @@ #include #include -#include +#include #include #include @@ -86,7 +86,7 @@ int main(int argc, char** argv) try using namespace Dumux; // define the type tag for this problem - using TypeTag = TTAG(InfiltrationThreePCCProblem); + using TypeTag = TTAG(TYPETAG); // initialize MPI, finalize is done automatically on exit const auto& mpiHelper = Dune::MPIHelper::instance(argc, argv); @@ -121,7 +121,7 @@ int main(int argc, char** argv) try // the solution vector using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector); - SolutionVector x(leafGridView.size(0)); + SolutionVector x(fvGridGeometry->numDofs()); problem->applyInitialSolution(x); auto xOld = x; @@ -157,8 +157,8 @@ int main(int argc, char** argv) try auto assembler = std::make_shared(problem, fvGridGeometry, gridVariables, timeLoop); // the linear solver - using LinearSolver = UMFPackBackend; - auto linearSolver = std::make_shared(); + using LinearSolver = Dumux::AMGBackend; + auto linearSolver = std::make_shared(leafGridView, fvGridGeometry->dofMapper()); // the non-linear solver using NewtonController = Dumux::NewtonController; diff --git a/test/porousmediumflow/3p/implicit/test_cc3p.input b/test/porousmediumflow/3p/implicit/test_3p_fv.input similarity index 100% rename from test/porousmediumflow/3p/implicit/test_cc3p.input rename to test/porousmediumflow/3p/implicit/test_3p_fv.input diff --git a/test/porousmediumflow/3p/implicit/test_cc3pniconduction.cc b/test/porousmediumflow/3p/implicit/test_3pni_fv_conduction.cc similarity index 98% rename from test/porousmediumflow/3p/implicit/test_cc3pniconduction.cc rename to test/porousmediumflow/3p/implicit/test_3pni_fv_conduction.cc index 858dbea7e6..c3be2c2f3c 100644 --- a/test/porousmediumflow/3p/implicit/test_cc3pniconduction.cc +++ b/test/porousmediumflow/3p/implicit/test_3pni_fv_conduction.cc @@ -86,7 +86,7 @@ int main(int argc, char** argv) try using namespace Dumux; // define the type tag for this problem - using TypeTag = TTAG(ThreePNIConductionCCProblem); + using TypeTag = TTAG(TYPETAG); // initialize MPI, finalize is done automatically on exit const auto& mpiHelper = Dune::MPIHelper::instance(argc, argv); @@ -121,7 +121,7 @@ int main(int argc, char** argv) try // the solution vector using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector); - SolutionVector x(leafGridView.size(0)); + SolutionVector x(fvGridGeometry->numDofs()); problem->applyInitialSolution(x); auto xOld = x; @@ -161,7 +161,7 @@ int main(int argc, char** argv) try // the linear solver using LinearSolver = Dumux::AMGBackend; - auto linearSolver = std::make_shared(leafGridView, fvGridGeometry->elementMapper()); + auto linearSolver = std::make_shared(leafGridView, fvGridGeometry->dofMapper()); // the non-linear solver using NewtonController = Dumux::NewtonController; diff --git a/test/porousmediumflow/3p/implicit/test_cc3pniconduction.input b/test/porousmediumflow/3p/implicit/test_3pni_fv_conduction.input similarity index 56% rename from test/porousmediumflow/3p/implicit/test_cc3pniconduction.input rename to test/porousmediumflow/3p/implicit/test_3pni_fv_conduction.input index 11dff4a2c5..9fc89f231c 100644 --- a/test/porousmediumflow/3p/implicit/test_cc3pniconduction.input +++ b/test/porousmediumflow/3p/implicit/test_3pni_fv_conduction.input @@ -8,9 +8,9 @@ UpperRight = 5 1 Cells = 200 1 [Problem] -Name = test_cc3pniconduction # name passed to the output routines +Name = test_3pniconduction # name passed to the output routines OutputInterval = 5 # every 5th timestep an output file is written -EnableGravity = 0 # disable gravity +EnableGravity = false # disable gravity [Vtk] -AddVelocity = 1 #Enable velocity output +AddVelocity = true #Enable velocity output diff --git a/test/porousmediumflow/3p/implicit/test_cc3pniconvection.cc b/test/porousmediumflow/3p/implicit/test_3pni_fv_convection.cc similarity index 98% rename from test/porousmediumflow/3p/implicit/test_cc3pniconvection.cc rename to test/porousmediumflow/3p/implicit/test_3pni_fv_convection.cc index 77ee4c8b20..15becc03f3 100644 --- a/test/porousmediumflow/3p/implicit/test_cc3pniconvection.cc +++ b/test/porousmediumflow/3p/implicit/test_3pni_fv_convection.cc @@ -86,7 +86,7 @@ int main(int argc, char** argv) try using namespace Dumux; // define the type tag for this problem - using TypeTag = TTAG(ThreePNIConvectionCCProblem); + using TypeTag = TTAG(TYPETAG); // initialize MPI, finalize is done automatically on exit const auto& mpiHelper = Dune::MPIHelper::instance(argc, argv); @@ -121,7 +121,7 @@ int main(int argc, char** argv) try // the solution vector using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector); - SolutionVector x(leafGridView.size(0)); + SolutionVector x(fvGridGeometry->numDofs()); problem->applyInitialSolution(x); auto xOld = x; @@ -161,7 +161,7 @@ int main(int argc, char** argv) try // the linear solver using LinearSolver = Dumux::AMGBackend; - auto linearSolver = std::make_shared(leafGridView, fvGridGeometry->elementMapper()); + auto linearSolver = std::make_shared(leafGridView, fvGridGeometry->dofMapper()); // the non-linear solver using NewtonController = Dumux::NewtonController; diff --git a/test/porousmediumflow/3p/implicit/test_box3pniconvection.input b/test/porousmediumflow/3p/implicit/test_3pni_fv_convection.input similarity index 62% rename from test/porousmediumflow/3p/implicit/test_box3pniconvection.input rename to test/porousmediumflow/3p/implicit/test_3pni_fv_convection.input index 74c95f92a7..8670882f24 100644 --- a/test/porousmediumflow/3p/implicit/test_box3pniconvection.input +++ b/test/porousmediumflow/3p/implicit/test_3pni_fv_convection.input @@ -8,10 +8,10 @@ UpperRight = 20 1 Cells = 80 1 [Problem] -Name = test_box3pniconvection # name passed to the output routines +Name = test_3pniconvection # name passed to the output routines OutputInterval = 5 # every 5th timestep an output file is written DarcyVelocity = 1e-4 # [m/s] inflow at the left boundary -EnableGravity = 0 # disable gravity +EnableGravity = false # disable gravity [Vtk] -AddVelocity = 1 #Enable velocity output +AddVelocity = true #Enable velocity output diff --git a/test/porousmediumflow/3p/implicit/test_box3p.cc b/test/porousmediumflow/3p/implicit/test_box3p.cc deleted file mode 100644 index 1f2ae7a3d7..0000000000 --- a/test/porousmediumflow/3p/implicit/test_box3p.cc +++ /dev/null @@ -1,252 +0,0 @@ -// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- -// vi: set et ts=4 sw=4 sts=4: -/***************************************************************************** - * See the file COPYING for full copying permissions. * - * * - * This program is free software: you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation, either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program. If not, see . * - *****************************************************************************/ -/*! - * \file - * - * \brief Test for the three-phase box model - */ -#include -#include "infiltration3pproblem.hh" - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include - -#include - -/*! - * \brief Provides an interface for customizing error messages associated with - * reading in parameters. - * - * \param progName The name of the program, that was tried to be started. - * \param errorMsg The error message that was issued by the start function. - * Comprises the thing that went wrong and a general help message. - */ -void usage(const char *progName, const std::string &errorMsg) -{ - if (errorMsg.size() > 0) { - std::string errorMessageOut = "\nUsage: "; - errorMessageOut += progName; - errorMessageOut += " [options]\n"; - errorMessageOut += errorMsg; - errorMessageOut += "\n\nThe list of mandatory options for this program is:\n" - "\t-TimeManager.TEnd End of the simulation [s] \n" - "\t-TimeManager.DtInitial Initial timestep size [s] \n" - "\t-Grid.File Name of the file containing the grid \n" - "\t definition in DGF format\n"; - - std::cout << errorMessageOut - << "\n"; - } -} - -int main(int argc, char** argv) try -{ - - using namespace Dumux; - - // define the type tag for this problem - using TypeTag = TTAG(InfiltrationThreePBoxProblem); - - //////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////// - - // initialize MPI, finalize is done automatically on exit - const auto& mpiHelper = Dune::MPIHelper::instance(argc, argv); - - // print dumux start message - if (mpiHelper.rank() == 0) - DumuxMessage::print(/*firstCall=*/true); - - // parse command line arguments and input file - Parameters::init(argc, argv, usage); - - // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); - - //////////////////////////////////////////////////////////// - // run instationary non-linear problem on this grid - //////////////////////////////////////////////////////////// - - // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); - - // create the finite volume grid geometry - using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); - auto fvGridGeometry = std::make_shared(leafGridView); - fvGridGeometry->update(); - - // the problem (initial and boundary conditions) - using Problem = typename GET_PROP_TYPE(TypeTag, Problem); - auto problem = std::make_shared(fvGridGeometry); - - // the solution vector - using GridView = typename GET_PROP_TYPE(TypeTag, GridView); - using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector); - SolutionVector x(leafGridView.size(GridView::dimension)); - problem->applyInitialSolution(x); - auto xOld = x; - - // the grid variables - using GridVariables = typename GET_PROP_TYPE(TypeTag, GridVariables); - auto gridVariables = std::make_shared(problem, fvGridGeometry); - gridVariables->init(x, xOld); - - // get some time loop parameters - using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar); - const auto tEnd = getParam("TimeLoop.TEnd"); - const auto maxDivisions = getParam("TimeLoop.MaxTimeStepDivisions"); - const auto maxDt = getParam("TimeLoop.MaxTimeStepSize"); - auto dt = getParam("TimeLoop.DtInitial"); - - // check if we are about to restart a previously interrupted simulation - Scalar restartTime = 0; - if (Parameters::getTree().hasKey("Restart") || Parameters::getTree().hasKey("TimeLoop.Restart")) - restartTime = getParam("TimeLoop.Restart"); - - // intialize the vtk output module - using VtkOutputFields = typename GET_PROP_TYPE(TypeTag, VtkOutputFields); - VtkOutputModule vtkWriter(*problem, *fvGridGeometry, *gridVariables, x, problem->name()); - VtkOutputFields::init(vtkWriter); //! Add model specific output fields - vtkWriter.write(0.0); - - // instantiate time loop - auto timeLoop = std::make_shared>(restartTime, dt, tEnd); - timeLoop->setMaxTimeStepSize(maxDt); - - // the assembler with time loop for instationary problem - using Assembler = FVAssembler; - auto assembler = std::make_shared(problem, fvGridGeometry, gridVariables, timeLoop); - - // the linear solver - using LinearSolver = Dumux::AMGBackend; - auto linearSolver = std::make_shared(leafGridView, fvGridGeometry->elementMapper()); - - // the non-linear solver - using NewtonController = Dumux::NewtonController; - using NewtonMethod = Dumux::NewtonMethod; - auto newtonController = std::make_shared(leafGridView.comm(), timeLoop); - NewtonMethod nonLinearSolver(newtonController, assembler, linearSolver); - - // time loop - timeLoop->start(); do - { - // set previous solution for storage evaluations - assembler->setPreviousSolution(xOld); - - // try solving the non-linear system - for (int i = 0; i < maxDivisions; ++i) - { - // linearize & solve - auto converged = nonLinearSolver.solve(x); - - if (converged) - break; - - if (!converged && i == maxDivisions-1) - DUNE_THROW(Dune::MathError, - "Newton solver didn't converge after " - << maxDivisions - << " time-step divisions. dt=" - << timeLoop->timeStepSize() - << ".\nThe solutions of the current and the previous time steps " - << "have been saved to restart files."); - } - - // make the new solution the old solution - xOld = x; - gridVariables->advanceTimeStep(); - - // advance to the time loop to the next step - timeLoop->advanceTimeStep(); - - // write vtk output - vtkWriter.write(timeLoop->time()); - - // report statistics of this time step - timeLoop->reportTimeStep(); - - // set new dt as suggested by newton controller - timeLoop->setTimeStepSize(newtonController->suggestTimeStepSize(timeLoop->timeStepSize())); - problem->setTime(timeLoop->time()+timeLoop->timeStepSize()); - - } while (!timeLoop->finished()); - - timeLoop->finalize(leafGridView.comm()); - - //////////////////////////////////////////////////////////// - // finalize, print dumux message to say goodbye - //////////////////////////////////////////////////////////// - - // print dumux end message - if (mpiHelper.rank() == 0) - { - Parameters::print(); - DumuxMessage::print(/*firstCall=*/false); - } - - return 0; - -} -catch (Dumux::ParameterException &e) -{ - std::cerr << std::endl << e << " ---> Abort!" << std::endl; - return 1; -} -catch (Dune::DGFException & e) -{ - std::cerr << "DGF exception thrown (" << e << - "). Most likely, the DGF file name is wrong " - "or the DGF file is corrupted, " - "e.g. missing hash at end of file or wrong number (dimensions) of entries." - << " ---> Abort!" << std::endl; - return 2; -} -catch (Dune::Exception &e) -{ - std::cerr << "Dune reported error: " << e << " ---> Abort!" << std::endl; - return 3; -} -catch (...) -{ - std::cerr << "Unknown exception thrown! ---> Abort!" << std::endl; - return 4; -} diff --git a/test/porousmediumflow/3p/implicit/test_box3p.input b/test/porousmediumflow/3p/implicit/test_box3p.input deleted file mode 100644 index b41123ccc3..0000000000 --- a/test/porousmediumflow/3p/implicit/test_box3p.input +++ /dev/null @@ -1,22 +0,0 @@ -[TimeLoop] -DtInitial = 60 # [s] -TEnd = 3600 # [s] - -[Grid] -UpperRight = 500 10 -Cells = 50 10 - -[Problem] -Name = infiltration3pbox - -[SpatialParams] -permeability = 1.e-11 # m^2 -porosity = 0.40 -vanGenuchtenAlpha = 0.0005 -vanGenuchtenN = 4.0 - -[Output] -PlotFluidMatrixInteractions = false - -[Newton] -MaxRelativeShift = 1e-4 diff --git a/test/porousmediumflow/3p/implicit/test_box3pniconduction.cc b/test/porousmediumflow/3p/implicit/test_box3pniconduction.cc deleted file mode 100644 index bb5ab3447f..0000000000 --- a/test/porousmediumflow/3p/implicit/test_box3pniconduction.cc +++ /dev/null @@ -1,259 +0,0 @@ -// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- -// vi: set et ts=4 sw=4 sts=4: -/***************************************************************************** - * See the file COPYING for full copying permissions. * - * * - * This program is free software: you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation, either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program. If not, see . * - *****************************************************************************/ -/*! - * \file - * - * \brief test for the 3pni box model - */ -#include -#include "3pniconductionproblem.hh" - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include - -#include - -/*! - * \brief Provides an interface for customizing error messages associated with - * reading in parameters. - * - * \param progName The name of the program, that was tried to be started. - * \param errorMsg The error message that was issued by the start function. - * Comprises the thing that went wrong and a general help message. - */ -void usage(const char *progName, const std::string &errorMsg) -{ - if (errorMsg.size() > 0) { - std::string errorMessageOut = "\nUsage: "; - errorMessageOut += progName; - errorMessageOut += " [options]\n"; - errorMessageOut += errorMsg; - errorMessageOut += "\n\nThe list of mandatory options for this program is:\n" - "\t-TimeManager.TEnd End of the simulation [s] \n" - "\t-TimeManager.DtInitial Initial timestep size [s] \n" - "\t-Grid.File Name of the file containing the grid \n" - "\t definition in DGF format\n"; - - std::cout << errorMessageOut - << "\n"; - } -} - -int main(int argc, char** argv) try -{ - - using namespace Dumux; - - // define the type tag for this problem - using TypeTag = TTAG(ThreePNIConductionBoxProblem); - - //////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////// - - // initialize MPI, finalize is done automatically on exit - const auto& mpiHelper = Dune::MPIHelper::instance(argc, argv); - - // print dumux start message - if (mpiHelper.rank() == 0) - DumuxMessage::print(/*firstCall=*/true); - - // parse command line arguments and input file - Parameters::init(argc, argv, usage); - - // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); - - //////////////////////////////////////////////////////////// - // run instationary non-linear problem on this grid - //////////////////////////////////////////////////////////// - - // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); - - // create the finite volume grid geometry - using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); - auto fvGridGeometry = std::make_shared(leafGridView); - fvGridGeometry->update(); - - // the problem (initial and boundary conditions) - using Problem = typename GET_PROP_TYPE(TypeTag, Problem); - auto problem = std::make_shared(fvGridGeometry); - - // the solution vector - using GridView = typename GET_PROP_TYPE(TypeTag, GridView); - using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector); - SolutionVector x(leafGridView.size(GridView::dimension)); - problem->applyInitialSolution(x); - auto xOld = x; - - // the grid variables - using GridVariables = typename GET_PROP_TYPE(TypeTag, GridVariables); - auto gridVariables = std::make_shared(problem, fvGridGeometry); - gridVariables->init(x, xOld); - - // get some time loop parameters - using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar); - const auto tEnd = getParam("TimeLoop.TEnd"); - const auto maxDivisions = getParam("TimeLoop.MaxTimeStepDivisions"); - const auto maxDt = getParam("TimeLoop.MaxTimeStepSize"); - auto dt = getParam("TimeLoop.DtInitial"); - - // check if we are about to restart a previously interrupted simulation - Scalar restartTime = 0; - if (Parameters::getTree().hasKey("Restart") || Parameters::getTree().hasKey("TimeLoop.Restart")) - restartTime = getParam("TimeLoop.Restart"); - - // intialize the vtk output module - using VtkOutputFields = typename GET_PROP_TYPE(TypeTag, VtkOutputFields); - VtkOutputModule vtkWriter(*problem, *fvGridGeometry, *gridVariables, x, problem->name()); - VtkOutputFields::init(vtkWriter); //! Add model specific output fields - vtkWriter.addField(problem->getExactTemperature(), "temperatureExact"); - vtkWriter.write(0.0); - // output every vtkOutputInterval time step - const auto vtkOutputInterval = getParam("Problem.OutputInterval"); - - // instantiate time loop - auto timeLoop = std::make_shared>(restartTime, dt, tEnd); - timeLoop->setMaxTimeStepSize(maxDt); - - // the assembler with time loop for instationary problem - using Assembler = FVAssembler; - auto assembler = std::make_shared(problem, fvGridGeometry, gridVariables, timeLoop); - - // the linear solver - using LinearSolver = Dumux::AMGBackend; - auto linearSolver = std::make_shared(leafGridView, fvGridGeometry->vertexMapper()); - - // the non-linear solver - using NewtonController = Dumux::NewtonController; - using NewtonMethod = Dumux::NewtonMethod; - auto newtonController = std::make_shared(leafGridView.comm(), timeLoop); - NewtonMethod nonLinearSolver(newtonController, assembler, linearSolver); - - // time loop - timeLoop->start(); do - { - // set previous solution for storage evaluations - assembler->setPreviousSolution(xOld); - - // try solving the non-linear system - for (int i = 0; i < maxDivisions; ++i) - { - // linearize & solve - auto converged = nonLinearSolver.solve(x); - - if (converged) - break; - - if (!converged && i == maxDivisions-1) - DUNE_THROW(Dune::MathError, - "Newton solver didn't converge after " - << maxDivisions - << " time-step divisions. dt=" - << timeLoop->timeStepSize() - << ".\nThe solutions of the current and the previous time steps " - << "have been saved to restart files."); - } - - // compute the new analytical temperature field for the output - problem->updateExactTemperature(x, timeLoop->time()+timeLoop->timeStepSize()); - - // make the new solution the old solution - xOld = x; - gridVariables->advanceTimeStep(); - - // advance to the time loop to the next step - timeLoop->advanceTimeStep(); - - // report statistics of this time step - timeLoop->reportTimeStep(); - - // set new dt as suggested by newton controller - timeLoop->setTimeStepSize(newtonController->suggestTimeStepSize(timeLoop->timeStepSize())); - - // write vtk output - if (timeLoop->timeStepIndex()==0 || timeLoop->timeStepIndex() % vtkOutputInterval == 0 || timeLoop->willBeFinished()) - vtkWriter.write(timeLoop->time()); - - - } while (!timeLoop->finished()); - - timeLoop->finalize(leafGridView.comm()); - - //////////////////////////////////////////////////////////// - // finalize, print dumux message to say goodbye - //////////////////////////////////////////////////////////// - - // print dumux end message - if (mpiHelper.rank() == 0) - { - Parameters::print(); - DumuxMessage::print(/*firstCall=*/false); - } - - return 0; - -} -catch (Dumux::ParameterException &e) -{ - std::cerr << std::endl << e << " ---> Abort!" << std::endl; - return 1; -} -catch (Dune::DGFException & e) -{ - std::cerr << "DGF exception thrown (" << e << - "). Most likely, the DGF file name is wrong " - "or the DGF file is corrupted, " - "e.g. missing hash at end of file or wrong number (dimensions) of entries." - << " ---> Abort!" << std::endl; - return 2; -} -catch (Dune::Exception &e) -{ - std::cerr << "Dune reported error: " << e << " ---> Abort!" << std::endl; - return 3; -} -catch (...) -{ - std::cerr << "Unknown exception thrown! ---> Abort!" << std::endl; - return 4; -} diff --git a/test/porousmediumflow/3p/implicit/test_box3pniconduction.input b/test/porousmediumflow/3p/implicit/test_box3pniconduction.input deleted file mode 100644 index cddf9d588e..0000000000 --- a/test/porousmediumflow/3p/implicit/test_box3pniconduction.input +++ /dev/null @@ -1,16 +0,0 @@ -[TimeLoop] -DtInitial = 1 # [s] -TEnd = 1e5 # [s] -MaxTimeStepSize = 1e10 - -[Grid] -UpperRight = 5 1 -Cells = 200 1 - -[Problem] -Name = test_box3pniconduction # name passed to the output routines -OutputInterval = 5 # every 5th timestep an output file is written -EnableGravity = 0 # disable gravity - -[Vtk] -AddVelocity = 1 #Enable velocity output diff --git a/test/porousmediumflow/3p/implicit/test_box3pniconvection.cc b/test/porousmediumflow/3p/implicit/test_box3pniconvection.cc deleted file mode 100644 index 7cca342837..0000000000 --- a/test/porousmediumflow/3p/implicit/test_box3pniconvection.cc +++ /dev/null @@ -1,257 +0,0 @@ -// -*- mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- -// vi: set et ts=4 sw=4 sts=4: -/***************************************************************************** - * See the file COPYING for full copying permissions. * - * * - * This program is free software: you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation, either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program. If not, see . * - *****************************************************************************/ -/*! - * \file - * - * \brief test for the 3pni box model - */ -#include -#include "3pniconvectionproblem.hh" - -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include -#include - -#include -#include - -#include - -#include - -/*! - * \brief Provides an interface for customizing error messages associated with - * reading in parameters. - * - * \param progName The name of the program, that was tried to be started. - * \param errorMsg The error message that was issued by the start function. - * Comprises the thing that went wrong and a general help message. - */ -void usage(const char *progName, const std::string &errorMsg) -{ - if (errorMsg.size() > 0) { - std::string errorMessageOut = "\nUsage: "; - errorMessageOut += progName; - errorMessageOut += " [options]\n"; - errorMessageOut += errorMsg; - errorMessageOut += "\n\nThe list of mandatory options for this program is:\n" - "\t-TimeManager.TEnd End of the simulation [s] \n" - "\t-TimeManager.DtInitial Initial timestep size [s] \n" - "\t-Grid.File Name of the file containing the grid \n" - "\t definition in DGF format\n"; - - std::cout << errorMessageOut - << "\n"; - } -} - -int main(int argc, char** argv) try -{ - - using namespace Dumux; - - // define the type tag for this problem - using TypeTag = TTAG(ThreePNIConvectionBoxProblem); - - //////////////////////////////////////////////////////////// - //////////////////////////////////////////////////////////// - - // initialize MPI, finalize is done automatically on exit - const auto& mpiHelper = Dune::MPIHelper::instance(argc, argv); - - // print dumux start message - if (mpiHelper.rank() == 0) - DumuxMessage::print(/*firstCall=*/true); - - // parse command line arguments and input file - Parameters::init(argc, argv, usage); - - // try to create a grid (from the given grid file or the input file) - using GridCreator = typename GET_PROP_TYPE(TypeTag, GridCreator); - GridCreator::makeGrid(); - GridCreator::loadBalance(); - - //////////////////////////////////////////////////////////// - // run instationary non-linear problem on this grid - //////////////////////////////////////////////////////////// - - // we compute on the leaf grid view - const auto& leafGridView = GridCreator::grid().leafGridView(); - - // create the finite volume grid geometry - using FVGridGeometry = typename GET_PROP_TYPE(TypeTag, FVGridGeometry); - auto fvGridGeometry = std::make_shared(leafGridView); - fvGridGeometry->update(); - - // the problem (initial and boundary conditions) - using Problem = typename GET_PROP_TYPE(TypeTag, Problem); - auto problem = std::make_shared(fvGridGeometry); - - // the solution vector - using GridView = typename GET_PROP_TYPE(TypeTag, GridView); - using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector); - SolutionVector x(leafGridView.size(GridView::dimension)); - problem->applyInitialSolution(x); - auto xOld = x; - - // the grid variables - using GridVariables = typename GET_PROP_TYPE(TypeTag, GridVariables); - auto gridVariables = std::make_shared(problem, fvGridGeometry); - gridVariables->init(x, xOld); - - // get some time loop parameters - using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar); - const auto tEnd = getParam("TimeLoop.TEnd"); - const auto maxDivisions = getParam("TimeLoop.MaxTimeStepDivisions"); - const auto maxDt = getParam("TimeLoop.MaxTimeStepSize"); - auto dt = getParam("TimeLoop.DtInitial"); - - // check if we are about to restart a previously interrupted simulation - Scalar restartTime = 0; - if (Parameters::getTree().hasKey("Restart") || Parameters::getTree().hasKey("TimeLoop.Restart")) - restartTime = getParam("TimeLoop.Restart"); - - // intialize the vtk output module - using VtkOutputFields = typename GET_PROP_TYPE(TypeTag, VtkOutputFields); - VtkOutputModule vtkWriter(*problem, *fvGridGeometry, *gridVariables, x, problem->name()); - VtkOutputFields::init(vtkWriter); //! Add model specific output fields - vtkWriter.addField(problem->getExactTemperature(), "temperatureExact"); - vtkWriter.write(0.0); - // output every vtkOutputInterval time step - const int vtkOutputInterval = getParam("Problem.OutputInterval"); - - // instantiate time loop - auto timeLoop = std::make_shared>(restartTime, dt, tEnd); - timeLoop->setMaxTimeStepSize(maxDt); - - // the assembler with time loop for instationary problem - using Assembler = FVAssembler; - auto assembler = std::make_shared(problem, fvGridGeometry, gridVariables, timeLoop); - - // the linear solver - using LinearSolver = Dumux::AMGBackend; - auto linearSolver = std::make_shared(leafGridView, fvGridGeometry->vertexMapper()); - - // the non-linear solver - using NewtonController = Dumux::NewtonController; - using NewtonMethod = Dumux::NewtonMethod; - auto newtonController = std::make_shared(leafGridView.comm(), timeLoop); - NewtonMethod nonLinearSolver(newtonController, assembler, linearSolver); - - // time loop - timeLoop->start(); do - { - // set previous solution for storage evaluations - assembler->setPreviousSolution(xOld); - - // try solving the non-linear system - for (int i = 0; i < maxDivisions; ++i) - { - // linearize & solve - auto converged = nonLinearSolver.solve(x); - - if (converged) - break; - - if (!converged && i == maxDivisions-1) - DUNE_THROW(Dune::MathError, - "Newton solver didn't converge after " - << maxDivisions - << " time-step divisions. dt=" - << timeLoop->timeStepSize() - << ".\nThe solutions of the current and the previous time steps " - << "have been saved to restart files."); - } - - // compute the new analytical temperature field for the output - problem->updateExactTemperature(x, timeLoop->time()+timeLoop->timeStepSize()); - - // make the new solution the old solution - xOld = x; - gridVariables->advanceTimeStep(); - - // advance to the time loop to the next step - timeLoop->advanceTimeStep(); - - // report statistics of this time step - timeLoop->reportTimeStep(); - - // set new dt as suggested by newton controller - timeLoop->setTimeStepSize(newtonController->suggestTimeStepSize(timeLoop->timeStepSize())); - - if (timeLoop->timeStepIndex()==0 || timeLoop->timeStepIndex() % vtkOutputInterval == 0 || timeLoop->willBeFinished()) - vtkWriter.write(timeLoop->time()); - - } while (!timeLoop->finished()); - - timeLoop->finalize(leafGridView.comm()); - - //////////////////////////////////////////////////////////// - // finalize, print dumux message to say goodbye - //////////////////////////////////////////////////////////// - - // print dumux end message - if (mpiHelper.rank() == 0) - { - Parameters::print(); - DumuxMessage::print(/*firstCall=*/false); - } - - return 0; - -} -catch (Dumux::ParameterException &e) -{ - std::cerr << std::endl << e << " ---> Abort!" << std::endl; - return 1; -} -catch (Dune::DGFException & e) -{ - std::cerr << "DGF exception thrown (" << e << - "). Most likely, the DGF file name is wrong " - "or the DGF file is corrupted, " - "e.g. missing hash at end of file or wrong number (dimensions) of entries." - << " ---> Abort!" << std::endl; - return 2; -} -catch (Dune::Exception &e) -{ - std::cerr << "Dune reported error: " << e << " ---> Abort!" << std::endl; - return 3; -} -catch (...) -{ - std::cerr << "Unknown exception thrown! ---> Abort!" << std::endl; - return 4; -} diff --git a/test/porousmediumflow/3p/implicit/test_cc3pniconvection.input b/test/porousmediumflow/3p/implicit/test_cc3pniconvection.input deleted file mode 100644 index fc7f889439..0000000000 --- a/test/porousmediumflow/3p/implicit/test_cc3pniconvection.input +++ /dev/null @@ -1,18 +0,0 @@ -[TimeLoop] -DtInitial = 1 # [s] -TEnd = 3e4 # [s] -MaxTimeStepSize = 1e3 - -[Grid] -UpperRight = 20 1 -Cells = 80 1 - -[Problem] -Name = test_cc3pniconvection # name passed to the output routines -OutputInterval = 5 # every 5th timestep an output file is written -DarcyVelocity = 1e-4 # [m/s] inflow at the left boundary -EnableGravity = 0 # disable gravity - -[Vtk] -AddVelocity = 1 #Enable velocity output - -- GitLab