8#ifndef EXECUTIONRECIPE_H_
9#define EXECUTIONRECIPE_H_
24 std::vector<std::unique_ptr<Coupling>>*
const couplers)
73 void subCouple(
const MInt couplerId,
const MInt step,
const MInt solverId, std::vector<MBool>& solverCompleted) {
74 m_subCouple[couplerId](step, solverId, solverCompleted);
92 MInt solverId = oldSolverId;
95 solverId = it->second;
110 const std::vector<std::unique_ptr<Solver>>*
const m_solvers;
111 const std::vector<std::unique_ptr<Coupling>>*
const m_couplers;
176 const MString propName =
"solverOrder_" + std::to_string(solver);
180 m_solverOrder[step][solver] = (
MBool)Context::getBasicProperty<MInt>(propName, AT_, step);
187 const MString propName =
"couplerOrder_" + std::to_string(coupler);
191 m_couplerOrder[step][coupler] = (
MBool)Context::getBasicProperty<MInt>(propName, AT_, step);
213 m_log <<
" === Execution recipe: call order with " <<
m_maxNoSteps <<
" steps" << std::endl;
216 m_log <<
" " << step;
221 m_log <<
"solver #" << solver <<
": ";
228 m_log <<
"coupler #" << cpl <<
":";
248 for(
MInt i = 0; i < size; i++) {
249 const MInt oldId = Context::getBasicProperty<MInt>(
"swapSolverSolutionStep", AT_, i);
250 const MInt newId = Context::getBasicProperty<MInt>(
"swapSolverSolutionStep", AT_, i + 1);
266 m_solvers->at(solverId)->setSolverStatus(active);
295 return m_couplers->at(couplerId)->subCouple(i, s, sc);
326 [=](
const MInt v,
const MInt s, std::vector<MBool>& sc) {
return m_couplers->at(i)->subCouple(v, s, sc); });
338 if(!solver->isActive()) {
342 solver->startLoadTimer(AT_);
344 solver->stopLoadTimer(AT_);
358 if(!solver->isActive()) {
363 MBool completed =
false;
366 solver->startLoadTimer(AT_);
368 solver->stopLoadTimer(AT_);
398 coupler->startLoadTimer(AT_);
400 coupler->stopLoadTimer(AT_);
412 coupler->startLoadTimer(AT_);
414 coupler->stopLoadTimer(AT_);
427 std::vector<std::unique_ptr<Coupling>>*
const couplers)
443 MBool advanceTimeStep =
false;
449 advanceTimeStep =
true;
463 return advanceTimeStep;
470 MBool completed =
false;
473 std::vector<MBool> solverCompleted(
noSolvers(),
false);
496 coupler->startLoadTimer(AT_);
498 coupler->stopLoadTimer(AT_);
501 completed &= solverCompleted[solverId];
516 std::vector<std::unique_ptr<Coupling>>*
const couplers)
532 MBool advanceTimeStep =
false;
538 advanceTimeStep =
true;
552 return advanceTimeStep;
565 const MInt solverId = solver->solverId();
568 solver->startLoadTimer(AT_);
570 solver->stopLoadTimer(AT_);
574 MBool timeStepCompleted =
false;
577 std::vector<MBool> solverTimeStepCompleted(
noSolvers(),
false);
579 while(!timeStepCompleted) {
580 timeStepCompleted =
true;
584 if(solver->isActive() && !solverTimeStepCompleted[solverId]) {
586 solver->startLoadTimer(AT_);
587 solverTimeStepCompleted[solverId] =
solutionStep(solver->solverId());
588 timeStepCompleted &= solverTimeStepCompleted[solverId];
589 solver->stopLoadTimer(AT_);
594 solver->startLoadTimer(AT_);
597 solver->stopLoadTimer(AT_);
static MInt propertyLength(const MString &name, MInt solverId=m_noSolvers)
Returns the number of elements of a property.
static void assertPropertyLength(const MString &name, const MInt length, const MInt solverId=m_noSolvers)
Assert that the length of a property matches the given length.
static MBool propertyExists(const MString &name, MInt solver=m_noSolvers)
This function checks if a property exists in general.
Base recipe provides public interface to Application.
void setSolverStatus(MInt, MBool)
: Wrapper function to set solvers active or idle
void stopLoadTimer(const MInt solverId)
MBool couplerOrder(const MInt couplerId) const
MBool solutionStep(const MInt solverId)
MBool solverIsActive(const MInt solverId)
void startLoadTimer(const MInt solverId)
virtual void postTimeStep() final
: Calls each solvers postTimeStep - might be empty
virtual void postCouple() final
: Calls each couplers postCouple - might be empty
std::vector< std::function< void(const MInt)> > m_postCouple
std::map< MInt, MInt > m_swapSolverIds
MBool callAdaptation() const
MInt m_maxSolutionIteration
MInt swapedSolverId(const MInt oldSolverId)
std::vector< std::function< MBool()> > m_solutionStep
std::vector< std::function< void()> > m_postStep
void readCallOrder()
: Reads the call order of solvers, couplers and adaptation
virtual void preCouple() final
: Calls each couplers preCouple - might be empty
const std::vector< std::unique_ptr< Coupling > > *const m_couplers
std::vector< std::function< void(const MInt, const MInt, std::vector< MBool > &)> > m_subCouple
std::vector< std::function< void(const MInt)> > m_preCouple
std::vector< std::function< void(const MInt)> > m_preSolutionStep
MBool solverOrder(const MInt solverId) const
std::vector< std::function< void()> > m_preStep
virtual MBool updateCallOrder()
ExecutionRecipe(std::vector< std::unique_ptr< Solver > > *const solvers, std::vector< std::unique_ptr< Coupling > > *const couplers)
const std::vector< std::unique_ptr< Solver > > *const m_solvers
void initFunctionPointers()
: Initialize the vector containing function pointers to preTimeStep, solutionStep and postTimestep as...
std::vector< std::vector< MBool > > m_couplerOrder
std::vector< MBool > m_adaptationOrder
const std::vector< std::unique_ptr< Solver > > * a_solvers() const
void subCouple(const MInt couplerId, const MInt step, const MInt solverId, std::vector< MBool > &solverCompleted)
const std::vector< std::unique_ptr< Coupling > > * a_couplers() const
void preSolutionStep(const MInt solverId, const MInt mode)
virtual void preTimeStep() final
: Calls each solvers preTimeStep - might be empty
MBool postSolutionStep(const MInt solverId)
std::vector< std::vector< MBool > > m_solverOrder
virtual void timeStep()
: Single solver time step function. Calls solutionStep() of the specific solver
void setCouplerStatus(const MInt couplerId, const MBool active)
: Wrapper function to set couplers active or empty
std::vector< std::function< MBool()> > m_postSolutionStep
ExecutionRecipeIntraStepCoupling(std::vector< std::unique_ptr< Solver > > *const solvers, std::vector< std::unique_ptr< Coupling > > *const couplers)
void timeStep() override
: Single solver time step function. Calls solutionStep() of the specific solver
MBool updateCallOrder() override
ExecutionRecipeSolutionIteration(std::vector< std::unique_ptr< Solver > > *const solvers, std::vector< std::unique_ptr< Coupling > > *const couplers)
MBool updateCallOrder() override
void timeStep() override
: Single solver time step function. Calls solutionStep() of the specific solver
std::basic_string< char > MString