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 "SubChannelAddVariablesAction.h" 11 : #include "ActionWarehouse.h" 12 : #include "ActionFactory.h" 13 : #include "AddAuxVariableAction.h" 14 : #include "SubChannelApp.h" 15 : 16 : registerMooseAction("SubChannelApp", SubChannelAddVariablesAction, "meta_action"); 17 : 18 : InputParameters 19 214 : SubChannelAddVariablesAction::validParams() 20 : { 21 214 : InputParameters params = Action::validParams(); 22 214 : params.addClassDescription("Adds the variables associated with the subchannel problem"); 23 214 : return params; 24 0 : } 25 : 26 214 : SubChannelAddVariablesAction::SubChannelAddVariablesAction(const InputParameters & parameters) 27 : : Action(parameters), 28 214 : _fe_family(AddVariableAction::getNonlinearVariableFamilies()), 29 214 : _fe_order(AddVariableAction::getNonlinearVariableOrders()) 30 : { 31 214 : } 32 : 33 : void 34 214 : SubChannelAddVariablesAction::act() 35 : { 36 : std::vector<std::string> var_names = {SubChannelApp::MASS_FLOW_RATE, 37 : SubChannelApp::SURFACE_AREA, 38 : SubChannelApp::SUM_CROSSFLOW, 39 : SubChannelApp::PRESSURE, 40 : SubChannelApp::PRESSURE_DROP, 41 : SubChannelApp::WETTED_PERIMETER, 42 : SubChannelApp::LINEAR_HEAT_RATE, 43 : SubChannelApp::DUCT_LINEAR_HEAT_RATE, 44 : SubChannelApp::ENTHALPY, 45 : SubChannelApp::TEMPERATURE, 46 : SubChannelApp::PIN_TEMPERATURE, 47 : SubChannelApp::PIN_DIAMETER, 48 : SubChannelApp::DUCT_TEMPERATURE, 49 : SubChannelApp::DENSITY, 50 : SubChannelApp::VISCOSITY, 51 3638 : SubChannelApp::DISPLACEMENT}; 52 : 53 : // Get a list of the already existing AddAuxVariableAction 54 214 : const auto & aux_actions = _awh.getActions<AddAuxVariableAction>(); 55 : 56 3638 : for (auto & vn : var_names) 57 : { 58 3424 : const std::string class_name = "AddAuxVariableAction"; 59 3424 : InputParameters params = _action_factory.getValidParams(class_name); 60 3424 : params.set<MooseEnum>("family") = _fe_family; 61 3424 : params.set<MooseEnum>("order") = _fe_order; 62 : 63 : std::shared_ptr<Action> action = 64 6848 : std::static_pointer_cast<Action>(_action_factory.create(class_name, vn, params)); 65 : 66 : // Avoid trying (and failing) to override the user variable selection 67 : bool add_action = true; 68 26064 : for (const auto aux_action : aux_actions) 69 22640 : if (aux_action->name() == vn) 70 : add_action = false; 71 : 72 3424 : if (add_action) 73 6099 : _awh.addActionBlock(action); 74 3424 : } 75 428 : }