https://mooseframework.inl.gov
THMActionComponent.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 "THMActionComponent.h"
11 #include "Control.h"
12 
15 {
17  return params;
18 }
19 
21 
22 void
24 {
25  if (_current_task == "THM:add_component")
27  if (_current_task == "THM:add_closures")
28  addClosures();
29  if (_current_task == "THM:add_control_logic")
31 }
32 
33 THMProblem &
35 {
36  THMProblem * thm_problem = dynamic_cast<THMProblem *>(_problem.get());
37  if (thm_problem)
38  return *thm_problem;
39  else
40  mooseError("The Problem must derive from THMProblem to use THMActionComponents. Please include "
41  "a [Components] block in your input file, even if empty.");
42 }
43 
44 void
45 THMActionComponent::addTHMComponent(const std::string & class_name,
46  const std::string & obj_name,
47  InputParameters & params)
48 {
49  auto & thm_problem = getTHMProblem();
50  params.set<THMProblem *>("_thm_problem") = &thm_problem;
51  thm_problem.addComponent(class_name, obj_name, params);
52 }
53 
54 void
55 THMActionComponent::addClosuresObject(const std::string & class_name,
56  const std::string & obj_name,
57  InputParameters & params)
58 {
59  auto & thm_problem = getTHMProblem();
60  params.set<THMProblem *>("_thm_problem") = &thm_problem;
61  params.set<Logger *>("_logger") = &(thm_problem.log());
62  thm_problem.addClosures(class_name, obj_name, params);
63 }
64 
65 void
66 THMActionComponent::addControlLogicObject(const std::string & class_name,
67  const std::string & obj_name,
68  InputParameters & params)
69 {
70  auto & thm_problem = getTHMProblem();
71  params.set<FEProblemBase *>("_fe_problem_base") = _problem.get();
72  params.set<THMProblem *>("_thm_problem") = &thm_problem;
73  std::shared_ptr<Control> control = _factory.create<Control>(class_name, obj_name, params);
74  thm_problem.getControlWarehouse().addObject(control);
75 }
Keeps the error and warning messages.
Definition: Logger.h:17
virtual void addControlLogic()
Specialization of FEProblem to run with component subsystem.
Definition: THMProblem.h:18
virtual void addTHMComponents()
void addControlLogicObject(const std::string &class_name, const std::string &obj_name, InputParameters &params)
Adds a ControlLogic object.
Factory & _factory
T & set(const std::string &name, bool quiet_mode=false)
std::shared_ptr< MooseObject > create(const std::string &obj_name, const std::string &name, const InputParameters &parameters, THREAD_ID tid=0, bool print_deprecated=true)
static InputParameters validParams()
THMActionComponent(const InputParameters &params)
virtual void actOnAdditionalTasks() override
const std::string & _current_task
THMProblem & getTHMProblem()
Gets the THM problem.
virtual void addComponent(const std::string &type, const std::string &name, InputParameters params)
Add a component into this simulation.
Definition: Simulation.C:991
void addClosuresObject(const std::string &class_name, const std::string &obj_name, InputParameters &params)
Adds a Closures object.
void mooseError(Args &&... args) const
std::shared_ptr< FEProblemBase > & _problem
virtual void addClosures()
void addTHMComponent(const std::string &class_name, const std::string &obj_name, InputParameters &params)
Adds a THM component.
static InputParameters validParams()