Skip to content
Permalink
Browse files

Merge pull request #13188 from permcody/start_time_fix

Start time fix
  • Loading branch information...
lindsayad committed Apr 9, 2019
2 parents c55590f + 0986d12 commit 6b48511ed6b3779e7ff213be797beab5ae4ebfbc
Showing with 327 additions and 68 deletions.
  1. +2 −0 framework/include/executioners/PicardSolve.h
  2. +4 −2 framework/include/outputs/Console.h
  3. +3 −0 framework/include/problems/FEProblemBase.h
  4. +3 −2 framework/src/executioners/PicardSolve.C
  5. +20 −8 framework/src/executioners/Transient.C
  6. +34 −20 framework/src/outputs/Console.C
  7. +0 −1 modules/combined/test/tests/adaptive_timestepping/adapt_tstep_function_change_restart2.i
  8. +0 −1 modules/combined/test/tests/adaptive_timestepping/adapt_tstep_function_change_restart2_sm.i
  9. +12 −6 modules/doc/content/application_usage/restart_recover.md
  10. +0 −1 modules/tensor_mechanics/test/tests/thermal_expansion/constant_expansion_coeff_restart.i
  11. +0 −1 test/tests/geomsearch/2d_moving_penetration/restart2.i
  12. +0 −1 test/tests/restart/restart/xda_restart_part2.i
  13. BIN test/tests/restart/restart_diffusion/gold/restart_diffusion_transient_from_steady_out.e
  14. +1 −0 test/tests/restart/restart_diffusion/restart_diffusion_transient_from_steady.i
  15. +51 −19 test/tests/restart/restart_diffusion/tests
  16. +0 −1 test/tests/restart/restart_subapp_not_master/two_step_solve_sub_restart.i
  17. +7 −0 test/tests/restart/start_time_override/gold/start_time_override_nonzero.csv
  18. +7 −0 test/tests/restart/start_time_override/gold/start_time_override_out.csv
  19. +7 −0 test/tests/restart/start_time_override/gold/start_time_override_zero.csv
  20. +66 −0 test/tests/restart/start_time_override/start_time_override.i
  21. +49 −0 test/tests/restart/start_time_override/tests
  22. +61 −0 test/tests/restart/start_time_override/transient.i
  23. +0 −3 test/tests/time_steppers/iteration_adaptive/adapt_tstep_grow_dtfunc_restart.i
  24. +0 −1 test/tests/time_steppers/iteration_adaptive/adapt_tstep_grow_init_dt_restart.i
  25. +0 −1 test/tests/time_steppers/iteration_adaptive/adapt_tstep_shrink_init_dt_restart.i
@@ -153,5 +153,7 @@ class PicardSolve : public SolveObject

/// Time of previous Picard solve as a subapp
Real _previous_entering_time;

const std::string _solve_message;
};
#endif // PICARDSOLVE_H
@@ -126,9 +126,11 @@ class Console : public TableOutput
virtual void outputSystemInformation() override;

/**
* Prints the time step information for the screen output
* Prints the time step information for the screen output. The Boolean controls whether the dt is
* output. It doesn't really make sense to output this quantity the first time since it's a delta
* quantity indicating the step size from the previous step.
*/
void writeTimestepInformation();
void writeTimestepInformation(bool output_dt);

