https://mooseframework.inl.gov
AddComponentAction.C
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 #include "AddComponentAction.h"
11 #include "THMProblem.h"
12 #include "THMMesh.h"
13 
14 registerMooseAction("ThermalHydraulicsApp", AddComponentAction, "THM:add_component");
15 
18 {
20  params.makeParamNotRequired<std::string>("type");
21  params.set<std::string>("type") = "ComponentGroup";
22  return params;
23 }
24 
26  : MooseObjectAction(params), _group(_type == "ComponentGroup")
27 {
28 }
29 
30 void
32 {
33  // Error if using an unsupported mesh type, as most components cannot handle working with a
34  // regular MooseMesh instead of a THM mesh
35  if (!dynamic_cast<THMMesh *>(_mesh.get()))
36  mooseError("The Components block cannot be used to add a Component in conjunction with the "
37  "Mesh block at this time");
38 
39  if (!_group)
40  {
41  THMProblem * thm_problem = dynamic_cast<THMProblem *>(_problem.get());
42  if (thm_problem)
43  {
44  _moose_object_pars.set<THMProblem *>("_thm_problem") = thm_problem;
45 
46  std::vector<std::string> parts;
47  MooseUtils::tokenize<std::string>(_moose_object_pars.blockFullpath(), parts);
48 
49  std::stringstream res;
50  std::copy(++parts.begin(), parts.end(), std::ostream_iterator<std::string>(res, "/"));
51 
52  std::string comp_name = res.str();
53  comp_name.pop_back();
54 
55  thm_problem->addComponent(_type, comp_name, _moose_object_pars);
56  }
57  }
58 }
Specialization of FEProblem to run with component subsystem.
Definition: THMProblem.h:18
static InputParameters validParams()
AddComponentAction(const InputParameters &params)
T & set(const std::string &name, bool quiet_mode=false)
registerMooseAction("ThermalHydraulicsApp", AddComponentAction, "THM:add_component")
static InputParameters validParams()
void makeParamNotRequired(const std::string &name)
std::shared_ptr< MooseMesh > & _mesh
std::string _type
virtual void addComponent(const std::string &type, const std::string &name, InputParameters params)
Add a component into this simulation.
Definition: Simulation.C:991
InputParameters _moose_object_pars
std::string blockFullpath() const
void mooseError(Args &&... args) const
std::shared_ptr< FEProblemBase > & _problem
virtual void act() override
bool _group
True if building a component group.