Skip to content
Snippets Groups Projects
Commit 5742f5f6 authored by Timo Koch's avatar Timo Koch Committed by Ned Coltman
Browse files

[test][2pfracture] Write out reference timestepsize files if no file is given

parent bc0d1a11
No related branches found
No related tags found
1 merge request!2042[test][2p][fracture] fix failing 2p fracture tests
dune_symlink_to_source_files(FILES "params.input" "grids" "timesteps") dune_symlink_to_source_files(FILES "params.input" "grids" "dt")
# tests without gravity # tests without gravity
dumux_add_test(NAME test_2p_fracture_box dumux_add_test(NAME test_2p_fracture_box
...@@ -10,7 +10,7 @@ dumux_add_test(NAME test_2p_fracture_box ...@@ -10,7 +10,7 @@ dumux_add_test(NAME test_2p_fracture_box
CMD_ARGS --script fuzzy CMD_ARGS --script fuzzy
--files ${CMAKE_SOURCE_DIR}/test/references/test_2p_fracture_box-reference.vtu --files ${CMAKE_SOURCE_DIR}/test/references/test_2p_fracture_box-reference.vtu
${CMAKE_CURRENT_BINARY_DIR}/test_2p_fracture_box-00001.vtu ${CMAKE_CURRENT_BINARY_DIR}/test_2p_fracture_box-00001.vtu
--command "${CMAKE_CURRENT_BINARY_DIR}/test_2p_fracture_box params.input -Problem.Name test_2p_fracture_box -TimeLoop.FixedTimeStepFile ./timesteps/test_2p_fracture_box_timestepsizes.dat") --command "${CMAKE_CURRENT_BINARY_DIR}/test_2p_fracture_box params.input -Problem.Name test_2p_fracture_box -TimeLoop.TimeStepSizeFile dt/test_2p_fracture_box_dt-reference.dat")
dumux_add_test(NAME test_2p_fracture_tpfa dumux_add_test(NAME test_2p_fracture_tpfa
LABELS porousmediumflow 2p LABELS porousmediumflow 2p
...@@ -33,7 +33,7 @@ dumux_add_test(NAME test_2p_fracture_mpfa ...@@ -33,7 +33,7 @@ dumux_add_test(NAME test_2p_fracture_mpfa
CMD_ARGS --script fuzzy CMD_ARGS --script fuzzy
--files ${CMAKE_SOURCE_DIR}/test/references/test_2p_fracture_mpfa-reference.vtu --files ${CMAKE_SOURCE_DIR}/test/references/test_2p_fracture_mpfa-reference.vtu
${CMAKE_CURRENT_BINARY_DIR}/test_2p_fracture_mpfa-00001.vtu ${CMAKE_CURRENT_BINARY_DIR}/test_2p_fracture_mpfa-00001.vtu
--command "${CMAKE_CURRENT_BINARY_DIR}/test_2p_fracture_mpfa params.input -Problem.Name test_2p_fracture_mpfa -TimeLoop.FixedTimeStepFile ./timesteps/test_2p_fracture_mpfa_timestepsizes.dat") --command "${CMAKE_CURRENT_BINARY_DIR}/test_2p_fracture_mpfa params.input -Problem.Name test_2p_fracture_mpfa -TimeLoop.TimeStepSizeFile dt/test_2p_fracture_mpfa_dt-reference.dat")
# tests with gravity # tests with gravity
dumux_add_test(NAME test_2p_fracture_gravity_box dumux_add_test(NAME test_2p_fracture_gravity_box
...@@ -44,7 +44,7 @@ dumux_add_test(NAME test_2p_fracture_gravity_box ...@@ -44,7 +44,7 @@ dumux_add_test(NAME test_2p_fracture_gravity_box
CMD_ARGS --script fuzzy CMD_ARGS --script fuzzy
--files ${CMAKE_SOURCE_DIR}/test/references/test_2p_fracture_gravity_box-reference.vtu --files ${CMAKE_SOURCE_DIR}/test/references/test_2p_fracture_gravity_box-reference.vtu
${CMAKE_CURRENT_BINARY_DIR}/test_2p_fracture_gravity_box-00001.vtu ${CMAKE_CURRENT_BINARY_DIR}/test_2p_fracture_gravity_box-00001.vtu
--command "${CMAKE_CURRENT_BINARY_DIR}/test_2p_fracture_box params.input -Problem.Name test_2p_fracture_gravity_box -Problem.EnableGravity true -Newton.MaxRelativeShift 1e-12 -TimeLoop.FixedTimeStepFile ./timesteps/test_2p_fracture_gravity_box_timestepsizes.dat") --command "${CMAKE_CURRENT_BINARY_DIR}/test_2p_fracture_box params.input -Problem.Name test_2p_fracture_gravity_box -Problem.EnableGravity true -Newton.MaxRelativeShift 1e-12 -TimeLoop.TimeStepSizeFile dt/test_2p_fracture_gravity_box_dt-reference.dat")
dumux_add_test(NAME test_2p_fracture_gravity_tpfa dumux_add_test(NAME test_2p_fracture_gravity_tpfa
TARGET test_2p_fracture_tpfa TARGET test_2p_fracture_tpfa
...@@ -65,4 +65,4 @@ dumux_add_test(NAME test_2p_fracture_gravity_mpfa ...@@ -65,4 +65,4 @@ dumux_add_test(NAME test_2p_fracture_gravity_mpfa
CMD_ARGS --script fuzzy CMD_ARGS --script fuzzy
--files ${CMAKE_SOURCE_DIR}/test/references/test_2p_fracture_gravity_mpfa-reference.vtu --files ${CMAKE_SOURCE_DIR}/test/references/test_2p_fracture_gravity_mpfa-reference.vtu
${CMAKE_CURRENT_BINARY_DIR}/test_2p_fracture_gravity_mpfa-00001.vtu ${CMAKE_CURRENT_BINARY_DIR}/test_2p_fracture_gravity_mpfa-00001.vtu
--command "${CMAKE_CURRENT_BINARY_DIR}/test_2p_fracture_mpfa params.input -Problem.Name test_2p_fracture_gravity_mpfa -Problem.EnableGravity true -TimeLoop.FixedTimeStepFile ./timesteps/test_2p_fracture_gravity_mpfa_timestepsizes.dat") --command "${CMAKE_CURRENT_BINARY_DIR}/test_2p_fracture_mpfa params.input -Problem.Name test_2p_fracture_gravity_mpfa -Problem.EnableGravity true -TimeLoop.TimeStepSizeFile dt/test_2p_fracture_gravity_mpfa_dt-reference.dat")
...@@ -23,7 +23,8 @@ ...@@ -23,7 +23,8 @@
*/ */
#include <config.h> #include <config.h>
#include <ctime> #include <limits>
#include <numeric>
#include <iostream> #include <iostream>
#include <dune/common/parallel/mpihelper.hh> #include <dune/common/parallel/mpihelper.hh>
...@@ -123,25 +124,25 @@ int main(int argc, char** argv) try ...@@ -123,25 +124,25 @@ int main(int argc, char** argv) try
vtkWriter.write(0.0); vtkWriter.write(0.0);
// get some time loop parameters // get some time loop parameters
using Scalar = GetPropType<TypeTag, Properties::Scalar>; std::shared_ptr<CheckPointTimeLoop<double>> timeLoop;
const bool useFixedTimeSteps = hasParam("TimeLoop.FixedTimeStepFile"); const bool hasTimeStepSizeFile = hasParam("TimeLoop.TimeStepSizeFile");
const auto tEnd = getParam<Scalar>("TimeLoop.TEnd"); std::vector<double> timeStepSizes;
const auto maxDt = getParam<Scalar>("TimeLoop.MaxTimeStepSize");
std::vector<double> fixedTimeSteps; if (hasTimeStepSizeFile)
auto dt = getParam<Scalar>("TimeLoop.DtInitial");
if (useFixedTimeSteps)
{ {
// Use fixed time step sizes. Read time steps from a file to get repeatable test results. timeStepSizes = readFileToContainer<std::vector<double>>(getParam<std::string>("TimeLoop.TimeStepSizeFile"));
const auto fixedTimeStepsFileName = getParam<std::string>("TimeLoop.FixedTimeStepFile"); const auto dtInit = timeStepSizes[0];
fixedTimeSteps = readFileToContainer<std::vector<double>>(fixedTimeStepsFileName); const auto tEnd = std::accumulate(timeStepSizes.begin(), timeStepSizes.end(), 0.0);
dt = fixedTimeSteps[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);
} }
// instantiate time loop
auto timeLoop = std::make_shared<CheckPointTimeLoop<Scalar>>(0, dt, tEnd);
timeLoop->setMaxTimeStepSize(maxDt);
// the assembler with time loop for instationary problem // the assembler with time loop for instationary problem
using Assembler = FVAssembler<TypeTag, DiffMethod::numeric>; using Assembler = FVAssembler<TypeTag, DiffMethod::numeric>;
...@@ -161,6 +162,13 @@ int main(int argc, char** argv) try ...@@ -161,6 +162,13 @@ int main(int argc, char** argv) try
// solve the non-linear system with time step control // solve the non-linear system with time step control
nonLinearSolver.solve(x, *timeLoop); 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 // make the new solution the old solution
xOld = x; xOld = x;
gridVariables->advanceTimeStep(); gridVariables->advanceTimeStep();
...@@ -176,8 +184,8 @@ int main(int argc, char** argv) try ...@@ -176,8 +184,8 @@ int main(int argc, char** argv) try
timeLoop->reportTimeStep(); timeLoop->reportTimeStep();
// set new dt as suggested by the newton solver // set new dt as suggested by the newton solver
if (useFixedTimeSteps) if (hasTimeStepSizeFile)
timeLoop->setTimeStepSize(fixedTimeSteps[timeLoop->timeStepIndex()]); timeLoop->setTimeStepSize(timeStepSizes[timeLoop->timeStepIndex()]);
else else
timeLoop->setTimeStepSize(nonLinearSolver.suggestTimeStepSize(timeLoop->timeStepSize())); timeLoop->setTimeStepSize(nonLinearSolver.suggestTimeStepSize(timeLoop->timeStepSize()));
...@@ -192,6 +200,11 @@ int main(int argc, char** argv) try ...@@ -192,6 +200,11 @@ int main(int argc, char** argv) try
// print dumux end message // print dumux end message
if (mpiHelper.rank() == 0) if (mpiHelper.rank() == 0)
{ {
// write out the exact time steps this program used to produce a well-reproducible test
if (!hasTimeStepSizeFile)
writeContainerToFile(timeStepSizes, "dt/" + problem->name() + "_dt-reference.dat",
std::numeric_limits<double>::digits10);
Parameters::print(); Parameters::print();
DumuxMessage::print(/*firstCall=*/false); DumuxMessage::print(/*firstCall=*/false);
} }
......
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