/**
* Write message to screen and/or file
@@ -1611,6 +1611,9 @@ class FEProblemBase : public SubProblem, public Restartable
using SubProblem::haveADObjects;
void haveADObjects(bool have_ad_objects) override;

// Whether or not we should solve this system
bool shouldSolve() const { return _solve; }

protected:
/// Create extra tagged vectors and matrices
void createTagVectors();
@@ -101,7 +101,8 @@ PicardSolve::PicardSolve(Executioner * ex)
_picard_status(MoosePicardConvergenceReason::UNSOLVED),
_xfem_update_count(0),
_xfem_repeat_step(false),
_previous_entering_time(_problem.time() - 1)
_previous_entering_time(_problem.time() - 1),
_solve_message(_problem.shouldSolve() ? "Solve Converged!" : "Solve Skipped!")
{
if (_relax_factor != 1.0)
// Store a copy of the previous solution here
@@ -382,7 +383,7 @@ PicardSolve::solveStep(Real begin_norm_old,
else
_picard_status = MoosePicardConvergenceReason::CONVERGED_NONLINEAR;

_console << COLOR_GREEN << " Solve Converged!" << COLOR_DEFAULT << std::endl;
_console << COLOR_GREEN << ' ' << _solve_message << COLOR_DEFAULT << std::endl;

// Relax the "relaxed_variables"
if (relax)
@@ -183,7 +183,7 @@ Transient::Transient(const InputParameters & parameters)
// is (in case anyone else is interested.
if (_app.hasStartTime())
_start_time = _app.getStartTime();
else if (parameters.isParamSetByUser("start_time"))
else if (parameters.isParamSetByUser("start_time") && !_app.isRecovering())
_app.setStartTime(_start_time);

_time = _time_old = _start_time;
@@ -212,10 +212,9 @@ Transient::init()

/**
* We have a default "dt" set in the Transient parameters but it's possible for users to set
* other
* parameters explicitly that could provide a better calculated "dt". Rather than provide
* difficult
* to understand behavior using the default "dt" in this case, we'll calculate "dt" properly.
* other parameters explicitly that could provide a better calculated "dt". Rather than provide
* difficult to understand behavior using the default "dt" in this case, we'll calculate "dt"
* properly.
*/
if (!_pars.isParamSetByAddParam("end_time") && !_pars.isParamSetByAddParam("num_steps") &&
_pars.isParamSetByAddParam("dt"))
@@ -231,10 +230,23 @@ Transient::init()
_problem.execute(EXEC_PRE_MULTIAPP_SETUP);
_problem.initialSetup();

_time_stepper->init();

/**
* If this is a restart run, the user may want to override the start time, which we already set in
* the constructor. "_time" however will have been "restored" from the restart file. We need to
* honor the original request of the developer now that the restore has been completed. This must
* occur before we init the time stepper (since that prints out the start time). The multiapp case
* is also bit complicated. If we didn't set a start time, the app won't have it yet, so we just
* restart the old time from the current time.
*/
if (_app.isRestarting())
_time_old = _time;
{
if (_app.hasStartTime())
_time = _time_old = _app.getStartTime();
else
_time_old = _time;
}

_time_stepper->init();

if (_app.isRecovering()) // Recover case
{
@@ -274,9 +274,6 @@ Console::initialSetup()
if (!_pars.isParamSetByUser("vector_postprocessor_execute_on"))
_advanced_execute_on["vector_postprocessors"].push_back("final");
}

if (_execute_on.contains(EXEC_INITIAL))
writeTimestepInformation();
}

std::string
@@ -288,7 +285,7 @@ Console::filename()
void
Console::timestepSetup()
{
writeTimestepInformation();
writeTimestepInformation(/*output_dt = */ true);
}

void
@@ -309,8 +306,12 @@ Console::output(const ExecFlagType & type)
outputInput();

// Write the timestep information ("Time Step 0 ..."), this is controlled with "execute_on"
if (type == EXEC_FINAL && _execute_on.contains(EXEC_FINAL))
writeTimestepInformation();
// We only write the initial and final here. All of the intermediate outputs will be written
// through timestepSetup.
if (type == EXEC_INITIAL && _execute_on.contains(EXEC_INITIAL))
writeTimestepInformation(/*output_dt = */ false);
else if (type == EXEC_FINAL && _execute_on.contains(EXEC_FINAL))
writeTimestepInformation(/*output_dt = */ true);

// Print Non-linear Residual (control with "execute_on")
if (type == EXEC_NONLINEAR && _execute_on.contains(EXEC_NONLINEAR))
@@ -383,7 +384,7 @@ Console::writeStreamToFile(bool append)
}

