Skip to content
Snippets Groups Projects
Commit 0dd5c21b authored by Dmitri Naumov's avatar Dmitri Naumov
Browse files

[PL] TL; Extract initialization part of the loop.

parent eea6b1eb
No related branches found
No related tags found
No related merge requests found
......@@ -235,6 +235,7 @@ int main(int argc, char* argv[])
INFO("Solve processes.");
auto& time_loop = project.getTimeLoop();
time_loop.initialize();
solver_succeeded = time_loop.loop();
#ifdef USE_INSITU
......
......@@ -379,44 +379,33 @@ double TimeLoop::computeTimeStepping(const double prev_dt, double& t,
return dt;
}
/*
* TODO:
* Now we have a structure inside the time loop which is very similar to the
* nonlinear solver. And admittedly, the control flow inside the nonlinear
* solver is rather complicated. Maybe in the future con can introduce an
* abstraction that can do both the convergence checks of the coupling loop and
* of the nonlinear solver.
*/
bool TimeLoop::loop()
/// initialize output, convergence criterion, etc.
void TimeLoop::initialize()
{
// initialize output, convergence criterion, etc.
int process_id = 0;
for (auto& process_data : _per_process_data)
{
int process_id = 0;
for (auto& process_data : _per_process_data)
{
auto& pcs = process_data->process;
_output->addProcess(pcs, process_id);
auto& pcs = process_data->process;
_output->addProcess(pcs, process_id);
process_data->process_id = process_id;
setTimeDiscretizedODESystem(*process_data);
process_data->process_id = process_id;
setTimeDiscretizedODESystem(*process_data);
if (auto* conv_crit =
dynamic_cast<NumLib::ConvergenceCriterionPerComponent*>(
process_data->conv_crit.get()))
{
conv_crit->setDOFTable(pcs.getDOFTable(process_id),
pcs.getMesh());
}
if (auto* conv_crit =
dynamic_cast<NumLib::ConvergenceCriterionPerComponent*>(
process_data->conv_crit.get()))
{
conv_crit->setDOFTable(pcs.getDOFTable(process_id), pcs.getMesh());
}
// Add the fixed times of output to time stepper in order that
// the time stepping is performed and the results are output at
// these times. Note: only the adaptive time steppers can have the
// the fixed times.
auto& timestepper = process_data->timestepper;
timestepper->addFixedOutputTimes(_output->getFixedOutputTimes());
// Add the fixed times of output to time stepper in order that
// the time stepping is performed and the results are output at
// these times. Note: only the adaptive time steppers can have the
// the fixed times.
auto& timestepper = process_data->timestepper;
timestepper->addFixedOutputTimes(_output->getFixedOutputTimes());
++process_id;
}
++process_id;
}
// init solution storage
......@@ -438,6 +427,22 @@ bool TimeLoop::loop()
_start_time, *_output, &Output::doOutput);
}
}
/*
* TODO:
* Now we have a structure inside the time loop which is very similar to the
* nonlinear solver. And admittedly, the control flow inside the nonlinear
* solver is rather complicated. Maybe in the future con can introduce an
* abstraction that can do both the convergence checks of the coupling loop and
* of the nonlinear solver.
*/
bool TimeLoop::loop()
{
// All _per_process_data share the first process.
bool const is_staggered_coupling =
!isMonolithicProcess(*_per_process_data[0]);
double t = _start_time;
std::size_t accepted_steps = 0;
std::size_t rejected_steps = 0;
......
......@@ -47,6 +47,7 @@ public:
std::unique_ptr<ChemistryLib::PhreeqcIO>&& chemical_system,
const double start_time, const double end_time);
void initialize();
bool loop();
~TimeLoop();
......
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