Skip to content
Permalink
Browse files

Merge pull request #12930 from YaqiWang/time

Remove one unnecessary mesh adaptation
  • Loading branch information...
permcody committed Feb 19, 2019
2 parents 7d4ae5d + 5501091 commit edcef65f02b074e202a8cfa0c8a53a3271bcaf83
@@ -220,27 +220,17 @@ class Transient : public Executioner
Real & _unconstrained_dt;
bool & _at_sync_point;

/// Whether or not the multiapps failed during the last timestem
bool & _multiapps_converged;

/// Whether or not the last solve converged
bool & _last_solve_converged;

/// Whether step should be repeated due to xfem modifying the mesh
bool _xfem_repeat_step;
/// Counter for number of xfem updates that have been performed in the current step
unsigned int _xfem_update_count;
/// Maximum number of xfem updates per step
unsigned int _max_xfem_update;
/// Controls whether xfem should update the mesh at the beginning of the time step
bool _update_xfem_at_timestep_begin;

Real _end_time;
Real _dtmin;
Real _dtmax;
unsigned int _num_steps;
int _n_startup_steps;
unsigned int _steps_taken;

/**
* Steady state detection variables:
@@ -138,18 +138,13 @@ Transient::Transient(const InputParameters & parameters)
_dt_old(_problem.dtOld()),
_unconstrained_dt(declareRecoverableData<Real>("unconstrained_dt", -1)),
_at_sync_point(declareRecoverableData<bool>("at_sync_point", false)),
_multiapps_converged(declareRecoverableData<bool>("multiapps_converged", true)),
_last_solve_converged(declareRecoverableData<bool>("last_solve_converged", true)),
_xfem_repeat_step(false),
_xfem_update_count(0),
_max_xfem_update(getParam<unsigned int>("max_xfem_update")),
_update_xfem_at_timestep_begin(getParam<bool>("update_xfem_at_timestep_begin")),
_end_time(getParam<Real>("end_time")),
_dtmin(getParam<Real>("dtmin")),
_dtmax(getParam<Real>("dtmax")),
_num_steps(getParam<unsigned int>("num_steps")),
_n_startup_steps(getParam<int>("n_startup_steps")),
_steps_taken(0),
_steady_state_detection(getParam<bool>("steady_state_detection")),
_steady_state_tolerance(getParam<Real>("steady_state_tolerance")),
_steady_state_start_time(getParam<Real>("steady_state_start_time")),
@@ -275,14 +270,6 @@ Transient::preExecute()
"2. If you are developing a new time stepper, make sure that initial time step "
"size in your code is computed correctly.");
_nl.getTimeIntegrator()->init();
++_t_step;

// NOTE: if you remove this line, you will see a subset of tests failing. Those tests might have
// a wrong answer and might need to be regolded. The reason is that we actually move the
// solution back in time before we actually start solving (which I think is wrong). So this
// call here is to maintain backward compatibility and so that MOOSE is giving the same answer.
// However, we might remove this call and regold the test in the future eventually.
_problem.advanceState();
}
}

@@ -303,23 +290,25 @@ Transient::execute()
{
preExecute();

// FIXME: cannot move the following into preExecute because of the way TransientMultiApp is coded.
// We will need to cleanup TransientMultiApp first for the cleanup here.
if (_app.isRecovering())
incrementStepOrReject();

// Start time loop...
while (keepGoing())
{
incrementStepOrReject();
preStep();
computeDT();
takeStep();
endStep();
postStep();
}

_steps_taken++;

incrementStepOrReject();
if (lastSolveConverged())
{
_t_step++;
if (_picard_solve.hasPicardIteration())
{
_problem.finishMultiAppStep(EXEC_TIMESTEP_BEGIN);
_problem.finishMultiAppStep(EXEC_TIMESTEP_END);
}
}

if (!_app.halfTransient())
@@ -349,21 +338,21 @@ Transient::incrementStepOrReject()
{
if (lastSolveConverged())
{
if (_xfem_repeat_step)
{
_time = _time_old;
}
else
if (!_xfem_repeat_step)
{
#ifdef LIBMESH_ENABLE_AMR
_problem.adaptMesh();
if (_t_step != 0)
_problem.adaptMesh();
#endif

_time_old = _time;
_t_step++;

_problem.advanceState();

if (_t_step == 1)
return;

/*
* Call the multi-app executioners endStep and
* postStep methods when doing Picard. We do not perform these calls for
@@ -375,6 +364,7 @@ Transient::incrementStepOrReject()
_problem.finishMultiAppStep(EXEC_TIMESTEP_BEGIN);
_problem.finishMultiAppStep(EXEC_TIMESTEP_END);
}

/*
* Ensure that we increment the sub-application time steps so that
* when dt selection is made in the master application, we are using
@@ -415,7 +405,7 @@ Transient::takeStep(Real input_dt)
_time_stepper->step();
_xfem_repeat_step = _picard_solve.XFEMRepeatStep();

_multiapps_converged = true;
_last_solve_converged = _time_stepper->converged();

if (!(_problem.haveXFEM() && _picard_solve.XFEMRepeatStep()))
{
@@ -443,22 +433,25 @@ Transient::endStep(Real input_time)
else
_time = input_time;

_last_solve_converged = lastSolveConverged();

if (_last_solve_converged && !_xfem_repeat_step)
if (lastSolveConverged())
{
_nl.getTimeIntegrator()->postStep();
if (_xfem_repeat_step)
_time = _time_old;
else
{
_nl.getTimeIntegrator()->postStep();

// Compute the Error Indicators and Markers
_problem.computeIndicators();
_problem.computeMarkers();
// Compute the Error Indicators and Markers
_problem.computeIndicators();
_problem.computeMarkers();

// Perform the output of the current time step
_problem.outputStep(EXEC_TIMESTEP_END);
// Perform the output of the current time step
_problem.outputStep(EXEC_TIMESTEP_END);

// output
if (_time_interval && (_time + _timestep_tolerance >= _next_interval_output_time))
_next_interval_output_time += _time_interval_output_interval;
// output
if (_time_interval && (_time + _timestep_tolerance >= _next_interval_output_time))
_next_interval_output_time += _time_interval_output_interval;
}
}
}

@@ -555,33 +548,37 @@ Transient::keepGoing()
bool keep_going = !_problem.isSolveTerminationRequested();

// Check for stop condition based upon steady-state check flag:
if (lastSolveConverged() && !_xfem_repeat_step && _steady_state_detection == true &&
_time > _steady_state_start_time)
if (lastSolveConverged())
{
// Check solution difference relative norm against steady-state tolerance
if (_sln_diff_norm < _steady_state_tolerance)
{
_console << "Steady-State Solution Achieved at time: " << _time << std::endl;
// Output last solve if not output previously by forcing it
keep_going = false;
}
else // Keep going
if (!_xfem_repeat_step)
{
// Update solution norm for next time step
_old_time_solution_norm = _nl.currentSolution()->l2_norm();
// Print steady-state relative error norm
_console << "Steady-State Relative Differential Norm: " << _sln_diff_norm << std::endl;
}
}

// Check for stop condition based upon number of simulation steps and/or solution end time:
if (static_cast<unsigned int>(_t_step) > _num_steps)
keep_going = false;
if (_steady_state_detection == true && _time > _steady_state_start_time)
{
// Check solution difference relative norm against steady-state tolerance
if (_sln_diff_norm < _steady_state_tolerance)
{
_console << "Steady-State Solution Achieved at time: " << _time << std::endl;
// Output last solve if not output previously by forcing it
keep_going = false;
}
else // Keep going
{
// Update solution norm for next time step
_old_time_solution_norm = _nl.currentSolution()->l2_norm();
// Print steady-state relative error norm
_console << "Steady-State Relative Differential Norm: " << _sln_diff_norm << std::endl;
}
}

if ((_time > _end_time) || (fabs(_time - _end_time) <= _timestep_tolerance))
keep_going = false;
// Check for stop condition based upon number of simulation steps and/or solution end time:
if (static_cast<unsigned int>(_t_step) >= _num_steps)
keep_going = false;

if (!lastSolveConverged() && _abort)
if ((_time >= _end_time) || (fabs(_time - _end_time) <= _timestep_tolerance))
keep_going = false;
}
}
else if (_abort)
{
_console << "Aborting as solve did not converge and input selected to abort" << std::endl;
keep_going = false;
@@ -598,7 +595,7 @@ Transient::estimateTimeError()
bool
Transient::lastSolveConverged() const
{
return _time_stepper->converged();
return _last_solve_converged;
}

void
@@ -658,5 +658,10 @@ void TransientMultiApp::setupApp(unsigned int i, Real /*time*/) // FIXME: Should
}

