Skip to content

Commit

Permalink
not allow copies of all input parameters in the warehouse idaholab#22068
Browse files Browse the repository at this point in the history
  • Loading branch information
YaqiWang committed Sep 13, 2022
1 parent 898132d commit 8af9ff7
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 8 deletions.
6 changes: 6 additions & 0 deletions framework/include/outputs/formatters/ExodusFormatter.h
Expand Up @@ -11,6 +11,12 @@

#include "InputFileFormatter.h"

#include <sstream>
#include <string>
#include <vector>

class ActionWarehouse;

/*
* Dumps the input file in the Exodus output
*/
Expand Down
Expand Up @@ -12,9 +12,7 @@
#include <string>
#include <ostream>

#include "InputParameters.h"
#include "ActionWarehouse.h"
#include "MooseSyntax.h"
class InputParameters;

/**
* This interface is for classes that want to be called to format InputParameters. When the
Expand Down
2 changes: 2 additions & 0 deletions framework/include/outputs/formatters/YAMLFormatter.h
Expand Up @@ -10,6 +10,8 @@
#pragma once

#include "SyntaxTree.h"
#include "InputParameters.h"

#include <sstream>
#include <iterator>

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;
friend class ActionWarehouse;

// For setting _from_legacy_construction (remove with #19440)
template <typename T>
Expand Down
1 change: 1 addition & 0 deletions framework/include/utils/SyntaxTree.h
Expand Up @@ -13,6 +13,7 @@

#include <string>
#include <map>
#include <set>

// Forward declarations
class InputParameters;
Expand Down
8 changes: 7 additions & 1 deletion framework/src/actions/ActionWarehouse.C
Expand Up @@ -20,6 +20,7 @@
#include "InfixIterator.h"
#include "FEProblem.h"
#include "MemoryUtils.h"
#include "InputParameterWarehouse.h"

#include "libmesh/simple_range.h"

Expand Down Expand Up @@ -411,10 +412,15 @@ ActionWarehouse::printInputFile(std::ostream & out)
bool is_parent;
if (_syntax.isAssociated(name, &is_parent) != "")
{
InputParameters params = act->parameters();
const auto & all_params = _app.getInputParameterWarehouse().getInputParameters();
InputParameters & params = *(all_params.find(act->uniqueActionName())->second.get());

// temporarily allow input parameter copies required by the input file formatter
params.allowCopy(true);

// TODO: Do we need to insert more nodes for each task?
tree.insertNode(name, *tasks.begin(), true, &params);
params.allowCopy(false);

MooseObjectAction * moose_object_action = dynamic_cast<MooseObjectAction *>(act);
if (moose_object_action)
Expand Down
1 change: 1 addition & 0 deletions framework/src/outputs/formatters/ExodusFormatter.C
Expand Up @@ -13,6 +13,7 @@
#include "MooseApp.h"
#include "SystemInfo.h"
#include "CommandLine.h"
#include "ActionWarehouse.h"

#include "libmesh/exodusII.h"

Expand Down
1 change: 1 addition & 0 deletions framework/src/outputs/formatters/InputFileFormatter.C
Expand Up @@ -9,6 +9,7 @@

#include "InputFileFormatter.h"
#include "MooseUtils.h"
#include "InputParameters.h"

#include <sstream>
#include <vector>
Expand Down
5 changes: 1 addition & 4 deletions framework/src/utils/InputParameterWarehouse.C
Expand Up @@ -98,10 +98,7 @@ InputParameterWarehouse::addInputParameters(const std::string & name,
ptr->addPrivateParam<THREAD_ID>("_tid", tid);

// no more copies allowed
// Note: we have to skip action parameters for now due to parameter copy operations in
// the input parameter printing capability in ActionWarehouse::printInputFile.
if (base != "Action")
ptr->allowCopy(false);
ptr->allowCopy(false);

// Return a reference to the InputParameters object
return *ptr;
Expand Down

0 comments on commit 8af9ff7

Please sign in to comment.