www.mooseframework.org
Public Member Functions | Public Attributes | Protected Member Functions | Protected 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...
 
ActionIterator actionBlocksWithActionBegin (const std::string &task)
 Iterators to the Actions in the warehouse. More...
 
ActionIterator actionBlocksWithActionEnd (const std::string &task)
 
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...
 
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
 

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...
 

Detailed Description

Storage for action instances.

Definition at line 40 of file ActionWarehouse.h.

Constructor & Destructor Documentation

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

Definition at line 28 of file ActionWarehouse.C.

30  _app(app),
31  _syntax(syntax),
32  _action_factory(factory),
33  _generator_valid(false),
34  _show_actions(false),
35  _show_parser(false)
36 {
37 }
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 ( )

Definition at line 39 of file ActionWarehouse.C.

39 {}

Member Function Documentation

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(), empty(), 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.
ActionIterator ActionWarehouse::actionBlocksWithActionEnd ( const std::string &  task)

Definition at line 176 of file ActionWarehouse.C.

Referenced by SetupDampersAction::act(), empty(), 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.
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. In this case, the ActionFactory itself would have already set the task it found from the build info used to construct the Action.
  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 68 of file ActionWarehouse.C.

Referenced by DetermineSystemType::act(), buildBuildableActions(), CommonOutputAction::create(), AddVariableAction::createInitialConditionAction(), MooseApp::createMinimalApp(), SetupDebugAction::createOutputAction(), empty(), MaterialOutputAction::materialOutputHelper(), and Parser::walkRaw().

69 {
80  std::string registered_identifier =
81  action->parameters().get<std::string>("registered_identifier");
82  std::set<std::string> tasks;
83 
84  if (_show_parser)
85  Moose::err << COLOR_DEFAULT << "Parsing Syntax: " << COLOR_GREEN << action->name()
86  << '\n'
87  << COLOR_DEFAULT << "Building Action: " << COLOR_DEFAULT << action->type()
88  << '\n'
89  << COLOR_DEFAULT << "Registered Identifier: " << COLOR_GREEN << registered_identifier
90  << '\n'
91  << COLOR_DEFAULT << "Specific Task: " << COLOR_CYAN
92  << action->specificTaskName() << '\n';
93 
117  if (action->specificTaskName() != "") // Case 1
118  tasks.insert(action->specificTaskName());
119  else if (registered_identifier == "") // 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  _all_ptrs.push_back(action);
162  _action_blocks[task].push_back(action.get());
163  }
164 
165  if (_show_parser)
166  Moose::err << std::endl;
167 }
Syntax & _syntax
Reference to a "syntax" of actions.
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
bool verifyMooseObjectTask(const std::string &base, const std::string &task) const
Definition: Syntax.C:231
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 hasTask(const std::string &task)
Definition: Syntax.C:93
std::set< std::string > getTasksByAction(const std::string &action) const
ActionFactory & _action_factory
The Factory that builds Actions.
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 42 of file ActionWarehouse.C.

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

43 {
45  for (const auto & name : _ordered_names)
47 }
Syntax & _syntax
Reference to a "syntax" of actions.
const std::vector< std::string > & getSortedTask()
Definition: Syntax.C:81
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.
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 198 of file ActionWarehouse.C.

Referenced by build(), and getCurrentTaskName().

199 {
200  if (_syntax.isActionRequired(task) && _action_blocks[task].empty())
201  {
202  bool ret_value = false;
203  std::pair<std::multimap<std::string, std::string>::const_iterator,
204  std::multimap<std::string, std::string>::const_iterator>
205  range = _action_factory.getActionsByTask(task);
206  for (std::multimap<std::string, std::string>::const_iterator it = range.first;
207  it != range.second;
208  ++it)
209  {
210  InputParameters params = _action_factory.getValidParams(it->second);
211  params.set<ActionWarehouse *>("awh") = this;
212 
213  if (params.areAllRequiredParamsValid())
214  {
215  params.set<std::string>("registered_identifier") = "(AutoBuilt)";
216  params.set<std::string>("task") = task;
217  addActionBlock(_action_factory.create(it->second, "", params));
218  ret_value = true;
219  }
220  }
221 
222  if (!ret_value)
223  _unsatisfied_dependencies.insert(task);
224  }
225 }
InputParameters getValidParams(const std::string &name)
Definition: ActionFactory.C:74
Syntax & _syntax
Reference to a "syntax" of actions.
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 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.
bool isActionRequired(const std::string &task)
Definition: Syntax.C:99
std::shared_ptr< Action > create(const std::string &action, const std::string &action_name, InputParameters parameters)
Definition: ActionFactory.C:26
std::pair< std::multimap< std::string, std::string >::const_iterator, std::multimap< std::string, std::string >::const_iterator > getActionsByTask(const std::string &task) const
std::set< std::string > _unsatisfied_dependencies
Use to store the current list of unsatisfied dependencies.
ActionFactory & _action_factory
The Factory that builds Actions.
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 228 of file ActionWarehouse.C.

