Skip to content

Commit

Permalink
Merge pull request #13005 from YaqiWang/close_13004
Browse files Browse the repository at this point in the history
Small interface improvement in ActionWarehouse::getActionListByName
  • Loading branch information
permcody committed Mar 6, 2019
2 parents 9a12949 + 19dab88 commit a0a6ea0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
3 changes: 3 additions & 0 deletions framework/include/actions/ActionWarehouse.h
Expand Up @@ -99,6 +99,7 @@ class ActionWarehouse : public ConsoleStreamInterface

/**
* Retrieve a constant list of \p Action pointers associated with the passed in task.
* Empty list will be returned if no actions are associated with the task.
*/
const std::list<Action *> & getActionListByName(const std::string & task) const;

Expand Down Expand Up @@ -282,6 +283,8 @@ class ActionWarehouse : public ConsoleStreamInterface
std::string _final_task;

ActionIterator _act_iter;

const std::list<Action *> _empty_action_list;
};

#endif // ACTIONWAREHOUSE_H
6 changes: 3 additions & 3 deletions framework/src/actions/ActionWarehouse.C
Expand Up @@ -189,9 +189,9 @@ ActionWarehouse::getActionListByName(const std::string & task) const
{
const auto it = _action_blocks.find(task);
if (it == _action_blocks.end())
mooseError("The task ", task, " does not exist.");

return it->second;
return _empty_action_list;
else
return it->second;
}

bool
Expand Down
37 changes: 17 additions & 20 deletions framework/src/actions/CheckOutputAction.C
Expand Up @@ -41,27 +41,24 @@ CheckOutputAction::act()
void
CheckOutputAction::checkVariableOutput(const std::string & task)
{
if (_awh.hasActions(task))
// Loop through the actions for the given task
const auto & actions = _awh.getActionListByName(task);
for (const auto & act : actions)
{
// Loop through the actions for the given task
const auto & actions = _awh.getActionListByName(task);
for (const auto & act : actions)
{
// Cast the object to AddVariableAction so that that
// OutputInterface::buildOutputHideVariableList may be called
AddVariableAction * ptr = dynamic_cast<AddVariableAction *>(act);

// If the cast fails move to the next action, this is the case with NodalNormals which is also
// associated with
// the "add_aux_variable" task.
if (ptr == NULL)
continue;

// Create the hide list for the action
std::set<std::string> names_set;
names_set.insert(ptr->name());
ptr->buildOutputHideVariableList(names_set);
}
// Cast the object to AddVariableAction so that that
// OutputInterface::buildOutputHideVariableList may be called
AddVariableAction * ptr = dynamic_cast<AddVariableAction *>(act);

// If the cast fails move to the next action, this is the case with NodalNormals which is also
// associated with
// the "add_aux_variable" task.
if (ptr == NULL)
continue;

// Create the hide list for the action
std::set<std::string> names_set;
names_set.insert(ptr->name());
ptr->buildOutputHideVariableList(names_set);
}
}

Expand Down

0 comments on commit a0a6ea0

Please sign in to comment.