https://mooseframework.inl.gov
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | Private Attributes | List of all members
ActionWarehouse Class Reference

Storage for action instances. More...

#include <ActionWarehouse.h>

Inheritance diagram for ActionWarehouse:
[legend]

Public Member Functions

 ActionWarehouse (MooseApp &app, Syntax &syntax, ActionFactory &factory)
 
 ~ActionWarehouse ()
 
void build ()
 Builds all auto-buildable tasks. More...
 
void clear ()
 This method deletes all of the Actions in the warehouse. More...
 
bool empty () const
 returns a Boolean indicating whether the warehouse is empty or not. More...
 
void addActionBlock (std::shared_ptr< Action > blk)
 This method add an Action instance to the warehouse. More...
 
void checkUnsatisfiedActions () const
 This method checks the actions stored in the warehouse against the list of required registered actions to see if all of them have been satisfied. More...
 
void printActionDependencySets () const
 This method is used only during debugging when show_actions is set to true. More...
 
void printInputFile (std::ostream &out)
 This method uses the Actions in the warehouse to reproduce the input file. More...
 
const std::vector< std::shared_ptr< Action > > & allActionBlocks () const
 Returns a reference to all of the actions. More...
 
const std::list< Action * > & getActionListByName (const std::string &task) const
 Retrieve a constant list of Action pointers associated with the passed in task. More...
 
template<class T >
const T & getAction (const std::string &name) const
 Retrieve an action with its name and the desired type. More...
 
template<class T >
T & getAction (const std::string &name)
 
template<class T >
T * getPhysics (const std::string &name) const
 Retrieve a Physics with its name and the desired type. More...
 
template<class T >
std::vector< const T * > getActions ()
 Retrieve all actions in a specific type ordered by their names. More...
 
template<class T >
std::vector< T * > getPhysics ()
 Retrieve all Physics with a specific type ordered by their names. More...
 
template<class T >
const T * getActionByTask (const std::string &task)
 Retrieve the action on a specific task with its type. More...
 
void setFinalTask (const std::string &task)
 
bool hasActions (const std::string &task) const
 Check if Actions associated with passed in task exist. More...
 
void executeAllActions ()
 This method loops over all actions in the warehouse and executes them. More...
 
void executeActionsWithAction (const std::string &task_name)
 This method executes only the actions in the warehouse that satisfy the task passed in. More...
 
void showActionDependencies (bool state=true)
 This method sets a Boolean which is used to print information about action dependencies before various warehouse operations during the problem setup phase. More...
 
void showActions (bool state=true)
 This method sets a Boolean which is used to show information about action execution of various warehouse operations during the problem setup phase. More...
 
void showParser (bool state=true)
 This method sets a Boolean which is used to show debugging information when actions are inserted in the warehouse by the parser. More...
 
Syntaxsyntax ()
 
std::shared_ptr< MooseMesh > & mesh ()
 
const std::shared_ptr< MooseMesh > & getMesh () const
 
std::shared_ptr< MooseMesh > & displacedMesh ()
 
const std::shared_ptr< MooseMesh > & getDisplacedMesh () const
 
std::shared_ptr< FEProblemBase > & problemBase ()
 
std::shared_ptr< FEProblemproblem ()
 
MooseAppmooseApp ()
 
const std::string & getMooseAppName ()
 
const std::string & getCurrentTaskName () const
 
const ActiongetCurrentAction () const
 
std::string getCurrentActionName () const
 
bool hasTask (const std::string &task) const
 
bool isTaskComplete (const std::string &task) const
 
ActionIterator actionBlocksWithActionBegin (const std::string &task)
 Iterators to the Actions in the warehouse. More...
 
ActionIterator actionBlocksWithActionEnd (const std::string &task)
 

Public Attributes

const ConsoleStream _console
 An instance of helper class to write streams to the Console objects. More...
 

Protected Member Functions

void buildBuildableActions (const std::string &task)
 This method auto-builds all Actions that needs to be built and adds them to ActionWarehouse. More...
 
std::vector< UserObjectName > getUserObjectParamDependencies (const InputParameters &params) const
 
void sortUserObjectActions (std::list< Action *> &actions) const
 Reorder the UserObject-constructing actions actions so that a UserObject that references another (through a UserObjectName parameter) is constructed after the one it references. More...
 

Protected Attributes

std::vector< std::shared_ptr< Action > > _all_ptrs
 
MooseApp_app
 The MooseApp this Warehouse is associated with. More...
 
Syntax_syntax
 Reference to a "syntax" of actions. More...
 
ActionFactory_action_factory
 The Factory that builds Actions. More...
 
std::map< std::string, std::list< Action * > > _action_blocks
 Pointers to the actual parsed input file blocks. More...
 
std::vector< std::string > _ordered_names
 The container that holds the sorted action names from the DependencyResolver. More...
 
std::set< std::string > _completed_tasks
 The completed tasks. More...
 
std::set< std::string > _unsatisfied_dependencies
 Use to store the current list of unsatisfied dependencies. More...
 
bool _generator_valid
 Flag to indicate whether or not there is an active iterator on this class. More...
 
bool _show_action_dependencies
 Whether or not the action warehouse prints the action dependency information. More...
 
bool _show_actions
 Whether or not the action warehouse prints the action execution information. More...
 
bool _show_parser
 Whether or not to print messages when actions are inserted in the warehouse by the parser. More...
 
std::string _current_task
 
Action_current_action
 
std::shared_ptr< MooseMesh_mesh
 Mesh class. More...
 
std::shared_ptr< MooseMesh_displaced_mesh
 Possible mesh for displaced problem. More...
 
std::shared_ptr< FEProblemBase_problem
 Problem class. More...
 

Private Attributes

std::string _final_task
 Last task to run before (optional) early termination - blank means no early termination. More...
 
const std::list< Action * > _empty_action_list
 
std::mutex _completed_tasks_mutex
 Mutex for preventing read/write races for _completed_tasks. More...
 

Detailed Description

Storage for action instances.

Definition at line 35 of file ActionWarehouse.h.

Constructor & Destructor Documentation

◆ ActionWarehouse()

ActionWarehouse::ActionWarehouse ( MooseApp app,
Syntax syntax,
ActionFactory factory 
)

Definition at line 109 of file ActionWarehouse.C.

110  : ConsoleStreamInterface(app),
111  _app(app),
112  _syntax(syntax),
113  _action_factory(factory),
114  _generator_valid(false),
116  _show_actions(false),
117  _show_parser(false),
118  _current_action(nullptr),
119  _mesh(nullptr),
120  _displaced_mesh(nullptr)
121 {
122 }
bool _show_parser
Whether or not to print messages when actions are inserted in the warehouse by the parser...
Syntax & _syntax
Reference to a "syntax" of actions.
ConsoleStreamInterface(MooseApp &app)
A class for providing a helper stream object for writting message to all the Output objects...
std::shared_ptr< MooseMesh > _displaced_mesh
Possible mesh for displaced problem.
bool _generator_valid
Flag to indicate whether or not there is an active iterator on this class.
std::shared_ptr< MooseMesh > _mesh
Mesh class.
bool _show_actions
Whether or not the action warehouse prints the action execution information.
MooseApp & _app
The MooseApp this Warehouse is associated with.
Action * _current_action
bool _show_action_dependencies
Whether or not the action warehouse prints the action dependency information.
ActionFactory & _action_factory
The Factory that builds Actions.

◆ ~ActionWarehouse()

ActionWarehouse::~ActionWarehouse ( )

Definition at line 124 of file ActionWarehouse.C.

124 {}

Member Function Documentation

◆ actionBlocksWithActionBegin()

ActionIterator ActionWarehouse::actionBlocksWithActionBegin ( const std::string &  task)

Iterators to the Actions in the warehouse.

Iterators should always be used when executing Actions to capture dynamically added Actions (meta-Actions). Meta-Actions are allowed to create and add additional Actions to the warehouse on the fly. Those Actions will fire as long as their associated task hasn't already passed (i.e. matches or is later).

