https://mooseframework.inl.gov
Loading...
Searching...
No Matches
WCNSFVInletTemperatureBC.C
Go to the documentation of this file.
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
11#include "INSFVEnergyVariable.h"
12#include "NS.h"
13
15
18{
20 params += INSFVFlowBC::validParams();
21
22 params.addParam<Real>("scaling_factor", 1, "To scale the velocity");
23
24 // Three different ways to input temperature
25 // 1) Postprocessor with the temperature value directly
26 params.addParam<PostprocessorName>("temperature_pp", "Postprocessor with the inlet temperature");
27
28 // 2) Postprocessors for velocity and energy, functors for specific heat and density
29 params.addParam<PostprocessorName>("energy_pp", "Postprocessor with the inlet energy flow rate");
30 params.addParam<PostprocessorName>("velocity_pp", "Postprocessor with the inlet velocity norm");
31 params.addParam<MooseFunctorName>(NS::density, "Density functor");
32 params.addParam<MooseFunctorName>(NS::cp, "specific heat capacity functor");
33
34 // 3) Postprocessors for mass flow rate and energy, functor for specific heat
35 params.addParam<PostprocessorName>("mdot_pp", "Postprocessor with the inlet mass flow rate");
36
37 return params;
38}
39
41 : FVDirichletBCBase(params),
42 INSFVFlowBC(params),
43 _scaling_factor(getParam<Real>("scaling_factor")),
44 _temperature_pp(isParamValid("temperature_pp") ? &getPostprocessorValue("temperature_pp")
45 : nullptr),
46 _energy_pp(isParamValid("energy_pp") ? &getPostprocessorValue("energy_pp") : nullptr),
47 _velocity_pp(isParamValid("velocity_pp") ? &getPostprocessorValue("velocity_pp") : nullptr),
48 _mdot_pp(isParamValid("mdot_pp") ? &getPostprocessorValue("mdot_pp") : nullptr),
49 _area_pp(isParamValid("area_pp") ? &getPostprocessorValue("area_pp") : nullptr),
50 _rho(isParamValid(NS::density) ? &getFunctor<ADReal>(NS::density) : nullptr),
51 _cp(isParamValid(NS::cp) ? &getFunctor<ADReal>(NS::cp) : nullptr)
52{
53 if (!dynamic_cast<INSFVEnergyVariable *>(&_var))
55 "variable",
56 "The variable argument to WCNSFVInletTemperatureBC must be of type INSFVEnergyVariable");
57
58 // Density is often set as global parameters so it is not checked
61 "If setting the temperature directly, no need for inlet velocity, mass flow or energy");
62
63 // Need enough information if trying to use a mass flow rate postprocessor
64 if (!_temperature_pp)
65 {
66 if (!_energy_pp)
67 mooseError("If not providing the temperature, the energy flow rate should be provided");
68 if (!_velocity_pp && !_mdot_pp)
69 mooseError("If not providing the inlet temperature, the inlet velocity or mass flow should "
70 "be provided");
71 if (_velocity_pp && (!_rho || !_cp || !_area_pp))
72 mooseError("If providing the inlet velocity, the density, the area and the specific heat "
73 "capacity should be provided as well");
74 if (_mdot_pp && !_cp)
75 mooseError("If providing the inlet mass flow rate, the inlet specific heat capacity should "
76 "be provided as well");
77 }
78 else if (params.isParamSetByUser("scaling_factor"))
79 paramError("scaling_factor",
80 "The scaling factor is meant to adjust for a different area or "
81 "mass flow rate, it should not be set if the temperature is set directly");
82}
83
86{
87
88 if (_area_pp)
89 if (MooseUtils::absoluteFuzzyEqual(*_area_pp, 0))
90 mooseError("Surface area is 0");
91
93 return *_temperature_pp;
94 else if (_velocity_pp)
95 {
96 ADReal rho = (*_rho)(singleSidedFaceArg(&fi), state);
97 ADReal cp = (*_cp)(singleSidedFaceArg(&fi), state);
98
99 return _scaling_factor * (*_energy_pp) / (*_area_pp * rho * *_velocity_pp * cp);
100 }
101 else
102 {
103 ADReal cp = (*_cp)(singleSidedFaceArg(&fi), state);
104
105 return _scaling_factor * (*_energy_pp) / (*_mdot_pp * cp);
106 }
107}
DualNumber< Real, DNDerivativeType, true > ADReal
const double rho
registerMooseObject("NavierStokesApp", WCNSFVInletTemperatureBC)
MooseVariableFV< Real > & _var
Moose::FaceArg singleSidedFaceArg(const FaceInfo *fi=nullptr, Moose::FV::LimiterType limiter_type=Moose::FV::LimiterType::CentralDifference, bool correct_skewness=false, const Moose::StateArg *state_limiter=nullptr) const
static InputParameters validParams()
A parent class for INSFV flow boundary conditions.
Definition INSFVFlowBC.h:18
static InputParameters validParams()
Definition INSFVFlowBC.C:14
bool isParamSetByUser(const std::string &name) const
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void paramError(const std::string &param, Args... args) const
void mooseError(Args &&... args) const
void mooseWarning(Args &&... args) const
Dirichlet boundary conditions for the temperature, set from either a temperature postprocessor or an ...
const Moose::Functor< ADReal > *const _cp
Fluid specific heat capacity functor.
const PostprocessorValue *const _temperature_pp
Postprocessor with the inlet temperature.
static InputParameters validParams()
const PostprocessorValue *const _mdot_pp
Postprocessor with the inlet mass flow rate.
const PostprocessorValue *const _area_pp
Postprocessor with the inlet area.
ADReal boundaryValue(const FaceInfo &fi, const Moose::StateArg &state) const override
const Moose::Functor< ADReal > *const _rho
Fluid density functor.
const Real _scaling_factor
Scaling factor.
const PostprocessorValue *const _velocity_pp
Postprocessor with the inlet velocity.
const PostprocessorValue *const _energy_pp
Postprocessor with the inlet energy flow rate.
WCNSFVInletTemperatureBC(const InputParameters &params)
static const std::string density
Definition NS.h:34
static const std::string cp
Definition NS.h:125