https://mooseframework.inl.gov
Loading...
Searching...
No Matches
INSFEFluidEnergyBC.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
10#include "INSFEFluidEnergyBC.h"
11
14 MDFluidEnergyBC,
15 "02/01/2024 00:00",
17
20{
22 params.addClassDescription("Specifies flow of energy through a boundary");
23 params.addParam<FunctionName>("v_fn", "Velocity function with time at the boundary");
24 params.addParam<FunctionName>("T_fn", "Temperature function with time at the boundary");
25 params.addCoupledVar("porosity_elem", "Element averaged porosity");
26 params.addCoupledVar("T_branch", "Coupled scalar branch temperature");
27 return params;
28}
29
31 : INSFEFluidIntegratedBCBase(parameters),
32 _cp(getMaterialProperty<Real>("cp_fluid")),
33 _has_vbc(parameters.isParamValid("v_fn")),
34 _has_Tbc(parameters.isParamValid("T_fn")),
35 _v_fn(_has_vbc ? &getFunction("v_fn") : NULL),
36 _T_fn(_has_Tbc ? &getFunction("T_fn") : NULL),
37 _k_elem(getMaterialProperty<Real>("k_fluid_elem")),
38 _has_porosity_elem(isParamValid("porosity_elem")),
39 _porosity_elem(_has_porosity_elem ? coupledValue("porosity_elem")
40 : (_has_porosity ? coupledValue("porosity") : _zero)),
41 _has_Tbranch(parameters.isParamValid("T_branch")),
42 _T_branch(_has_Tbranch ? coupledScalarValue("T_branch") : _zero),
43 _T_branch_var_number(_has_Tbranch ? coupledScalar("T_branch") : libMesh::invalid_uint)
44{
45 if (_has_vbc && !_has_Tbc)
46 mooseError("For an inlet condition ('v_fn' is given), a boundary temperature ('T_fn') is also "
47 "needed.");
49 mooseError("Temperature function and branch temperature cannot be BOTH specified in "
50 "INSFEFluidEnergyBC.");
51}
52
53Real
55{
56 RealVectorValue vec_vel(_u_vel[_qp], _v_vel[_qp], _w_vel[_qp]);
57
58 Real v_bc = _has_vbc ? -_v_fn->value(_t, _q_point[_qp]) : vec_vel * _normals[_qp];
59 Real T_bc = _u[_qp];
60 // A more restrict condition might be needed here
61 // For an inlet or reverse outlet flow condition, a T_bc or a T_branch should be required.
62 if (v_bc < 0)
63 {
64 if (_has_Tbc)
65 T_bc = _T_fn->value(_t, _q_point[_qp]);
66 if (_has_Tbranch)
67 T_bc = _T_branch[0];
68 }
69 Real enthalpy = _eos.h_from_p_T(_pressure[_qp], T_bc);
70
71 Real convection_term = _rho[_qp] * v_bc * enthalpy * _test[_i][_qp];
72 Real diffusion_term =
74
75 return convection_term + diffusion_term;
76}
77
78Real
80{
81 RealVectorValue vec_vel(_u_vel[_qp], _v_vel[_qp], _w_vel[_qp]);
82 Real v_bc = _has_vbc ? -_v_fn->value(_t, _q_point[_qp]) : vec_vel * _normals[_qp];
83
84 Real convection_term = 0;
85 if (v_bc < 0) // Inlet
86 convection_term = 0;
87 else // Outlet or not a real boundary
88 {
89 Real rho, drho_dp, drho_dT;
90 _eos.rho_from_p_T(_pressure[_qp], _u[_qp], rho, drho_dp, drho_dT);
91 Real enthalpy = _eos.h_from_p_T(_pressure[_qp], _u[_qp]);
92
93 convection_term =
94 (_rho[_qp] * _cp[_qp] + drho_dT * enthalpy) * v_bc * _phi[_j][_qp] * _test[_i][_qp];
95 }
96
97 Real diffusion_term =
99
100 return convection_term + diffusion_term;
101}
102
103Real
105{
106 // this is jocabian term w.r.t branch temperature
107 if (jvar == _T_branch_var_number)
108 {
109 RealVectorValue vec_vel(_u_vel[_qp], _v_vel[_qp], _w_vel[_qp]);
110 Real v_bc = _has_vbc ? -_v_fn->value(_t, _q_point[_qp]) : vec_vel * _normals[_qp];
111 if (v_bc < 0)
112 {
113 return _rho[_qp] * v_bc * _eos.cp_from_p_T(1e5, _T_branch[0]) * _test[_i][_qp];
114 }
115 }
116
117 Real jac = 0;
118 unsigned m = this->mapVarNumber(jvar);
119 switch (m)
120 {
121 case 1:
122 case 2:
123 case 3:
124 if (!_has_vbc) // if has_vbc, Jacobians are zero
125 {
126 RealVectorValue vec_vel(_u_vel[_qp], _v_vel[_qp], _w_vel[_qp]);
127 Real v_bc = vec_vel * _normals[_qp];
128 Real T_bc = _u[_qp];
129 if (v_bc < 0)
130 {
131 if (_has_Tbc)
132 T_bc = _T_fn->value(_t, _q_point[_qp]);
133 if (_has_Tbranch)
134 T_bc = _T_branch[0];
135 }
136 Real enthalpy = _eos.h_from_p_T(_pressure[_qp], T_bc);
137 jac = _rho[_qp] * _phi[_j][_qp] * enthalpy * _normals[_qp](m - 1) * _test[_i][_qp];
138 }
139 break;
140
141 default:
142 jac = 0;
143 }
144 return jac;
145}
const double rho
registerMooseObject("NavierStokesApp", INSFEFluidEnergyBC)
registerMooseObjectRenamed("NavierStokesApp", MDFluidEnergyBC, "02/01/2024 00:00", INSFEFluidEnergyBC)
virtual Real value(Real t, const Point &p) const
An integral BC for the energy (temperature) equation.
const VariableValue & _T_branch
const MaterialProperty< Real > & _cp
const Function * _v_fn
const Function * _T_fn
const VariableValue & _porosity_elem
virtual Real computeQpJacobian() override
const MaterialProperty< Real > & _k_elem
INSFEFluidEnergyBC(const InputParameters &parameters)
static InputParameters validParams()
unsigned int _T_branch_var_number
virtual Real computeQpResidual() override
virtual Real computeQpOffDiagJacobian(unsigned int jvar) override
This class couples together all the variables for the 3D fluid equations to allow them to be used in ...
static InputParameters validParams()
const MaterialProperty< Real > & _rho
const SinglePhaseFluidProperties & _eos
void addParam(const std::string &name, const std::initializer_list< typename T::value_type > &value, const std::string &doc_string)
void addClassDescription(const std::string &doc_string)
void addCoupledVar(const std::string &name, const std::string &doc_string)
unsigned int _qp
unsigned int _i
unsigned int _j
const MooseArray< Point > & _q_point
const VariablePhiGradient & _grad_phi
const VariableGradient & _grad_u
const VariableValue & _u
const VariablePhiValue & _phi
const MooseArray< Point > & _normals
const VariableTestValue & _test
void mooseError(Args &&... args) const
The following methods are specializations for using the Parallel::packed_range_* routines for a vecto...