Referenced by CheckIntegrityAction::act(), and empty().

229 {
230  std::stringstream oss;
231  bool empty = true;
232 
233  for (const auto & udep : _unsatisfied_dependencies)
234  {
235  if (_action_blocks.find(udep) == _action_blocks.end())
236  {
237  if (empty)
238  empty = false;
239  else
240  oss << " ";
241  oss << udep;
242  }
243  }
244 
245  if (!empty)
246  mooseError(
247  std::string(
248  "The following unsatisfied actions where found while setting up the MOOSE problem:\n") +
249  oss.str() + "\n");
250 }
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
std::map< std::string, std::list< Action * > > _action_blocks
Pointers to the actual parsed input file blocks.
bool empty() const
returns a Boolean indicating whether the warehouse is empty or not.
std::set< std::string > _unsatisfied_dependencies
Use to store the current list of unsatisfied dependencies.
void ActionWarehouse::clear ( )

This method deletes all of the Actions in the warehouse.

Definition at line 50 of file ActionWarehouse.C.

Referenced by MooseApp::~MooseApp().

51 {
52  for (auto & ptr : _all_ptrs)
53  ptr.reset();
54 
55  _action_blocks.clear();
56  _generator_valid = false;
57 
58  // Due to the way ActionWarehouse is cleaned up (see MooseApp's
59  // destructor) we must guarantee that ActionWarehouse::clear()
60  // releases all the resources which have to be released _before_ the
61  // _comm object owned by the MooseApp is destroyed.
62  _problem.reset();
63  _displaced_mesh.reset();
64  _mesh.reset();
65 }
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.
std::shared_ptr<MooseMesh>& ActionWarehouse::displacedMesh ( )
inline

Definition at line 184 of file ActionWarehouse.h.

Referenced by MooseApp::executeMeshModifiers().

184 { return _displaced_mesh; }
std::shared_ptr< MooseMesh > _displaced_mesh
Possible mesh for displaced problem.
bool ActionWarehouse::empty ( ) const
inline

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

Definition at line 60 of file ActionWarehouse.h.

Referenced by checkUnsatisfiedActions().

60 { return _action_blocks.empty(); }
std::map< std::string, std::list< Action * > > _action_blocks
Pointers to the actual parsed input file blocks.
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 340 of file ActionWarehouse.C.

Referenced by executeAllActions(), getActions(), and MooseApp::meshOnly().

341 {
342  // Set the current task name
343  _current_task = task;
344 
345  for (ActionIterator act_iter = actionBlocksWithActionBegin(task);
346  act_iter != actionBlocksWithActionEnd(task);
347  ++act_iter)
348  {
349  if (_show_actions)
350  {
351  _console << "[DBG][ACT] "
352  << "TASK (" << COLOR_YELLOW << std::setw(24) << task << COLOR_DEFAULT << ") "
353  << "TYPE (" << COLOR_YELLOW << std::setw(32) << (*act_iter)->type() << COLOR_DEFAULT
354  << ") "
355  << "NAME (" << COLOR_YELLOW << std::setw(16) << (*act_iter)->name() << COLOR_DEFAULT
356  << ")" << std::endl;
357 
358  (*act_iter)->act();
359  }
360  else
361  (*act_iter)->act();
362  }
363 }
std::list< Action * >::iterator ActionIterator
alias to hide implementation details
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.
std::string _current_task
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 325 of file ActionWarehouse.C.

Referenced by getActions(), and MooseApp::runInputFile().

326 {
327  if (_show_actions)
328  {
329  _console << "[DBG][ACT] Action Dependency Sets:\n";
331 
332  _console << "\n[DBG][ACT] Executing actions:" << std::endl;
333  }
334 
335  for (const auto & task : _ordered_names)
337 }
void executeActionsWithAction(const std::string &name)
This method executes only the actions in the warehouse that satisfy the task passed in...
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.
void printActionDependencySets() const
This method is used only during debugging when show_actions is set to true.
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 108 of file ActionWarehouse.h.

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

Referenced by MaterialOutputAction::buildMaterialOutputObjects(), CheckOutputAction::checkVariableOutput(), Console::Console(), empty(), MooseApp::getCheckpointFiles(), and OutputWarehouse::getOutputNames().

