LCOV - code coverage report
Current view: top level - src/physics - WCNSFVFluidHeatTransferPhysics.C (source / functions) Hit Total Coverage
Test: idaholab/moose navier_stokes: 2bd28b Lines: 287 328 87.5 %
Date: 2025-10-23 22:11:45 Functions: 12 12 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 "WCNSFVFluidHeatTransferPhysics.h"
      11             : #include "WCNSFVFlowPhysics.h"
      12             : #include "NSFVBase.h"
      13             : #include "NS.h"
      14             : 
      15             : registerNavierStokesPhysicsBaseTasks("NavierStokesApp", WCNSFVFluidHeatTransferPhysics);
      16             : registerWCNSFVFluidHeatTransferPhysicsBaseTasks("NavierStokesApp", WCNSFVFluidHeatTransferPhysics);
      17             : 
      18             : InputParameters
      19        1306 : WCNSFVFluidHeatTransferPhysics::validParams()
      20             : {
      21        1306 :   InputParameters params = WCNSFVFluidHeatTransferPhysicsBase::validParams();
      22        1306 :   params.transferParam<MooseEnum>(NSFVBase::validParams(), "energy_face_interpolation");
      23        1306 :   params.transferParam<Real>(NSFVBase::validParams(), "energy_scaling");
      24        2612 :   params.addParam<bool>(
      25             :       "check_bc_compatibility",
      26        2612 :       true,
      27             :       "Whether to check for known incompatibility between boundary conditions for "
      28             :       "the heat transport equation physics and other physics");
      29        2612 :   params.addParamNamesToGroup("check_bc_compatibility", "Advanced");
      30             : 
      31        2612 :   params.addParamNamesToGroup("energy_face_interpolation energy_scaling", "Numerical scheme");
      32        1306 :   return params;
      33           0 : }
      34             : 
      35        1306 : WCNSFVFluidHeatTransferPhysics::WCNSFVFluidHeatTransferPhysics(const InputParameters & parameters)
      36        1306 :   : WCNSFVFluidHeatTransferPhysicsBase(parameters)
      37             : {
      38        2608 :   checkSecondParamNotSetIfFirstOneSet("solve_for_enthalpy", "fluid_temperature_variable");
      39        1304 : }
      40             : 
      41             : void
      42        1280 : WCNSFVFluidHeatTransferPhysics::addSolverVariables()
      43             : {
      44             :   // For compatibility with Modules/NavierStokesFV syntax
      45        1280 :   if (!_has_energy_equation)
      46             :     return;
      47             : 
      48             :   const auto & solver_variable_name =
      49         707 :       _solve_for_enthalpy ? _fluid_enthalpy_name : _fluid_temperature_name;
      50             : 
      51             :   // Dont add if the user already defined the variable
      52         707 :   if (!shouldCreateVariable(solver_variable_name, _blocks, /*error if aux*/ true))
      53          27 :     reportPotentiallyMissedParameters({"system_names",
      54             :                                        "energy_scaling",
      55             :                                        "energy_face_interpolation",
      56             :                                        "energy_two_term_bc_expansion"},
      57             :                                       "INSFVEnergyVariable");
      58         680 :   else if (_define_variables)
      59             :   {
      60         678 :     auto params = getFactory().getValidParams("INSFVEnergyVariable");
      61         678 :     assignBlocks(params, _blocks);
      62        2034 :     params.set<std::vector<Real>>("scaling") = {getParam<Real>("energy_scaling")};
      63        2034 :     params.set<MooseEnum>("face_interp_method") = getParam<MooseEnum>("energy_face_interpolation");
      64         678 :     params.set<bool>("two_term_boundary_expansion") =
      65        1356 :         getParam<bool>("energy_two_term_bc_expansion");
      66        1356 :     params.set<SolverSystemName>("solver_sys") = getSolverSystem(solver_variable_name);
      67         678 :     getProblem().addVariable("INSFVEnergyVariable", solver_variable_name, params);
      68         678 :   }
      69             :   else
      70             :     // we don't let the user select the enthalpy variable name at this time
      71           4 :     paramError(_solve_for_enthalpy ? "solve_for_enthalpy" : "fluid_temperature_variable",
      72           2 :                "Variable (" + solver_variable_name +
      73             :                    ") supplied to the WCNSFVFluidHeatTransferPhysics does not exist!");
      74             : }
      75             : 
      76             : void
      77         163 : WCNSFVFluidHeatTransferPhysics::addEnergyTimeKernels()
      78             : {
      79             :   std::string kernel_type =
      80         163 :       ((_compressibility == "weakly-compressible") ? "WCNSFVEnergyTimeDerivative"
      81         239 :                                                    : "INSFVEnergyTimeDerivative");
      82             :   std::string kernel_name =
      83         163 :       prefix() + ((_compressibility == "weakly-compressible") ? "wcns" : "ins") + "_energy_time";
      84         163 :   if (_porous_medium_treatment)
      85             :   {
      86             :     kernel_type = "PINSFVEnergyTimeDerivative";
      87         168 :     kernel_name = prefix() + ((_compressibility == "weakly-compressible") ? "pwcns" : "pins") +
      88          84 :                   "_energy_time";
      89             :   }
      90             : 
      91             :   const auto & solver_variable_name =
      92         163 :       _solve_for_enthalpy ? _fluid_enthalpy_name : _fluid_temperature_name;
      93             : 
      94         163 :   InputParameters params = getFactory().getValidParams(kernel_type);
      95         163 :   assignBlocks(params, _blocks);
      96         326 :   params.set<NonlinearVariableName>("variable") = solver_variable_name;
      97         163 :   params.set<MooseFunctorName>(NS::density) = _density_name;
      98         326 :   params.set<MooseFunctorName>(NS::time_deriv(NS::specific_enthalpy)) =
      99         163 :       NS::time_deriv(NS::specific_enthalpy);
     100         163 :   if (_compressibility == "weakly-compressible")
     101             :   {
     102         348 :     params.set<MooseFunctorName>(NS::time_deriv(NS::density)) = NS::time_deriv(_density_name);
     103         174 :     params.set<MooseFunctorName>(NS::specific_enthalpy) = NS::specific_enthalpy;
     104             :   }
     105         163 :   if (_porous_medium_treatment)
     106             :   {
     107          84 :     params.set<MooseFunctorName>(NS::porosity) =
     108         168 :         _flow_equations_physics->getPorosityFunctorName(/*smoothed=*/false);
     109         168 :     if (getProblem().hasFunctor(NS::time_deriv(_density_name),
     110             :                                 /*thread_id=*/0))
     111             :     {
     112         252 :       params.set<MooseFunctorName>(NS::time_deriv(NS::density)) = NS::time_deriv(_density_name);
     113         168 :       params.set<MooseFunctorName>(NS::specific_enthalpy) = NS::specific_enthalpy;
     114             :     }
     115             : 
     116          84 :     params.set<bool>("is_solid") = false;
     117             :   }
     118             : 
     119         163 :   getProblem().addFVKernel(kernel_type, kernel_name, params);
     120         326 : }
     121             : 
     122             : void
     123         695 : WCNSFVFluidHeatTransferPhysics::addEnergyAdvectionKernels()
     124             : {
     125         695 :   std::string kernel_type = "INSFVEnergyAdvection";
     126           0 :   std::string kernel_name = prefix() + "ins_energy_advection";
     127         695 :   if (_porous_medium_treatment)
     128             :   {
     129             :     kernel_type = "PINSFVEnergyAdvection";
     130         438 :     kernel_name = prefix() + "pins_energy_advection";
     131             :   }
     132             : 
     133             :   const auto & solver_variable_name =
     134         695 :       _solve_for_enthalpy ? _fluid_enthalpy_name : _fluid_temperature_name;
     135             : 
     136         695 :   InputParameters params = getFactory().getValidParams(kernel_type);
     137        1390 :   params.set<NonlinearVariableName>("variable") = solver_variable_name;
     138         695 :   assignBlocks(params, _blocks);
     139         695 :   params.set<MooseEnum>("velocity_interp_method") = _velocity_interpolation;
     140        1390 :   params.set<UserObjectName>("rhie_chow_user_object") = _flow_equations_physics->rhieChowUOName();
     141        1390 :   params.set<MooseEnum>("advected_interp_method") =
     142        2085 :       getParam<MooseEnum>("energy_advection_interpolation");
     143             : 
     144         695 :   getProblem().addFVKernel(kernel_type, kernel_name, params);
     145        1390 : }
     146             : 
     147             : void
     148         695 : WCNSFVFluidHeatTransferPhysics::addEnergyHeatConductionKernels()
     149             : {
     150         695 :   const auto vector_conductivity = processThermalConductivity();
     151             :   const auto num_blocks = _thermal_conductivity_blocks.size();
     152             :   const auto num_used_blocks = num_blocks ? num_blocks : 1;
     153             :   const auto & solver_variable_name =
     154         689 :       _solve_for_enthalpy ? _fluid_enthalpy_name : _fluid_temperature_name;
     155             : 
     156        1397 :   for (const auto block_i : make_range(num_used_blocks))
     157             :   {
     158         708 :     std::string block_name = "";
     159         708 :     if (num_blocks)
     160          76 :       block_name = Moose::stringify(_thermal_conductivity_blocks[block_i]);
     161             :     else
     162             :       block_name = "all";
     163             : 
     164         708 :     if (_porous_medium_treatment)
     165             :     {
     166             :       const auto kernel_type =
     167         236 :           vector_conductivity ? "PINSFVEnergyAnisotropicDiffusion" : "PINSFVEnergyDiffusion";
     168             : 
     169         236 :       InputParameters params = getFactory().getValidParams(kernel_type);
     170         472 :       params.set<NonlinearVariableName>("variable") = solver_variable_name;
     171         274 :       const auto block_names = num_blocks ? _thermal_conductivity_blocks[block_i] : _blocks;
     172         236 :       assignBlocks(params, block_names);
     173         434 :       const auto conductivity_name = vector_conductivity ? NS::kappa : NS::k;
     174         236 :       params.set<MooseFunctorName>(NS::porosity) =
     175         236 :           _flow_equations_physics->getPorosityFunctorName(true);
     176         472 :       params.set<bool>("effective_conductivity") = getParam<bool>("effective_conductivity");
     177         236 :       if (!_solve_for_enthalpy)
     178         236 :         params.set<MooseFunctorName>(conductivity_name) = _thermal_conductivity_name[block_i];
     179             :       else
     180           0 :         params.set<MooseFunctorName>(conductivity_name) =
     181           0 :             _thermal_conductivity_name[block_i] + "_by_cp";
     182             : 
     183         708 :       getProblem().addFVKernel(
     184         472 :           kernel_type, prefix() + "pins_energy_diffusion_" + block_name, params);
     185         236 :     }
     186             :     else
     187             :     {
     188         472 :       const std::string kernel_type = "FVDiffusion";
     189         472 :       InputParameters params = getFactory().getValidParams(kernel_type);
     190         944 :       params.set<NonlinearVariableName>("variable") = solver_variable_name;
     191             :       std::vector<SubdomainName> block_names =
     192         472 :           num_blocks ? _thermal_conductivity_blocks[block_i] : _blocks;
     193         472 :       assignBlocks(params, block_names);
     194         472 :       if (!_solve_for_enthalpy)
     195         830 :         params.set<MooseFunctorName>("coeff") = _thermal_conductivity_name[block_i];
     196             :       else
     197         228 :         params.set<MooseFunctorName>("coeff") = _thermal_conductivity_name[block_i] + "_by_cp";
     198             : 
     199         944 :       getProblem().addFVKernel(
     200         472 :           kernel_type, prefix() + "ins_energy_diffusion_" + block_name, params);
     201         472 :     }
     202             :   }
     203         689 : }
     204             : 
     205             : void
     206         225 : WCNSFVFluidHeatTransferPhysics::addEnergyAmbientConvection()
     207             : {
     208         225 :   unsigned int num_convection_blocks = _ambient_convection_blocks.size();
     209             :   unsigned int num_used_blocks = num_convection_blocks ? num_convection_blocks : 1;
     210             :   const auto & solver_variable_name =
     211         225 :       _solve_for_enthalpy ? _fluid_enthalpy_name : _fluid_temperature_name;
     212             : 
     213         225 :   const std::string kernel_type = "PINSFVEnergyAmbientConvection";
     214         225 :   InputParameters params = getFactory().getValidParams(kernel_type);
     215         450 :   params.set<NonlinearVariableName>("variable") = solver_variable_name;
     216         225 :   params.set<MooseFunctorName>(NS::T_fluid) = _fluid_temperature_name;
     217         225 :   params.set<bool>("is_solid") = false;
     218             : 
     219         450 :   for (unsigned int block_i = 0; block_i < num_used_blocks; ++block_i)
     220             :   {
     221         225 :     std::string block_name = "";
     222         225 :     if (num_convection_blocks)
     223             :     {
     224          19 :       params.set<std::vector<SubdomainName>>("block") = _ambient_convection_blocks[block_i];
     225          38 :       block_name = Moose::stringify(_ambient_convection_blocks[block_i]);
     226             :     }
     227             :     else
     228             :     {
     229         206 :       assignBlocks(params, _blocks);
     230         412 :       block_name = std::to_string(block_i);
     231             :     }
     232             : 
     233         450 :     params.set<MooseFunctorName>("h_solid_fluid") = _ambient_convection_alpha[block_i];
     234         225 :     params.set<MooseFunctorName>(NS::T_solid) = _ambient_temperature[block_i];
     235             : 
     236         675 :     getProblem().addFVKernel(kernel_type, prefix() + "ambient_convection_" + block_name, params);
     237             :   }
     238         450 : }
     239             : 
     240             : void
     241         143 : WCNSFVFluidHeatTransferPhysics::addEnergyExternalHeatSource()
     242             : {
     243             :   const auto & solver_variable_name =
     244         143 :       _solve_for_enthalpy ? _fluid_enthalpy_name : _fluid_temperature_name;
     245         143 :   const std::string kernel_type = "FVCoupledForce";
     246         143 :   InputParameters params = getFactory().getValidParams(kernel_type);
     247         286 :   params.set<NonlinearVariableName>("variable") = solver_variable_name;
     248         143 :   assignBlocks(params, _blocks);
     249         429 :   params.set<MooseFunctorName>("v") = getParam<MooseFunctorName>("external_heat_source");
     250         286 :   params.set<Real>("coef") = getParam<Real>("external_heat_source_coeff");
     251             : 
     252         286 :   getProblem().addFVKernel(kernel_type, prefix() + "external_heat_source", params);
     253         286 : }
     254             : 
     255             : void
     256         685 : WCNSFVFluidHeatTransferPhysics::addEnergyInletBC()
     257             : {
     258         685 :   const auto & inlet_boundaries = _flow_equations_physics->getInletBoundaries();
     259             :   // These are parameter errors for now. If Components add boundaries to Physics, the error
     260             :   // may not be due to parameters anymore.
     261         685 :   if (inlet_boundaries.size() != _energy_inlet_types.size())
     262           4 :     paramError("energy_inlet_types",
     263           2 :                "Energy inlet types (size " + std::to_string(_energy_inlet_types.size()) +
     264           2 :                    ") should be the same size as inlet_boundaries (size " +
     265           2 :                    std::to_string(inlet_boundaries.size()) + ")");
     266         683 :   if (inlet_boundaries.size() != _energy_inlet_functors.size())
     267           0 :     paramError("energy_inlet_functors",
     268           0 :                "Energy inlet functors (size " + std::to_string(_energy_inlet_functors.size()) +
     269           0 :                    ") should be the same size as inlet_boundaries (size " +
     270           0 :                    std::to_string(inlet_boundaries.size()) + ")");
     271             : 
     272             :   const auto & solver_variable_name =
     273         683 :       _solve_for_enthalpy ? _fluid_enthalpy_name : _fluid_temperature_name;
     274             : 
     275             :   unsigned int flux_bc_counter = 0;
     276        1339 :   for (const auto bc_ind : index_range(_energy_inlet_types))
     277             :   {
     278         656 :     if (_energy_inlet_types[bc_ind] == "fixed-temperature")
     279             :     {
     280         375 :       const std::string bc_type = _solve_for_enthalpy
     281             :                                       ? "FVSpecificEnthalpyFromPressureTemperatureDirichletBC"
     282         731 :                                       : "FVADFunctorDirichletBC";
     283         375 :       InputParameters params = getFactory().getValidParams(bc_type);
     284         750 :       params.set<NonlinearVariableName>("variable") = solver_variable_name;
     285         375 :       if (!_solve_for_enthalpy)
     286         712 :         params.set<MooseFunctorName>("functor") = _energy_inlet_functors[bc_ind];
     287             :       else
     288             :       {
     289             :         mooseAssert(_flow_equations_physics, "Should be coupled");
     290          19 :         params.set<UserObjectName>(NS::fluid) = getParam<UserObjectName>(NS::fluid);
     291          19 :         params.set<MooseFunctorName>(NS::pressure) = _flow_equations_physics->getPressureName();
     292          19 :         params.set<MooseFunctorName>(NS::T_fluid) = _energy_inlet_functors[bc_ind];
     293             :       }
     294        1125 :       params.set<std::vector<BoundaryName>>("boundary") = {inlet_boundaries[bc_ind]};
     295             : 
     296         375 :       getProblem().addFVBC(bc_type, solver_variable_name + "_" + inlet_boundaries[bc_ind], params);
     297             : 
     298             :       // Check the BCs for momentum
     299             :       const auto momentum_inlet_type =
     300         375 :           _flow_equations_physics->inletBoundaryType(inlet_boundaries[bc_ind]);
     301        1125 :       if (getParam<bool>("check_bc_compatibility") &&
     302         375 :           (momentum_inlet_type == NS::MomentumInletTypes::FLUX_VELOCITY ||
     303             :            momentum_inlet_type == NS::MomentumInletTypes::FLUX_MASS))
     304           0 :         paramError("energy_inlet_types",
     305           0 :                    "At inlet '" + inlet_boundaries[bc_ind] +
     306             :                        "', you are using a Dirichlet boundary condition on temperature, and a "
     307             :                        "flux boundary condition on momentum. This is known to create an "
     308             :                        "undesirable inlet source term.");
     309         375 :     }
     310         281 :     else if (_energy_inlet_types[bc_ind] == "heatflux")
     311             :     {
     312         180 :       const std::string bc_type = "FVFunctionNeumannBC";
     313         180 :       InputParameters params = getFactory().getValidParams(bc_type);
     314         360 :       params.set<NonlinearVariableName>("variable") = solver_variable_name;
     315         360 :       params.set<FunctionName>("function") = _energy_inlet_functors[bc_ind];
     316         540 :       params.set<std::vector<BoundaryName>>("boundary") = {inlet_boundaries[bc_ind]};
     317             : 
     318         180 :       getProblem().addFVBC(bc_type, solver_variable_name + "_" + inlet_boundaries[bc_ind], params);
     319         180 :     }
     320         101 :     else if (_energy_inlet_types[bc_ind] == "flux-mass" ||
     321          65 :              _energy_inlet_types[bc_ind] == "flux-velocity")
     322             :     {
     323         101 :       const std::string bc_type = "WCNSFVEnergyFluxBC";
     324         101 :       InputParameters params = getFactory().getValidParams(bc_type);
     325         202 :       params.set<NonlinearVariableName>("variable") = solver_variable_name;
     326         101 :       const auto & flux_inlet_directions = _flow_equations_physics->getFluxInletDirections();
     327             :       const auto & flux_inlet_pps = _flow_equations_physics->getFluxInletPPs();
     328             : 
     329         101 :       if (flux_inlet_pps.size() < flux_bc_counter)
     330           0 :         _flow_equations_physics->paramError(
     331             :             "flux_inlet_pps",
     332             :             "Should be specified for all 'flux-mass/velocity' boundary conditions");
     333             : 
     334         101 :       if (flux_inlet_directions.size())
     335             :       {
     336          18 :         if (flux_inlet_directions.size() < flux_bc_counter)
     337           0 :           _flow_equations_physics->paramError("flux_inlet_pps",
     338             :                                               "Should be specified for all or none of the "
     339             :                                               "'flux-mass/velocity' boundary conditions");
     340          18 :         params.set<Point>("direction") = flux_inlet_directions[flux_bc_counter];
     341             :       }
     342         101 :       if (_energy_inlet_types[bc_ind] == "flux-mass")
     343             :       {
     344          36 :         params.set<PostprocessorName>("mdot_pp") = flux_inlet_pps[flux_bc_counter];
     345         144 :         params.set<PostprocessorName>("area_pp") = "area_pp_" + inlet_boundaries[bc_ind];
     346             :       }
     347             :       else
     348         130 :         params.set<PostprocessorName>("velocity_pp") = flux_inlet_pps[flux_bc_counter];
     349             : 
     350         202 :       params.set<PostprocessorName>("temperature_pp") = _energy_inlet_functors[bc_ind];
     351         101 :       params.set<MooseFunctorName>(NS::density) = _density_name;
     352         101 :       params.set<MooseFunctorName>(NS::cp) = _specific_heat_name;
     353         202 :       params.set<MooseFunctorName>(NS::T_fluid) = _fluid_temperature_name;
     354             : 
     355         101 :       if (isParamValid(NS::fluid))
     356             :       {
     357          38 :         params.set<UserObjectName>(NS::fluid) = getParam<UserObjectName>(NS::fluid);
     358          76 :         params.set<MooseFunctorName>(NS::pressure) = _flow_equations_physics->getPressureName();
     359             :       }
     360             : 
     361         101 :       if (_solve_for_enthalpy)
     362          76 :         params.set<MooseFunctorName>(NS::specific_enthalpy) = _fluid_enthalpy_name;
     363             : 
     364         284 :       for (const auto d : make_range(dimension()))
     365         366 :         params.set<MooseFunctorName>(NS::velocity_vector[d]) = _velocity_names[d];
     366             : 
     367         303 :       params.set<std::vector<BoundaryName>>("boundary") = {inlet_boundaries[bc_ind]};
     368             : 
     369         101 :       getProblem().addFVBC(bc_type, solver_variable_name + "_" + inlet_boundaries[bc_ind], params);
     370         101 :       flux_bc_counter += 1;
     371         101 :     }
     372             :   }
     373         683 : }
     374             : 
     375             : void
     376         683 : WCNSFVFluidHeatTransferPhysics::addEnergyWallBC()
     377             : {
     378        1366 :   const auto & wall_boundaries = isParamSetByUser("energy_wall_boundaries")
     379        1404 :                                      ? getParam<std::vector<BoundaryName>>("energy_wall_boundaries")
     380         645 :                                      : _flow_equations_physics->getWallBoundaries();
     381         683 :   if (wall_boundaries.size() != _energy_wall_types.size())
     382           4 :     paramError("energy_wall_types",
     383           2 :                "Energy wall types (size " + std::to_string(_energy_wall_types.size()) +
     384           2 :                    ") should be the same size as wall_boundaries (size " +
     385           2 :                    std::to_string(wall_boundaries.size()) + ")");
     386         681 :   if (wall_boundaries.size() != _energy_wall_functors.size())
     387           0 :     paramError("energy_wall_functors",
     388           0 :                "Energy wall functors (size " + std::to_string(_energy_wall_functors.size()) +
     389           0 :                    ") should be the same size as wall_boundaries (size " +
     390           0 :                    std::to_string(wall_boundaries.size()) + ")");
     391             : 
     392             :   const auto & solver_variable_name =
     393         681 :       _solve_for_enthalpy ? _fluid_enthalpy_name : _fluid_temperature_name;
     394             : 
     395        2125 :   for (unsigned int bc_ind = 0; bc_ind < _energy_wall_types.size(); ++bc_ind)
     396             :   {
     397        1444 :     if (_energy_wall_types[bc_ind] == "fixed-temperature")
     398             :     {
     399         170 :       const std::string bc_type = _solve_for_enthalpy
     400             :                                       ? "FVSpecificEnthalpyFromPressureTemperatureDirichletBC"
     401         264 :                                       : "FVADFunctorDirichletBC";
     402         170 :       InputParameters params = getFactory().getValidParams(bc_type);
     403         340 :       params.set<NonlinearVariableName>("variable") = solver_variable_name;
     404         170 :       if (!_solve_for_enthalpy)
     405         188 :         params.set<MooseFunctorName>("functor") = _energy_wall_functors[bc_ind];
     406             :       else
     407             :       {
     408          76 :         params.set<UserObjectName>(NS::fluid) = getParam<UserObjectName>(NS::fluid);
     409          76 :         params.set<MooseFunctorName>(NS::pressure) = _flow_equations_physics->getPressureName();
     410          76 :         params.set<MooseFunctorName>(NS::T_fluid) = _energy_wall_functors[bc_ind];
     411             :       }
     412         510 :       params.set<std::vector<BoundaryName>>("boundary") = {wall_boundaries[bc_ind]};
     413             : 
     414         170 :       getProblem().addFVBC(bc_type, solver_variable_name + "_" + wall_boundaries[bc_ind], params);
     415         170 :     }
     416        1274 :     else if (_energy_wall_types[bc_ind] == "heatflux")
     417             :     {
     418        1220 :       const std::string bc_type = "FVFunctorNeumannBC";
     419        1220 :       InputParameters params = getFactory().getValidParams(bc_type);
     420        2440 :       params.set<NonlinearVariableName>("variable") = solver_variable_name;
     421        2440 :       params.set<MooseFunctorName>("functor") = _energy_wall_functors[bc_ind];
     422        3660 :       params.set<std::vector<BoundaryName>>("boundary") = {wall_boundaries[bc_ind]};
     423             : 
     424        1220 :       getProblem().addFVBC(bc_type, solver_variable_name + "_" + wall_boundaries[bc_ind], params);
     425        1220 :     }
     426          54 :     else if (_energy_wall_types[bc_ind] == "convection")
     427             :     {
     428           0 :       const std::string bc_type = "FVFunctorConvectiveHeatFluxBC";
     429           0 :       InputParameters params = getFactory().getValidParams(bc_type);
     430           0 :       params.set<NonlinearVariableName>("variable") = solver_variable_name;
     431           0 :       params.set<MooseFunctorName>("T_bulk") = _fluid_temperature_name;
     432           0 :       params.set<std::vector<BoundaryName>>("boundary") = {wall_boundaries[bc_ind]};
     433           0 :       params.set<bool>("is_solid") = false;
     434             :       const auto Tinf_htc_functors =
     435           0 :           MooseUtils::split(_energy_wall_functors[bc_ind], /*delimiter=*/":", /*max_count=*/1);
     436           0 :       if (Tinf_htc_functors.size() != 2)
     437           0 :         paramError("energy_wall_functors",
     438             :                    "'convective' wall types require two functors specified as "
     439             :                    "<Tinf_functor>:<htc_functor>.");
     440           0 :       params.set<MooseFunctorName>("T_solid") = Tinf_htc_functors[0];
     441           0 :       params.set<MooseFunctorName>("heat_transfer_coefficient") = Tinf_htc_functors[1];
     442             : 
     443           0 :       getProblem().addFVBC(bc_type, solver_variable_name + "_" + wall_boundaries[bc_ind], params);
     444           0 :     }
     445             :     // We add this boundary condition here to facilitate the input of wall boundaries / functors for
     446             :     // energy. If there are too many turbulence options and this gets out of hand we will have to
     447             :     // move this to the turbulence Physics
     448          54 :     else if (_energy_wall_types[bc_ind] == "wallfunction")
     449             :     {
     450          54 :       if (!_turbulence_physics)
     451           0 :         paramError("coupled_turbulence_physics",
     452             :                    "A coupled turbulence Physics was not found for defining the wall function "
     453           0 :                    "boundary condition on boundary: " +
     454           0 :                        wall_boundaries[bc_ind]);
     455          54 :       const std::string bc_type = "INSFVTurbulentTemperatureWallFunction";
     456          54 :       InputParameters params = getFactory().getValidParams(bc_type);
     457         108 :       params.set<NonlinearVariableName>("variable") = solver_variable_name;
     458         162 :       params.set<std::vector<BoundaryName>>("boundary") = {wall_boundaries[bc_ind]};
     459          54 :       params.set<MooseEnum>("wall_treatment") =
     460         162 :           _turbulence_physics->turbulenceTemperatureWallTreatment();
     461          54 :       params.set<MooseFunctorName>("T_w") = _energy_wall_functors[bc_ind];
     462          54 :       params.set<MooseFunctorName>(NS::density) = _density_name;
     463          54 :       params.set<MooseFunctorName>(NS::mu) = _dynamic_viscosity_name;
     464         162 :       params.set<MooseFunctorName>(NS::TKE) = _turbulence_physics->tkeName();
     465          54 :       if (_thermal_conductivity_name.size() != 1)
     466           0 :         mooseError("Several anisotropic thermal conductivity (kappa) regions have been specified. "
     467             :                    "Selecting the right kappa coefficient for the turbulence boundaries is not "
     468           0 :                    "currently implemented.\nBoundaries:\n" +
     469           0 :                    Moose::stringify(_turbulence_physics->turbulenceWalls()) +
     470           0 :                    "\nKappa(s) specified:\n" + Moose::stringify(_thermal_conductivity_name));
     471          54 :       params.set<MooseFunctorName>(NS::kappa) = _thermal_conductivity_name[0];
     472          54 :       params.set<MooseFunctorName>(NS::cp) = _specific_heat_name;
     473         216 :       const std::string u_names[3] = {"u", "v", "w"};
     474         162 :       for (const auto d : make_range(dimension()))
     475         216 :         params.set<MooseFunctorName>(u_names[d]) = _velocity_names[d];
     476             :       // Currently only Newton method for WCNSFVFluidHeatTransferPhysics
     477          54 :       params.set<bool>("newton_solve") = true;
     478         162 :       getProblem().addFVBC(bc_type, prefix() + "wallfunction_" + wall_boundaries[bc_ind], params);
     479         270 :     }
     480             :     else
     481           0 :       paramError(
     482           0 :           "energy_wall_types", _energy_wall_types[bc_ind], " wall type is currently unsupported.");
     483             :   }
     484         681 : }
     485             : 
     486             : void
     487        1264 : WCNSFVFluidHeatTransferPhysics::addMaterials()
     488             : {
     489        1264 :   if (!_has_energy_equation)
     490         569 :     return;
     491             : 
     492             :   // Note that this material choice does not make sense for Newton-INSFV + solve_for_enthalpy since
     493             :   // this material explicitly computes enthalpy from temperature
     494             :   const auto object_type = "INSFVEnthalpyFunctorMaterial";
     495             : 
     496         695 :   InputParameters params = getFactory().getValidParams(object_type);
     497         695 :   assignBlocks(params, _blocks);
     498             : 
     499         695 :   params.set<MooseFunctorName>(NS::density) = _density_name;
     500         695 :   params.set<MooseFunctorName>(NS::cp) = _specific_heat_name;
     501             : 
     502         695 :   if (_solve_for_enthalpy)
     503             :   {
     504          57 :     params.set<MooseFunctorName>(NS::pressure) = _flow_equations_physics->getPressureName();
     505         114 :     params.set<MooseFunctorName>(NS::specific_enthalpy + "_in") = _fluid_enthalpy_name;
     506          57 :     params.set<bool>("assumed_constant_cp") = false;
     507          57 :     if (isParamValid(NS::fluid))
     508          57 :       params.set<UserObjectName>(NS::fluid) = getParam<UserObjectName>(NS::fluid);
     509             :     else
     510           0 :       paramError(NS::fluid, "Required when solving for enthalpy");
     511             :   }
     512             :   // the functor material defines the temperature
     513             :   else
     514             :   {
     515        1276 :     params.set<MooseFunctorName>("temperature") = _fluid_temperature_name;
     516        1276 :     params.set<MooseFunctorName>(NS::specific_enthalpy) = _fluid_enthalpy_name;
     517         638 :     if (isParamValid(NS::fluid))
     518             :     {
     519           0 :       params.set<bool>("assumed_constant_cp") = false;
     520           0 :       params.set<UserObjectName>(NS::fluid) = getParam<UserObjectName>(NS::fluid);
     521             :     }
     522             :   }
     523         695 :   if (_solve_for_enthalpy)
     524             :   {
     525         171 :     params.set<std::vector<std::string>>("output_properties") = {_fluid_temperature_name};
     526         171 :     params.set<std::vector<OutputName>>("outputs") = {"all"};
     527             :   }
     528             : 
     529        2085 :   getProblem().addMaterial(object_type, prefix() + "enthalpy_material", params);
     530             : 
     531         695 :   if (_solve_for_enthalpy)
     532          57 :     WCNSFVFluidHeatTransferPhysicsBase::defineKOverCpFunctors(/*use ad*/ true);
     533         752 : }
     534             : 
     535             : void
     536         681 : WCNSFVFluidHeatTransferPhysics::addEnergySeparatorBC()
     537             : {
     538         681 :   if (_flow_equations_physics->getHydraulicSeparators().size())
     539             :   {
     540             :     const auto & solver_variable_name =
     541          19 :         _solve_for_enthalpy ? _fluid_enthalpy_name : _fluid_temperature_name;
     542             : 
     543          19 :     const std::string bc_type = "INSFVScalarFieldSeparatorBC";
     544          19 :     InputParameters params = getFactory().getValidParams(bc_type);
     545          38 :     params.set<NonlinearVariableName>("variable") = solver_variable_name;
     546          38 :     params.set<std::vector<BoundaryName>>("boundary") =
     547          38 :         _flow_equations_physics->getHydraulicSeparators();
     548          38 :     getProblem().addFVBC(bc_type, prefix() + solver_variable_name + "_separators", params);
     549          19 :   }
     550         681 : }

Generated by: LCOV version 1.14