Skip to content

Commit

Permalink
addressing Alex Lindsay's comments idaholab#22068
Browse files Browse the repository at this point in the history
  • Loading branch information
YaqiWang committed Sep 15, 2022
1 parent 10a5af0 commit 9be6b4d
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 22 deletions.
2 changes: 1 addition & 1 deletion framework/doc/content/syntax/Controls/index.md
Expand Up @@ -152,7 +152,7 @@ The two postprocessors in [controls_tags] declare the same control tag `tag`.
Thus their controllable parameter `point` can be set by controls simultaneously with `tag/*/point` as in [controls_tags_use].

!listing test/tests/controls/tag_based_naming_access/param.i
block=Postprocessors
block=Controls
id=controls_tags_use
caption=Example of usinging the tagged controllable parameters.

Expand Down
3 changes: 3 additions & 0 deletions framework/include/actions/GlobalParamsAction.h
Expand Up @@ -27,6 +27,9 @@ class GlobalParamsAction : public Action
*/
void remove(const std::string & name);

/**
* Obtain a non-const reference of the action parameters in the InputParameterWarehouse.
*/
InputParameters & parameters();

template <typename T>
Expand Down
3 changes: 1 addition & 2 deletions framework/include/interfaces/MeshMetaDataInterface.h
Expand Up @@ -9,15 +9,14 @@

#pragma once

#include "MooseObject.h"
#include "MooseError.h"
#include "InputParameters.h"
#include "RestartableData.h"

#include <string>

class MooseApp;
class MeshGenerator;
class MooseObject;

/**
* The Interface used to retrieve mesh meta data (attributes) set by the MeshGenerator system.
Expand Down
4 changes: 3 additions & 1 deletion framework/include/interfaces/PerfGraphInterface.h
Expand Up @@ -11,7 +11,6 @@

#include "Moose.h"
#include "PerfGuard.h"
#include "InputParameters.h"

#ifndef MOOSE_NO_PERF_GRAPH
#define TIME_SECTION1(id) \
Expand Down Expand Up @@ -39,6 +38,9 @@
#define TIME_SECTION(...) \
GET_MACRO(__VA_ARGS__, TIME_SECTION4, TIME_SECTION3, TIME_SECTION2, TIME_SECTION1, )(__VA_ARGS__)

class InputParameters;
class MooseObject;

/**
* Interface for objects interacting with the PerfGraph.
*
Expand Down
1 change: 1 addition & 0 deletions framework/include/utils/InputParameters.h
Expand Up @@ -1015,6 +1015,7 @@ class InputParameters : public Parameters
friend InputParameters emptyInputParameters();
friend class InputParameterWarehouse;
friend class Parser;
// for the printInputFile function in the action warehouse
friend class ActionWarehouse;

// For setting _from_legacy_construction (remove with #19440)
Expand Down
28 changes: 12 additions & 16 deletions framework/src/actions/ActionFactory.C
Expand Up @@ -43,25 +43,21 @@ ActionFactory::reg(const std::string & name,
std::shared_ptr<Action>
ActionFactory::create(const std::string & action,
const std::string & full_action_name,
InputParameters & parameters)
InputParameters & incoming_parser_params)
{
std::string action_name = MooseUtils::shortName(full_action_name);
parameters.addPrivateParam("_moose_app", &_app);
parameters.addPrivateParam("action_type", action);
incoming_parser_params.addPrivateParam("_moose_app", &_app);
incoming_parser_params.addPrivateParam("action_type", action);
std::pair<ActionFactory::iterator, ActionFactory::iterator> iters;

if (!(parameters.have_parameter<bool>("isObjectAction") &&
parameters.get<bool>("isObjectAction")))
parameters.set<std::vector<std::string>>("control_tags")
.push_back(MooseUtils::baseName(full_action_name));

std::string unique_action_name = action + parameters.get<std::string>("task") + full_action_name;
std::string unique_action_name =
action + incoming_parser_params.get<std::string>("task") + full_action_name;
// Create the actual parameters object that the object will reference
InputParameters & params =
_app.getInputParameterWarehouse().addInputParameters(unique_action_name, parameters);
InputParameters & action_params = _app.getInputParameterWarehouse().addInputParameters(
unique_action_name, incoming_parser_params);

// Check to make sure that all required parameters are supplied
params.checkParams(action_name);
action_params.checkParams(action_name);

iters = _name_to_build_info.equal_range(action);
BuildInfo * build_info = &(iters.first->second);
Expand All @@ -71,11 +67,11 @@ ActionFactory::create(const std::string & action,
action_name);

// Add the name to the parameters and create the object
params.set<std::string>("_action_name") = action_name;
params.set<std::string>("_unique_action_name") = unique_action_name;
std::shared_ptr<Action> action_obj = (*build_info->_build_pointer)(params);
action_params.set<std::string>("_action_name") = action_name;
action_params.set<std::string>("_unique_action_name") = unique_action_name;
std::shared_ptr<Action> action_obj = (*build_info->_build_pointer)(action_params);

if (parameters.get<std::string>("task") == "")
if (action_params.get<std::string>("task") == "")
action_obj->appendTask(build_info->_task);

return action_obj;
Expand Down
3 changes: 1 addition & 2 deletions framework/src/actions/GlobalParamsAction.C
Expand Up @@ -44,6 +44,5 @@ GlobalParamsAction::remove(const std::string & name)
InputParameters &
GlobalParamsAction::parameters()
{
const auto & params = _app.getInputParameterWarehouse().getInputParameters();
return *(params.find(uniqueActionName())->second.get());
return const_cast<InputParameters &>(_pars);
}
4 changes: 4 additions & 0 deletions framework/src/parser/Parser.C
Expand Up @@ -484,6 +484,10 @@ Parser::walkRaw(std::string /*fullpath*/, std::string /*nodepath*/, hit::Node *
params.blockLocation() = n->filename() + ":" + std::to_string(n->line());
params.blockFullpath() = n->fullpath();

if (!(params.have_parameter<bool>("isObjectAction") && params.get<bool>("isObjectAction")))
params.set<std::vector<std::string>>("control_tags")
.push_back(MooseUtils::baseName(curr_identifier));

// Create the Action
std::shared_ptr<Action> action_obj =
_action_factory.create(it->second._action, curr_identifier, params);
Expand Down

0 comments on commit 9be6b4d

Please sign in to comment.