Line data Source code
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 : 16 : InputParameters 17 8189 : AddComponentAction::validParams() 18 : { 19 8189 : InputParameters params = MooseObjectAction::validParams(); 20 8189 : params.makeParamNotRequired<std::string>("type"); 21 8189 : params.set<std::string>("type") = "ComponentGroup"; 22 8189 : return params; 23 0 : } 24 : 25 8189 : AddComponentAction::AddComponentAction(const InputParameters & params) 26 8189 : : MooseObjectAction(params), _group(_type == "ComponentGroup") 27 : { 28 8189 : } 29 : 30 : void 31 8179 : AddComponentAction::act() 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 8179 : if (!dynamic_cast<THMMesh *>(_mesh.get())) 36 2 : mooseError("The Components block cannot be used to add a Component in conjunction with the " 37 : "Mesh block at this time"); 38 : 39 8177 : if (!_group) 40 : { 41 8171 : THMProblem * thm_problem = dynamic_cast<THMProblem *>(_problem.get()); 42 8171 : if (thm_problem) 43 : { 44 8171 : _moose_object_pars.set<THMProblem *>("_thm_problem") = thm_problem; 45 : 46 : std::vector<std::string> parts; 47 16342 : MooseUtils::tokenize<std::string>(_moose_object_pars.blockFullpath(), parts); 48 : 49 8171 : std::stringstream res; 50 8171 : std::copy(++parts.begin(), parts.end(), std::ostream_iterator<std::string>(res, "/")); 51 : 52 : std::string comp_name = res.str(); 53 8171 : comp_name.pop_back(); 54 : 55 8171 : thm_problem->addComponent(_type, comp_name, _moose_object_pars); 56 8169 : } 57 : } 58 8175 : }