From e9ae1caf7baafadd147290ce33c519ceb33de355 Mon Sep 17 00:00:00 2001 From: Thomas Fetzer <thomas.fetzer@iws.uni-stuttgart.de> Date: Mon, 27 Jul 2015 08:34:33 +0000 Subject: [PATCH] [mpnc] test_boxmpnckinetic now uses the start.hh and the interfacegridcreator.hh updated parameters and removed tabs from input file test still fails, but the results with/without these changes are identical reviewed by kilian git-svn-id: svn://svn.iws.uni-stuttgart.de/DUMUX/dumux/trunk@15165 2fb0f335-1f38-0410-981e-8018bf24f1b0 --- .../mpnc/evaporationatmosphereproblem.hh | 4 + .../evaporationatmospherespatialparams.hh | 4 +- test/implicit/mpnc/grids/interfacedomain.dgf | 15 -- test/implicit/mpnc/test_boxmpnckinetic.cc | 248 ++---------------- test/implicit/mpnc/test_boxmpnckinetic.input | 92 +++---- 5 files changed, 66 insertions(+), 297 deletions(-) delete mode 100644 test/implicit/mpnc/grids/interfacedomain.dgf diff --git a/test/implicit/mpnc/evaporationatmosphereproblem.hh b/test/implicit/mpnc/evaporationatmosphereproblem.hh index 577b13adcb..549d95237e 100644 --- a/test/implicit/mpnc/evaporationatmosphereproblem.hh +++ b/test/implicit/mpnc/evaporationatmosphereproblem.hh @@ -62,6 +62,7 @@ #include <dumux/material/fluidsystems/h2on2fluidsystemkinetic.hh> #include <dumux/io/gnuplotinterface.hh> +#include <dumux/io/interfacegridcreator.hh> #include <dumux/io/plotoverline2d.hh> #include <dumux/material/fluidstates/nonequilibriumfluidstate.hh> @@ -95,6 +96,9 @@ SET_PROP(EvaporationAtmosphereProblem, Grid) #endif }; +// Use the interface grid creator to create the grid +SET_TYPE_PROP(EvaporationAtmosphereProblem, GridCreator, InterfaceGridCreator<TypeTag>); + // Set the problem property SET_TYPE_PROP(EvaporationAtmosphereProblem, Problem, diff --git a/test/implicit/mpnc/evaporationatmospherespatialparams.hh b/test/implicit/mpnc/evaporationatmospherespatialparams.hh index b6c8affbdc..2b18af70c0 100644 --- a/test/implicit/mpnc/evaporationatmospherespatialparams.hh +++ b/test/implicit/mpnc/evaporationatmospherespatialparams.hh @@ -199,8 +199,8 @@ public: void setInputInitialize() { eps_ = 1e-6; - heightPM_ = GET_RUNTIME_PARAM(TypeTag, Scalar, Grid.InterfacePos); - heightDomain_ = GET_RUNTIME_PARAM(TypeTag, Scalar, Grid.YMax); + heightPM_ = GET_RUNTIME_PARAM(TypeTag, Scalar, Grid.InterfacePosY); + heightDomain_ = GET_RUNTIME_PARAM(TypeTag, Scalar, Grid.UpperRightY); // BEWARE! First the input values have to be set, than the material parameters can be set // this is the parameter value from file part diff --git a/test/implicit/mpnc/grids/interfacedomain.dgf b/test/implicit/mpnc/grids/interfacedomain.dgf deleted file mode 100644 index 561efaa1f4..0000000000 --- a/test/implicit/mpnc/grids/interfacedomain.dgf +++ /dev/null @@ -1,15 +0,0 @@ -DGF -Interval -0 0 % first corner -1 0.5 % second corner -1 1 % 1 cells in x and 1 in y direction -# - -Cube -0 1 2 3 -# - -BOUNDARYDOMAIN -default 1 % all boundaries have id 1 -#BOUNDARYDOMAIN -# unitcube.dgf diff --git a/test/implicit/mpnc/test_boxmpnckinetic.cc b/test/implicit/mpnc/test_boxmpnckinetic.cc index d1dccc42b6..ad075f1539 100644 --- a/test/implicit/mpnc/test_boxmpnckinetic.cc +++ b/test/implicit/mpnc/test_boxmpnckinetic.cc @@ -24,233 +24,38 @@ #include "config.h" #include <dumux/common/start.hh> -#include <dumux/io/interfacemeshcreator.hh> #include "evaporationatmosphereproblem.hh" -/*! - * \brief Print a usage string for simulations. - * - * \param progName The name of the executable - */ -void printUsage(const char *progName) -{ - std::cout << "usage: " << progName - << " [--restart restartTime] -parameterFile evaporationatmosphere.input\n"; - exit(1); -} - -/*! - * \ingroup Start - * \brief Read the command line arguments and write them into the parameter tree. - * Do some syntax checks. - * - * \param argc The 'argc' argument of the main function: count of arguments (1 if there are no arguments) - * \param argv The 'argv' argument of the main function: array of pointers to the argument strings - * \param paramTree The parameterTree. It can be filled from an input file or the command line. - * \return Empty string if everything worked out. Otherwise the thing that could not be read. - */ -std::string readOptions_(int argc, char **argv, Dune::ParameterTree ¶mTree) -{ - // All command line options need to start with '-' - for (int i = 1; i < argc; ++i) { - if (argv[i][0] != '-') { - std::ostringstream oss; - oss << "\n -> Command line argument " << i << " (='" << argv[i] << "') is invalid. <- \n\n\n\n"; - return oss.str(); - } - - // read a -MyOpt VALUE option - std::string paramName = argv[i] + 1; - - if (argc == i + 1 || argv[i+1][0] == '-') { - std::ostringstream oss; - oss << "\n -> No argument given for parameter '" << argv[i] << "'! <- \n\n\n\n"; - return oss.str(); - } - - std::string paramValue = argv[i+1]; - ++i; // In the case of '-MyOpt VALUE' each pair counts as two arguments - - // Put the key=value pair into the parameter tree - paramTree[paramName] = paramValue; - } - return ""; -} - - -template <class TypeTag> -int start_(int argc, - char **argv) -{ - typedef typename GET_PROP_TYPE(TypeTag, Scalar) Scalar; - typedef typename GET_PROP_TYPE(TypeTag, Grid) Grid; - typedef typename GET_PROP_TYPE(TypeTag, Problem) Problem; - typedef typename GET_PROP_TYPE(TypeTag, TimeManager) TimeManager; - - typedef Dune::GridPtr<Grid> GridPointer; - - //////////////////////////////////////////////////////////// - // Load the input parameters - //////////////////////////////////////////////////////////// - -// typedef typename GET_PROP(TypeTag, ParameterTree) ParameterTree; -// Dune::ParameterTreeParser::readOptions(argc, argv, ParameterTree::tree()); - - // fill the parameter tree with the options from the command line - typedef typename GET_PROP(TypeTag, ParameterTree) ParameterTree; - std::string s = readOptions_(argc, argv, ParameterTree::tree()); - - if (ParameterTree::tree().hasKey("ParameterFile") or argc==1) - { - // read input file, but do not overwrite options specified - // on the command line, since the latter have precedence. - std::string inputFileName ; - if(argc==1) // if there are no arguments given (and there is a file ./<programname>.input) we use it as input file - { - std::cout<< "\nNo parameter file given. \n" - << "Defaulting to '" - << argv[0] - << ".input' for input file.\n"; - inputFileName = argv[0]; - inputFileName += ".input"; - } - else - inputFileName = GET_RUNTIME_PARAM(TypeTag, std::string, ParameterFile); // otherwise we read from the command line - - std::ifstream parameterFile; - - // check whether the parameter file exists. - parameterFile.open(inputFileName.c_str()); - if (not parameterFile.is_open()){ - std::cout<< "\n\t -> Could not open file" - << inputFileName - << ". <- \n\n\n\n"; - printUsage(argv[0]); - return 1; - } - parameterFile.close(); - - Dune::ParameterTreeParser::readINITree(inputFileName, - ParameterTree::tree(), - /*overwrite=*/false); - } - - // initialize MPI, finalize is done automatically on exit - static Dune::MPIHelper& mpiHelper = Dune::MPIHelper::instance(argc, argv); - - // define the problem dimensions - const int dim=2; - - // deal with the restart stuff - int argIdx = 1; - bool restart = false; - double tStart = 0.0; - if (argc > 1 && std::string("--restart") == argv[argIdx]) - { - restart = true; - ++argIdx; - - std::istringstream(argv[argIdx++]) >> tStart; - } - - std::string dgfFileName; - Scalar dt, tEnd; - Dune::FieldVector<int, dim> numElements; - Scalar interfacePos, gradingFactor; - int gridRefinement; - bool useInterfaceMeshCreator; - - dgfFileName = GET_RUNTIME_PARAM_FROM_GROUP(TypeTag, std::string, Grid, File); - dt = GET_RUNTIME_PARAM_FROM_GROUP(TypeTag, Scalar, TimeManager, DtInitial); - tEnd = GET_RUNTIME_PARAM_FROM_GROUP(TypeTag, Scalar, TimeManager, TEnd); - numElements[0] = GET_RUNTIME_PARAM_FROM_GROUP(TypeTag, int, Grid, CellsX); - if (dim>1) numElements[1] = GET_RUNTIME_PARAM_FROM_GROUP(TypeTag, int, Grid, CellsY); - if (dim==3) numElements[2] = GET_RUNTIME_PARAM_FROM_GROUP(TypeTag, int, Grid, CellsZ); - interfacePos = GET_RUNTIME_PARAM_FROM_GROUP(TypeTag, Scalar, Grid, InterfacePos); - gradingFactor = GET_RUNTIME_PARAM_FROM_GROUP(TypeTag, Scalar, Grid, Grading); - gridRefinement = GET_RUNTIME_PARAM_FROM_GROUP(TypeTag, Scalar, Grid, Refinement); - useInterfaceMeshCreator = GET_RUNTIME_PARAM_FROM_GROUP(TypeTag, bool, Grid, UseInterfaceMeshCreator); - - std::cout << "Starting with timestep size = " << dt << "s, simulation end = " << tEnd << "s\n"; - - GridPointer gridPtr; - if (useInterfaceMeshCreator) - { - Dumux::InterfaceMeshCreator<Grid> interfaceMeshCreator; - gridPtr = interfaceMeshCreator.create(dgfFileName, numElements, interfacePos, gradingFactor); - } - else - gridPtr = GridPointer(dgfFileName); - - if (gridRefinement) - { - Grid& grid = *gridPtr; - grid.globalRefine(gridRefinement); - } - - if (mpiHelper.size() > 1) { - if (!Dune::Capabilities::isParallel<Grid>::v) { - std::cerr << "WARNING: THE PROGRAM IS STARTED USING MPI, BUT THE GRID IMPLEMENTATION\n" - << " YOU HAVE CHOSEN IS NOT PARALLEL!\n"; - } - (*gridPtr).loadBalance(); - } - - // Instantiate the time manager - TimeManager timeManager; - - // instantiate coupled problem - Problem problem(timeManager, gridPtr->leafGridView()); - Dumux::Parameters::print<TypeTag>(); - - // run the simulation - timeManager.init(problem, - tStart, // initial time - dt, // initial time step - tEnd, // final time - restart); - - // print all properties - Dumux::Properties::print<TypeTag>(); - - timeManager.run(); - - return 0; -} /*! - * \ingroup Start - * - * \brief Provides a main function which reads in parameters from the - * command line and a parameter file. - * - * In this function only the differentiation between debugger - * or not is made. - * - * \tparam TypeTag The type tag of the problem which needs to be solved + * \brief Print a usage string for simulations. * - * \param argc The number of command line arguments of the program - * \param argv The contents of the command line arguments of the program + * \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. */ -template <class TypeTag> -int start(int argc, char **argv) +void printUsage(const char *progName, const std::string &errorMsg) { - try { - return start_<TypeTag>(argc, argv); - } - catch (Dumux::ParameterException &e) - { - std::cerr << e << ". Abort!\n"; - printUsage(argv[0]); - return 1; - } - catch (Dune::Exception &e) { - std::cerr << "Dune reported error: " << e << std::endl; - return 2; - } - catch (...) { - std::cerr << "Unknown exception thrown!\n"; - return 3; + if (errorMsg.size() > 0) { + std::string errorMessageOut = "\nUsage: "; + errorMessageOut += progName; + errorMessageOut += " [options]\n"; + errorMessageOut += errorMsg; + errorMessageOut += "\nAn uncomplete list of mandatory options for this program is:\n" + "[Grid]\n" + "LowerLeftX Minumum x-coordinate [m]\n" + "UpperRightX Maximum x-coordinate [m]\n" + "LowerLeftY Minumum y-coordinate [m]\n" + "UpperRightY Maximum y-coordinate [m]\n" + "NumberOfCellsX Number of cells in x-direction\n" + "NumberOfCellsY Number of cells in y-direction\n" + "GradingFactorY Vertical grading of the cells\n" + "RefineTop Specifies whethter the top of the free flow will be refined\n" + "InterfacePosY Vertical position of the interface [m]\n" + "\n"; + + std::cout << errorMessageOut + << "\n"; } } @@ -262,7 +67,6 @@ int main(int argc, char** argv) return 77; #else typedef TTAG(EvaporationAtmosphereProblem) ProblemTypeTag; - return start<ProblemTypeTag>(argc, argv);//, usage); + return Dumux::start<ProblemTypeTag>(argc, argv, printUsage);//, usage); #endif - } diff --git a/test/implicit/mpnc/test_boxmpnckinetic.input b/test/implicit/mpnc/test_boxmpnckinetic.input index c0a3b0c476..4207de86bb 100644 --- a/test/implicit/mpnc/test_boxmpnckinetic.input +++ b/test/implicit/mpnc/test_boxmpnckinetic.input @@ -1,75 +1,56 @@ - [TimeManager] -DtInitial = 1.5 # [s] +DtInitial = 1.5 # [s] TEnd = 10 # [s] -MaxTimeStepSize = 2e20 # maximum allowed timestep size - +MaxTimeStepSize = 2e20 # maximum allowed timestep size [Grid] -UseInterfaceMeshCreator = true - -File = ./grids/interfacedomain.dgf # ./grids/evaporationatmosphere5x79.dgf - -Refinement = 0 - -CellsX = 14 # -CellsY = 30 # -CellsZ = 1 -Grading = 1.13 - -XMin = 0.0 -XMax = 0.25 -YMin = 0.0 -YMax = 0.5 - -InterfacePos = 0.25 - - - +NumberOfCellsX = 14 # +NumberOfCellsY = 30 # +LowerLeftX = 0.0 +UpperRightX = 1.0 +LowerLeftY = 0.0 +UpperRightY = 0.5 +InterfacePosY = 0.25 +GradingFactorY = 1.13 +RefineTop = false [InitialConditions] -SwFFInitial = 1e-5 # - 0.001# -SwPMInitial = 0.999 # - -pnInitial = 1e5 # 6.8e6 # 1e5 # 101475 # Pa -TInitial = 293 -pnInjection = 100003 +SwFFInitial = 1e-5 # - 0.001# +SwPMInitial = 0.999 # - +pnInitial = 1e5 # 6.8e6 # 1e5 # 101475 # Pa +TInitial = 293 +pnInjection = 100003 [BoundaryConditions] percentOfEquil = .1 # percentage of the equilibrium concentration water in the nPhase influx TInject = 293 massFluxInjectedPhase = 0.75 - [SpatialParams.PorousMedium] -permeability = 1e-11 # m^2 -porosity = 0.4 # -meanPoreSize = 1e-4 # characteristic length of the system -factorEnergyTransfer = 1 # -factorMassTransfer = 1 # - +permeability = 1e-11 # m^2 +porosity = 0.4 # +meanPoreSize = 1e-4 # characteristic length of the system +factorEnergyTransfer = 1 # +factorMassTransfer = 1 # [SpatialParams.FreeFlow] -permeability = 1e-6 # m^2 -porosity = 0.99 # -meanPoreSize = 1e-2 # 4e-5 # characteristic length of the system +permeability = 1e-6 # m^2 +porosity = 0.99 # +meanPoreSize = 1e-2 # 4e-5 # characteristic length of the system [SpatialParams.soil] - -density = 2600. # kg/m^3 http://www.agriinfo.in/default.aspx?page=topic&superid=4&topicid=271 -thermalConductivity = 3 # W / (m K) -heatCapacity = 817 # J / (kg K) - # characteristic length, i.e. mean pore size - # 40 micrometer i.e. 1e-5 for the micromodel +density = 2600. # kg/m^3 http://www.agriinfo.in/default.aspx?page=topic&superid=4&topicid=271 +thermalConductivity = 3 # W / (m K) +heatCapacity= 817 # J / (kg K) +# characteristic length, i.e. mean pore size +# 40 micrometer i.e. 1e-5 for the micromodel VGAlpha = 3.512e-04 # VGN = 4.716e+00 # - Swr = 0 # Snr = 0 # - specificSolidsurface = 4022.994# (1/m) - aWettingNonWettingA1 = -1.603e-01 # aWettingNonWettingA2 = 1.429e-05 # aWettingNonWettingA3 = 1.915e-01 # @@ -81,19 +62,14 @@ aNonWettingSolidA1 = 1.369e+03 # aNonWettingSolidA2 = -3.782e+00 # aNonWettingSolidA3 = 1.063e-09 # - [SourceSink] heatIntoSolid = 0 # -[Constants] -outputName = evaporationatmosphere - -nRestart = 100 # after so many timesteps a restart file should be written +[Constants] +outputName = evaporationatmosphere +nRestart = 100 # after so many timesteps a restart file should be written [FluidSystem] -nTemperature = 100 # for the tabulation of water: so many interpolation points -nPressure = 100 # for the tabulation of water: so many interpolation points - +nTemperature = 100 # for the tabulation of water: so many interpolation points +nPressure = 100 # for the tabulation of water: so many interpolation points hammer = 1e4 - - -- GitLab