183 {
184  const auto it = _action_blocks.find(task);
185  if (it == _action_blocks.end())
186  mooseError("The task ", task, " does not exist.");
187 
188  return it->second;
189 }
void mooseError(Args &&...args)
Emit an error message with the given stringified, concatenated args and terminate the application...
Definition: MooseError.h:182
std::map< std::string, std::list< Action * > > _action_blocks
Pointers to the actual parsed input file blocks.
template<class T >
std::vector<const T *> ActionWarehouse::getActions ( )
inline

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

Definition at line 130 of file ActionWarehouse.h.

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

Definition at line 189 of file ActionWarehouse.h.

189 { return _current_task; }
std::string _current_task
bool ActionWarehouse::hasActions ( const std::string &  task) const

Check if Actions associated with passed in task exist.

Definition at line 192 of file ActionWarehouse.C.

Referenced by DetermineSystemType::act(), MaterialOutputAction::buildMaterialOutputObjects(), CheckOutputAction::checkVariableOutput(), and getActions().

193 {
194  return _action_blocks.find(task) != _action_blocks.end();
195 }
std::map< std::string, std::list< Action * > > _action_blocks
Pointers to the actual parsed input file blocks.
std::shared_ptr<MooseMesh>& ActionWarehouse::mesh ( )
inline

Definition at line 183 of file ActionWarehouse.h.

Referenced by MooseApp::executeMeshModifiers(), and MooseApp::meshOnly().

183 { return _mesh; }
std::shared_ptr< MooseMesh > _mesh
Mesh class.
MooseApp& ActionWarehouse::mooseApp ( )
inline

Definition at line 188 of file ActionWarehouse.h.

Referenced by ExodusFormatter::printInputFile().

188 { return _app; }
MooseApp & _app
The MooseApp this Warehouse is associated with.
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 253 of file ActionWarehouse.C.

Referenced by empty(), and executeAllActions().

254 {
264  std::ostringstream oss;
265 
266  const auto & ordered_names = _syntax.getSortedTaskSet();
267  for (const auto & task_vector : ordered_names)
268  {
269  oss << "[DBG][ACT] (" << COLOR_YELLOW;
270  std::copy(
271  task_vector.begin(), task_vector.end(), infix_ostream_iterator<std::string>(oss, ", "));
272  oss << COLOR_DEFAULT << ")\n";
273 
274  std::set<std::string> task_set(task_vector.begin(), task_vector.end());
275  for (const auto & task : task_set)
276  {
277  if (_action_blocks.find(task) == _action_blocks.end())
278  continue;
279 
280  for (const auto & act : _action_blocks.at(task))
281  {
282  // The Syntax of the Action if it exists
283  if (act->name() != "")
284  oss << "[DBG][ACT]\t" << COLOR_GREEN << act->name() << COLOR_DEFAULT << '\n';
285 
286  // The task sets
287  oss << "[DBG][ACT]\t" << act->type();
288  const std::set<std::string> tasks = act->getAllTasks();
289  if (tasks.size() > 1)
290  {
291  oss << " (";
292  // Break the current Action's tasks into 2 sets, those intersecting with current set and
293  // then the difference.
294  std::set<std::string> intersection, difference;
295  std::set_intersection(tasks.begin(),
296  tasks.end(),
297  task_set.begin(),
298  task_set.end(),
299  std::inserter(intersection, intersection.end()));
300  std::set_difference(tasks.begin(),
301  tasks.end(),
302  intersection.begin(),
303  intersection.end(),
304  std::inserter(difference, difference.end()));
305 
306  oss << COLOR_CYAN;
307  std::copy(intersection.begin(),
308  intersection.end(),
310  oss << COLOR_MAGENTA << (difference.empty() ? "" : ", ");
311  std::copy(
312  difference.begin(), difference.end(), infix_ostream_iterator<std::string>(oss, ", "));
313  oss << COLOR_DEFAULT << ")";
314  }
315  oss << '\n';
316  }
317  }
318  }
319 
320  if (_show_actions)
321  _console << oss.str() << std::endl;
322 }
Syntax & _syntax
Reference to a "syntax" of actions.
const std::vector< std::vector< std::string > > & getSortedTaskSet()
Definition: Syntax.C:87
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.
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 empty(), 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->isParamValid("parser_syntax"))
381  name = act->getParam<std::string>("parser_syntax");
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)
Method for determining whether a piece of syntax is associated with an Action TODO: I need a better n...
Definition: Syntax.C:159
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...
std::shared_ptr< FEProblem > ActionWarehouse::problem ( )

