https://mooseframework.inl.gov
Loading...
Searching...
No Matches
InputParameterWarehouse.h
Go to the documentation of this file.
1//* This file is part of the MOOSE framework
2//* https://mooseframework.inl.gov
3//*
4//* All rights reserved, see COPYRIGHT for full restrictions
5//* https://github.com/idaholab/moose/blob/master/COPYRIGHT
6//*
7//* Licensed under LGPL 2.1, please see LICENSE for details
8//* https://www.gnu.org/licenses/lgpl-2.1.html
9
10#pragma once
11
12#include <gtest/gtest.h>
13#include "MooseObjectName.h"
14#include "MooseTypes.h"
15#include "ControllableItem.h"
17#include "ControlOutput.h"
18
19// Forward declarations
20class InputParameters;
21class Factory;
22class ActionFactory;
23
34{
35public:
40
44 virtual ~InputParameterWarehouse() = default;
45
51 {
52 friend class Factory;
53 friend class ActionFactory;
54 FRIEND_TEST(InputParameterWarehouseTest, getControllableItems);
55 FRIEND_TEST(InputParameterWarehouseTest, getControllableParameter);
56 FRIEND_TEST(InputParameterWarehouseTest, getControllableParameterValues);
57 FRIEND_TEST(InputParameterWarehouseTest, emptyControllableParameterValues);
58 FRIEND_TEST(InputParameterWarehouseTest, addControllableParameterConnection);
59 FRIEND_TEST(InputParameterWarehouseTest, addControllableParameterAlias);
62 };
63
65
73 const InputParameters & getInputParametersObject(const std::string & name,
74 THREAD_ID tid = 0) const;
75 const InputParameters & getInputParametersObject(const std::string & tag,
76 const std::string & name,
77 THREAD_ID tid = 0) const;
79 THREAD_ID tid = 0) const;
81
84 const std::multimap<MooseObjectName, std::shared_ptr<InputParameters>> &
85 getInputParameters(THREAD_ID tid = 0) const;
86
91 const MooseObjectParameterName & secondary,
92 bool error_on_empty = true);
93
101 const MooseObjectParameterName & secondary);
102
106 void addControllableObjectAlias(const MooseObjectName & alias, const MooseObjectName & secondary);
107
108 /***
109 * Helper method for printing controllable items.
110 */
111 std::string dumpChangedControls(bool reset_changed) const;
112
117 template <typename T>
118 std::vector<T> getControllableParameterValues(const MooseObjectParameterName & input) const;
119
123 std::vector<MooseObjectParameterName>
125
139 InputParameters & addInputParameters(const std::string & name,
140 const InputParameters & parameters,
141 THREAD_ID tid,
142 const AddRemoveParamsKey);
143
147 void
148 removeInputParameters(const MooseObject & moose_object, THREAD_ID tid, const AddRemoveParamsKey);
149
150private:
153 std::vector<std::multimap<MooseObjectName, std::shared_ptr<InputParameters>>> _input_parameters;
154
159 std::vector<std::vector<std::shared_ptr<ControllableItem>>> _controllable_items;
160
168
173 std::vector<ControllableItem *> getControllableItems(const MooseObjectParameterName & desired,
174 THREAD_ID tid = 0) const;
175
177
189 InputParameters & getInputParameters(const std::string & name, THREAD_ID tid = 0) const;
191 getInputParameters(const std::string & tag, const std::string & name, THREAD_ID tid = 0) const;
193 THREAD_ID tid = 0) const;
195
201 friend class Control;
202
203 // Allow unit test to call methods
204 FRIEND_TEST(InputParameterWarehouseTest, getControllableItems);
205 FRIEND_TEST(InputParameterWarehouseTest, getControllableParameter);
206 FRIEND_TEST(InputParameterWarehouseTest, getControllableParameterValues);
207 FRIEND_TEST(InputParameterWarehouseTest, emptyControllableParameterValues);
208 FRIEND_TEST(InputParameterWarehouseTest, addControllableParameterConnection);
209 FRIEND_TEST(InputParameterWarehouseTest, addControllableParameterAlias);
210};
211
212template <typename T>
213std::vector<T>
unsigned int THREAD_ID
Definition MooseTypes.h:237
Specialized factory for generic Action System objects.
Base class for Control objects.
Definition Control.h:44
The ControllableParameter class is simply a set of ControllableItem objects.
std::vector< T > get(bool type_check=true, bool warn_when_values_difffer=false) const
Return a copy of the values of the given type.
Generic factory class for build all sorts of objects.
Definition Factory.h:29
Class that is used as a parameter to [add/remove]InputParameters() to restrict access.
FRIEND_TEST(InputParameterWarehouseTest, addControllableParameterConnection)
FRIEND_TEST(InputParameterWarehouseTest, emptyControllableParameterValues)
FRIEND_TEST(InputParameterWarehouseTest, addControllableParameterAlias)
FRIEND_TEST(InputParameterWarehouseTest, getControllableItems)
FRIEND_TEST(InputParameterWarehouseTest, getControllableParameter)
FRIEND_TEST(InputParameterWarehouseTest, getControllableParameterValues)
Storage container for all InputParamter objects.
FRIEND_TEST(InputParameterWarehouseTest, addControllableParameterConnection)
std::vector< std::vector< std::shared_ptr< ControllableItem > > > _controllable_items
Storage for controllable parameters via ControllableItem objects, a unique_ptr is used to avoid creat...
std::vector< MooseObjectParameterName > getControllableParameterNames(const MooseObjectParameterName &input) const
Return a vector of parameters names matching the supplied name.
ControllableParameter getControllableParameter(const MooseObjectParameterName &input) const
Returns a ControllableParameter object that contains all matches to ControllableItem objects for the ...
FRIEND_TEST(InputParameterWarehouseTest, addControllableParameterAlias)
void removeInputParameters(const MooseObject &moose_object, THREAD_ID tid, const AddRemoveParamsKey)
Allows for the deletion and cleanup of an object while the simulation is running.
std::string dumpChangedControls(bool reset_changed) const
std::vector< T > getControllableParameterValues(const MooseObjectParameterName &input) const
Returns a copy of the current values for a controllable parameter.
virtual ~InputParameterWarehouse()=default
Destruction.
std::vector< ControllableItem * > getControllableItems(const MooseObjectParameterName &desired, THREAD_ID tid=0) const
Returns a ControllableItem iterator, if the name is located.
const InputParameters & getInputParametersObject(const std::string &name, THREAD_ID tid=0) const
Return a const reference to the InputParameters for the named object.
const std::multimap< MooseObjectName, std::shared_ptr< InputParameters > > & getInputParameters(THREAD_ID tid=0) const
Return const reference to the map containing the InputParameter objects.
InputParameterWarehouse()
Class constructor.
FRIEND_TEST(InputParameterWarehouseTest, getControllableItems)
FRIEND_TEST(InputParameterWarehouseTest, emptyControllableParameterValues)
FRIEND_TEST(InputParameterWarehouseTest, getControllableParameter)
FRIEND_TEST(InputParameterWarehouseTest, getControllableParameterValues)
void addControllableObjectAlias(const MooseObjectName &alias, const MooseObjectName &secondary)
Method for creating alias for all shared controllable parameters between the two objects.
std::vector< std::multimap< MooseObjectName, std::shared_ptr< InputParameters > > > _input_parameters
Storage for the InputParameters objects TODO: Remove multimap.
void addControllableParameterConnection(const MooseObjectParameterName &primary, const MooseObjectParameterName &secondary, bool error_on_empty=true)
Method for linking control parameters of different names.
void addControllableParameterAlias(const MooseObjectParameterName &alias, const MooseObjectParameterName &secondary)
Method for creating alias to an existing controllable parameters.
InputParameters & addInputParameters(const std::string &name, const InputParameters &parameters, THREAD_ID tid, const AddRemoveParamsKey)
Method for adding a new InputParameters object.
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system.
A class for storing the names of MooseObject by tag and object name.
A class for storing an input parameter name.
Every object that can be built by the factory should be derived from this class.
Definition MooseObject.h:31