ex->preExecute();
if (!_app.isRecovering())
{
problem.timeStep()++;
problem.advanceState();
}
_transient_executioners[i] = ex;
}
@@ -169,7 +169,6 @@ TimeStepper::acceptStep()
void
TimeStepper::rejectStep()
{
_converged = false;
_fe_problem.restoreSolutions();
}

@@ -26,7 +26,7 @@ class TimeSequenceStepperFailTest : public TimeSequenceStepper
public:
TimeSequenceStepperFailTest(const InputParameters & parameters);

virtual bool converged() const override;
virtual void step() override;

protected:
/// stores a copy of the original sequence of time points, is not updated due to failures.
@@ -25,9 +25,11 @@ TimeSequenceStepperFailTest::TimeSequenceStepperFailTest(const InputParameters &
{
}

bool
TimeSequenceStepperFailTest::converged() const
void
TimeSequenceStepperFailTest::step()
{
TimeStepper::step();

// The goal is to fail exactly one timestep which matches its
// original sequence point order, other than the initial condition.
// This can only happen once, since after you fail, you are no
@@ -41,8 +43,9 @@ TimeSequenceStepperFailTest::converged() const
{
mooseDoOnce(
Moose::out << "TimeSequenceStepperFailTest: Simulating failed solve of first timestep.\n");
return false;
_converged = false;
}

return TimeStepper::converged();
if (converged())
_current_step++;
}
@@ -1,29 +1,31 @@
[Tests]
design = 'Outputs/index.md Console.md'
issues = '#2173'
[./basic]
# Tests that the various components of the simulation information header are printed to the screen
type = RunApp
input = 'system_info.i'
expect_out = 'Framework\sInformation:.*?Mesh:.*?Nonlinear\sSystem:.*?Auxiliary\sSystem:.*?Execution\sInformation:'
requirement = 'The system shall print the various components of the simulation information header to the screen'
[../]

[./mesh]
# Check that mesh information prints when the mesh changes
type = RunApp
input = 'system_info_mesh.i'
expect_out = 'time\s=\s0.1.*?Nodes:.*?time\s=\s0.2.*?Nodes:.*?time\s=\s0.3.*?Nodes:'
expect_out = 'time\s=\s0.1.*?Nodes:.*?time\s=\s0.2.*?Nodes:'
requirement = 'The system shall print the mesh information to the screen when the mesh changes'
[../]

[./aux]
# Check that Aux system information prints when the mesh changes
type = RunApp
input = 'system_info_mesh.i'
expect_out = 'Num DOFs:\s*2889'
expect_out = 'Num DOFs:\s*1892'
requirement = 'The system shall print the auxiliary system information to the screen when the mesh changes'
[../]

[./nonlinear]
# Check that Nonlinear system information prints when the mesh changes
type = RunApp
input = 'system_info_mesh.i'
expect_out = 'Num DOFs:\s*1009'
expect_out = 'Num DOFs:\s*672'
requirement = 'The system shall print the nonlinear system information to the screen when the mesh changes'
[../]
[]

0 comments on commit edcef65

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