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 "THMProblem.h" 11 : #include "Component.h" 12 : #include "FlowChannelBase.h" 13 : #include "ConstantFunction.h" 14 : #include "THMNames.h" 15 : 16 : using namespace libMesh; 17 : 18 : InputParameters 19 8320 : FlowModel::validParams() 20 : { 21 8320 : InputParameters params = MooseObject::validParams(); 22 8320 : params.addPrivateParam<THMProblem *>("_thm_problem"); 23 8320 : params.addPrivateParam<FlowChannelBase *>("_flow_channel"); 24 16640 : params.addRequiredParam<UserObjectName>( 25 : "fp", "The name of the user object that defines fluid properties"); 26 16640 : params.addRequiredParam<bool>("output_vector_velocity", 27 : "True if velocity is put out as a vector field."); 28 8320 : params.registerBase("THM:flow_model"); 29 8320 : return params; 30 0 : } 31 : 32 : const std::string FlowModel::AREA = THM::AREA; 33 : const std::string FlowModel::AREA_LINEAR = THM::AREA_LINEAR; 34 : const std::string FlowModel::HEAT_FLUX_WALL = THM::HEAT_FLUX_WALL; 35 : const std::string FlowModel::HEAT_FLUX_PERIMETER = THM::HEAT_FLUX_PERIMETER; 36 : const std::string FlowModel::NUSSELT_NUMBER = THM::NUSSELT_NUMBER; 37 : const std::string FlowModel::TEMPERATURE_WALL = THM::TEMPERATURE_WALL; 38 : const std::string FlowModel::UNITY = THM::UNITY; 39 : const std::string FlowModel::DIRECTION = THM::DIRECTION; 40 : 41 4160 : FlowModel::FlowModel(const InputParameters & params) 42 : : MooseObject(params), 43 4160 : _sim(*params.getCheckedPointerParam<THMProblem *>("_thm_problem")), 44 4160 : _factory(_app.getFactory()), 45 4160 : _flow_channel(*params.getCheckedPointerParam<FlowChannelBase *>("_flow_channel")), 46 4160 : _fe_type(_sim.getFlowFEType()), 47 4160 : _fp_name(params.get<UserObjectName>("fp")), 48 4160 : _comp_name(name()), 49 8320 : _gravity_vector(_flow_channel.getParam<RealVectorValue>("gravity_vector")), 50 4160 : _gravity_magnitude(_gravity_vector.norm()), 51 8320 : _output_vector_velocity(params.get<bool>("output_vector_velocity")) 52 : { 53 4160 : } 54 : 55 : const FunctionName & 56 3967 : FlowModel::getVariableFn(const FunctionName & fn_param_name) 57 : { 58 3967 : const FunctionName & fn_name = _flow_channel.getParam<FunctionName>(fn_param_name); 59 3967 : const Function & fn = _sim.getFunction(fn_name); 60 : 61 3967 : if (dynamic_cast<const ConstantFunction *>(&fn) != nullptr) 62 : { 63 7844 : _flow_channel.connectObject(fn.parameters(), fn_name, fn_param_name, "value"); 64 : } 65 : 66 3967 : return fn_name; 67 : } 68 : 69 : void 70 4048 : FlowModel::addCommonVariables() 71 : { 72 4048 : const std::vector<SubdomainName> & subdomains = _flow_channel.getSubdomainNames(); 73 : 74 4048 : _sim.addSimVariable(false, AREA, _fe_type, subdomains); 75 4048 : _sim.addSimVariable(false, HEAT_FLUX_PERIMETER, _fe_type, subdomains); 76 4048 : _sim.addSimVariable(false, AREA_LINEAR, FEType(FIRST, LAGRANGE), subdomains); 77 4048 : } 78 : 79 : void 80 4048 : FlowModel::addCommonInitialConditions() 81 : { 82 12144 : if (_flow_channel.isParamValid("A") && !_app.isRestarting()) 83 : { 84 4000 : const std::vector<SubdomainName> & block = _flow_channel.getSubdomainNames(); 85 4000 : const FunctionName & area_function = _flow_channel.getAreaFunctionName(); 86 : 87 4000 : if (!_sim.hasFunction(area_function)) 88 : { 89 2735 : const Function & fn = _sim.getFunction(area_function); 90 5470 : _sim.addConstantIC(AREA, fn.value(0, Point()), block); 91 5470 : _sim.addConstantIC(AREA_LINEAR, fn.value(0, Point()), block); 92 : 93 5470 : _flow_channel.makeFunctionControllableIfConstant(area_function, "Area", "value"); 94 : } 95 : else 96 : { 97 1265 : _sim.addFunctionIC(AREA_LINEAR, area_function, block); 98 : 99 : { 100 1265 : const std::string class_name = "FunctionNodalAverageIC"; 101 1265 : InputParameters params = _factory.getValidParams(class_name); 102 2530 : params.set<VariableName>("variable") = AREA; 103 1265 : params.set<std::vector<SubdomainName>>("block") = block; 104 1265 : params.set<FunctionName>("function") = area_function; 105 2530 : _sim.addSimInitialCondition(class_name, genName(_comp_name, AREA, "ic"), params); 106 1265 : } 107 : } 108 : } 109 4048 : } 110 : 111 : void 112 4048 : FlowModel::addCommonMooseObjects() 113 : { 114 : // add material property equal to one, useful for dummy multiplier values 115 : { 116 4048 : const std::string class_name = "ConstantMaterial"; 117 4048 : InputParameters params = _factory.getValidParams(class_name); 118 4048 : params.set<std::vector<SubdomainName>>("block") = _flow_channel.getSubdomainNames(); 119 4048 : params.set<std::string>("property_name") = FlowModel::UNITY; 120 4048 : params.set<Real>("value") = 1.0; 121 4048 : params.set<std::vector<VariableName>>("derivative_vars") = _derivative_vars; 122 4048 : _sim.addMaterial(class_name, genName(_comp_name, FlowModel::UNITY), params); 123 4048 : } 124 4048 : }