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 "FlowModelSetup.h" 11 : #include "MooseObjectAction.h" 12 : #include "AddVariableAction.h" 13 : #include "Numerics.h" 14 : 15 : InputParameters 16 50 : FlowModelSetup::validParams() 17 : { 18 50 : InputParameters params = emptyInputParameters(); 19 : 20 100 : params.addParam<bool>("2nd_order_mesh", false, "Use 2nd order elements in the mesh"); 21 100 : params.addParam<Real>( 22 : "gravity_magnitude", THM::gravity_const, "Gravitational acceleration magnitude"); 23 : 24 50 : return params; 25 0 : } 26 : 27 50 : FlowModelSetup::FlowModelSetup(const InputParameters & params) 28 50 : : _this_params(params), 29 50 : _this_app(*_this_params.getCheckedPointerParam<MooseApp *>("_moose_app")), 30 50 : _this_action_factory(_this_app.getActionFactory()), 31 50 : _this_action_warehouse(*_this_params.getCheckedPointerParam<ActionWarehouse *>("awh")), 32 50 : _fe_family(AddVariableAction::getNonlinearVariableFamilies()), 33 50 : _fe_order(AddVariableAction::getNonlinearVariableOrders()), 34 150 : _gravity_magnitude(getParam<Real>("gravity_magnitude")) 35 : { 36 100 : if (getParam<bool>("2nd_order_mesh")) 37 0 : _fe_order = "SECOND"; 38 50 : } 39 : 40 : void 41 150 : FlowModelSetup::addSolutionVariable(const VariableName & var_name, const Real & scaling) 42 : { 43 150 : const std::string class_name = "AddVariableAction"; 44 150 : InputParameters params = _this_action_factory.getValidParams(class_name); 45 150 : params.set<std::vector<Real>>("scaling") = {scaling}; 46 150 : params.set<MooseEnum>("family") = _fe_family; 47 150 : params.set<MooseEnum>("order") = _fe_order; 48 : 49 : std::shared_ptr<Action> action = 50 150 : std::static_pointer_cast<Action>(_this_action_factory.create(class_name, var_name, params)); 51 : 52 450 : _this_action_warehouse.addActionBlock(action); 53 300 : } 54 : 55 : void 56 400 : FlowModelSetup::addAuxVariable(const VariableName & var_name) 57 : { 58 400 : const std::string class_name = "AddAuxVariableAction"; 59 400 : InputParameters params = _this_action_factory.getValidParams(class_name); 60 : 61 : std::shared_ptr<Action> action = 62 400 : std::static_pointer_cast<Action>(_this_action_factory.create(class_name, var_name, params)); 63 : 64 1200 : _this_action_warehouse.addActionBlock(action); 65 800 : } 66 : 67 : void 68 200 : FlowModelSetup::addFunctionIC(const VariableName & var_name, const FunctionName & function_name) 69 : { 70 200 : const std::string class_name = "AddInitialConditionAction"; 71 200 : InputParameters params = _this_action_factory.getValidParams(class_name); 72 200 : params.set<std::string>("type") = "FunctionIC"; 73 : 74 : std::shared_ptr<MooseObjectAction> action = std::static_pointer_cast<MooseObjectAction>( 75 400 : _this_action_factory.create(class_name, var_name + "_IC", params)); 76 : 77 200 : action->getObjectParams().set<VariableName>("variable") = var_name; 78 200 : action->getObjectParams().set<FunctionName>("function") = function_name; 79 : 80 600 : _this_action_warehouse.addActionBlock(action); 81 400 : } 82 : 83 : void 84 50 : FlowModelSetup::addMaterials() 85 : { 86 : { 87 50 : const std::string class_name = "AddMaterialAction"; 88 50 : InputParameters params = _this_action_factory.getValidParams(class_name); 89 50 : params.set<std::string>("type") = "DirectionMaterial"; 90 : 91 : std::shared_ptr<MooseObjectAction> action = std::static_pointer_cast<MooseObjectAction>( 92 50 : _this_action_factory.create(class_name, "direction_material", params)); 93 150 : _this_action_warehouse.addActionBlock(action); 94 50 : } 95 50 : }