From 18cdb801be23434f79fc4323edb42778772cabf6 Mon Sep 17 00:00:00 2001 From: Markus Wolff <markus.wolff@twt-gmbh.de> Date: Wed, 15 Feb 2012 08:44:22 +0000 Subject: [PATCH] changed decoupled adaptive 2p test to new start-from-input-file style git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/trunk@7784 2fb0f335-1f38-0410-981e-8018bf24f1b0 --- test/decoupled/2padaptive/input | 5 - ...ence.vtu => test_2padaptive-reference.vtu} | 0 .../2padaptive/test_impes_adaptive.cc | 124 ++++-------------- .../2padaptive/test_impes_adaptive.input | 36 +++++ .../2padaptive/test_impes_adaptive_problem.hh | 15 ++- 5 files changed, 69 insertions(+), 111 deletions(-) delete mode 100644 test/decoupled/2padaptive/input rename test/decoupled/2padaptive/{output2padaptive-reference.vtu => test_2padaptive-reference.vtu} (100%) create mode 100644 test/decoupled/2padaptive/test_impes_adaptive.input diff --git a/test/decoupled/2padaptive/input b/test/decoupled/2padaptive/input deleted file mode 100644 index e3cf995411..0000000000 --- a/test/decoupled/2padaptive/input +++ /dev/null @@ -1,5 +0,0 @@ -tEnd = 2e7 -MinLevel = 0 -MaxLevel = 5 -RefineTolerance = 0.05 -CoarsenTolerance = 0.001 diff --git a/test/decoupled/2padaptive/output2padaptive-reference.vtu b/test/decoupled/2padaptive/test_2padaptive-reference.vtu similarity index 100% rename from test/decoupled/2padaptive/output2padaptive-reference.vtu rename to test/decoupled/2padaptive/test_2padaptive-reference.vtu diff --git a/test/decoupled/2padaptive/test_impes_adaptive.cc b/test/decoupled/2padaptive/test_impes_adaptive.cc index 6ccdaddc02..c417c5c189 100644 --- a/test/decoupled/2padaptive/test_impes_adaptive.cc +++ b/test/decoupled/2padaptive/test_impes_adaptive.cc @@ -42,115 +42,37 @@ int main() #else #include "test_impes_adaptive_problem.hh" - -#include <dune/grid/common/gridinfo.hh> -#include <dune/grid/utility/structuredgridfactory.hh> - -#include <dune/common/exceptions.hh> -#include <dune/common/mpihelper.hh> -#include <dune/common/parametertreeparser.hh> - -#include <iostream> - +#include <dumux/common/start.hh> //////////////////////// // the main function //////////////////////// -void usage(const char *progname) +void usage(const char *progName, const std::string &errorMsg) { - std::cout << "usage: " << progname << " [--restart restartTime] InputFileName\n"; - exit(1); + if (errorMsg.size() > 0) { + std::string errorMessageOut = "\nUsage: "; + errorMessageOut += progName; + errorMessageOut += " [options]\n"; + errorMessageOut += errorMsg; + errorMessageOut += "\n\nThe List of Mandatory arguments for this program is:\n" + "\t-tEnd The end of the simulation. [s] \n" + "\t-dtInitial The initial timestep size. [s] \n" + "\t-MinLevel Minimum grid level [-] \n" + "\t-MaxLevel Maximum grid level [-] \n" + "\t-RefineTolerance threshold for refinement criterion [-] \n" + "\t-CoarsenTolerance threshold for coarsening criterion [-] \n" + "\t-Grid.numberOfCellsX Resolution in x-direction [-]\n" + "\t-Grid.numberOfCellsY Resolution in y-direction [-]\n" + "\t-Grid.upperRightX Dimension of the grid [m]\n" + "\t-Grid.upperRightY Dimension of the grid [m]\n"; + std::cout << errorMessageOut + << "\n"; + } } int main(int argc, char** argv) { - try { - typedef TTAG(TestIMPESAdaptiveProblem) TypeTag; - typedef GET_PROP_TYPE(TypeTag, Scalar) Scalar; - typedef GET_PROP_TYPE(TypeTag, Grid) Grid; - typedef GET_PROP_TYPE(TypeTag, Problem) Problem; - typedef GET_PROP_TYPE(TypeTag, TimeManager) TimeManager; - typedef Dune::FieldVector<Scalar, Grid::dimensionworld> GlobalPosition; - typedef typename GET_PROP(TypeTag, ParameterTree) Params; - - static const int dim = Grid::dimension; - - //todo: diese zwei Zeile nach dem testen entfernen - typedef GET_PROP_TYPE(TypeTag, GridView) GridView; - typedef typename GridView::Codim<0>::Iterator ElementLeafIterator; - -// static const int dim = Grid::dimension; - - // initialize MPI, finalize is done automatically on exit - Dune::MPIHelper::instance(argc, argv); - - //////////////////////////////////////////////////////////// - // parse the command line arguments - //////////////////////////////////////////////////////////// - if (argc < 2) - usage(argv[0]); - - // deal with the restart stuff - int argPos = 1; - bool restart = false; - double startTime = 0; - if (std::string("--restart") == argv[argPos]) { - restart = true; - ++argPos; - - std::istringstream(argv[argPos++]) >> startTime; - } - - if (argc - argPos != 1) { - usage(argv[0]); - } - - - std::string inputFileName; - inputFileName = argv[argPos++]; - - //////////////////////////////////////////////////////////// - // Read Input file and create grid - //////////////////////////////////////////////////////////// - - Dune::ParameterTreeParser::readINITree(inputFileName, Params::tree()); - - Dune::array< unsigned int, dim > numberOfCells; - numberOfCells[0] = 2; - numberOfCells[1] = 1; - Dune::FieldVector<double, dim> lowerLeftCorner(0); - Dune::FieldVector<double, dim> domainSize(300); - domainSize[1] = 100; - - Dune::shared_ptr<Grid> grid(Dune::StructuredGridFactory<Grid>::createCubeGrid(lowerLeftCorner, domainSize, numberOfCells)); - grid->setClosureType(Grid::ClosureType::NONE); - - grid->globalRefine(Params::tree().get<int>("MaxLevel")); - - // read the initial time step and the end time - double tEnd, dt; - tEnd = Params::tree().get<double>("tEnd"); - dt = tEnd; - - //////////////////////////////////////////////////////////// - // instantiate and run the concrete problem - //////////////////////////////////////////////////////////// - TimeManager timeManager; - Problem problem(timeManager, grid->leafView()); - problem.setGrid(*grid); - - timeManager.init(problem, startTime, dt, tEnd, restart); - timeManager.run(); - return 0; - } - catch (Dune::Exception &e) { - std::cerr << "Dune reported error: " << e << std::endl; - } - catch (...) { - std::cerr << "Unknown exception thrown!\n"; - throw; - } - - return 3; + typedef TTAG(TestIMPESAdaptiveProblem) ProblemTypeTag; + return Dumux::start<ProblemTypeTag>(argc, argv, usage); } #endif diff --git a/test/decoupled/2padaptive/test_impes_adaptive.input b/test/decoupled/2padaptive/test_impes_adaptive.input new file mode 100644 index 0000000000..c1c07c258e --- /dev/null +++ b/test/decoupled/2padaptive/test_impes_adaptive.input @@ -0,0 +1,36 @@ +############################################################# +# Parameter file for test_impes # +# Everything behind a '#' is a comment # +# Groups can be ordered e.g. : [BoundaryConditions], # +# see ../boxmodels/2p2c/ for a more detailed example # +############################################################# + +############################################################# +# Mandatory arguments # +############################################################# +tEnd = 2e7 # [s] +dtInitial = 0 # [s] + +#for grid adaption +MinLevel = 0 # [-] minimum level of refinement +MaxLevel = 5 # [-] maximum level of refinement +RefineTolerance = 0.05 # threshold for refinement criterion +CoarsenTolerance = 0.001 # threshold for coarsening criterion + +[Grid] +numberOfCellsX = 2 # [-] level 0 resolution in x-direction +numberOfCellsY = 1 # [-] level 0 resolution in y-direction + +upperRightX = 300 # [m] dimension of the grid +upperRightY = 100 # [m] dimension of the grid + +######################################################################### +# Simulation restart # +# # +# DuMux simulations can be restarted from *.drs files # +# Set restart to the value of a specific file, e.g.: 'restart = 27184.1'# +# for the restart file # +# name_time=27184.1_rank=0.drs # +# Please comment in the below value, if restart is desired. # +######################################################################### +# restart= ... diff --git a/test/decoupled/2padaptive/test_impes_adaptive_problem.hh b/test/decoupled/2padaptive/test_impes_adaptive_problem.hh index 1e9202e5c6..6d9a690dde 100644 --- a/test/decoupled/2padaptive/test_impes_adaptive_problem.hh +++ b/test/decoupled/2padaptive/test_impes_adaptive_problem.hh @@ -30,10 +30,7 @@ #define DUMUX_TEST_IMPES_ADAPTIVE_PROBLEM_HH #include <dune/grid/uggrid.hh> - -//#include <dune/grid/yaspgrid.hh> -//#include <dune/grid/sgrid.hh> -#include <dune/grid/io/file/dgfparser/dgfug.hh> +#include <dumux/common/cubegridcreator.hh> #include <dumux/material/fluidsystems/liquidphase.hh> #include <dumux/material/components/simpleh2o.hh> @@ -68,6 +65,9 @@ SET_PROP(TestIMPESAdaptiveProblem, Grid) #endif }; +// set the GridCreator property +SET_TYPE_PROP(TestIMPESAdaptiveProblem, GridCreator, CubeGridCreator<TypeTag>); + // Set the problem property SET_TYPE_PROP(TestIMPESAdaptiveProblem, Problem, Dumux::TestIMPESAdaptiveProblem<TypeTag>); @@ -151,11 +151,16 @@ class TestIMPESAdaptiveProblem: public IMPESProblem2P<TypeTag> typedef typename GET_PROP_TYPE(TypeTag, BoundaryTypes) BoundaryTypes; typedef typename GET_PROP(TypeTag, SolutionTypes) SolutionTypes; typedef typename SolutionTypes::PrimaryVariables PrimaryVariables; + typedef typename GET_PROP_TYPE(TypeTag, GridCreator) GridCreator; public: TestIMPESAdaptiveProblem(TimeManager &timeManager, const GridView &gridView) : ParentType(timeManager, gridView), eps_(1e-6) { + GridCreator::grid().setClosureType(Grid::ClosureType::NONE); + GridCreator::grid().globalRefine(GET_PARAM(TypeTag, int, MaxLevel)); + this->setGrid(GridCreator::grid()); + this->setOutputInterval(10); } @@ -170,7 +175,7 @@ public: */ const char *name() const { - return "output2padaptive"; + return "test_2padaptive"; } bool shouldWriteRestartFile() const -- GitLab