www.mooseframework.org
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)
 Retrieve an action 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 >
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 &name)
 This method executes only the actions in the warehouse that satisfy the task passed in. More...
 
void showActions (bool state=true)
 This method sets a Boolean which is used to show debugging information during various warehouse operations during the problem setup phase. More...
 
void showParser (bool state=true)
 
Syntaxsyntax ()
 
std::shared_ptr< MooseMesh > & mesh ()
 
std::shared_ptr< MooseMesh > & displacedMesh ()
 
std::shared_ptr< FEProblemBase > & problemBase ()
 
std::shared_ptr< FEProblemproblem ()
 
MooseAppmooseApp ()
 
const std::string & getCurrentTaskName () const
 
std::string getCurrentActionName () 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...
 

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::map< std::string, std::vector< Action * > > _requested_action_blocks
 Action blocks that have been requested. More...
 
std::vector< std::string > _ordered_names
 The container that holds the sorted action names from the DependencyResolver. 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_actions
 
bool _show_parser
 
std::string _current_task
 
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...
 
ActionIterator _act_iter
 

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 25 of file ActionWarehouse.C.

27  _app(app),
28  _syntax(syntax),
29  _action_factory(factory),
30  _generator_valid(false),
31  _show_actions(false),
32  _show_parser(false)
33 {
34 }
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...
bool _generator_valid
Flag to indicate whether or not there is an active iterator on this class.
MooseApp & _app
The MooseApp this Warehouse is associated with.
ActionFactory & _action_factory
The Factory that builds Actions.

◆ ~ActionWarehouse()

ActionWarehouse::~ActionWarehouse ( )

Definition at line 36 of file ActionWarehouse.C.

36 {}

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 170 of file ActionWarehouse.C.

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

171 {
172  return _action_blocks[task].begin();
173 }
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 176 of file ActionWarehouse.C.

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

177 {
178  return _action_blocks[task].end();
179 }
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 satisify 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 73 of file ActionWarehouse.C.

Referenced by buildBuildableActions(), CommonOutputAction::create(), AddVariableAction::createInitialConditionAction(), MooseApp::createMinimalApp(), and Parser::walkRaw().

74 {
82  std::string registered_identifier =
83  action->parameters().get<std::string>("registered_identifier");
84  std::set<std::string> tasks;
85 
86  if (_show_parser)
87  Moose::err << COLOR_DEFAULT << "Parsing Syntax: " << COLOR_GREEN << action->name()
88  << '\n'
89  << COLOR_DEFAULT << "Building Action: " << COLOR_DEFAULT << action->type()
90  << '\n'
91  << COLOR_DEFAULT << "Registered Identifier: " << COLOR_GREEN << registered_identifier
92  << '\n'
93  << COLOR_DEFAULT << "Specific Task: " << COLOR_CYAN
94  << action->specificTaskName() << '\n';
95 
116  if (action->specificTaskName() != "") // Case 1
117  tasks.insert(action->specificTaskName());
118  else if (registered_identifier == "" &&
119  _syntax.getSyntaxByAction(action->type()).size() > 1) // Case 2
120  {
121  std::set<std::string> local_tasks = action->getAllTasks();
122  mooseAssert(local_tasks.size() == 1, "More than one task inside of the " << action->name());
123  tasks.insert(*local_tasks.begin());
124  }
125  else // Case 3
126  tasks = _action_factory.getTasksByAction(action->type());
127 
128  // TODO: Now we need to weed out the double registrations!
129  for (const auto & task : tasks)
130  {
131  // Some error checking
132  if (!_syntax.hasTask(task))
133  mooseError("A(n) ", task, " is not a registered task");
134 
135  // Make sure that the ObjectAction task and Action task are consistent
136  // otherwise that means that is action was built by the wrong type
137  std::shared_ptr<MooseObjectAction> moa = std::dynamic_pointer_cast<MooseObjectAction>(action);
138  if (moa.get())
139  {
140  const InputParameters & mparams = moa->getObjectParams();
141 
142  if (mparams.have_parameter<std::string>("_moose_base"))
143  {
144  const std::string & base = mparams.get<std::string>("_moose_base");
145 
146  if (!_syntax.verifyMooseObjectTask(base, task))
147  mooseError("Task ", task, " is not registered to build ", base, " derived objects");
148  }
149  else
150  mooseError("Unable to locate registered base parameter for ", moa->getMooseObjectType());
151  }
152 
153  // Add the current task to current action
154  action->appendTask(task);
155 
156  if (_show_parser)
157  Moose::err << COLOR_YELLOW << "Adding Action: " << COLOR_DEFAULT << action->type()
158  << " (" << COLOR_YELLOW << task << COLOR_DEFAULT << ")\n";
159 
160  // Add it to the warehouse
161  _action_blocks[task].push_back(action.get());
162  }
163  _all_ptrs.push_back(action);
164 
165  if (_show_parser)
166  Moose::err << std::endl;
167 }
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:103
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
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...
std::unique_ptr< T_DEST, T_DELETER > dynamic_pointer_cast(std::unique_ptr< T_SRC, T_DELETER > &src)
std::vector< std::string > getSyntaxByAction(const std::string &action, const std::string &task="")
Retrieve the syntax associated with the passed in action type string.
Definition: Syntax.C:183
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:277
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 182 of file ActionWarehouse.C.

