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