diff --git a/test/porousmediumflow/richards/implicit/CMakeLists.txt b/test/porousmediumflow/richards/implicit/CMakeLists.txt index 876d0e51b4db31f3b3c6068a45c0f3a07d58bc22..a7baf2d5ce9de309d865e085a76f7eafb90bf724 100644 --- a/test/porousmediumflow/richards/implicit/CMakeLists.txt +++ b/test/porousmediumflow/richards/implicit/CMakeLists.txt @@ -1,67 +1,82 @@ add_input_file_links() if(MPI_FOUND) - add_dumux_test(test_boxrichards_parallel test_boxrichards test_boxrichards.cc - python ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py - --script fuzzy - --files ${CMAKE_SOURCE_DIR}/test/references/richardslensbox-reference-parallel.vtu - ${CMAKE_CURRENT_BINARY_DIR}/s0002-p0000-richardslensbox-00008.vtu - --command "${MPIEXEC} -np 2 ${CMAKE_CURRENT_BINARY_DIR}/test_boxrichards") +dune_add_test(SOURCES test_richardslens_fv.cc + NAME test_boxrichards_parallel + COMPILE_DEFINITIONS TYPETAG=RichardsLensBoxProblem + COMMAND ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py + CMD_ARGS --script fuzzy + --files ${CMAKE_SOURCE_DIR}/test/references/richardslensbox-reference-parallel.vtu + ${CMAKE_CURRENT_BINARY_DIR}/s0002-p0000-richardslensbox-00008.vtu + --command "${MPIEXEC} -np 2 ${CMAKE_CURRENT_BINARY_DIR}/test_boxrichards test_richardslens.input -Problem.Name test_boxrichards") endif() # isothermal tests -add_dumux_test(test_boxrichards test_boxrichards test_boxrichards.cc - python ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py - --script fuzzy - --files ${CMAKE_SOURCE_DIR}/test/references/richardslensbox-reference.vtu - ${CMAKE_CURRENT_BINARY_DIR}/richardslensbox-00008.vtu - --command "${CMAKE_CURRENT_BINARY_DIR}/test_boxrichards") +dune_add_test(SOURCES test_richardslens_fv.cc + NAME test_boxrichards + COMPILE_DEFINITIONS TYPETAG=RichardsLensBoxProblem + COMMAND ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py + CMD_ARGS --script fuzzy + --files ${CMAKE_SOURCE_DIR}/test/references/richardslensbox-reference.vtu + ${CMAKE_CURRENT_BINARY_DIR}/test_boxrichards-00008.vtu + --command "${CMAKE_CURRENT_BINARY_DIR}/test_boxrichards test_richardslens.input -Problem.Name test_boxrichards") -add_dumux_test(test_ccrichards test_ccrichards test_ccrichards.cc - python ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py - --script fuzzy - --files ${CMAKE_SOURCE_DIR}/test/references/richardslenscc-reference.vtu - ${CMAKE_CURRENT_BINARY_DIR}/richardslenscc-00007.vtu - --command "${CMAKE_CURRENT_BINARY_DIR}/test_ccrichards") +dune_add_test(SOURCES test_richardslens_fv.cc + NAME test_ccrichards + COMPILE_DEFINITIONS TYPETAG=RichardsLensCCProblem + COMMAND ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py + CMD_ARGS --script fuzzy + --files ${CMAKE_SOURCE_DIR}/test/references/richardslenscc-reference.vtu + ${CMAKE_CURRENT_BINARY_DIR}/test_ccrichards-00007.vtu + --command "${CMAKE_CURRENT_BINARY_DIR}/test_ccrichards test_richardslens.input -Problem.Name test_ccrichards") # comparison to analytical solution - only with cc -add_dumux_test(test_ccrichardsanalytical test_ccrichardsanalytical test_ccrichardsanalytical.cc - python ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py - --script fuzzy - --files ${CMAKE_SOURCE_DIR}/test/references/richardsanalyticalcc-reference.vtu - ${CMAKE_CURRENT_BINARY_DIR}/richardsanalyticalcc-00000.vtu - --command "${CMAKE_CURRENT_BINARY_DIR}/test_ccrichardsanalytical") - +dune_add_test(SOURCES test_ccrichardsanalytical.cc + NAME test_ccrichardsanalytical + COMPILE_DEFINITIONS TYPETAG=RichardsAnalyticalCCProblem + COMMAND ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py + CMD_ARGS --script fuzzy + --files ${CMAKE_SOURCE_DIR}/test/references/richardsanalyticalcc-reference.vtu + ${CMAKE_CURRENT_BINARY_DIR}/richardsanalyticalcc-00000.vtu + --command "${CMAKE_CURRENT_BINARY_DIR}/test_ccrichardsanalytical test_ccrichardsanalytical.input -Problem.Name test_ccrichardsanalytical") # non-isothermal tests -add_dumux_test(test_boxrichardsniconvection test_boxrichardsniconvection test_boxrichardsniconvection.cc - python ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py - --script fuzzy - --files ${CMAKE_SOURCE_DIR}/test/references/richardsniconvectionbox-reference.vtu - ${CMAKE_CURRENT_BINARY_DIR}/test_boxrichardsniconvection-00010.vtu - --command "${CMAKE_CURRENT_BINARY_DIR}/test_boxrichardsniconvection" - --zeroThreshold {"velocity":1e-16}) +dune_add_test(SOURCES test_richardsniconvection_fv.cc + NAME test_boxrichardsniconvection + COMPILE_DEFINITIONS TYPETAG=RichardsNIConvectionBoxProblem + COMMAND ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py + CMD_ARGS --script fuzzy + --files ${CMAKE_SOURCE_DIR}/test/references/richardsniconvectionbox-reference.vtu + ${CMAKE_CURRENT_BINARY_DIR}/test_boxrichardsniconvection-00010.vtu + --command "${CMAKE_CURRENT_BINARY_DIR}/test_boxrichardsniconvection test_richardsniconvection.input -Problem.Name test_boxrichardsniconvection" + --zeroThreshold {"velocity":1e-16}) -add_dumux_test(test_ccrichardsniconvection test_ccrichardsniconvection test_ccrichardsniconvection.cc - python ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py - --script fuzzy - --files ${CMAKE_SOURCE_DIR}/test/references/richardsniconvectioncc-reference.vtu - ${CMAKE_CURRENT_BINARY_DIR}/test_ccrichardsniconvection-00010.vtu - --command "${CMAKE_CURRENT_BINARY_DIR}/test_ccrichardsniconvection") +dune_add_test(SOURCES test_richardsniconvection_fv.cc + NAME test_ccrichardsniconvection + COMPILE_DEFINITIONS TYPETAG=RichardsNIConvectionCCProblem + COMMAND ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py + CMD_ARGS --script fuzzy + --files ${CMAKE_SOURCE_DIR}/test/references/richardsniconvectioncc-reference.vtu + ${CMAKE_CURRENT_BINARY_DIR}/test_ccrichardsniconvection-00010.vtu + --command "${CMAKE_CURRENT_BINARY_DIR}/test_ccrichardsniconvection test_richardsniconvection.input -Problem.Name test_ccrichardsniconvection") -add_dumux_test(test_boxrichardsniconduction test_boxrichardsniconduction test_boxrichardsniconduction.cc - python ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py - --script fuzzy - --files ${CMAKE_SOURCE_DIR}/test/references/richardsniconductionbox-reference.vtu - ${CMAKE_CURRENT_BINARY_DIR}/test_boxrichardsniconduction-00006.vtu - --command "${CMAKE_CURRENT_BINARY_DIR}/test_boxrichardsniconduction" - --zeroThreshold {"velocity":1e-8}) +dune_add_test(SOURCES test_richardsniconduction_fv.cc + NAME test_boxrichardsniconduction + COMPILE_DEFINITIONS TYPETAG=RichardsNIConductionBoxProblem + COMMAND ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py + CMD_ARGS --script fuzzy + --files ${CMAKE_SOURCE_DIR}/test/references/richardsniconductionbox-reference.vtu + ${CMAKE_CURRENT_BINARY_DIR}/test_boxrichardsniconduction-00006.vtu + --command "${CMAKE_CURRENT_BINARY_DIR}/test_boxrichardsniconduction test_richardsniconduction.input -Problem.Name test_boxrichardsniconduction" + --zeroThreshold {"velocity":1e-8}) -add_dumux_test(test_ccrichardsniconduction test_ccrichardsniconduction test_ccrichardsniconduction.cc - python ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py - --script fuzzy - --files ${CMAKE_SOURCE_DIR}/test/references/richardsniconductioncc-reference.vtu - ${CMAKE_CURRENT_BINARY_DIR}/test_ccrichardsniconduction-00006.vtu - --command "${CMAKE_CURRENT_BINARY_DIR}/test_ccrichardsniconduction" - --zeroThreshold {"velocity":1e-8}) +dune_add_test(SOURCES test_richardsniconduction_fv.cc + NAME test_ccrichardsniconduction + COMPILE_DEFINITIONS TYPETAG=RichardsNIConductionCCProblem + COMMAND ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py + CMD_ARGS --script fuzzy + --files ${CMAKE_SOURCE_DIR}/test/references/richardsniconductioncc-reference.vtu + ${CMAKE_CURRENT_BINARY_DIR}/test_ccrichardsniconduction-00006.vtu + --command "${CMAKE_CURRENT_BINARY_DIR}/test_ccrichardsniconduction test_richardsniconduction.input -Problem.Name test_ccrichardsniconduction" + --zeroThreshold {"velocity":1e-8}) #install sources install(FILES @@ -72,11 +87,8 @@ richardslensspatialparams.hh richardsniconductionproblem.hh richardsniconvectionproblem.hh richardsnispatialparams.hh -test_boxrichards.cc -test_boxrichardsniconduction.cc -test_boxrichardsniconvection.cc +test_richardslens_fv.cc +test_richardsniconduction_fv.cc +test_richardsniconvection_fv.cc test_ccrichardsanalytical.cc -test_ccrichards.cc -test_ccrichardsniconduction.cc -test_ccrichardsniconvection.cc DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dumux/test/implicit/richards) diff --git a/test/porousmediumflow/richards/implicit/test_ccrichards.cc b/test/porousmediumflow/richards/implicit/test_ccrichards.cc deleted file mode 100644 index d630ff8babb7d2f6557ac66347638262a3746b77..0000000000000000000000000000000000000000 --- a/test/porousmediumflow/richards/implicit/test_ccrichards.cc +++ /dev/null @@ -1,247 +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 <http://www.gnu.org/licenses/>. * - *****************************************************************************/ -/*! - * \file - * - * \brief Test for the Richards CC model. - */ -#include <config.h> - -#include "richardslensproblem.hh" - -#include <ctime> -#include <iostream> - -#include <dune/common/parallel/mpihelper.hh> -#include <dune/common/timer.hh> -#include <dune/grid/io/file/dgfparser/dgfexception.hh> -#include <dune/grid/io/file/vtk.hh> -#include <dune/istl/io.hh> - -#include <dumux/common/propertysystem.hh> -#include <dumux/common/parameters.hh> -#include <dumux/common/valgrind.hh> -#include <dumux/common/dumuxmessage.hh> -#include <dumux/common/defaultusagemessage.hh> - -#include <dumux/linear/amgbackend.hh> -#include <dumux/nonlinear/newtonmethod.hh> -#include <dumux/nonlinear/newtoncontroller.hh> -#include <dumux/porousmediumflow/richards/implicit/newtoncontroller.hh> - -#include <dumux/assembly/fvassembler.hh> - -#include <dumux/io/vtkoutputmodule.hh> -/*! - * \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"; - } -} - -//////////////////////// -// the main function -//////////////////////// -int main(int argc, char** argv) try -{ - using namespace Dumux; - - // define the type tag for this problem - using TypeTag = TTAG(RichardsLensCCProblem); - - // 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<FVGridGeometry>(leafGridView); - fvGridGeometry->update(); - - // the problem (initial and boundary conditions) - using Problem = typename GET_PROP_TYPE(TypeTag, Problem); - auto problem = std::make_shared<Problem>(fvGridGeometry); - - // the solution vector - using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector); - SolutionVector x(fvGridGeometry->numDofs()); - problem->applyInitialSolution(x); - auto xOld = x; - - // the grid variables - using GridVariables = typename GET_PROP_TYPE(TypeTag, GridVariables); - auto gridVariables = std::make_shared<GridVariables>(problem, fvGridGeometry); - gridVariables->init(x, xOld); - - // get some time loop parameters - using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar); - const auto tEnd = getParam<Scalar>("TimeLoop.TEnd"); - const auto maxDivisions = getParam<int>("TimeLoop.MaxTimeStepDivisions"); - const auto maxDt = getParam<Scalar>("TimeLoop.MaxTimeStepSize"); - auto dt = getParam<Scalar>("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<Scalar>("TimeLoop.Restart"); - - // intialize the vtk output module - using VtkOutputFields = typename GET_PROP_TYPE(TypeTag, VtkOutputFields); - VtkOutputModule<TypeTag> 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<TimeLoop<Scalar>>(restartTime, dt, tEnd); - timeLoop->setMaxTimeStepSize(maxDt); - - // the assembler with time loop for instationary problem - using Assembler = FVAssembler<TypeTag, DiffMethod::numeric>; - auto assembler = std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables, timeLoop); - - // the linear solver - using LinearSolver = Dumux::ILU0BiCGSTABBackend<TypeTag>; - auto linearSolver = std::make_shared<LinearSolver>(); - - // the non-linear solver - using NewtonController = Dumux::RichardsNewtonController<TypeTag>; - using NewtonMethod = Dumux::NewtonMethod<NewtonController, Assembler, LinearSolver>; - auto newtonController = std::make_shared<NewtonController>(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())); - - } 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/richards/implicit/test_ccrichards.input b/test/porousmediumflow/richards/implicit/test_ccrichards.input deleted file mode 100644 index fb2fb8c31bebf5bf2c82dee845b94fac630a4868..0000000000000000000000000000000000000000 --- a/test/porousmediumflow/richards/implicit/test_ccrichards.input +++ /dev/null @@ -1,19 +0,0 @@ -[TimeLoop] -DtInitial = 100 # [s] -TEnd = 3000 # [s] - -[Grid] -UpperRight = 6 4 -Cells = 24 16 - -[Problem] -Name = richardslenscc -EnableGravity = true # enable gravity - -[Implicit] -EnablePartialReassemble = true # enable partial reassembly of the Jacobian matrix -EnableJacobianRecycling = true # - -[Newton] -TargetSteps = 18 # set the "desireable" number of newton iterations of a time step -EnableChop = true # chop for better convergence diff --git a/test/porousmediumflow/richards/implicit/test_ccrichardsniconduction.cc b/test/porousmediumflow/richards/implicit/test_ccrichardsniconduction.cc deleted file mode 100644 index 07812769c37c38df271c776bd727c7a9a218124e..0000000000000000000000000000000000000000 --- a/test/porousmediumflow/richards/implicit/test_ccrichardsniconduction.cc +++ /dev/null @@ -1,250 +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 <http://www.gnu.org/licenses/>. * - *****************************************************************************/ -/*! - * \file - * - * \brief Test for the Richards CC model. - */ -#include <config.h> - -#include "richardsniconductionproblem.hh" - -#include <ctime> -#include <iostream> - -#include <dune/common/parallel/mpihelper.hh> -#include <dune/common/timer.hh> -#include <dune/grid/io/file/dgfparser/dgfexception.hh> -#include <dune/grid/io/file/vtk.hh> -#include <dune/istl/io.hh> - -#include <dumux/common/propertysystem.hh> -#include <dumux/common/parameters.hh> -#include <dumux/common/valgrind.hh> -#include <dumux/common/dumuxmessage.hh> -#include <dumux/common/defaultusagemessage.hh> - -#include <dumux/linear/amgbackend.hh> -#include <dumux/nonlinear/newtonmethod.hh> -#include <dumux/nonlinear/newtoncontroller.hh> -#include <dumux/porousmediumflow/richards/implicit/newtoncontroller.hh> - -#include <dumux/assembly/fvassembler.hh> - -#include <dumux/io/vtkoutputmodule.hh> -/*! - * \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"; - } -} - -//////////////////////// -// the main function -//////////////////////// -int main(int argc, char** argv) try -{ - using namespace Dumux; - - // define the type tag for this problem - using TypeTag = TTAG(RichardsNIConductionCCProblem); - - // 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<FVGridGeometry>(leafGridView); - fvGridGeometry->update(); - - // the problem (initial and boundary conditions) - using Problem = typename GET_PROP_TYPE(TypeTag, Problem); - auto problem = std::make_shared<Problem>(fvGridGeometry); - - // the solution vector - using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector); - SolutionVector x(fvGridGeometry->numDofs()); - problem->applyInitialSolution(x); - auto xOld = x; - - // the grid variables - using GridVariables = typename GET_PROP_TYPE(TypeTag, GridVariables); - auto gridVariables = std::make_shared<GridVariables>(problem, fvGridGeometry); - gridVariables->init(x, xOld); - - // get some time loop parameters - using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar); - const auto tEnd = getParam<Scalar>("TimeLoop.TEnd"); - const auto maxDivisions = getParam<int>("TimeLoop.MaxTimeStepDivisions"); - const auto maxDt = getParam<Scalar>("TimeLoop.MaxTimeStepSize"); - auto dt = getParam<Scalar>("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<Scalar>("TimeLoop.Restart"); - - // intialize the vtk output module - using VtkOutputFields = typename GET_PROP_TYPE(TypeTag, VtkOutputFields); - VtkOutputModule<TypeTag> vtkWriter(*problem, *fvGridGeometry, *gridVariables, x, problem->name()); - VtkOutputFields::init(vtkWriter); //! Add model specific output fields - vtkWriter.addField(problem->getExactTemperature(), "temperatureExact"); - vtkWriter.write(0.0); - - // instantiate time loop - auto timeLoop = std::make_shared<TimeLoop<Scalar>>(restartTime, dt, tEnd); - timeLoop->setMaxTimeStepSize(maxDt); - - // the assembler with time loop for instationary problem - using Assembler = FVAssembler<TypeTag, DiffMethod::numeric>; - auto assembler = std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables, timeLoop); - - // the linear solver - using LinearSolver = Dumux::ILU0BiCGSTABBackend<TypeTag>; - auto linearSolver = std::make_shared<LinearSolver>(); - - // the non-linear solver - using NewtonController = Dumux::RichardsNewtonController<TypeTag>; - using NewtonMethod = Dumux::NewtonMethod<NewtonController, Assembler, LinearSolver>; - auto newtonController = std::make_shared<NewtonController>(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(); - - // 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())); - - } 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/richards/implicit/test_ccrichardsniconduction.input b/test/porousmediumflow/richards/implicit/test_ccrichardsniconduction.input deleted file mode 100644 index fa4803bb64ad929e831eb4079febe74dea1dc96f..0000000000000000000000000000000000000000 --- a/test/porousmediumflow/richards/implicit/test_ccrichardsniconduction.input +++ /dev/null @@ -1,16 +0,0 @@ -[TimeLoop] -DtInitial = 1 # [s] -TEnd = 1e5 # [s] -MaxTimeStepSize = 1e10 # [s] - -[Grid] -UpperRight = 5 1 -Cells = 200 1 - -[Problem] -Name = test_ccrichardsniconduction # name passed to the output routines -OutputInterval = 5 # every 5th timestep an output file is written -EnableGravity= 0 # disable gravity - -[Newton] -EnableChop = false # chop for better convergence diff --git a/test/porousmediumflow/richards/implicit/test_ccrichardsniconvection.cc b/test/porousmediumflow/richards/implicit/test_ccrichardsniconvection.cc deleted file mode 100644 index 47b703e730d8b33830e57c115736f2b9608364ec..0000000000000000000000000000000000000000 --- a/test/porousmediumflow/richards/implicit/test_ccrichardsniconvection.cc +++ /dev/null @@ -1,250 +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 <http://www.gnu.org/licenses/>. * - *****************************************************************************/ -/*! - * \file - * - * \brief Test for the Richards CC model. - */ -#include <config.h> - -#include "richardsniconvectionproblem.hh" - -#include <ctime> -#include <iostream> - -#include <dune/common/parallel/mpihelper.hh> -#include <dune/common/timer.hh> -#include <dune/grid/io/file/dgfparser/dgfexception.hh> -#include <dune/grid/io/file/vtk.hh> -#include <dune/istl/io.hh> - -#include <dumux/common/propertysystem.hh> -#include <dumux/common/parameters.hh> -#include <dumux/common/valgrind.hh> -#include <dumux/common/dumuxmessage.hh> -#include <dumux/common/defaultusagemessage.hh> - -#include <dumux/linear/amgbackend.hh> -#include <dumux/nonlinear/newtonmethod.hh> -#include <dumux/nonlinear/newtoncontroller.hh> -#include <dumux/porousmediumflow/richards/implicit/newtoncontroller.hh> - -#include <dumux/assembly/fvassembler.hh> - -#include <dumux/io/vtkoutputmodule.hh> -/*! - * \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"; - } -} - -//////////////////////// -// the main function -//////////////////////// -int main(int argc, char** argv) try -{ - using namespace Dumux; - - // define the type tag for this problem - using TypeTag = TTAG(RichardsNIConvectionCCProblem); - - // 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<FVGridGeometry>(leafGridView); - fvGridGeometry->update(); - - // the problem (initial and boundary conditions) - using Problem = typename GET_PROP_TYPE(TypeTag, Problem); - auto problem = std::make_shared<Problem>(fvGridGeometry); - - // the solution vector - using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector); - SolutionVector x(fvGridGeometry->numDofs()); - problem->applyInitialSolution(x); - auto xOld = x; - - // the grid variables - using GridVariables = typename GET_PROP_TYPE(TypeTag, GridVariables); - auto gridVariables = std::make_shared<GridVariables>(problem, fvGridGeometry); - gridVariables->init(x, xOld); - - // get some time loop parameters - using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar); - const auto tEnd = getParam<Scalar>("TimeLoop.TEnd"); - const auto maxDivisions = getParam<int>("TimeLoop.MaxTimeStepDivisions"); - const auto maxDt = getParam<Scalar>("TimeLoop.MaxTimeStepSize"); - auto dt = getParam<Scalar>("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<Scalar>("TimeLoop.Restart"); - - // intialize the vtk output module - using VtkOutputFields = typename GET_PROP_TYPE(TypeTag, VtkOutputFields); - VtkOutputModule<TypeTag> vtkWriter(*problem, *fvGridGeometry, *gridVariables, x, problem->name()); - VtkOutputFields::init(vtkWriter); //! Add model specific output fields - vtkWriter.addField(problem->getExactTemperature(), "temperatureExact"); - vtkWriter.write(0.0); - - // instantiate time loop - auto timeLoop = std::make_shared<TimeLoop<Scalar>>(restartTime, dt, tEnd); - timeLoop->setMaxTimeStepSize(maxDt); - - // the assembler with time loop for instationary problem - using Assembler = FVAssembler<TypeTag, DiffMethod::numeric>; - auto assembler = std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables, timeLoop); - - // the linear solver - using LinearSolver = Dumux::ILU0BiCGSTABBackend<TypeTag>; - auto linearSolver = std::make_shared<LinearSolver>(); - - // the non-linear solver - using NewtonController = Dumux::RichardsNewtonController<TypeTag>; - using NewtonMethod = Dumux::NewtonMethod<NewtonController, Assembler, LinearSolver>; - auto newtonController = std::make_shared<NewtonController>(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(); - - // 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())); - - } 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/richards/implicit/test_ccrichardsniconvection.input b/test/porousmediumflow/richards/implicit/test_ccrichardsniconvection.input deleted file mode 100644 index 8d1e9d7bc29d4fe9e0a2f777c89c6fec0abab165..0000000000000000000000000000000000000000 --- a/test/porousmediumflow/richards/implicit/test_ccrichardsniconvection.input +++ /dev/null @@ -1,17 +0,0 @@ -[TimeLoop] -DtInitial = 1 # [s] -TEnd = 3e4 # [s] -MaxTimeStepSize = 1e3 # [s] - -[Grid] -UpperRight = 20 1 -Cells = 80 1 - -[Problem] -Name = test_ccrichardsniconvection # 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 - -[Newton] -EnableChop = false # chop for better convergence diff --git a/test/porousmediumflow/richards/implicit/test_boxrichards.input b/test/porousmediumflow/richards/implicit/test_richardslens.input similarity index 94% rename from test/porousmediumflow/richards/implicit/test_boxrichards.input rename to test/porousmediumflow/richards/implicit/test_richardslens.input index 6b43b23a8271cc3cf4510ceb5e15600af9211035..c602ef1cf916c3ca5775102a0d44cd5decacf89b 100644 --- a/test/porousmediumflow/richards/implicit/test_boxrichards.input +++ b/test/porousmediumflow/richards/implicit/test_richardslens.input @@ -7,7 +7,7 @@ UpperRight = 6 4 Cells = 24 16 [Problem] -Name = richardslensbox +Name = richardslens EnableGravity = 1 # enable gravity [Implicit] diff --git a/test/porousmediumflow/richards/implicit/test_boxrichards.cc b/test/porousmediumflow/richards/implicit/test_richardslens_fv.cc similarity index 99% rename from test/porousmediumflow/richards/implicit/test_boxrichards.cc rename to test/porousmediumflow/richards/implicit/test_richardslens_fv.cc index 5805bb62baea7c9561600731e9a71703bd0f702c..dd3ebbdd6920da3aedf1c0f7e2daf072238e3ef6 100644 --- a/test/porousmediumflow/richards/implicit/test_boxrichards.cc +++ b/test/porousmediumflow/richards/implicit/test_richardslens_fv.cc @@ -82,7 +82,7 @@ int main(int argc, char** argv) try using namespace Dumux; // define the type tag for this problem - using TypeTag = TTAG(RichardsLensBoxProblem); + using TypeTag = TTAG(TYPETAG); // initialize MPI, finalize is done automatically on exit const auto& mpiHelper = Dune::MPIHelper::instance(argc, argv); diff --git a/test/porousmediumflow/richards/implicit/test_boxrichardsniconduction.input b/test/porousmediumflow/richards/implicit/test_richardsniconduction.input similarity index 100% rename from test/porousmediumflow/richards/implicit/test_boxrichardsniconduction.input rename to test/porousmediumflow/richards/implicit/test_richardsniconduction.input diff --git a/test/porousmediumflow/richards/implicit/test_boxrichardsniconduction.cc b/test/porousmediumflow/richards/implicit/test_richardsniconduction_fv.cc similarity index 99% rename from test/porousmediumflow/richards/implicit/test_boxrichardsniconduction.cc rename to test/porousmediumflow/richards/implicit/test_richardsniconduction_fv.cc index 014685dda5ce55739d91cd5f0668be873c847c29..a46a4dc46c7458ba03c90d8f09768775ba9bad2e 100644 --- a/test/porousmediumflow/richards/implicit/test_boxrichardsniconduction.cc +++ b/test/porousmediumflow/richards/implicit/test_richardsniconduction_fv.cc @@ -82,7 +82,7 @@ int main(int argc, char** argv) try using namespace Dumux; // define the type tag for this problem - using TypeTag = TTAG(RichardsNIConductionBoxProblem); + using TypeTag = TTAG(TYPETAG); // initialize MPI, finalize is done automatically on exit const auto& mpiHelper = Dune::MPIHelper::instance(argc, argv); diff --git a/test/porousmediumflow/richards/implicit/test_boxrichardsniconvection.input b/test/porousmediumflow/richards/implicit/test_richardsniconvection.input similarity index 100% rename from test/porousmediumflow/richards/implicit/test_boxrichardsniconvection.input rename to test/porousmediumflow/richards/implicit/test_richardsniconvection.input diff --git a/test/porousmediumflow/richards/implicit/test_boxrichardsniconvection.cc b/test/porousmediumflow/richards/implicit/test_richardsniconvection_fv.cc similarity index 99% rename from test/porousmediumflow/richards/implicit/test_boxrichardsniconvection.cc rename to test/porousmediumflow/richards/implicit/test_richardsniconvection_fv.cc index c6b60e4770210543de8d2218ae600a5d3f97c4db..aca9e19be86c9ddef5ee247968f345bdc8470866 100644 --- a/test/porousmediumflow/richards/implicit/test_boxrichardsniconvection.cc +++ b/test/porousmediumflow/richards/implicit/test_richardsniconvection_fv.cc @@ -82,7 +82,7 @@ int main(int argc, char** argv) try using namespace Dumux; // define the type tag for this problem - using TypeTag = TTAG(RichardsNIConvectionBoxProblem); + using TypeTag = TTAG(TYPETAG); // initialize MPI, finalize is done automatically on exit const auto& mpiHelper = Dune::MPIHelper::instance(argc, argv); diff --git a/test/porousmediumflow/richardsnc/implicit/CMakeLists.txt b/test/porousmediumflow/richardsnc/implicit/CMakeLists.txt index 3acfc9b965d18e10d3e63ee5afc0e2fa8a8469b8..c3694c9640f6f3745be4f4d30df60311e1f90d93 100644 --- a/test/porousmediumflow/richardsnc/implicit/CMakeLists.txt +++ b/test/porousmediumflow/richardsnc/implicit/CMakeLists.txt @@ -1,24 +1,26 @@ add_input_file_links() +dune_add_test(SOURCES test_richardsnc_fv.cc + NAME test_boxrichardsnc + COMPILE_DEFINITIONS TYPETAG=RichardsWellTracerBoxProblem + COMMAND ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py + CMD_ARGS --script fuzzy + --files ${CMAKE_SOURCE_DIR}/test/references/richardswelltracerbox-reference.vtu + ${CMAKE_CURRENT_BINARY_DIR}/test_boxrichardsnc-00035.vtu + --command "${CMAKE_CURRENT_BINARY_DIR}/test_boxrichardsnc test_richardsnc.input -Problem.Name test_boxrichardsnc") -add_dumux_test(test_boxrichardsnc test_boxrichardsnc test_boxrichardsnc.cc - python ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py - --script fuzzy - --files ${CMAKE_SOURCE_DIR}/test/references/richardswelltracerbox-reference.vtu - ${CMAKE_CURRENT_BINARY_DIR}/richardswelltracerbox-00035.vtu - --command "${CMAKE_CURRENT_BINARY_DIR}/test_boxrichardsnc") - -add_dumux_test(test_ccrichardsnc test_ccrichardsnc test_ccrichardsnc.cc - python ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py - --script fuzzy - --files ${CMAKE_SOURCE_DIR}/test/references/richardswelltracercc-reference.vtu - ${CMAKE_CURRENT_BINARY_DIR}/richardswelltracercc-00033.vtu - --command "${CMAKE_CURRENT_BINARY_DIR}/test_ccrichardsnc") +dune_add_test(SOURCES test_richardsnc_fv.cc + NAME test_ccrichardsnc + COMPILE_DEFINITIONS TYPETAG=RichardsWellTracerCCProblem + COMMAND ${CMAKE_SOURCE_DIR}/bin/testing/runtest.py + CMD_ARGS --script fuzzy + --files ${CMAKE_SOURCE_DIR}/test/references/richardswelltracercc-reference.vtu + ${CMAKE_CURRENT_BINARY_DIR}/test_ccrichardsnc-00033.vtu + --command "${CMAKE_CURRENT_BINARY_DIR}/test_ccrichardsnc test_richardsnc.input -Problem.Name test_ccrichardsnc") #install sources install(FILES richardswelltracerproblem.hh richardswelltracerspatialparams.hh -test_boxrichardsnc.cc -test_ccrichardsnc.cc +test_richardsnc_fv.cc DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dumux/test/porousmediumflow/richardsnc/implicit) diff --git a/test/porousmediumflow/richardsnc/implicit/test_boxrichardsnc.cc b/test/porousmediumflow/richardsnc/implicit/test_boxrichardsnc.cc deleted file mode 100644 index d1092acbca73477187180b79b1863a3439569a0b..0000000000000000000000000000000000000000 --- a/test/porousmediumflow/richardsnc/implicit/test_boxrichardsnc.cc +++ /dev/null @@ -1,248 +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 <http://www.gnu.org/licenses/>. * - *****************************************************************************/ -/*! - * \file - * - * \brief Test for the Richards CC model. - */ -#include <config.h> - -#include "richardswelltracerproblem.hh" - -#include <ctime> -#include <iostream> - -#include <dune/common/parallel/mpihelper.hh> -#include <dune/common/timer.hh> -#include <dune/grid/io/file/dgfparser/dgfexception.hh> -#include <dune/grid/io/file/vtk.hh> -#include <dune/istl/io.hh> - -#include <dumux/common/propertysystem.hh> -#include <dumux/common/parameters.hh> -#include <dumux/common/valgrind.hh> -#include <dumux/common/dumuxmessage.hh> -#include <dumux/common/defaultusagemessage.hh> - -#include <dumux/linear/amgbackend.hh> -#include <dumux/nonlinear/newtonmethod.hh> -#include <dumux/nonlinear/newtoncontroller.hh> -#include <dumux/porousmediumflow/richards/implicit/newtoncontroller.hh> - -#include <dumux/assembly/fvassembler.hh> - -#include <dumux/io/vtkoutputmodule.hh> -/*! - * \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"; - } -} - -//////////////////////// -// the main function -//////////////////////// -int main(int argc, char** argv) try -{ - using namespace Dumux; - - // define the type tag for this problem - using TypeTag = TTAG(RichardsWellTracerBoxProblem); - - // 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<FVGridGeometry>(leafGridView); - fvGridGeometry->update(); - - // the problem (initial and boundary conditions) - using Problem = typename GET_PROP_TYPE(TypeTag, Problem); - auto problem = std::make_shared<Problem>(fvGridGeometry); - - // the solution vector - using SolutionVector = typename GET_PROP_TYPE(TypeTag, SolutionVector); - SolutionVector x(fvGridGeometry->numDofs()); - problem->applyInitialSolution(x); - auto xOld = x; - - // the grid variables - using GridVariables = typename GET_PROP_TYPE(TypeTag, GridVariables); - auto gridVariables = std::make_shared<GridVariables>(problem, fvGridGeometry); - gridVariables->init(x, xOld); - - // get some time loop parameters - using Scalar = typename GET_PROP_TYPE(TypeTag, Scalar); - const auto tEnd = getParam<Scalar>("TimeLoop.TEnd"); - const auto maxDivisions = getParam<int>("TimeLoop.MaxTimeStepDivisions"); - const auto maxDt = getParam<Scalar>("TimeLoop.MaxTimeStepSize"); - auto dt = getParam<Scalar>("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<Scalar>("TimeLoop.Restart"); - - // intialize the vtk output module - using VtkOutputFields = typename GET_PROP_TYPE(TypeTag, VtkOutputFields); - VtkOutputModule<TypeTag> 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<TimeLoop<Scalar>>(restartTime, dt, tEnd); - timeLoop->setMaxTimeStepSize(maxDt); - - // the assembler with time loop for instationary problem - using Assembler = FVAssembler<TypeTag, DiffMethod::numeric>; - auto assembler = std::make_shared<Assembler>(problem, fvGridGeometry, gridVariables, timeLoop); - - // the linear solver - using LinearSolver = Dumux::ILU0BiCGSTABBackend<TypeTag>; - auto linearSolver = std::make_shared<LinearSolver>(); - - // the non-linear solver - using NewtonController = Dumux::RichardsNewtonController<TypeTag>; - using NewtonMethod = Dumux::NewtonMethod<NewtonController, Assembler, LinearSolver>; - auto newtonController = std::make_shared<NewtonController>(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; - problem->postTimeStep(x, *gridVariables, timeLoop->timeStepSize()); - 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())); - - } 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/richardsnc/implicit/test_ccrichardsnc.input b/test/porousmediumflow/richardsnc/implicit/test_ccrichardsnc.input deleted file mode 100644 index 71d8dc9342fc8d1a87e54eccf06679a0f6601ade..0000000000000000000000000000000000000000 --- a/test/porousmediumflow/richardsnc/implicit/test_ccrichardsnc.input +++ /dev/null @@ -1,27 +0,0 @@ -[TimeLoop] -DtInitial = 10 # [s] -TEnd = 1e6 # [s] - -[Grid] -UpperRight = 3 1 -Cells = 50 20 - -[Problem] -Name = richardswelltracercc -EnableGravity = true -ContaminantMoleFraction = 1e-10 -PumpRate = 0.015 # kg/s -MolarMass = 20e-3 # in kg/mol, molar mass heavy water D2O - -LensLowerLeft = 0.8 0.2 -LensUpperRight = 1.2 0.8 - -[Component] -LiquidDiffusionCoefficient = 2.3e-9 -Name = "D2O" - -[Vtk] -AddVelocity = true - -[Newton] -EnableChop = false # chop for better convergences diff --git a/test/porousmediumflow/richardsnc/implicit/test_boxrichardsnc.input b/test/porousmediumflow/richardsnc/implicit/test_richardsnc.input similarity index 100% rename from test/porousmediumflow/richardsnc/implicit/test_boxrichardsnc.input rename to test/porousmediumflow/richardsnc/implicit/test_richardsnc.input diff --git a/test/porousmediumflow/richardsnc/implicit/test_ccrichardsnc.cc b/test/porousmediumflow/richardsnc/implicit/test_richardsnc_fv.cc similarity index 99% rename from test/porousmediumflow/richardsnc/implicit/test_ccrichardsnc.cc rename to test/porousmediumflow/richardsnc/implicit/test_richardsnc_fv.cc index dce20959bce306bf2c61925a1f82655a7cfefc63..3710a0bee5e40cc237f94cfd320bc1331086060e 100644 --- a/test/porousmediumflow/richardsnc/implicit/test_ccrichardsnc.cc +++ b/test/porousmediumflow/richardsnc/implicit/test_richardsnc_fv.cc @@ -82,7 +82,7 @@ int main(int argc, char** argv) try using namespace Dumux; // define the type tag for this problem - using TypeTag = TTAG(RichardsWellTracerCCProblem); + using TypeTag = TTAG(TYPETAG); // initialize MPI, finalize is done automatically on exit const auto& mpiHelper = Dune::MPIHelper::instance(argc, argv);