Referenced by AddRelationshipManager::act().

183 {
184  return _all_ptrs;
185 }
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 47 of file ActionWarehouse.C.

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

48 {
50  for (const auto & name : _ordered_names)
52 }
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:91
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 204 of file ActionWarehouse.C.

Referenced by build().

205 {
206  if (_syntax.shouldAutoBuild(task) && _action_blocks[task].empty())
207  {
208  bool ret_value = false;
209  auto it_pair = _action_factory.getActionsByTask(task);
210  for (const auto & action_pair : as_range(it_pair))
211  {
212  InputParameters params = _action_factory.getValidParams(action_pair.second);
213  params.set<ActionWarehouse *>("awh") = this;
214 
215  if (params.areAllRequiredParamsValid())
216  {
217  params.set<std::string>("registered_identifier") = "(AutoBuilt)";
218  addActionBlock(_action_factory.create(action_pair.second, "", params));
219  ret_value = true;
220  }
221  }
222 
223  if (!ret_value)
224  _unsatisfied_dependencies.insert(task);
225  }
226 }
InputParameters getValidParams(const std::string &name)
Definition: ActionFactory.C:70
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
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.
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:116
bool areAllRequiredParamsValid() const
This method returns true if all of the parameters in this object are valid (i.e.
std::map< std::string, std::list< Action * > > _action_blocks
Pointers to the actual parsed input file blocks.
std::shared_ptr< Action > create(const std::string &action, const std::string &action_name, InputParameters parameters)
Definition: ActionFactory.C:41
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 229 of file ActionWarehouse.C.

Referenced by CheckIntegrityAction::act().

230 {
231  std::stringstream oss;
232  bool empty = true;
233 
234  for (const auto & udep : _unsatisfied_dependencies)
235  {
236  if (_action_blocks.find(udep) == _action_blocks.end())
237  {
238  if (empty)
239  empty = false;
240  else
241  oss << " ";
242  oss << udep;
243  }
244  }
245 
246  if (!empty)
247  mooseError(
248  std::string(
249  "The following unsatisfied actions where found while setting up the MOOSE problem:\n") +
250  oss.str() + "\n");
251 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
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 55 of file ActionWarehouse.C.

Referenced by MooseApp::~MooseApp().

56 {
57  for (auto & ptr : _all_ptrs)
58  ptr.reset();
59 
60  _action_blocks.clear();
61  _generator_valid = false;
62 
63  // Due to the way ActionWarehouse is cleaned up (see MooseApp's
64  // destructor) we must guarantee that ActionWarehouse::clear()
65  // releases all the resources which have to be released _before_ the
66  // _comm object owned by the MooseApp is destroyed.
67  _problem.reset();
68  _displaced_mesh.reset();
69  _mesh.reset();
70 }
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 216 of file ActionWarehouse.h.

Referenced by MooseApp::executeMeshModifiers().

216 { 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 &  name)

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

Definition at line 345 of file ActionWarehouse.C.

Referenced by executeAllActions().

346 {
347  // Set the current task name
348  _current_task = task;
349 
351  ++_act_iter)
352  {
353  if (_show_actions)
354  _console << "[DBG][ACT] "
355  << "TASK (" << COLOR_YELLOW << std::setw(24) << task << COLOR_DEFAULT << ") "
356  << "TYPE (" << COLOR_YELLOW << std::setw(32) << (*_act_iter)->type() << COLOR_DEFAULT
357  << ") "
358  << "NAME (" << COLOR_YELLOW << std::setw(16) << (*_act_iter)->name() << COLOR_DEFAULT
359  << ")" << std::endl;
360 
361  (*_act_iter)->timedAct();
362  }
363 }
ActionIterator actionBlocksWithActionEnd(const std::string &task)
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.
ActionIterator _act_iter
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 326 of file ActionWarehouse.C.

Referenced by MooseApp::runInputFile().

327 {
328  if (_show_actions)
329  {
330  _console << "[DBG][ACT] Action Dependency Sets:\n";
332 
333  _console << "\n[DBG][ACT] Executing actions:" << std::endl;
334  }
335 
336  for (const auto & task : _ordered_names)
337  {
339  if (_final_task != "" && task == _final_task)
340  break;
341  }
342 }
void executeActionsWithAction(const std::string &name)
This method executes only the actions in the warehouse that satisfy the task passed in...
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.
const ConsoleStream _console
An instance of helper class to write streams to the Console objects.

◆ getAction()

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

Retrieve an action with its name and the desired type.

Parameters
nameThe action name.

Definition at line 110 of file ActionWarehouse.h.

111  {
112  T * p = NULL;
113  for (auto i = beginIndex(_all_ptrs); i < _all_ptrs.size(); ++i)
114  {
115  auto act = _all_ptrs[i].get();
116  if (act->name() == name)
117  {
118  p = dynamic_cast<T *>(act);
119  if (p)
120  break;
121  }
122  }
123  if (!p)
124  mooseError("Action with name being ", name, " does not exist");
125  return *p;
126  }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
std::vector< std::shared_ptr< Action > > _all_ptrs

◆ 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 158 of file ActionWarehouse.h.

Referenced by CreateProblemDefaultAction::act().

159  {
160  const auto it = _action_blocks.find(task);
161  if (it == _action_blocks.end())
162  return nullptr;
163 
164  T * p = nullptr;
165  for (const auto & action : it->second)
166  {
167  T * tp = dynamic_cast<T *>(action);
168  if (tp)
169  {
170  if (p)
171  mooseError("More than one actions have been detected in getActionByTask");
172  else
173  p = tp;
174  }
175  }
176  return p;
177  }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
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.

Definition at line 188 of file ActionWarehouse.C.

Referenced by MaterialOutputAction::act(), CheckOutputAction::checkVariableOutput(), Console::Console(), MooseApp::getCheckpointDirectories(), and OutputWarehouse::getOutputNames().

189 {
190  const auto it = _action_blocks.find(task);
191  if (it == _action_blocks.end())
192  mooseError("The task ", task, " does not exist.");
193 
194  return it->second;
195 }
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
std::map< std::string, std::list< Action * > > _action_blocks
Pointers to the actual parsed input file blocks.

◆ 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 132 of file ActionWarehouse.h.

133  {
134  // we need to create the map first to ensure that all actions in the map are unique
135  // and the actions are sorted by their names
136  std::map<std::string, const T *> actions;
137  for (auto i = beginIndex(_all_ptrs); i < _all_ptrs.size(); ++i)
138  {
139  auto act = _all_ptrs[i].get();
140  T * p = dynamic_cast<T *>(act);
141  if (p)
142  actions.insert(std::pair<std::string, const T *>(act->name(), p));
143  }
144  // construct the vector from the map entries
145  std::vector<const T *> action_vector;
146  for (auto & pair : actions)
147  action_vector.push_back(pair.second);
148  return action_vector;
149  }
std::vector< std::shared_ptr< Action > > _all_ptrs

◆ getCurrentActionName()

std::string ActionWarehouse::getCurrentActionName ( ) const

Definition at line 416 of file ActionWarehouse.C.

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

417 {
418  return (*_act_iter)->parameters().blockFullpath();
419 }

◆ getCurrentTaskName()

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

Definition at line 221 of file ActionWarehouse.h.

221 { return _current_task; }
std::string _current_task

◆ hasActions()

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

Check if Actions associated with passed in task exist.

Definition at line 198 of file ActionWarehouse.C.

Referenced by MaterialOutputAction::act(), CheckOutputAction::checkVariableOutput(), and OutputWarehouse::getOutputNames().

199 {
200  return _action_blocks.find(task) != _action_blocks.end();
201 }
std::map< std::string, std::list< Action * > > _action_blocks
Pointers to the actual parsed input file blocks.

◆ mesh()

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

Definition at line 215 of file ActionWarehouse.h.

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

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

◆ mooseApp()

MooseApp& ActionWarehouse::mooseApp ( )
inline

Definition at line 220 of file ActionWarehouse.h.

Referenced by ExodusFormatter::printInputFile().

220 { 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 254 of file ActionWarehouse.C.

Referenced by executeAllActions().

255 {
265  std::ostringstream oss;
266 
267  const auto & ordered_names = _syntax.getSortedTaskSet();
268  for (const auto & task_vector : ordered_names)
269  {
270  oss << "[DBG][ACT] (" << COLOR_YELLOW;
271  std::copy(
272  task_vector.begin(), task_vector.end(), infix_ostream_iterator<std::string>(oss, ", "));
273  oss << COLOR_DEFAULT << ")\n";
274 
275  std::set<std::string> task_set(task_vector.begin(), task_vector.end());
276  for (const auto & task : task_set)
277  {
278  if (_action_blocks.find(task) == _action_blocks.end())
279  continue;
280 
281  for (const auto & act : _action_blocks.at(task))
282  {
283  // The Syntax of the Action if it exists
284  if (act->name() != "")
285  oss << "[DBG][ACT]\t" << COLOR_GREEN << act->name() << COLOR_DEFAULT << '\n';
286 
287  // The task sets
288  oss << "[DBG][ACT]\t" << act->type();
289  const std::set<std::string> tasks = act->getAllTasks();
290  if (tasks.size() > 1)
291  {
292  oss << " (";
293  // Break the current Action's tasks into 2 sets, those intersecting with current set and
294  // then the difference.
295  std::set<std::string> intersection, difference;
296  std::set_intersection(tasks.begin(),
297  tasks.end(),
298  task_set.begin(),
299  task_set.end(),
300  std::inserter(intersection, intersection.end()));
301  std::set_difference(tasks.begin(),
302  tasks.end(),
303  intersection.begin(),
304  intersection.end(),
305  std::inserter(difference, difference.end()));
306 
307  oss << COLOR_CYAN;
308  std::copy(intersection.begin(),
309  intersection.end(),
311  oss << COLOR_MAGENTA << (difference.empty() ? "" : ", ");
312  std::copy(
313  difference.begin(), difference.end(), infix_ostream_iterator<std::string>(oss, ", "));
314  oss << COLOR_DEFAULT << ")";
315  }
316  oss << '\n';
317  }
318  }
319  }
320 
321  if (_show_actions)
322  _console << oss.str() << std::endl;
323 }
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:97
std::map< std::string, std::list< Action * > > _action_blocks
Pointers to the actual parsed input file blocks.
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 366 of file ActionWarehouse.C.

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

367 {
368  InputFileFormatter tree(false);
369 
370  std::map<std::string, std::vector<Action *>>::iterator iter;
371 
372  std::vector<Action *> ordered_actions;
373  for (const auto & block : _action_blocks)
374  for (const auto & act : block.second)
375  ordered_actions.push_back(act);
376 
377  for (const auto & act : ordered_actions)
378  {
379  std::string name;
380  if (act->parameters().blockFullpath() != "")
381  name = act->parameters().blockFullpath();
382  else
383  name = act->name();
384  const std::set<std::string> & tasks = act->getAllTasks();
385  mooseAssert(!tasks.empty(), "Task list is empty");
386 
387  bool is_parent;
388  if (_syntax.isAssociated(name, &is_parent) != "")
389  {
390  InputParameters params = act->parameters();
391 
392  // TODO: Do we need to insert more nodes for each task?
393  tree.insertNode(name, *tasks.begin(), true, &params);
394 
395  MooseObjectAction * moose_object_action = dynamic_cast<MooseObjectAction *>(act);
396  if (moose_object_action)
397  {
398  InputParameters obj_params = moose_object_action->getObjectParams();
399  tree.insertNode(name, *tasks.begin(), false, &obj_params);
400  }
401  }
402  }
403 
404  out << tree.print("");
405 }
Syntax & _syntax
Reference to a "syntax" of actions.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
std::string isAssociated(const std::string &real_id, bool *is_parent) const
Method for determining whether a piece of syntax is associated with an Action TODO: I need a better n...
Definition: Syntax.C:209
InputParameters & getObjectParams()
Retreive the parameters of the object to be created by this action.
std::map< std::string, std::list< Action * > > _action_blocks
Pointers to the actual parsed input file blocks.
This class produces produces a dump of the InputFileParameters that appears like the normal input fil...

◆ problem()

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

Definition at line 408 of file ActionWarehouse.C.

409 {
411  "ActionWarehouse::problem() is deprecated, please use ActionWarehouse::problemBase() \n");
413 }
Specialization of SubProblem for solving nonlinear equations plus auxiliary equations.
Definition: FEProblem.h:25
std::unique_ptr< T_DEST, T_DELETER > dynamic_pointer_cast(std::unique_ptr< T_SRC, T_DELETER > &src)
void mooseDeprecated(Args &&... args)
Emit a deprecated code/feature message with the given stringified, concatenated args.
Definition: MooseError.h:237
std::shared_ptr< FEProblemBase > _problem
Problem class.

◆ problemBase()

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

Definition at line 218 of file ActionWarehouse.h.

Referenced by Factory::create(), and MooseApp::setRestart().

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

◆ setFinalTask()

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

Definition at line 39 of file ActionWarehouse.C.

Referenced by MooseApp::setupOptions().

40 {
41  if (!_syntax.hasTask(task))
42  mooseError("cannot use unregistered task '", task, "' as final task");
43  _final_task = task;
44 }
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:103
void mooseError(Args &&... args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:208
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.

◆ showActions()

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

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

Parameters
stateFlag indicating whether to show action information.

Definition at line 203 of file ActionWarehouse.h.

Referenced by SetupDebugAction::SetupDebugAction().

203 { _show_actions = state; }

◆ showParser()

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

Definition at line 205 of file ActionWarehouse.h.

Referenced by SetupDebugAction::SetupDebugAction().

205 { _show_parser = state; }

◆ syntax()

Syntax& ActionWarehouse::syntax ( )
inline

Definition at line 208 of file ActionWarehouse.h.

Referenced by DynamicObjectRegistrationAction::DynamicObjectRegistrationAction().

208 { return _syntax; }
Syntax & _syntax
Reference to a "syntax" of actions.

Member Data Documentation

◆ _act_iter

ActionIterator ActionWarehouse::_act_iter
private

Definition at line 284 of file ActionWarehouse.h.

Referenced by executeActionsWithAction().

◆ _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 242 of file ActionWarehouse.h.

Referenced by addActionBlock(), and buildBuildableActions().

◆ _all_ptrs

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

Definition at line 235 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 238 of file ActionWarehouse.h.

Referenced by mooseApp().

◆ _console

const ConsoleStream ConsoleStreamInterface::_console
inherited

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

Definition at line 32 of file ConsoleStreamInterface.h.

Referenced by IterationAdaptiveDT::acceptStep(), SetupRecoverFileBaseAction::act(), Adaptivity::adaptMesh(), FEProblemBase::adaptMesh(), SimplePredictor::apply(), FEProblemBase::backupMultiApps(), FEProblemBase::checkProblemIntegrity(), IterationAdaptiveDT::computeAdaptiveDT(), Transient::computeConstrainedDT(), NonlinearSystemBase::computeDamping(), IterationAdaptiveDT::computeDT(), IterationAdaptiveDT::computeFailedDT(), IterationAdaptiveDT::computeInterpolationDT(), FEProblemBase::computeResidualTags(), IterationAdaptiveDT::constrainStep(), TimeStepper::constrainStep(), AB2PredictorCorrector::converged(), FEProblemBase::execMultiApps(), FEProblemBase::execMultiAppTransfers(), MultiAppPostprocessorTransfer::execute(), MultiAppPostprocessorInterpolationTransfer::execute(), MultiAppVariableValueSamplePostprocessorTransfer::execute(), MultiAppNearestNodeTransfer::execute(), MultiAppPostprocessorToAuxScalarTransfer::execute(), MultiAppScalarToAuxScalarTransfer::execute(), MultiAppVariableValueSampleTransfer::execute(), MultiAppInterpolationTransfer::execute(), MultiAppMeshFunctionTransfer::execute(), MultiAppUserObjectTransfer::execute(), MultiAppProjectionTransfer::execute(), MultiAppVectorPostprocessorTransfer::execute(), MultiAppCopyTransfer::execute(), Steady::execute(), MultiAppDTKUserObjectTransfer::execute(), executeActionsWithAction(), executeAllActions(), FEProblemBase::FEProblemBase(), ElementQualityChecker::finalize(), FEProblemBase::finishMultiAppStep(), MultiApp::globalAppToLocal(), InversePowerMethod::init(), NonlinearEigen::init(), Steady::init(), FEProblemBase::initialAdaptMesh(), FEProblemBase::initialSetup(), EigenExecutionerBase::inversePowerIteration(), Transient::keepGoing(), IterationAdaptiveDT::limitDTByFunction(), IterationAdaptiveDT::limitDTToPostprocessorValue(), EigenExecutionerBase::makeBXConsistent(), Console::meshChanged(), MooseObject::mooseDeprecated(), MooseObject::mooseInfo(), MooseObject::mooseWarning(), PerfGraphOutput::output(), DOFMapOutput::output(), VariableResidualNormsDebugOutput::output(), Console::output(), ControlOutput::outputActiveObjects(), ControlOutput::outputChangedControls(), ControlOutput::outputControls(), Console::outputInput(), Console::outputPostprocessors(), Console::outputScalarVariables(), Console::outputSystemInformation(), FEProblemBase::possiblyRebuildGeomSearchPatches(), EigenExecutionerBase::postExecute(), printActionDependencySets(), EigenExecutionerBase::printEigenvalue(), MaterialPropertyDebugOutput::printMaterialMap(), SolutionTimeAdaptiveDT::rejectStep(), DT2::rejectStep(), FEProblemBase::restoreMultiApps(), SimplePredictor::shouldApply(), NonlinearSystem::solve(), LStableDirk2::solve(), LStableDirk3::solve(), ImplicitMidpoint::solve(), ExplicitTVDRK2::solve(), AStableDirk4::solve(), LStableDirk4::solve(), ExplicitRK2::solve(), TransientMultiApp::solveStep(), Transient::solveStep(), DT2::step(), AB2PredictorCorrector::step(), NonlinearEigen::takeStep(), Console::writeTimestepInformation(), Console::writeVariableNorms(), and FEProblemBase::~FEProblemBase().

◆ _current_task

std::string ActionWarehouse::_current_task
protected

Definition at line 265 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 275 of file ActionWarehouse.h.

Referenced by clear(), and displacedMesh().

◆ _final_task

std::string ActionWarehouse::_final_task
private

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

Definition at line 282 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 257 of file ActionWarehouse.h.

Referenced by clear().

◆ _mesh

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

Mesh class.

Definition at line 272 of file ActionWarehouse.h.

Referenced by clear(), 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 248 of file ActionWarehouse.h.

Referenced by build(), and executeAllActions().

◆ _problem

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

Problem class.

Definition at line 278 of file ActionWarehouse.h.

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

◆ _requested_action_blocks

std::map<std::string, std::vector<Action *> > ActionWarehouse::_requested_action_blocks
protected

Action blocks that have been requested.

Definition at line 246 of file ActionWarehouse.h.

◆ _show_actions

bool ActionWarehouse::_show_actions
protected

◆ _show_parser

bool ActionWarehouse::_show_parser
protected

Definition at line 261 of file ActionWarehouse.h.

Referenced by addActionBlock(), and showParser().

◆ _syntax

Syntax& ActionWarehouse::_syntax
protected

Reference to a "syntax" of actions.

Definition at line 240 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 250 of file ActionWarehouse.h.

Referenced by buildBuildableActions(), and checkUnsatisfiedActions().


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