void
Console::writeTimestepInformation()
Console::writeTimestepInformation(bool output_dt)
{
// Stream to build the time step information
std::stringstream oss;
@@ -404,23 +405,36 @@ Console::writeTimestepInformation()
oss << std::scientific;

// Print the time
oss << ", time = " << time() << '\n';
oss << ", time = " << time();

// Show old time information, if desired
if (_verbose)
oss << std::right << std::setw(21) << std::setfill(' ') << "old time = " << std::left
<< timeOld() << '\n';
if (output_dt)
{
if (!_verbose)
// Show the time delta information
oss << ", dt = " << std::left << dt();

// Show the time delta information
oss << std::right << std::setw(21) << std::setfill(' ') << "dt = " << std::left << dt() << '\n';
// Show old time information, if desired on separate lines
else
{
oss << '\n'
<< std::right << std::setw(21) << std::setfill(' ') << "old time = " << std::left
<< timeOld() << '\n';

// Show the old time delta information, if desired
if (_verbose)
oss << std::right << std::setw(21) << std::setfill(' ') << "old dt = " << _dt_old << '\n';
}
// Show the time delta information
oss << std::right << std::setw(21) << std::setfill(' ') << "dt = " << std::left << dt()
<< '\n';

// Output to the screen
_console << oss.str() << std::flush;
// Show the old time delta information, if desired
if (_verbose)
oss << std::right << std::setw(21) << std::setfill(' ') << "old dt = " << _dt_old << '\n';
}
}

oss << '\n';

// Output to the screen
_console << oss.str() << std::flush;
}
}

void
@@ -134,7 +134,6 @@

verbose = true
nl_abs_tol = 1e-10
start_time = 0.0
num_steps = 50000
end_time = 2.002e6
[./TimeStepper]
@@ -147,7 +147,6 @@

verbose = true
nl_abs_tol = 1e-10
start_time = 0.0
num_steps = 50000
end_time = 2.002e6
[./TimeStepper]
@@ -19,12 +19,12 @@
[Mesh]
#MOOSE supports reading field data from ExodusII, XDA/XDR, and mesh checkpoint files (.e, .xda, .xdr, .cp)
file = previous.e
#This method of restart is only supported on serial meshes
distribution = serial
#This method of restart is only supported on serial meshes
distribution = serial
[]
[Variables]
[./nodal]
[./nodal]
family = LAGRANGE
order = FIRST
initial_from_file_var = nodal
@@ -33,7 +33,7 @@
[]
[AuxVariables]
[./elemental]
[./elemental]
family = MONOMIAL
order = CONSTANT
initial_from_file_var = elemental
@@ -77,8 +77,8 @@ For a complete list see the Doxygen page for Checkpoint. * You should always set
[Mesh]
#Serial number should match corresponding Executioner parameter
file = out_cp/0010_mesh.cpr
#This method of restart is only supported on serial meshes
distribution = serial
#This method of restart is only supported on serial meshes
distribution = serial
[]
[Problem]
@@ -100,3 +100,9 @@ For a complete list see the Doxygen page for Checkpoint. * You should always set
## MultiApp Restart

When running a multiapp simulation you do +not+ need to enable checkpoint output in each sub app input file. The master app stores the restart data for all sub apps in its file.

## Time Control on Restart

`start_time` can be continued on from the previous simulation, or can be overridden on restart. If this parameter is omitted from your input file
the default will be to continue from the previous simulation. If you supply the parameter in your input file, the new simulation will begin from
the supplied time.
@@ -115,7 +115,6 @@
nl_abs_tol = 1e-10
l_tol = 1e-9

start_time = 0.0
end_time = 0.1
dt = 0.0125
dtmin = 0.0001
@@ -220,7 +220,6 @@
nl_rel_tol = 1e-9
l_max_its = 10

start_time = 0.0
dt = 0.05
end_time = 1.0
[]
@@ -112,7 +112,6 @@
[Executioner]
type = Transient
solve_type = JFNK
start_time = 1
dt = 0.1
reset_dt = true #NECESSARY to force a change in DT when using restart!
num_steps = 3
@@ -57,6 +57,7 @@

solve_type = 'PJFNK'

# Reset the start_time here
start_time = 0.0
num_steps = 10
dt = .1
Oops, something went wrong.

0 comments on commit 6b48511

Please sign in to comment.
You can’t perform that action at this time.