Skip to content
Snippets Groups Projects
Commit 18cdb801 authored by Markus Wolff's avatar Markus Wolff
Browse files

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
parent ba187601
No related branches found
No related tags found
No related merge requests found
tEnd = 2e7
MinLevel = 0
MaxLevel = 5
RefineTolerance = 0.05
CoarsenTolerance = 0.001
......@@ -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
#############################################################
# 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= ...
......@@ -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
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment