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 15669 : AddComponentAction::validParams() 18 : { 19 15669 : InputParameters params = MooseObjectAction::validParams(); 20 15669 : params.makeParamNotRequired<std::string>("type"); 21 15669 : params.set<std::string>("type") = "ComponentGroup"; 22 15669 : return params; 23 0 : } 24 : 25 15669 : AddComponentAction::AddComponentAction(const InputParameters & params) 26 15669 : : MooseObjectAction(params), _group(_type == "ComponentGroup") 27 : { 28 15669 : } 29 : 30 : void 31 15659 : 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 15659 : 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 15657 : if (!_group) 40 : { 41 15643 : THMProblem * thm_problem = dynamic_cast<THMProblem *>(_problem.get()); 42 15643 : if (thm_problem) 43 : { 44 15643 : _moose_object_pars.set<THMProblem *>("_thm_problem") = thm_problem; 45 : 46 : std::vector<std::string> parts; 47 31286 : MooseUtils::tokenize<std::string>(_moose_object_pars.blockFullpath(), parts); 48 : 49 15643 : std::stringstream res; 50 15643 : std::copy(++parts.begin(), parts.end(), std::ostream_iterator<std::string>(res, "/")); 51 : 52 : std::string comp_name = res.str(); 53 15643 : comp_name.pop_back(); 54 : 55 15643 : thm_problem->addComponent(_type, comp_name, _moose_object_pars); 56 15641 : } 57 : } 58 15655 : }