www.mooseframework.org
InputParameterWarehouse.h
Go to the documentation of this file.
1 //* This file is part of the MOOSE framework
2 //* https://www.mooseframework.org
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"
16 #include "ControllableParameter.h"
17 #include "Factory.h"
18 #include "ControlOutput.h"
19 
20 // Forward declarations
21 class InputParameters;
22 
33 {
34 public:
39 
43  virtual ~InputParameterWarehouse() = default;
44 
46 
54  const InputParameters & getInputParametersObject(const std::string & name,
55  THREAD_ID tid = 0) const;
56  const InputParameters & getInputParametersObject(const std::string & tag,
57  const std::string & name,
58  THREAD_ID tid = 0) const;
59  const InputParameters & getInputParametersObject(const MooseObjectName & object_name,
60  THREAD_ID tid = 0) const;
62 
65  const std::multimap<MooseObjectName, std::shared_ptr<InputParameters>> &
66  getInputParameters(THREAD_ID tid = 0) const;
67 
72  const MooseObjectParameterName & slave,
73  bool error_on_empty = true);
74 
82  const MooseObjectParameterName & slave);
83 
84  /***
85  * Helper method for printing controllable items.
86  */
87  std::string dumpChangedControls(bool reset_changed) const;
88 
93  template <typename T>
94  std::vector<T> getControllableParameterValues(const MooseObjectParameterName & input) const;
95 
96 private:
99  std::vector<std::multimap<MooseObjectName, std::shared_ptr<InputParameters>>> _input_parameters;
100 
105  std::vector<std::vector<std::shared_ptr<ControllableItem>>> _controllable_items;
106 
121  addInputParameters(const std::string & name, InputParameters parameters, THREAD_ID tid = 0);
122 
126  void removeInputParameters(const MooseObject & moose_object, THREAD_ID tid = 0);
127 
135 
140  std::vector<ControllableItem *> getControllableItems(const MooseObjectParameterName & desired,
141  THREAD_ID tid = 0) const;
142 
144 
156  InputParameters & getInputParameters(const std::string & name, THREAD_ID tid = 0) const;
158  getInputParameters(const std::string & tag, const std::string & name, THREAD_ID tid = 0) const;
159  InputParameters & getInputParameters(const MooseObjectName & object_name,
160  THREAD_ID tid = 0) const;
162 
165  friend MooseObjectPtr
166  Factory::create(const std::string &, const std::string &, InputParameters, THREAD_ID, bool);
169 
175  friend class Control;
176 
177  // Allow unit test to call methods
183 };
184 
185 template <typename T>
186 std::vector<T>
188  const MooseObjectParameterName & input) const
189 {
191  return param.get<T>();
192 }
193 
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, InputParameters parameters, THREAD_ID tid=0, bool print_deprecated=true)
Build an object (must be registered) - THIS METHOD IS DEPRECATED (Use create<T>()) ...
Definition: Factory.C:87
std::vector< ControllableItem * > getControllableItems(const MooseObjectParameterName &desired, THREAD_ID tid=0) const
Returns a ControllableItem iterator, if the name is located.
Storage container for all InputParamter objects.
void addControllableParameterAlias(const MooseObjectParameterName &alias, const MooseObjectParameterName &slave)
Method for creating alias to an existing controllable parameters.
The ControllableParameter class is simply a set of ControllableItem objects.
virtual ~InputParameterWarehouse()=default
Destruction.
FRIEND_TEST(InputParameterWarehouse, getControllableItems)
The main MOOSE class responsible for handling user-defined parameters in almost every MOOSE system...
std::string dumpChangedControls(bool reset_changed) const
InputParameterWarehouse()
Class constructor.
const std::multimap< MooseObjectName, std::shared_ptr< InputParameters > > & getInputParameters(THREAD_ID tid=0) const
Return const reference to the map containing the InputParameter objects.
Every object that can be built by the factory should be derived from this class.
Definition: MooseObject.h:42
ControllableParameter getControllableParameter(const MooseObjectParameterName &input) const
Returns a ControllableParameter object that contains all matches to ControllableItem objects for the ...
InputParameters & addInputParameters(const std::string &name, InputParameters parameters, THREAD_ID tid=0)
Method for adding a new InputParameters object.
void releaseSharedObjects(const MooseObject &moose_object, THREAD_ID tid=0)
Releases any shared resources created as a side effect of creating an object through the Factory::cre...
Definition: Factory.C:166
void removeInputParameters(const MooseObject &moose_object, THREAD_ID tid=0)
Allows for the deletion and cleanup of an object while the simulation is running. ...
void addControllableParameterConnection(const MooseObjectParameterName &master, const MooseObjectParameterName &slave, bool error_on_empty=true)
Method for linking control parameters of different names.
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.
Base class for Control objects.
Definition: Control.h:37
const InputParameters & getInputParametersObject(const std::string &name, THREAD_ID tid=0) const
Return a const reference to the InputParameters for the named object.
std::vector< std::multimap< MooseObjectName, std::shared_ptr< InputParameters > > > _input_parameters
Storage for the InputParameters objects TODO: Remove multimap.
A class for storing an input parameter name.
std::shared_ptr< MooseObject > MooseObjectPtr
alias to wrap shared pointer type
Definition: Factory.h:123
A class for storing the names of MooseObject by tag and object name.
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< T > getControllableParameterValues(const MooseObjectParameterName &input) const
Returns a copy of the current values for a controllable parameter.
unsigned int THREAD_ID
Definition: MooseTypes.h:161