diff --git a/Applications/CLI/ogs.cpp b/Applications/CLI/ogs.cpp index 3dbb95bfb62d04d1f8beef1a158c63115d1ed1d5..1970b221063df59246f8cb6287c8c61d454d3961 100644 --- a/Applications/CLI/ogs.cpp +++ b/Applications/CLI/ogs.cpp @@ -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 diff --git a/ProcessLib/TimeLoop.cpp b/ProcessLib/TimeLoop.cpp index d11763bfe173240110025c54dec28e0f31e2ec06..8c1c1c019a368f87925943efc6d188031bbb2bd8 100644 --- a/ProcessLib/TimeLoop.cpp +++ b/ProcessLib/TimeLoop.cpp @@ -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; diff --git a/ProcessLib/TimeLoop.h b/ProcessLib/TimeLoop.h index 6d9db035ee9970fdbd12114e554f1c8821cc3aec..4221c2f59900a509af7e8a128484df2e3da5a634 100644 --- a/ProcessLib/TimeLoop.h +++ b/ProcessLib/TimeLoop.h @@ -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();