Skip to content
Snippets Groups Projects
Commit 5dbf5596 authored by Katharina Heck's avatar Katharina Heck
Browse files

Merge branch 'fix/test-saltwaterintrusion-increase-robustness' into 'master'

Fix/test saltwaterintrusion increase robustness

See merge request !2092
parents 009bb5a9 5f769cbc
No related branches found
No related tags found
No related merge requests found
add_input_file_links()
dune_symlink_to_source_files(FILES params.input test_1p2c_saltwaterintrusion_box_dt-reference.dat)
# salt-water intrusion test using the box model
dumux_add_test(NAME test_1p2c_saltwaterintrusion_box
......@@ -10,4 +10,4 @@ dumux_add_test(NAME test_1p2c_saltwaterintrusion_box
CMD_ARGS --script fuzzy
--files ${CMAKE_SOURCE_DIR}/test/references/test_1p2c_saltwaterintrusion_box-reference.vtu
${CMAKE_CURRENT_BINARY_DIR}/test_1p2c_saltwaterintrusion_box-00033.vtu
--command "${CMAKE_CURRENT_BINARY_DIR}/test_1p2c_saltwaterintrusion_box params.input -Problem.Name test_1p2c_saltwaterintrusion_box")
--command "${CMAKE_CURRENT_BINARY_DIR}/test_1p2c_saltwaterintrusion_box params.input -Problem.Name test_1p2c_saltwaterintrusion_box -TimeLoop.TimeStepSizeFile test_1p2c_saltwaterintrusion_box_dt-reference.dat")
......@@ -24,16 +24,11 @@
#include <config.h>
#include <ctime>
#include <iostream>
#include <limits>
#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/discretization/method.hh>
#include <dumux/common/properties.hh>
#include <dumux/common/parameters.hh>
......@@ -41,11 +36,11 @@
#include <dumux/linear/seqsolverbackend.hh>
#include <dumux/nonlinear/newtonsolver.hh>
#include <dumux/assembly/fvassembler.hh>
#include <dumux/io/vtkoutputmodule.hh>
#include <dumux/io/grid/gridmanager.hh>
#include <dumux/io/grid/gridmanager_yasp.hh>
#include <dumux/io/container.hh>
#include "problem.hh"
......@@ -94,7 +89,7 @@ int main(int argc, char** argv) try
// the solution vector
using SolutionVector = GetPropType<TypeTag, Properties::SolutionVector>;
SolutionVector x(gridGeometry->numDofs());
SolutionVector x;
problem->applyInitialSolution(x);
auto xOld = x;
......@@ -103,12 +98,6 @@ int main(int argc, char** argv) try
auto gridVariables = std::make_shared<GridVariables>(problem, gridGeometry);
gridVariables->init(x);
// get some time loop parameters
using Scalar = GetPropType<TypeTag, Properties::Scalar>;
auto tEnd = getParam<Scalar>("TimeLoop.TEnd");
auto dt = getParam<Scalar>("TimeLoop.DtInitial");
auto maxDt = getParam<Scalar>("TimeLoop.MaxTimeStepSize");
// intialize the vtk output module
VtkOutputModule<GridVariables, SolutionVector> vtkWriter(*gridVariables, x, problem->name());
using VelocityOutput = GetPropType<TypeTag, Properties::VelocityOutput>;
......@@ -117,9 +106,26 @@ int main(int argc, char** argv) try
IOFields::initOutputModule(vtkWriter); // Add model specific output fields
vtkWriter.write(0.0);
// instantiate time loop
auto timeLoop = std::make_shared<TimeLoop<Scalar>>(0.0, dt, tEnd);
timeLoop->setMaxTimeStepSize(maxDt);
// time loop and parameters
std::shared_ptr<CheckPointTimeLoop<double>> timeLoop;
const bool hasTimeStepSizeFile = hasParam("TimeLoop.TimeStepSizeFile");
std::vector<double> timeStepSizes;
if (hasTimeStepSizeFile)
{
timeStepSizes = readFileToContainer<std::vector<double>>(getParam<std::string>("TimeLoop.TimeStepSizeFile"));
const auto dtInit = timeStepSizes[0];
const auto tEnd = std::accumulate(timeStepSizes.begin(), timeStepSizes.end(), 0.0);
timeLoop = std::make_shared<CheckPointTimeLoop<double>>(0, dtInit, tEnd);
}
else
{
const auto dtInit = getParam<double>("TimeLoop.DtInitial");
const auto tEnd = getParam<double>("TimeLoop.TEnd");
const auto maxDt = getParam<double>("TimeLoop.MaxTimeStepSize");
timeLoop = std::make_shared<CheckPointTimeLoop<double>>(0, dtInit, tEnd);
timeLoop->setMaxTimeStepSize(maxDt);
}
// the assembler with time loop for instationary problem
using Assembler = FVAssembler<TypeTag, DiffMethod::numeric>;
......@@ -138,6 +144,13 @@ int main(int argc, char** argv) try
// solve the non-linear system with time step control
nonLinearSolver.solve(x, *timeLoop);
// if the time step sizes are not read from file
// save the succeeded time step size in the time step size vector
// we write that to file below to that it can be used on the next run
// to reproduce exactly the same time step sizes
if (!hasTimeStepSizeFile)
timeStepSizes.push_back(timeLoop->timeStepSize());
// make the new solution the old solution
xOld = x;
gridVariables->advanceTimeStep();
......@@ -152,7 +165,10 @@ int main(int argc, char** argv) try
timeLoop->reportTimeStep();
// set new dt as suggested by the newton solver
timeLoop->setTimeStepSize(nonLinearSolver.suggestTimeStepSize(timeLoop->timeStepSize()));
if (hasTimeStepSizeFile)
timeLoop->setTimeStepSize(timeStepSizes[timeLoop->timeStepIndex()]);
else
timeLoop->setTimeStepSize(nonLinearSolver.suggestTimeStepSize(timeLoop->timeStepSize()));
} while (!timeLoop->finished());
......@@ -164,17 +180,24 @@ int main(int argc, char** argv) try
// print dumux end message
if (mpiHelper.rank() == 0)
{
// write out the exact time steps this program used to produce a well-reproducible test
if (!hasTimeStepSizeFile)
writeContainerToFile(timeStepSizes, problem->name() + "_dt-reference.dat",
std::numeric_limits<double>::digits10);
DumuxMessage::print(/*firstCall=*/false);
}
return 0;
}
catch (Dumux::ParameterException &e)
catch (const Dumux::ParameterException &e)
{
std::cerr << std::endl << e << " ---> Abort!" << std::endl;
return 1;
}
catch (Dune::DGFException & e)
catch (const Dune::DGFException & e)
{
std::cerr << "DGF exception thrown (" << e <<
"). Most likely, the DGF file name is wrong "
......@@ -183,13 +206,8 @@ catch (Dune::DGFException & e)
<< " ---> Abort!" << std::endl;
return 2;
}
catch (Dune::Exception &e)
catch (const 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;
}
1.000000000000000e+00
1.500000000000000e+00
2.375000000000000e+00
3.760416666666667e+00
5.953993055555556e+00
9.923321759259261e+00
1.653886959876544e+01
2.756478266460906e+01
4.594130444101511e+01
7.656884073502518e+01
1.276147345583753e+02
2.126912242639588e+02
3.544853737732648e+02
5.908089562887747e+02
9.846815938146244e+02
1.641135989691041e+03
2.735226649485068e+03
4.558711082475114e+03
7.597851804125191e+03
1.266308634020865e+04
2.110514390034775e+04
3.517523983391292e+04
5.862539972318820e+04
9.282354956171467e+04
1.469706201393816e+05
2.327034818873542e+05
3.684471796549775e+05
5.526707694824662e+05
8.290061542236992e+05
1.243509231335549e+06
1.761638077725361e+06
2.202047597156702e+06
2.423620135097741e+06
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