LCOV - code coverage report
Current view: top level - src/base - FlowModel.C (source / functions) Hit Total Coverage
Test: idaholab/moose thermal_hydraulics: #32971 (54bef8) with base c6cf66 Lines: 58 59 98.3 %
Date: 2026-05-29 20:41:18 Functions: 6 6 100.0 %
Legend: Lines: hit not hit

          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        4284 : FlowModel::validParams()
      20             : {
      21        4284 :   InputParameters params = MooseObject::validParams();
      22        4284 :   params.addPrivateParam<THMProblem *>("_thm_problem");
      23        4284 :   params.addPrivateParam<FlowChannelBase *>("_flow_channel");
      24        8568 :   params.addRequiredParam<UserObjectName>(
      25             :       "fp", "The name of the user object that defines fluid properties");
      26        8568 :   params.addRequiredParam<bool>("output_vector_velocity",
      27             :                                 "True if velocity is put out as a vector field.");
      28        4284 :   params.registerBase("THM:flow_model");
      29        4284 :   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        2142 : FlowModel::FlowModel(const InputParameters & params)
      42             :   : MooseObject(params),
      43        2142 :     _sim(*params.getCheckedPointerParam<THMProblem *>("_thm_problem")),
      44        2142 :     _factory(_app.getFactory()),
      45        2142 :     _flow_channel(*params.getCheckedPointerParam<FlowChannelBase *>("_flow_channel")),
      46        2142 :     _fe_type(_sim.getFlowFEType()),
      47        2142 :     _fp_name(params.get<UserObjectName>("fp")),
      48        2142 :     _comp_name(name()),
      49        4284 :     _gravity_vector(_flow_channel.getParam<RealVectorValue>("gravity_vector")),
      50        2142 :     _gravity_magnitude(_gravity_vector.norm()),
      51        4284 :     _output_vector_velocity(params.get<bool>("output_vector_velocity"))
      52             : {
      53        2142 : }
      54             : 
      55             : const FunctionName &
      56        1991 : FlowModel::getVariableFn(const FunctionName & fn_param_name)
      57             : {
      58        1991 :   const FunctionName & fn_name = _flow_channel.getParam<FunctionName>(fn_param_name);
      59        1991 :   const Function & fn = _sim.getFunction(fn_name);
      60             : 
      61        1991 :   if (dynamic_cast<const ConstantFunction *>(&fn) != nullptr)
      62             :   {
      63        3940 :     _flow_channel.connectObject(fn.parameters(), fn_name, fn_param_name, "value");
      64             :   }
      65             : 
      66        1991 :   return fn_name;
      67             : }
      68             : 
      69             : void
      70        2046 : FlowModel::addCommonVariables()
      71             : {
      72        2046 :   const std::vector<SubdomainName> & subdomains = _flow_channel.getSubdomainNames();
      73             : 
      74        2046 :   _sim.addSimVariable(false, AREA, _fe_type, subdomains);
      75        2046 :   _sim.addSimVariable(false, HEAT_FLUX_PERIMETER, _fe_type, subdomains);
      76        2046 :   _sim.addSimVariable(false, AREA_LINEAR, FEType(FIRST, LAGRANGE), subdomains);
      77        2046 : }
      78             : 
      79             : void
      80        2046 : FlowModel::addCommonInitialConditions()
      81             : {
      82        6138 :   if (_flow_channel.isParamValid("A") && !_app.isRestarting())
      83             :   {
      84        2010 :     const std::vector<SubdomainName> & block = _flow_channel.getSubdomainNames();
      85        2010 :     const FunctionName & area_function = _flow_channel.getAreaFunctionName();
      86             : 
      87        2010 :     if (!_sim.hasFunction(area_function))
      88             :     {
      89        1398 :       const Function & fn = _sim.getFunction(area_function);
      90        2796 :       _sim.addConstantIC(AREA, fn.value(0, Point()), block);
      91        4194 :       _sim.addConstantIC(AREA_LINEAR, fn.value(0, Point()), block);
      92             :     }
      93             :     else
      94             :     {
      95         612 :       _sim.addFunctionIC(AREA_LINEAR, area_function, block);
      96             : 
      97             :       {
      98         612 :         const std::string class_name = "FunctionNodalAverageIC";
      99         612 :         InputParameters params = _factory.getValidParams(class_name);
     100        1224 :         params.set<VariableName>("variable") = AREA;
     101         612 :         params.set<std::vector<SubdomainName>>("block") = block;
     102         612 :         params.set<FunctionName>("function") = area_function;
     103        1224 :         _sim.addSimInitialCondition(class_name, genName(_comp_name, AREA, "ic"), params);
     104         612 :       }
     105             :     }
     106             :   }
     107        2046 : }
     108             : 
     109             : void
     110        2046 : FlowModel::addCommonMooseObjects()
     111             : {
     112             :   // add material property equal to one, useful for dummy multiplier values
     113             :   {
     114        2046 :     const std::string class_name = "ConstantMaterial";
     115        2046 :     InputParameters params = _factory.getValidParams(class_name);
     116        2046 :     params.set<std::vector<SubdomainName>>("block") = _flow_channel.getSubdomainNames();
     117        2046 :     params.set<std::string>("property_name") = FlowModel::UNITY;
     118        2046 :     params.set<Real>("value") = 1.0;
     119        2046 :     params.set<std::vector<VariableName>>("derivative_vars") = _derivative_vars;
     120        2046 :     _sim.addMaterial(class_name, genName(_comp_name, FlowModel::UNITY), params);
     121        2046 :   }
     122        2046 : }

Generated by: LCOV version 1.14