Definition at line 408 of file ActionWarehouse.C.

Referenced by problemBase().

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

Definition at line 186 of file ActionWarehouse.h.

Referenced by MooseApp::setRestart().

186 { return _problem; }
std::shared_ptr< FEProblemBase > _problem
Problem class.
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 171 of file ActionWarehouse.h.

Referenced by SetupDebugAction::SetupDebugAction().

171 { _show_actions = state; }
void ActionWarehouse::showParser ( bool  state = true)
inline

Definition at line 173 of file ActionWarehouse.h.

Referenced by SetupDebugAction::SetupDebugAction().

173 { _show_parser = state; }
Syntax& ActionWarehouse::syntax ( )
inline

Definition at line 176 of file ActionWarehouse.h.

Referenced by DynamicObjectRegistrationAction::DynamicObjectRegistrationAction().

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

Member Data Documentation

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

The Factory that builds Actions.

Definition at line 208 of file ActionWarehouse.h.

Referenced by addActionBlock(), and buildBuildableActions().

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

Definition at line 201 of file ActionWarehouse.h.

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

MooseApp& ActionWarehouse::_app
protected

The MooseApp this Warehouse is associated with.

Definition at line 204 of file ActionWarehouse.h.

Referenced by mooseApp().

const ConsoleStream ConsoleStreamInterface::_console
inherited

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

Definition at line 37 of file ConsoleStreamInterface.h.

Referenced by IterationAdaptiveDT::acceptStep(), CreateProblemAction::act(), SetupRecoverFileBaseAction::act(), Adaptivity::adaptMesh(), FEProblemBase::adaptMesh(), FEProblemBase::advanceMultiApps(), SimplePredictor::apply(), FEProblemBase::backupMultiApps(), FEProblemBase::checkProblemIntegrity(), IterationAdaptiveDT::computeAdaptiveDT(), Transient::computeConstrainedDT(), NonlinearSystemBase::computeDamping(), IterationAdaptiveDT::computeDT(), IterationAdaptiveDT::computeFailedDT(), IterationAdaptiveDT::computeInterpolationDT(), FEProblemBase::computeResidualType(), IterationAdaptiveDT::constrainStep(), TimeStepper::constrainStep(), AB2PredictorCorrector::converged(), FEProblemBase::execMultiApps(), FEProblemBase::execMultiAppTransfers(), MultiAppPostprocessorTransfer::execute(), MultiAppPostprocessorInterpolationTransfer::execute(), MultiAppVariableValueSamplePostprocessorTransfer::execute(), MultiAppNearestNodeTransfer::execute(), MultiAppPostprocessorToAuxScalarTransfer::execute(), MultiAppScalarToAuxScalarTransfer::execute(), MultiAppVariableValueSampleTransfer::execute(), MultiAppUserObjectTransfer::execute(), MultiAppInterpolationTransfer::execute(), MultiAppMeshFunctionTransfer::execute(), MultiAppProjectionTransfer::execute(), MultiAppCopyTransfer::execute(), Steady::execute(), MultiAppDTKUserObjectTransfer::execute(), executeActionsWithAction(), executeAllActions(), 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(), 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(), FEProblemBase::useFECache(), Console::writeTimestepInformation(), Console::writeVariableNorms(), and FEProblemBase::~FEProblemBase().

std::string ActionWarehouse::_current_task
protected

Definition at line 231 of file ActionWarehouse.h.

Referenced by executeActionsWithAction(), and getCurrentTaskName().

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

Possible mesh for displaced problem.

Definition at line 241 of file ActionWarehouse.h.

Referenced by clear(), and displacedMesh().

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

Referenced by clear().

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

Mesh class.

Definition at line 238 of file ActionWarehouse.h.

Referenced by clear(), and mesh().

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

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

Definition at line 214 of file ActionWarehouse.h.

Referenced by build(), and executeAllActions().

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

Problem class.

Definition at line 244 of file ActionWarehouse.h.

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

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

Action blocks that have been requested.

Definition at line 212 of file ActionWarehouse.h.

bool ActionWarehouse::_show_actions
protected
bool ActionWarehouse::_show_parser
protected

Definition at line 227 of file ActionWarehouse.h.

Referenced by addActionBlock(), and showParser().

Syntax& ActionWarehouse::_syntax
protected

Reference to a "syntax" of actions.

Definition at line 206 of file ActionWarehouse.h.

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

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

Use to store the current list of unsatisfied dependencies.

Definition at line 216 of file ActionWarehouse.h.

Referenced by buildBuildableActions(), and checkUnsatisfiedActions().


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