Definition at line 257 of file ActionWarehouse.C.

Referenced by SetupDampersAction::act(), executeActionsWithAction(), and CommonOutputAction::hasConsole().

258 {
259  return _action_blocks[task].begin();
260 }
std::map< std::string, std::list< Action * > > _action_blocks
Pointers to the actual parsed input file blocks.

◆ actionBlocksWithActionEnd()

ActionIterator ActionWarehouse::actionBlocksWithActionEnd ( const std::string &  task)

Definition at line 263 of file ActionWarehouse.C.

Referenced by SetupDampersAction::act(), executeActionsWithAction(), and CommonOutputAction::hasConsole().

264 {
265  return _action_blocks[task].end();
266 }
std::map< std::string, std::list< Action * > > _action_blocks
Pointers to the actual parsed input file blocks.

◆ addActionBlock()

void ActionWarehouse::addActionBlock ( std::shared_ptr< Action blk)

This method add an Action instance to the warehouse.

Note: This routine uses the XTerm colors directly which is not advised for general purpose output coloring. Most users should prefer using Problem::colorText() which respects the "color_output" option for terminals that do not support coloring. Since this routine is intended for debugging only and runs before several objects exist in the system, we are just using the constants directly.

We need to see if the current Action satisfies multiple tasks. There are a few cases to consider:

  1. The current Action is registered with multiple syntax blocks. In this case we can only use the current instance to satisfy the specific task listed for this syntax block. We can detect this case by inspecting whether it has a "specific task name" set in the Action instance.
  2. This action does not have a valid "registered identifier" set in the Action instance. This means that this Action was not built by the Parser. It was most likely created through a Meta-Action (See Case 3 for exception). In this case, the ActionFactory itself would have already set the task it found from the build info used to construct the Action so we'd arbitrarily satisfy a single task in this case.
  3. The current Action is registered with only a single syntax block. In this case we can simply re-use the current instance to act and satisfy all registered tasks. This is the normal case where we have a Parser-built Action that does not have a specific task name to satisfy. We will use the Action "type" to retrieve the list of tasks that this Action may satisfy.

Definition at line 161 of file ActionWarehouse.C.

Referenced by AddActionComponentAction::act(), CreateMeshSetupActionsForComponents::act(), buildBuildableActions(), CommonOutputAction::create(), AddVariableAction::createInitialConditionAction(), MooseApp::createMinimalApp(), DumpObjectsProblem::DumpObjectsProblem(), CreateExecutionerAction::setupAutoPreconditioning(), ReadExecutorParamsAction::setupAutoPreconditioning(), and Moose::Builder::walkRaw().

162 {
170  std::string registered_identifier =
171  action->parameters().get<std::string>("registered_identifier");
172  std::set<std::string> tasks;
173 
174  if (_show_parser)
175  Moose::err << COLOR_DEFAULT << "Parsing Syntax: " << COLOR_GREEN << action->name()
176  << '\n'
177  << COLOR_DEFAULT << "Building Action: " << COLOR_DEFAULT << action->type()
178  << '\n'
179  << COLOR_DEFAULT << "Registered Identifier: " << COLOR_GREEN << registered_identifier
180  << '\n'
181  << COLOR_DEFAULT << "Specific Task: " << COLOR_CYAN
182  << action->specificTaskName() << std::endl;
183 
204  if (action->specificTaskName() != "") // Case 1
205  tasks.insert(action->specificTaskName());
206  else if (registered_identifier == "" &&
207  _syntax.getNonDeprecatedSyntaxByAction(action->type()).size() > 1) // Case 2
208  {
209  std::set<std::string> local_tasks = action->getAllTasks();
210  mooseAssert(local_tasks.size() == 1, "More than one task inside of the " << action->name());
211  tasks.insert(*local_tasks.begin());
212  }
213  else // Case 3
214  tasks = _action_factory.getTasksByAction(action->type());
215 
216  // TODO: Now we need to weed out the double registrations!
217  for (const auto & task : tasks)
218  {
219  // Some error checking
220  if (!_syntax.hasTask(task))
221  mooseError("A(n) ", task, " is not a registered task");
222 
223  // Make sure that the ObjectAction task and Action task are consistent
224  // otherwise that means that is action was built by the wrong type
225  std::shared_ptr<MooseObjectAction> moa = std::dynamic_pointer_cast<MooseObjectAction>(action);
226  if (moa.get())
227  {
228  const InputParameters & mparams = moa->getObjectParams();
229 
230  if (mparams.hasBase())
231  {
232  const std::string & base = mparams.getBase();
233  if (!_syntax.verifyMooseObjectTask(base, task))
234  mooseError("Task ", task, " is not registered to build ", base, " derived objects");
235  }
236  else
237  mooseError("Unable to locate registered base parameter for ", moa->getMooseObjectType());
238  }
239 
240  // Add the current task to current action
241  action->appendTask(task);
242 
243  if (_show_parser)
244  Moose::err << COLOR_YELLOW << "Adding Action: " << COLOR_DEFAULT << action->type()
245  << " (" << COLOR_YELLOW << task << COLOR_DEFAULT << ")" << std::endl;
246 
247  // Add it to the warehouse
248  _action_blocks[task].push_back(action.get());
249  }
250  _all_ptrs.push_back(action);
251 
252  if (_show_parser)
253  Moose::err << std::endl;
254 }
bool hasTask(const std::string &task) const
Returns a Boolean indicating whether or not a task is registered with the syntax object.
Definition: Syntax.C:125
bool _show_parser
Whether or not to print messages when actions are inserted in the warehouse by the parser...
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
Syntax & _syntax
Reference to a "syntax" of actions.
std::set< std::string > getTasksByAction(const std::string &action) const
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
bool hasBase() const
std::unique_ptr< T_DEST, T_DELETER > dynamic_pointer_cast(std::unique_ptr< T_SRC, T_DELETER > &src)
These are reworked from https://stackoverflow.com/a/11003103.
const std::string & getBase() const
std::vector< std::string > getNonDeprecatedSyntaxByAction(const std::string &action, const std::string &task="")
Retrieve the non-deprecated syntax associated with the passed in action type string.
Definition: Syntax.C:237
std::map< std::string, std::list< Action * > > _action_blocks
Pointers to the actual parsed input file blocks.
std::vector< std::shared_ptr< Action > > _all_ptrs
bool verifyMooseObjectTask(const std::string &base, const std::string &task) const
Returns a Boolean indicating whether a task is associated with on of the MOOSE pluggable systems (BAS...
Definition: Syntax.C:334
ActionFactory & _action_factory
The Factory that builds Actions.

◆ allActionBlocks()

const std::vector< std::shared_ptr< Action > > & ActionWarehouse::allActionBlocks ( ) const

Returns a reference to all of the actions.

Definition at line 269 of file ActionWarehouse.C.

Referenced by AddRelationshipManager::act().

270 {
271  return _all_ptrs;
272 }
std::vector< std::shared_ptr< Action > > _all_ptrs

◆ build()

void ActionWarehouse::build ( )

Builds all auto-buildable tasks.

This method is typically called after the Parser has created Actions based on an input file.

Definition at line 135 of file ActionWarehouse.C.

Referenced by MooseApp::createMinimalApp(), and MooseApp::setupOptions().

136 {
138  for (const auto & name : _ordered_names)
139  buildBuildableActions(name);
140 }
Syntax & _syntax
Reference to a "syntax" of actions.
const std::vector< std::string > & getSortedTask()
Get a list of serialized tasks in a correct dependency order.
Definition: Syntax.C:105
std::vector< std::string > _ordered_names
The container that holds the sorted action names from the DependencyResolver.
void buildBuildableActions(const std::string &task)
This method auto-builds all Actions that needs to be built and adds them to ActionWarehouse.

◆ buildBuildableActions()

void ActionWarehouse::buildBuildableActions ( const std::string &  task)
protected

This method auto-builds all Actions that needs to be built and adds them to ActionWarehouse.

An Action needs to be built if it is associated with a task that is marked as required and all of it's parameters are valid (are not required or have default values supplied).

Parameters
taskThe name of the task to find and build Actions for.

Definition at line 292 of file ActionWarehouse.C.

Referenced by build().

293 {
294  if (_syntax.shouldAutoBuild(task) && _action_blocks[task].empty())
295  {
296  bool ret_value = false;
297  auto it_pair = _action_factory.getActionsByTask(task);
298  for (const auto & action_pair : as_range(it_pair))
299  {
300  const auto & type = action_pair.second;
302  params.set<ActionWarehouse *>("awh") = this;
303 
304  std::string name = "auto_" + type;
305  std::transform(
306  name.begin(), name.end(), name.begin(), [](const auto v) { return std::tolower(v); });
307 
308  if (params.areAllRequiredParamsValid())
309  {
310  params.set<std::string>("registered_identifier") = "(AutoBuilt)";
311  addActionBlock(_action_factory.create(type, name, params));
312  ret_value = true;
313  }
314  }
315 
316  if (!ret_value)
317  _unsatisfied_dependencies.insert(task);
318  }
319 }
std::string name(const ElemQuality q)
InputParameters getValidParams(const std::string &name)
Definition: ActionFactory.C:94
Syntax & _syntax
Reference to a "syntax" of actions.
std::pair< std::multimap< std::string, std::string >::const_iterator, std::multimap< std::string, std::string >::const_iterator > getActionsByTask(const std::string &task) const
Returns begin and end iterators in a multimap from tasks to actions names.
T & set(const std::string &name, bool quiet_mode=false)
Returns a writable reference to the named parameters.
Storage for action instances.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
void addActionBlock(std::shared_ptr< Action > blk)
This method add an Action instance to the warehouse.
std::shared_ptr< Action > create(const std::string &action, const std::string &action_name, InputParameters &parameters)
Definition: ActionFactory.C:40
bool shouldAutoBuild(const std::string &task) const
Returns a Boolean indicating whether MOOSE should attempt to automatically create an Action to satisf...
Definition: Syntax.C:138
bool areAllRequiredParamsValid() const
This method returns true if all of the parameters in this object are valid (i.e.
SimpleRange< IndexType > as_range(const std::pair< IndexType, IndexType > &p)
std::map< std::string, std::list< Action * > > _action_blocks
Pointers to the actual parsed input file blocks.
std::set< std::string > _unsatisfied_dependencies
Use to store the current list of unsatisfied dependencies.
ActionFactory & _action_factory
The Factory that builds Actions.

◆ checkUnsatisfiedActions()

void ActionWarehouse::checkUnsatisfiedActions ( ) const

This method checks the actions stored in the warehouse against the list of required registered actions to see if all of them have been satisfied.

It should be called before running a MOOSE problem

Definition at line 322 of file ActionWarehouse.C.

Referenced by CheckIntegrityAction::act().

323 {
324  std::stringstream oss;
325  bool empty = true;
326 
327  for (const auto & udep : _unsatisfied_dependencies)
328  {
329  if (_action_blocks.find(udep) == _action_blocks.end())
330  {
331  if (empty)
332  empty = false;
333  else
334  oss << " ";
335  oss << udep;
336  }
337  }
338 
339  if (!empty)
340  mooseError(
341  std::string(
342  "The following unsatisfied actions where found while setting up the MOOSE problem:\n") +
343  oss.str() + "\n");
344 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
bool empty() const
returns a Boolean indicating whether the warehouse is empty or not.
std::map< std::string, std::list< Action * > > _action_blocks
Pointers to the actual parsed input file blocks.
std::set< std::string > _unsatisfied_dependencies
Use to store the current list of unsatisfied dependencies.

◆ clear()

void ActionWarehouse::clear ( )

This method deletes all of the Actions in the warehouse.

Definition at line 143 of file ActionWarehouse.C.

144 {
145  for (auto & ptr : _all_ptrs)
146  ptr.reset();
147 
148  _action_blocks.clear();
149  _generator_valid = false;
150 
151  // Due to the way ActionWarehouse is cleaned up (see MooseApp's
152  // destructor) we must guarantee that ActionWarehouse::clear()
153  // releases all the resources which have to be released _before_ the
154  // _comm object owned by the MooseApp is destroyed.
155  _problem.reset();
156  _displaced_mesh.reset();
157  _mesh.reset();
158 }
std::map< std::string, std::list< Action * > > _action_blocks
Pointers to the actual parsed input file blocks.
std::shared_ptr< MooseMesh > _displaced_mesh
Possible mesh for displaced problem.
bool _generator_valid
Flag to indicate whether or not there is an active iterator on this class.
std::vector< std::shared_ptr< Action > > _all_ptrs
std::shared_ptr< FEProblemBase > _problem
Problem class.
std::shared_ptr< MooseMesh > _mesh
Mesh class.

◆ displacedMesh()

std::shared_ptr<MooseMesh>& ActionWarehouse::displacedMesh ( )
inline

Definition at line 283 of file ActionWarehouse.h.

Referenced by MooseApp::attachRelationshipManagers(), and MooseApp::removeRelationshipManager().

283 { return _displaced_mesh; }
std::shared_ptr< MooseMesh > _displaced_mesh
Possible mesh for displaced problem.

◆ empty()

bool ActionWarehouse::empty ( ) const
inline

returns a Boolean indicating whether the warehouse is empty or not.

Definition at line 55 of file ActionWarehouse.h.

Referenced by checkUnsatisfiedActions().

55 { return _action_blocks.empty(); }
std::map< std::string, std::list< Action * > > _action_blocks
Pointers to the actual parsed input file blocks.

◆ executeActionsWithAction()

void ActionWarehouse::executeActionsWithAction ( const std::string &  task_name)

This method executes only the actions in the warehouse that satisfy the task passed in.

Definition at line 452 of file ActionWarehouse.C.

Referenced by executeAllActions().

453 {
454  // Set the current task name
455  _current_task = task;
456 
457  // UserObjects may reference other UserObjects in their constructors (e.g. through a
458  // UserObjectName parameter). Construct them in dependency order so the input file does not have
459  // to declare a referenced UserObject before the UserObject that uses it.
460  if (task == "add_user_object")
462 
463  for (auto it = actionBlocksWithActionBegin(task); it != actionBlocksWithActionEnd(task); ++it)
464  {
465  _current_action = *it;
466 
467  if (_show_actions)
468  {
469  MemoryUtils::Stats stats;
471  auto usage =
473  _console << "[DBG][ACT] "
474  << "TASK (" << COLOR_YELLOW << std::setw(24) << task << COLOR_DEFAULT << ") "
475  << "TYPE (" << COLOR_YELLOW << std::setw(32) << _current_action->type()
476  << COLOR_DEFAULT << ") "
477  << "NAME (" << COLOR_YELLOW << std::setw(16) << _current_action->name()
478  << COLOR_DEFAULT << ") Memory usage " << usage << "MB" << std::endl;
479  }
480 
482  }
483 
484  _current_action = nullptr;
485 }
bool getMemoryStats(Stats &stats)
get all memory stats for the current process stats The Stats object to fill with the data ...
Definition: MemoryUtils.C:79
std::size_t _physical_memory
Definition: MemoryUtils.h:23
const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:103
void usage(const std::string &progName)
const std::string & type() const
Get the type of this class.
Definition: MooseBase.h:93
std::map< std::string, std::list< Action * > > _action_blocks
Pointers to the actual parsed input file blocks.
bool _show_actions
Whether or not the action warehouse prints the action execution information.
void timedAct()
The method called externally that causes the action to act()
Definition: Action.C:76
void sortUserObjectActions(std::list< Action *> &actions) const
Reorder the UserObject-constructing actions actions so that a UserObject that references another (thr...
ActionIterator actionBlocksWithActionEnd(const std::string &task)
Action * _current_action
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
ActionIterator actionBlocksWithActionBegin(const std::string &task)
Iterators to the Actions in the warehouse.
std::size_t convertBytes(std::size_t bytes, MemUnits unit)
convert bytes to selected unit prefix
Definition: MemoryUtils.C:174
std::string _current_task

◆ executeAllActions()

void ActionWarehouse::executeAllActions ( )

This method loops over all actions in the warehouse and executes them.

Meta-actions may add new actions to the warehouse on the fly and they will still be executed in order

Definition at line 419 of file ActionWarehouse.C.

Referenced by MooseApp::runInputFile().

420 {
421  _completed_tasks.clear();
422 
424  {
425  _console << "[DBG][ACT] Action Dependency Sets:\n";
427 
428  _console << "\n[DBG][ACT] Executing actions:" << std::endl;
429  }
430 
431  for (const auto & task : _ordered_names)
432  {
434  std::scoped_lock lock(_completed_tasks_mutex);
435  _completed_tasks.insert(task);
436  if (_final_task != "" && task == _final_task)
437  break;
438  }
439 
440  if (_show_actions)
441  {
442  MemoryUtils::Stats stats;
444  auto usage =
446  _console << "[DBG][ACT] Finished executing all actions with memory usage " << usage << "MB\n"
447  << std::endl;
448  }
449 }
void executeActionsWithAction(const std::string &task_name)
This method executes only the actions in the warehouse that satisfy the task passed in...
bool getMemoryStats(Stats &stats)
get all memory stats for the current process stats The Stats object to fill with the data ...
Definition: MemoryUtils.C:79
std::size_t _physical_memory
Definition: MemoryUtils.h:23
void printActionDependencySets() const
This method is used only during debugging when show_actions is set to true.
std::string _final_task
Last task to run before (optional) early termination - blank means no early termination.
std::vector< std::string > _ordered_names
The container that holds the sorted action names from the DependencyResolver.
std::set< std::string > _completed_tasks
The completed tasks.
std::mutex _completed_tasks_mutex
Mutex for preventing read/write races for _completed_tasks.
void usage(const std::string &progName)
bool _show_actions
Whether or not the action warehouse prints the action execution information.
bool _show_action_dependencies
Whether or not the action warehouse prints the action dependency information.
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.
std::size_t convertBytes(std::size_t bytes, MemUnits unit)
convert bytes to selected unit prefix
Definition: MemoryUtils.C:174

◆ getAction() [1/2]

template<class T >
const T& ActionWarehouse::getAction ( const std::string &  name) const
inline

Retrieve an action with its name and the desired type.

Parameters
nameThe action name.

Definition at line 111 of file ActionWarehouse.h.

Referenced by ComponentJunction::addMeshGenerators(), and PhysicsBase::getActionComponent().

112  {
113  typename std::shared_ptr<T> p;
114  for (auto act_ptr : _all_ptrs)
115  {
116  if (act_ptr->name() == name)
117  {
118  p = std::dynamic_pointer_cast<T>(act_ptr);
119  if (p)
120  break;
121  }
122  }
123  if (!p)
124  {
125  std::vector<std::string> all_names;
126  for (auto act_ptr : _all_ptrs)
127  if (!act_ptr->name().empty())
128  all_names.push_back(act_ptr->name());
129  else
130  all_names.push_back("unnamed");
131  mooseError("Action with name '",
132  name,
133  "' does not exist.\n These are the Actions that do exist:",
134  Moose::stringify(all_names));
135  }
136  return *p;
137  }
std::string name(const ElemQuality q)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
std::unique_ptr< T_DEST, T_DELETER > dynamic_pointer_cast(std::unique_ptr< T_SRC, T_DELETER > &src)
These are reworked from https://stackoverflow.com/a/11003103.
std::string stringify(const T &t)
conversion to string
Definition: Conversion.h:64
std::vector< std::shared_ptr< Action > > _all_ptrs

◆ getAction() [2/2]

template<class T >
T& ActionWarehouse::getAction ( const std::string &  name)
inline

Definition at line 139 of file ActionWarehouse.h.

140  {
141  return const_cast<T &>(static_cast<const ActionWarehouse *>(this)->getAction<T>(name));
142  }
Storage for action instances.

◆ getActionByTask()

template<class T >
const T* ActionWarehouse::getActionByTask ( const std::string &  task)
inline

Retrieve the action on a specific task with its type.

Error will be thrown if more than one actions are found.

Parameters
taskThe task name.
Returns
The action pointer. Null means that such an action does not exist.

Definition at line 207 of file ActionWarehouse.h.

Referenced by CreateProblemDefaultAction::act().

208  {
209  const auto it = _action_blocks.find(task);
210  if (it == _action_blocks.end())
211  return nullptr;
212 
213  T * p = nullptr;
214  for (const auto & action : it->second)
215  {
216  T * tp = dynamic_cast<T *>(action);
217  if (tp)
218  {
219  if (p)
220  mooseError("More than one actions have been detected in getActionByTask for the task '",
221  task,
222  "' in the app '",
223  getMooseAppName(),
224  "'");
225  else
226  p = tp;
227  }
228  }
229  return p;
230  }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
const std::string & getMooseAppName()
std::map< std::string, std::list< Action * > > _action_blocks
Pointers to the actual parsed input file blocks.

◆ getActionListByName()

const std::list< Action * > & ActionWarehouse::getActionListByName ( const std::string &  task) const

Retrieve a constant list of Action pointers associated with the passed in task.

Empty list will be returned if no actions are associated with the task.

Definition at line 275 of file ActionWarehouse.C.

Referenced by ElementIDOutputAction::act(), SetupMeshAction::act(), MeshOnlyAction::act(), SetupTimeStepperAction::act(), MaterialOutputAction::act(), MooseApp::getCheckpointDirectories(), and OutputWarehouse::getOutputNames().

276 {
277  const auto it = _action_blocks.find(task);
278  if (it == _action_blocks.end())
279  return _empty_action_list;
280  else
281  return it->second;
282 }
std::map< std::string, std::list< Action * > > _action_blocks
Pointers to the actual parsed input file blocks.
const std::list< Action * > _empty_action_list

◆ getActions()

template<class T >
std::vector<const T *> ActionWarehouse::getActions ( )
inline

Retrieve all actions in a specific type ordered by their names.

Definition at line 165 of file ActionWarehouse.h.

Referenced by CombineComponentsMeshes::act(), Console::Console(), NEML2Action::getCommonAction(), PhysicsBase::getCoupledPhysics(), JSONOutput::outputReporters(), MooseApp::setupOptions(), and PetscOutput::solveSetup().

166  {
167  // we need to create the map first to ensure that all actions in the map are unique
168  // and the actions are sorted by their names
169  typename std::map<std::string, const std::shared_ptr<T>> actions;
170  for (auto act_ptr : _all_ptrs)
171  {
172  auto p = std::dynamic_pointer_cast<T>(act_ptr);
173  if (p)
174  actions.insert(std::make_pair(act_ptr->name(), p));
175  }
176  // construct the vector from the map entries
177  std::vector<const T *> action_vector;
178  for (auto & pair : actions)
179  action_vector.push_back(pair.second.get());
180  return action_vector;
181  }
std::unique_ptr< T_DEST, T_DELETER > dynamic_pointer_cast(std::unique_ptr< T_SRC, T_DELETER > &src)
These are reworked from https://stackoverflow.com/a/11003103.
std::vector< std::shared_ptr< Action > > _all_ptrs

◆ getCurrentAction()

const Action* ActionWarehouse::getCurrentAction ( ) const
inline
Returns
The current action that is running, if any

Definition at line 295 of file ActionWarehouse.h.

Referenced by MooseApp::getCurrentActionHitNode(), and getCurrentActionName().

295 { return _current_action; }
Action * _current_action

◆ getCurrentActionName()

std::string ActionWarehouse::getCurrentActionName ( ) const
Returns
The name of the current action that is running

Definition at line 543 of file ActionWarehouse.C.

Referenced by DumpObjectsProblem::dumpObjectHelper(), and DumpObjectsProblem::dumpVariableHelper().

544 {
545  return getCurrentAction()->parameters().getHitNode()->fullpath();
546 }
const hit::Node * getHitNode(const std::string &param) const
const Action * getCurrentAction() const
const InputParameters & parameters() const
Get the parameters of the object.
Definition: MooseBase.h:131

◆ getCurrentTaskName()

const std::string& ActionWarehouse::getCurrentTaskName ( ) const
inline

◆ getDisplacedMesh()

const std::shared_ptr<MooseMesh>& ActionWarehouse::getDisplacedMesh ( ) const
inline

Definition at line 284 of file ActionWarehouse.h.

Referenced by MooseApp::getRelationshipManagerInfo().

284 { return _displaced_mesh; }
std::shared_ptr< MooseMesh > _displaced_mesh
Possible mesh for displaced problem.

◆ getMesh()

const std::shared_ptr<MooseMesh>& ActionWarehouse::getMesh ( ) const
inline

◆ getMooseAppName()

const std::string & ActionWarehouse::getMooseAppName ( )

Definition at line 549 of file ActionWarehouse.C.

Referenced by getActionByTask().

550 {
551  return _app.name();
552 }
const std::string & name() const
Get the name of the class.
Definition: MooseBase.h:103
MooseApp & _app
The MooseApp this Warehouse is associated with.

◆ getPhysics() [1/2]

template<class T >
T* ActionWarehouse::getPhysics ( const std::string &  name) const
inline

Retrieve a Physics with its name and the desired type.

Parameters
nameThe action name.

Definition at line 149 of file ActionWarehouse.h.

Referenced by ComponentPhysicsInterface::physicsExists().

150  {
151  auto physics = const_cast<T *>(&getAction<T>(name));
152  if (!dynamic_cast<const PhysicsBase *>(physics))
153  mooseError("The Physics requested of type '",
154  MooseUtils::prettyCppType<T>(),
155  "' and name '",
156  name,
157  "' is not derived from the PhysicsBase class");
158  return physics;
159  }
std::string name(const ElemQuality q)
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311

◆ getPhysics() [2/2]

template<class T >
std::vector<T *> ActionWarehouse::getPhysics ( )
inline

Retrieve all Physics with a specific type ordered by their names.

Definition at line 187 of file ActionWarehouse.h.

188  {
189  const auto physics_vector = getActions<T>();
190  for (const auto phys_ptr : physics_vector)
191  if (!dynamic_cast<const PhysicsBase *>(phys_ptr))
192  mooseError("The Physics requested of type '",
193  MooseUtils::prettyCppType<T>(),
194  "' and name '",
195  phys_ptr->name(),
196  "' is not derived from the PhysicsBase class");
197  return physics_vector;
198  }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311

◆ getUserObjectParamDependencies()

std::vector< UserObjectName > ActionWarehouse::getUserObjectParamDependencies ( const InputParameters params) const
protected
Returns
The names of the UserObjects referenced by params through its UserObjectName (or std::vector<UserObjectName>) parameters. Mirrors MeshGeneratorSystem::getMeshGeneratorParamDependencies.

Definition at line 31 of file ActionWarehouse.C.

Referenced by sortUserObjectActions().

32 {
33  std::vector<UserObjectName> dependencies;
34  for (const auto & [_, param] : params)
35  {
36  if (const auto dependency =
37  dynamic_cast<const libMesh::Parameters::Parameter<UserObjectName> *>(param.get()))
38  {
39  const auto & uo_name = dependency->get();
40  if (!uo_name.empty())
41  dependencies.push_back(uo_name);
42  }
43  else if (const auto vector_dependency =
45  param.get()))
46  for (const auto & uo_name : vector_dependency->get())
47  if (!uo_name.empty())
48  dependencies.push_back(uo_name);
49  }
50  return dependencies;
51 }

◆ hasActions()

bool ActionWarehouse::hasActions ( const std::string &  task) const

Check if Actions associated with passed in task exist.

Definition at line 285 of file ActionWarehouse.C.

Referenced by ElementIDOutputAction::act(), ReadExecutorParamsAction::act(), CreateExecutionerAction::act(), CreateMeshSetupActionsForComponents::act(), MaterialOutputAction::act(), and OutputWarehouse::getOutputNames().

286 {
287  auto it = _action_blocks.find(task);
288  return it != _action_blocks.end() && !it->second.empty();
289 }
std::map< std::string, std::list< Action * > > _action_blocks
Pointers to the actual parsed input file blocks.

◆ hasTask()

bool ActionWarehouse::hasTask ( const std::string &  task) const
Returns
True if a task with the name task is registered.

Definition at line 555 of file ActionWarehouse.C.

Referenced by AddActionComponentAction::AddActionComponentAction(), isTaskComplete(), and OutputWarehouse::mooseConsole().

556 {
557  return _action_factory.isRegisteredTask(task);
558 }
bool isRegisteredTask(const std::string &task) const
Whether or not a task with the name task is registered.
ActionFactory & _action_factory
The Factory that builds Actions.

◆ isTaskComplete()

bool ActionWarehouse::isTaskComplete ( const std::string &  task) const
Returns
True if the registered task with the name task is complete.

Definition at line 561 of file ActionWarehouse.C.

Referenced by OutputWarehouse::mooseConsole(), PostprocessorInterface::postprocessorsAdded(), ReporterInterface::reportersAdded(), and VectorPostprocessorInterface::vectorPostprocessorsAdded().

562 {
563  if (!hasTask(task))
564  mooseError("\"", task, "\" is not a registered task.");
565  std::scoped_lock lock(_completed_tasks_mutex);
566  return _completed_tasks.count(task);
567 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
bool hasTask(const std::string &task) const
std::set< std::string > _completed_tasks
The completed tasks.
std::mutex _completed_tasks_mutex
Mutex for preventing read/write races for _completed_tasks.

◆ mesh()

std::shared_ptr<MooseMesh>& ActionWarehouse::mesh ( )
inline

Definition at line 280 of file ActionWarehouse.h.

Referenced by MeshOnlyAction::act(), SplitMeshAction::act(), MooseApp::attachRelationshipManagers(), and MooseApp::removeRelationshipManager().

280 { return _mesh; }
std::shared_ptr< MooseMesh > _mesh
Mesh class.

◆ mooseApp()

MooseApp& ActionWarehouse::mooseApp ( )
inline

Definition at line 288 of file ActionWarehouse.h.

Referenced by ExodusFormatter::printInputFile(), and SetupDebugAction::SetupDebugAction().

288 { return _app; }
MooseApp & _app
The MooseApp this Warehouse is associated with.

◆ printActionDependencySets()

void ActionWarehouse::printActionDependencySets ( ) const

This method is used only during debugging when show_actions is set to true.

It prints all of the actions sets in the correct dependency resolved order with all of the Action objects inside.

Note: This routine uses the XTerm colors directly which is not advised for general purpose output coloring. Most users should prefer using Problem::colorText() which respects the "color_output" option for terminals that do not support coloring. Since this routine is intended for debugging only and runs before several objects exist in the system, we are just using the constants directly.

Definition at line 347 of file ActionWarehouse.C.

Referenced by executeAllActions().

348 {
358  std::ostringstream oss;
359 
360  const auto & ordered_names = _syntax.getSortedTaskSet();
361  for (const auto & task_vector : ordered_names)
362  {
363  oss << "[DBG][ACT] (" << COLOR_YELLOW;
364  std::copy(
365  task_vector.begin(), task_vector.end(), infix_ostream_iterator<std::string>(oss, ", "));
366  oss << COLOR_DEFAULT << ")\n";
367 
368  std::set<std::string> task_set(task_vector.begin(), task_vector.end());
369  for (const auto & task : task_set)
370  {
371  if (_action_blocks.find(task) == _action_blocks.end())
372  continue;
373 
374  for (const auto & act : _action_blocks.at(task))
375  {
376  // The Syntax of the Action if it exists
377  if (act->name() != "")
378  oss << "[DBG][ACT]\t" << COLOR_GREEN << act->name() << COLOR_DEFAULT << '\n';
379 
380  // The task sets
381  oss << "[DBG][ACT]\t" << act->type();
382  const std::set<std::string> tasks = act->getAllTasks();
383  if (tasks.size() > 1)
384  {
385  oss << " (";
386  // Break the current Action's tasks into 2 sets, those intersecting with current set and
387  // then the difference.
388  std::set<std::string> intersection, difference;
389  std::set_intersection(tasks.begin(),
390  tasks.end(),
391  task_set.begin(),
392  task_set.end(),
393  std::inserter(intersection, intersection.end()));
394  std::set_difference(tasks.begin(),
395  tasks.end(),
396  intersection.begin(),
397  intersection.end(),
398  std::inserter(difference, difference.end()));
399 
400  oss << COLOR_CYAN;
401  std::copy(intersection.begin(),
402  intersection.end(),
403  infix_ostream_iterator<std::string>(oss, ", "));
404  oss << COLOR_MAGENTA << (difference.empty() ? "" : ", ");
405  std::copy(
406  difference.begin(), difference.end(), infix_ostream_iterator<std::string>(oss, ", "));
407  oss << COLOR_DEFAULT << ")";
408  }
409  oss << '\n';
410  }
411  }
412  }
413 
415  _console << oss.str() << std::endl;
416 }
Syntax & _syntax
Reference to a "syntax" of actions.
const std::vector< std::vector< std::string > > & getSortedTaskSet()
Get a list of serialized tasks in a correct dependency order.
Definition: Syntax.C:119
std::map< std::string, std::list< Action * > > _action_blocks
Pointers to the actual parsed input file blocks.
bool _show_action_dependencies
Whether or not the action warehouse prints the action dependency information.
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.

◆ printInputFile()

void ActionWarehouse::printInputFile ( std::ostream &  out)

This method uses the Actions in the warehouse to reproduce the input file.

This method is useful for debugging as it can assist in finding difficult to track parsing or input file problems.

Parameters
outA writable ostream object where the output will be sent.

Definition at line 488 of file ActionWarehouse.C.

Referenced by Console::outputInput(), and ExodusFormatter::printInputFile().

489 {
490  InputFileFormatter tree(false);
491 
492  std::map<std::string, std::vector<Action *>>::iterator iter;
493 
494  std::vector<Action *> ordered_actions;
495  for (const auto & block : _action_blocks)
496  for (const auto & act : block.second)
497  ordered_actions.push_back(act);
498 
499  for (const auto & act : ordered_actions)
500  {
501  std::string name;
502  if (act->parameters().blockFullpath() != "")
503  name = act->parameters().blockFullpath();
504  else
505  name = act->name();
506  const std::set<std::string> & tasks = act->getAllTasks();
507  mooseAssert(!tasks.empty(), "Task list is empty");
508 
509  bool is_parent;
510  if (_syntax.isAssociated(name, &is_parent) != "")
511  {
512  const auto & all_params = _app.getInputParameterWarehouse().getInputParameters();
513  InputParameters & params = *(all_params.find(act->uniqueActionName())->second.get());
514 
515  // temporarily allow input parameter copies required by the input file formatter
516  params.allowCopy(true);
517 
518  // TODO: Do we need to insert more nodes for each task?
519  tree.insertNode(name, *tasks.begin(), true, &params);
520  params.allowCopy(false);
521 
522  MooseObjectAction * moose_object_action = dynamic_cast<MooseObjectAction *>(act);
523  if (moose_object_action)
524  {
525  InputParameters obj_params = moose_object_action->getObjectParams();
526  tree.insertNode(name, *tasks.begin(), false, &obj_params);
527  }
528  }
529  }
530 
531  out << tree.print("");
532 }
std::string name(const ElemQuality q)
InputParameterWarehouse & getInputParameterWarehouse()
Get the InputParameterWarehouse for MooseObjects.
Definition: MooseApp.C:2867
Syntax & _syntax
Reference to a "syntax" of actions.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
InputParameters & getObjectParams()
Retrieve the parameters of the object to be created by this action.
const std::multimap< MooseObjectName, std::shared_ptr< InputParameters > > & getInputParameters(THREAD_ID tid=0) const
Return const reference to the map containing the InputParameter objects.
std::map< std::string, std::list< Action * > > _action_blocks
Pointers to the actual parsed input file blocks.
std::string isAssociated(const std::string &real_id, bool *is_parent, const std::map< std::string, std::set< std::string >> &alt_map={}) const
Method for determining whether a piece of syntax is associated with an Action an optional syntax map ...
Definition: Syntax.C:251
void allowCopy(bool status)
Toggle the availability of the copy constructor.
MooseApp & _app
The MooseApp this Warehouse is associated with.
OStreamProxy out
This class produces produces a dump of the InputParameters that appears like the normal input file sy...

◆ problem()

std::shared_ptr< FEProblem > ActionWarehouse::problem ( )

Definition at line 535 of file ActionWarehouse.C.

536 {
538  "ActionWarehouse::problem() is deprecated, please use ActionWarehouse::problemBase() \n");
540 }
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
Definition: FEProblem.h:20
std::unique_ptr< T_DEST, T_DELETER > dynamic_pointer_cast(std::unique_ptr< T_SRC, T_DELETER > &src)
These are reworked from https://stackoverflow.com/a/11003103.
void mooseDeprecated(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
Definition: MooseError.h:363
std::shared_ptr< FEProblemBase > _problem
Problem class.

◆ problemBase()

std::shared_ptr<FEProblemBase>& ActionWarehouse::problemBase ( )
inline

Definition at line 286 of file ActionWarehouse.h.

Referenced by ActionComponent::getProblem(), and Factory::initialize().

286 { return _problem; }
std::shared_ptr< FEProblemBase > _problem
Problem class.

◆ setFinalTask()

void ActionWarehouse::setFinalTask ( const std::string &  task)

Definition at line 127 of file ActionWarehouse.C.

Referenced by MooseApp::setupOptions().

128 {
129  if (!_syntax.hasTask(task))
130  mooseError("cannot use unregistered task '", task, "' as final task");
131  _final_task = task;
132 }
bool hasTask(const std::string &task) const
Returns a Boolean indicating whether or not a task is registered with the syntax object.
Definition: Syntax.C:125
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:311
Syntax & _syntax
Reference to a "syntax" of actions.
std::string _final_task
Last task to run before (optional) early termination - blank means no early termination.

◆ showActionDependencies()

void ActionWarehouse::showActionDependencies ( bool  state = true)
inline

This method sets a Boolean which is used to print information about action dependencies before various warehouse operations during the problem setup phase.

Parameters
stateFlag indicating whether to print action dependencies.

Definition at line 256 of file ActionWarehouse.h.

Referenced by SetupDebugAction::SetupDebugAction().

256 { _show_action_dependencies = state; }
bool _show_action_dependencies
Whether or not the action warehouse prints the action dependency information.

◆ showActions()

void ActionWarehouse::showActions ( bool  state = true)
inline

This method sets a Boolean which is used to show information about action execution of various warehouse operations during the problem setup phase.

Parameters
stateFlag indicating whether to show action information.

Definition at line 263 of file ActionWarehouse.h.

Referenced by SetupDebugAction::SetupDebugAction().

263 { _show_actions = state; }
bool _show_actions
Whether or not the action warehouse prints the action execution information.

◆ showParser()

void ActionWarehouse::showParser ( bool  state = true)
inline

This method sets a Boolean which is used to show debugging information when actions are inserted in the warehouse by the parser.

Parameters
stateFlag indicating whether to show action insertion.

Definition at line 270 of file ActionWarehouse.h.

Referenced by SetupDebugAction::SetupDebugAction().

270 { _show_parser = state; }
bool _show_parser
Whether or not to print messages when actions are inserted in the warehouse by the parser...

◆ sortUserObjectActions()

void ActionWarehouse::sortUserObjectActions ( std::list< Action *> &  actions) const
protected

Reorder the UserObject-constructing actions actions so that a UserObject that references another (through a UserObjectName parameter) is constructed after the one it references.

This makes the input order-agnostic: a referenced UserObject no longer has to be declared before the UserObject that uses it in its constructor. Mirrors the dependency resolution MeshGeneratorSystem performs for mesh generators.

Definition at line 54 of file ActionWarehouse.C.

Referenced by executeActionsWithAction().

55 {
56  // We key on act->name() because for a MooseObjectAction the action name is exactly the name the
57  // UserObject is constructed under (see AddUserObjectAction), so a UserObjectName parameter value
58  // matches the action that builds the referenced object.
59  std::map<std::string, Action *> action_for_uo_name;
60  for (const auto act : actions)
61  if (dynamic_cast<MooseObjectAction *>(act))
62  action_for_uo_name.emplace(act->name(), act);
63  // A Physics does not build its UserObjects under its own action name, so it declares the names
64  // it supplies through getSuppliedUserObjects(). Key those to the Physics action so an object
65  // referencing a Physics-supplied UserObject is constructed after the Physics adds it.
66  else if (const auto physics = dynamic_cast<const PhysicsBase *>(act))
67  for (const auto & uo_name : physics->getSuppliedUserObjects())
68  action_for_uo_name.emplace(uo_name, act);
69 
70  // Seed the resolver in the current (input-file) order so that independent UserObjects keep their
71  // input order (DependencyResolver resolves in insertion order modulo dependencies).
73  for (const auto act : actions)
74  resolver.addItem(act);
75 
76  for (const auto act : actions)
77  {
78  // A MooseObjectAction carries its dependencies in the parameters of the object it builds. Any
79  // other action that consumes a UserObject (e.g. a Physics that programmatically adds one) names
80  // it in the action's own parameters, so the dependency is ordered against just the same.
81  const auto moose_object_action = dynamic_cast<MooseObjectAction *>(act);
82  const auto & relevant_params =
83  moose_object_action ? moose_object_action->getObjectParams() : act->parameters();
84  for (const auto & dep_name : getUserObjectParamDependencies(relevant_params))
85  {
86  const auto it = action_for_uo_name.find(dep_name);
87  if (it != action_for_uo_name.end() && it->second != act)
88  // act references the UserObject built by it->second, which must be constructed first
89  resolver.addEdge(it->second, act);
90  }
91  }
92 
93  // A UserObjectName parameter does not necessarily denote a construction-time dependency: many
94  // UserObjects only resolve a referenced UserObject during initialSetup() or execution. Mutually
95  // referencing UserObjects therefore form a cycle here even though they construct fine in input
96  // order. So a cycle is not an error - fall back to the original input order, which is the
97  // behavior prior to this sorting. A genuine construction-time cycle still surfaces as the usual
98  // "UserObject not found" error when the object is constructed.
99  try
100  {
101  const auto & sorted = resolver.getSortedValues();
102  actions.assign(sorted.begin(), sorted.end());
103  }
105  {
106  }
107 }
const std::vector< T > & getSortedValues()
This function also returns dependency resolved values but with a simpler single vector interface...
std::vector< UserObjectName > getUserObjectParamDependencies(const InputParameters &params) const
void addEdge(const T &a, const T &b)
Add an edge between nodes &#39;a&#39; and &#39;b&#39;.
void addItem(const T &value)
Add an independent item to the set.
InputParameters & getObjectParams()
Retrieve the parameters of the object to be created by this action.
Class that represents the dependecy as a graph.

◆ syntax()

Syntax& ActionWarehouse::syntax ( )
inline

Member Data Documentation

◆ _action_blocks

std::map<std::string, std::list<Action *> > ActionWarehouse::_action_blocks
protected

◆ _action_factory

ActionFactory& ActionWarehouse::_action_factory
protected

The Factory that builds Actions.

Definition at line 343 of file ActionWarehouse.h.

Referenced by addActionBlock(), buildBuildableActions(), and hasTask().

◆ _all_ptrs

std::vector<std::shared_ptr<Action> > ActionWarehouse::_all_ptrs
protected

Definition at line 336 of file ActionWarehouse.h.

Referenced by addActionBlock(), allActionBlocks(), clear(), getAction(), and getActions().

◆ _app

MooseApp& ActionWarehouse::_app
protected

The MooseApp this Warehouse is associated with.

Definition at line 339 of file ActionWarehouse.h.

Referenced by getMooseAppName(), mooseApp(), and printInputFile().

◆ _completed_tasks

std::set<std::string> ActionWarehouse::_completed_tasks
protected

The completed tasks.

Definition at line 349 of file ActionWarehouse.h.

Referenced by executeAllActions(), and isTaskComplete().

◆ _completed_tasks_mutex

std::mutex ActionWarehouse::_completed_tasks_mutex
mutableprivate

Mutex for preventing read/write races for _completed_tasks.

Definition at line 393 of file ActionWarehouse.h.

Referenced by executeAllActions(), and isTaskComplete().

◆ _console

const ConsoleStream ConsoleStreamInterface::_console
inherited

An instance of helper class to write streams to the Console objects.

Definition at line 31 of file ConsoleStreamInterface.h.

Referenced by IterationAdaptiveDT::acceptStep(), MeshOnlyAction::act(), SetupDebugAction::act(), MaterialOutputAction::act(), Adaptivity::adaptMesh(), FEProblemBase::adaptMesh(), PerfGraph::addToExecutionList(), SimplePredictor::apply(), SystemBase::applyScalingFactors(), MultiApp::backup(), FEProblemBase::backupMultiApps(), CoarsenedPiecewiseLinear::buildCoarsenedGrid(), DefaultSteadyStateConvergence::checkConvergence(), MeshDiagnosticsGenerator::checkElementOverlap(), MeshDiagnosticsGenerator::checkElementTypes(), MeshDiagnosticsGenerator::checkElementVolumes(), FEProblemBase::checkExceptionAndStopSolve(), SolverSystem::checkInvalidSolution(), MeshDiagnosticsGenerator::checkLocalJacobians(), MeshDiagnosticsGenerator::checkNonConformalMesh(), MeshDiagnosticsGenerator::checkNonConformalMeshFromAdaptivity(), MeshDiagnosticsGenerator::checkNonMatchingEdges(), MeshDiagnosticsGenerator::checkNonPlanarSides(), MeshDiagnosticsGenerator::checkPolygons(), FEProblemBase::checkProblemIntegrity(), ReferenceResidualConvergence::checkResidualConvergence(), MeshDiagnosticsGenerator::checkSidesetsOrientation(), MeshDiagnosticsGenerator::checkWatertightNodesets(), MeshDiagnosticsGenerator::checkWatertightSidesets(), IterationAdaptiveDT::computeAdaptiveDT(), TransientBase::computeConstrainedDT(), DefaultMultiAppFixedPointConvergence::computeCustomConvergencePostprocessor(), NonlinearSystemBase::computeDamping(), FixedPointIterationAdaptiveDT::computeDT(), IterationAdaptiveDT::computeDT(), IterationAdaptiveDT::computeFailedDT(), IterationAdaptiveDT::computeInitialDT(), IterationAdaptiveDT::computeInterpolationDT(), LinearSystem::computeLinearSystemTags(), FEProblemBase::computeLinearSystemTags(), NonlinearSystemBase::computeScaling(), Problem::console(), IterationAdaptiveDT::constrainStep(), TimeStepper::constrainStep(), MultiApp::createApp(), FEProblemBase::execMultiApps(), FEProblemBase::execMultiAppTransfers(), MFEMSteady::execute(), MessageFromInput::execute(), SteadyBase::execute(), Eigenvalue::execute(), executeActionsWithAction(), executeAllActions(), MeshGeneratorSystem::executeMeshGenerators(), ElementQualityChecker::finalize(), SidesetAroundSubdomainUpdater::finalize(), FEProblemBase::finishMultiAppStep(), MeshRepairGenerator::fixOverlappingNodes(), SurfaceSubdomainsDelaunayRemesher::General2DDelaunay(), OrientSurfaceMeshGenerator::generate(), CoarsenBlockGenerator::generate(), PolyLineMeshFollowingNodeSetGenerator::generate(), MeshGenerator::generateInternal(), VariableCondensationPreconditioner::getDofToCondense(), NonlinearEigen::init(), InversePowerMethod::init(), FEProblemBase::initialAdaptMesh(), DefaultMultiAppFixedPointConvergence::initialize(), SubProblem::initialSetup(), EigenExecutionerBase::inversePowerIteration(), FEProblemBase::joinAndFinalize(), TransientBase::keepGoing(), IterationAdaptiveDT::limitDTByFunction(), IterationAdaptiveDT::limitDTToPostprocessorValue(), FEProblemBase::logAdd(), EigenExecutionerBase::makeBXConsistent(), Console::meshChanged(), SurfaceDelaunayGeneratorBase::meshNormalDeviation2D(), MooseBase::mooseDeprecated(), MooseBase::mooseDeprecatedNoTrace(), MooseBase::mooseInfo(), MooseBase::mooseWarning(), MooseBase::mooseWarningNonPrefixed(), ReferenceResidualConvergence::nonlinearConvergenceSetup(), ReporterDebugOutput::output(), PerfGraphOutput::output(), SolutionInvalidityOutput::output(), MaterialPropertyDebugOutput::output(), DOFMapOutput::output(), VariableResidualNormsDebugOutput::output(), Console::output(), ControlOutput::outputActiveObjects(), ControlOutput::outputChangedControls(), ControlOutput::outputControls(), Console::outputInput(), WebServerControl::outputMessage(), Console::outputPostprocessors(), PseudoTimestep::outputPseudoTimestep(), Console::outputReporters(), DefaultMultiAppFixedPointConvergence::outputResidualNorm(), Console::outputScalarVariables(), Console::outputSystemInformation(), FEProblemBase::possiblyRebuildGeomSearchPatches(), EigenExecutionerBase::postExecute(), AB2PredictorCorrector::postSolve(), printActionDependencySets(), BlockRestrictionDebugOutput::printBlockRestrictionGroups(), BlockRestrictionDebugOutput::printBlockRestrictionMap(), BlockRestrictionDebugOutput::printBoundaryRestrictionGroups(), SolutionInvalidity::printDebug(), EigenExecutionerBase::printEigenvalue(), SecantSolve::printFixedPointConvergenceHistory(), SteffensenSolve::printFixedPointConvergenceHistory(), PicardSolve::printFixedPointConvergenceHistory(), FixedPointSolve::printFixedPointConvergenceReason(), PerfGraphLivePrint::printLiveMessage(), MaterialPropertyDebugOutput::printMaterialMap(), PerfGraphLivePrint::printStats(), NEML2Action::printSummary(), AutomaticMortarGeneration::projectPrimaryNodesSinglePair(), AutomaticMortarGeneration::projectSecondaryNodesSinglePair(), CoarsenBlockGenerator::recursiveCoarsen(), SolutionTimeAdaptiveDT::rejectStep(), MultiApp::restore(), FEProblemBase::restoreMultiApps(), FEProblemBase::restoreSolutions(), NonlinearSystemBase::setInitialSolution(), MooseApp::setupOptions(), Checkpoint::shouldOutput(), SubProblem::showFunctorRequestors(), SubProblem::showFunctors(), FullSolveMultiApp::showStatusMessage(), EigenProblem::solve(), FEProblemSolve::solve(), FixedPointSolve::solve(), NonlinearSystem::solve(), LStableDirk2::solve(), LStableDirk3::solve(), ImplicitMidpoint::solve(), LinearSystem::solve(), ExplicitTVDRK2::solve(), AStableDirk4::solve(), LStableDirk4::solve(), ExplicitRK2::solve(), TransientMultiApp::solveStep(), FixedPointSolve::solveStep(), MeshRepairGenerator::splitNonConvexPolygons(), PerfGraphLivePrint::start(), WebServerControl::startServer(), AB2PredictorCorrector::step(), NonlinearEigen::takeStep(), MFEMTransient::takeStep(), TransientBase::takeStep(), TerminateChainControl::terminate(), SubProblem::timestepSetup(), FEProblemBase::updateMeshXFEM(), Convergence::verboseOutput(), Console::writeTimestepInformation(), Console::writeVariableNorms(), and FEProblemBase::~FEProblemBase().

◆ _current_action

Action* ActionWarehouse::_current_action
protected

Definition at line 371 of file ActionWarehouse.h.

Referenced by executeActionsWithAction(), and getCurrentAction().

◆ _current_task

std::string ActionWarehouse::_current_task
protected

Definition at line 369 of file ActionWarehouse.h.

Referenced by executeActionsWithAction(), and getCurrentTaskName().

◆ _displaced_mesh

std::shared_ptr<MooseMesh> ActionWarehouse::_displaced_mesh
protected

Possible mesh for displaced problem.

Definition at line 381 of file ActionWarehouse.h.

Referenced by clear(), displacedMesh(), and getDisplacedMesh().

◆ _empty_action_list

const std::list<Action *> ActionWarehouse::_empty_action_list
private

Definition at line 390 of file ActionWarehouse.h.

Referenced by getActionListByName().

◆ _final_task

std::string ActionWarehouse::_final_task
private

Last task to run before (optional) early termination - blank means no early termination.

Definition at line 388 of file ActionWarehouse.h.

Referenced by executeAllActions(), and setFinalTask().

◆ _generator_valid

bool ActionWarehouse::_generator_valid
protected

Flag to indicate whether or not there is an active iterator on this class.

There can only be a single active iterator because of the potential for meta Actions to add new Actions into the warehouse on the fly

Definition at line 358 of file ActionWarehouse.h.

Referenced by clear().

◆ _mesh

std::shared_ptr<MooseMesh> ActionWarehouse::_mesh
protected

Mesh class.

Definition at line 378 of file ActionWarehouse.h.

Referenced by clear(), getMesh(), and mesh().

◆ _ordered_names

std::vector<std::string> ActionWarehouse::_ordered_names
protected

The container that holds the sorted action names from the DependencyResolver.

Definition at line 347 of file ActionWarehouse.h.

Referenced by build(), and executeAllActions().

◆ _problem

std::shared_ptr<FEProblemBase> ActionWarehouse::_problem
protected

Problem class.

Definition at line 384 of file ActionWarehouse.h.

Referenced by clear(), problem(), and problemBase().

◆ _show_action_dependencies

bool ActionWarehouse::_show_action_dependencies
protected

Whether or not the action warehouse prints the action dependency information.

Definition at line 361 of file ActionWarehouse.h.

Referenced by executeAllActions(), printActionDependencySets(), and showActionDependencies().

◆ _show_actions

bool ActionWarehouse::_show_actions
protected

Whether or not the action warehouse prints the action execution information.

Definition at line 363 of file ActionWarehouse.h.

Referenced by executeActionsWithAction(), executeAllActions(), and showActions().

◆ _show_parser

bool ActionWarehouse::_show_parser
protected

Whether or not to print messages when actions are inserted in the warehouse by the parser.

Definition at line 365 of file ActionWarehouse.h.

Referenced by addActionBlock(), and showParser().

◆ _syntax

Syntax& ActionWarehouse::_syntax
protected

Reference to a "syntax" of actions.

Definition at line 341 of file ActionWarehouse.h.

Referenced by addActionBlock(), build(), buildBuildableActions(), printActionDependencySets(), printInputFile(), setFinalTask(), and syntax().

◆ _unsatisfied_dependencies

std::set<std::string> ActionWarehouse::_unsatisfied_dependencies
protected

Use to store the current list of unsatisfied dependencies.

Definition at line 351 of file ActionWarehouse.h.

Referenced by buildBuildableActions(), and checkUnsatisfiedActions().


The documentation for this class was generated from the following files: