https://mooseframework.inl.gov
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | Private Member Functions | Private Attributes | List of all members
IncompressibleEnergySPScalarKernelTempl< is_ad > Class Template Reference

#include <IncompressibleEnergySPScalarKernel.h>

Inheritance diagram for IncompressibleEnergySPScalarKernelTempl< is_ad >:
[legend]

Public Member Functions

 IncompressibleEnergySPScalarKernelTempl (const InputParameters &parameters)
 
virtual bool isADObject () const override
 
const Moose::Functor< Real > * defaultFunctor (const std::string &name)
 
const Moose::Functor< ADReal > * defaultFunctor (const std::string &name)
 

Static Public Member Functions

static InputParameters validParams ()
 
static std::string deduceFunctorName (const std::string &name, const InputParameters &params)
 

Protected Member Functions

virtual GenericReal< is_ad > computeQpResidual () override
 
virtual Real computeQpJacobian () override
 
Real computeQpJacobian ()
 
std::string deduceFunctorName (const std::string &name) const
 
const Moose::Functor< T > & getFunctor (const std::string &name)
 
const Moose::Functor< T > & getFunctor (const std::string &name, THREAD_ID tid)
 
const Moose::Functor< T > & getFunctor (const std::string &name, SubProblem &subproblem)
 
const Moose::Functor< T > & getFunctor (const std::string &name, SubProblem &subproblem, THREAD_ID tid)
 
bool isFunctor (const std::string &name) const
 
bool isFunctor (const std::string &name, const SubProblem &subproblem) const
 
Moose::ElemArg makeElemArg (const Elem *elem, bool correct_skewnewss=false) const
 
void checkFunctorSupportsSideIntegration (const std::string &name, bool qp_integration)
 
const Moose::Functor< T > & getFunctorByName (const std::string &name)
 

Protected Attributes

const SinglePhaseFluidProperties & _fp
 Fluid properties object.
 
const VariableValue & _m
 Coupled mass flow rate through the segment.
 
const VariableValue & _Tup
 Coupled temperature of the upstream segment.
 
const VariableValue & _Tdown
 Coupled temperature of the downstream segment.
 
const VariableValue & _Tw
 Coupled temperature of the component wall.
 
const bool _is_implicit
 Property state integration flag.
 
const Moose::Functor< GenericReal< is_ad > > & _Pref
 System reference pressure.
 
const Moose::Functor< GenericReal< is_ad > > & _area
 Flow area of the segment.
 
const Moose::Functor< GenericReal< is_ad > > & _perimeter
 Wetted perimeter of the segment.
 
const Moose::Functor< GenericReal< is_ad > > & _length
 Length of the segment.
 

Private Types

using Base = typename std::conditional< is_ad, ADScalarKernel, ScalarKernel >::type
 

Private Member Functions

const Moose::Functor< T > * defaultFunctor (const std::string &name)
 
const Moose::Functor< Real > * defaultFunctor (const std::string &name)
 
const Moose::Functor< ADReal > * defaultFunctor (const std::string &name)
 
const Moose::Functor< T > & getFunctorByName (const std::string &name, SubProblem &subproblem, THREAD_ID tid)
 

Private Attributes

const InputParameters & _fi_params
 
const std::string _fi_name
 
SubProblem *const _fi_subproblem
 
const THREAD_ID _fi_tid
 
std::vector< std::unique_ptr< Moose::Functor< Real > > > _default_real_functors
 
std::vector< std::unique_ptr< Moose::Functor< ADReal > > > _default_ad_real_functors
 

Detailed Description

template<bool is_ad>
class IncompressibleEnergySPScalarKernelTempl< is_ad >

Definition at line 19 of file IncompressibleEnergySPScalarKernel.h.

Member Typedef Documentation

◆ Base

template<bool is_ad>
using IncompressibleEnergySPScalarKernelTempl< is_ad >::Base = typename std::conditional<is_ad, ADScalarKernel, ScalarKernel>::type
private

Definition at line 23 of file IncompressibleEnergySPScalarKernel.h.

Constructor & Destructor Documentation

◆ IncompressibleEnergySPScalarKernelTempl()

Definition at line 56 of file IncompressibleEnergySPScalarKernel.C.

58 : Base(parameters),
59 FunctorInterface(this),
60 _fp(this->template getUserObject<SinglePhaseFluidProperties>("fp")),
62 _Tup(ScalarCoupleable::coupledScalarValue("inlet_temperature")),
63 _Tdown(ScalarCoupleable::coupledScalarValue("outlet_temperature")),
64 _Tw(ScalarCoupleable::coupledScalarValue("wall_temperature")),
65 _is_implicit(this->template getParam<bool>("is_implicit")),
66 _Pref(this->template getFunctor<GenericReal<is_ad>>("reference_pressure")),
67 _area(this->template getFunctor<GenericReal<is_ad>>("area")),
68 _perimeter(this->template getFunctor<GenericReal<is_ad>>("perimeter")),
69 _length(this->template getFunctor<GenericReal<is_ad>>("length"))
70{
71}
Moose::GenericType< Real, is_ad > GenericReal
const Moose::Functor< T > & getFunctor(const std::string &name)
const VariableValue & _Tup
Coupled temperature of the upstream segment.
const VariableValue & _m
Coupled mass flow rate through the segment.
const VariableValue & _Tdown
Coupled temperature of the downstream segment.
const Moose::Functor< GenericReal< is_ad > > & _perimeter
Wetted perimeter of the segment.
const VariableValue & _Tw
Coupled temperature of the component wall.
const Moose::Functor< GenericReal< is_ad > > & _area
Flow area of the segment.
const Moose::Functor< GenericReal< is_ad > > & _length
Length of the segment.
const bool _is_implicit
Property state integration flag.
const SinglePhaseFluidProperties & _fp
Fluid properties object.
typename std::conditional< is_ad, ADScalarKernel, ScalarKernel >::type Base
const Moose::Functor< GenericReal< is_ad > > & _Pref
System reference pressure.
const VariableValue & coupledScalarValue(const std::string &var_name, unsigned int comp=0) const

Member Function Documentation

◆ computeQpJacobian() [1/2]

Real IncompressibleEnergySPScalarKernelTempl< true >::computeQpJacobian ( )
protected

Definition at line 149 of file IncompressibleEnergySPScalarKernel.C.

150{
151 mooseError("Internal error, calling computeQpJacobian in AD class.");
152 return 0.0;
153}
void mooseError(Args &&... args)

◆ computeQpJacobian() [2/2]

template<bool is_ad>
Real IncompressibleEnergySPScalarKernelTempl< is_ad >::computeQpJacobian ( )
overrideprotectedvirtual

Definition at line 109 of file IncompressibleEnergySPScalarKernel.C.

110{
111 if constexpr (!is_ad)
112 {
113 Real energy_jacob = 0;
114 const Moose::ElemArg qp = Moose::ElemArg();
115 const int i = 0;
116 const auto state = _is_implicit ? Moose::currentState() : Moose::oldState();
117 // start by getting fluid properties
118 const auto in = 1.0 / 2.0 * (1 - abs(_m[i]) / _m[i]) * _Tdown[i] +
119 1.0 / 2.0 * (1 + abs(_m[i]) / _m[i]) * _Tup[i];
120 const auto mu = _fp.mu_from_p_T(_Pref(qp, state), (Base::_u[i] + in) / 2);
121 const auto rho = _fp.rho_from_p_T(_Pref(qp, state), (Base::_u[i] + in) / 2);
122 const auto cp = _fp.cp_from_p_T(_Pref(qp, state), (Base::_u[i] + in) / 2);
123 const auto k = _fp.k_from_p_T(_Pref(qp, state), (Base::_u[i] + in) / 2);
124
125 // Decide flow regime for HTC
126 const auto Dh = 4.0 * _area(qp, state) / _perimeter(qp, state);
127 const auto G = abs(_m[i]) / _area(qp, state);
128 const auto Re = G * Dh / mu;
129 const auto Pr = mu * cp / k;
130 // Heat transfer to fluid (Dittus-Boelter)
131 const auto h = 0.023 * pow(Re, 0.8) * pow(Pr, 0.4) * k / Dh;
132 const auto q = -h * _perimeter(qp, state) / 2.0;
133 // Advection component
134 energy_jacob += abs(_m[i]) / _length(qp, state) / _area(qp, state) / rho;
135 // Wall heat transfer
136 energy_jacob -= q / _area(qp, state) / rho / cp;
137
138 return energy_jacob;
139 }
140 else
141 {
142 mooseError("computeQpJacobian() should not be called in AD mode");
143 return 0;
144 }
145}
ExpressionBuilder::EBTerm pow(const ExpressionBuilder::EBTerm &left, T exponent)
const double mu
const double Re
const double rho
MetaPhysicL::DualNumber< V, D, asd > abs(const MetaPhysicL::DualNumber< V, D, asd > &a)
StateArg oldState()
StateArg currentState()
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real

◆ computeQpResidual()

template<bool is_ad>
GenericReal< is_ad > IncompressibleEnergySPScalarKernelTempl< is_ad >::computeQpResidual ( )
overrideprotectedvirtual

Definition at line 75 of file IncompressibleEnergySPScalarKernel.C.

76{
77 GenericReal<is_ad> energy_residual = 0;
78 const Moose::ElemArg qp = Moose::ElemArg();
79 const int i = 0;
80 const auto state = _is_implicit ? Moose::currentState() : Moose::oldState();
81 // start by getting fluid properties
82 const auto in = 1.0 / 2.0 * (1 - abs(_m[i]) / _m[i]) * _Tdown[i] +
83 1.0 / 2.0 * (1 + abs(_m[i]) / _m[i]) * _Tup[i];
84 const auto mu = _fp.mu_from_p_T(_Pref(qp, state), (Base::_u[i] + in) / 2);
85 const auto rho = _fp.rho_from_p_T(_Pref(qp, state), (Base::_u[i] + in) / 2);
86 const auto cp = _fp.cp_from_p_T(_Pref(qp, state), (Base::_u[i] + in) / 2);
87 const auto k = _fp.k_from_p_T(_Pref(qp, state), (Base::_u[i] + in) / 2);
88
89 // Compute HTC quantities
90 const auto Dh = 4.0 * _area(qp, state) / _perimeter(qp, state);
91 const auto G = abs(_m[i]) / _area(qp, state);
92 const auto Re = G * Dh / mu;
93 const auto Pr = mu * cp / k;
94 // Heat transfer to fluid (Dittus-Boelter)
95 const auto h = 0.023 * pow(Re, 0.8) * pow(Pr, 0.4) * k / Dh;
96 const auto q = h * _perimeter(qp, state) / 2.0 * (2.0 * _Tw[i] - Base::_u[i] - in);
97 // Advection component
98 energy_residual += (_m[i] / 2.0 * (1 - abs(_m[i]) / _m[i]) * _Tdown[i] -
99 _m[i] / 2.0 * (1 + abs(_m[i]) / _m[i]) * _Tup[i] + abs(_m[i]) * Base::_u[i]) /
100 _length(qp, state) / _area(qp, state) / rho;
101 // Wall heat transfer
102 energy_residual -= q / _area(qp, state) / rho / cp;
103
104 return energy_residual;
105}

◆ isADObject()

template<bool is_ad>
virtual bool IncompressibleEnergySPScalarKernelTempl< is_ad >::isADObject ( ) const
inlineoverridevirtual

Implements FunctorInterface.

Definition at line 27 of file IncompressibleEnergySPScalarKernel.h.

27{ return is_ad; };

◆ validParams()

template<bool is_ad>
InputParameters IncompressibleEnergySPScalarKernelTempl< is_ad >::validParams ( )
static

Definition at line 21 of file IncompressibleEnergySPScalarKernel.C.

22{
25 params.addClassDescription("Implements a generic energy solve over a 1D flow path segment.");
26 params.addCoupledVar("mass_flow_rate",
27 {},
28 "Mass flow rate in component. Takes a "
29 "scalar variable name");
30 params.addCoupledVar("inlet_temperature",
31 {},
32 "Fluid temperature of nominal inlet segment/component (N-1). Takes a "
33 "scalar variable name");
34 params.addCoupledVar("outlet_temperature",
35 {},
36 "Fluid temperature of nominal outlet segment/component (N+1). Takes a "
37 "scalar variable name");
38 params.addCoupledVar("wall_temperature",
39 {},
40 "Wall temperature adjacent to fluid. Takes a "
41 "scalar variable name");
42 params.addParam<bool>(
43 "is_implicit",
44 false,
45 "Whether an explicit (previous value calculation) or implicit (current value) is used");
46 params.addRequiredParam<MooseFunctorName>("reference_pressure", "system reference pressure [Pa]");
47 params.addRequiredParam<UserObjectName>("fp", "The name of the user object for fluid properties");
48 params.addRequiredParam<MooseFunctorName>("area", "Segment/Component flow area [m^2]");
49 params.addRequiredParam<MooseFunctorName>("perimeter", "Segment/Component wetted perimeter [m]");
50 params.addRequiredParam<MooseFunctorName>("length", "Segment/Component length [m]");
51
52 return params;
53}
static InputParameters validParams()
static InputParameters validParams()
void addRequiredParam(const std::string &name, const std::string &doc_string)
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)

Member Data Documentation

◆ _area

template<bool is_ad>
const Moose::Functor<GenericReal<is_ad> >& IncompressibleEnergySPScalarKernelTempl< is_ad >::_area
protected

Flow area of the segment.

Definition at line 48 of file IncompressibleEnergySPScalarKernel.h.

◆ _fp

template<bool is_ad>
const SinglePhaseFluidProperties& IncompressibleEnergySPScalarKernelTempl< is_ad >::_fp
protected

Fluid properties object.

Definition at line 34 of file IncompressibleEnergySPScalarKernel.h.

◆ _is_implicit

template<bool is_ad>
const bool IncompressibleEnergySPScalarKernelTempl< is_ad >::_is_implicit
protected

Property state integration flag.

Definition at line 44 of file IncompressibleEnergySPScalarKernel.h.

◆ _length

template<bool is_ad>
const Moose::Functor<GenericReal<is_ad> >& IncompressibleEnergySPScalarKernelTempl< is_ad >::_length
protected

Length of the segment.

Definition at line 52 of file IncompressibleEnergySPScalarKernel.h.

◆ _m

template<bool is_ad>
const VariableValue& IncompressibleEnergySPScalarKernelTempl< is_ad >::_m
protected

Coupled mass flow rate through the segment.

Definition at line 36 of file IncompressibleEnergySPScalarKernel.h.

◆ _perimeter

template<bool is_ad>
const Moose::Functor<GenericReal<is_ad> >& IncompressibleEnergySPScalarKernelTempl< is_ad >::_perimeter
protected

Wetted perimeter of the segment.

Definition at line 50 of file IncompressibleEnergySPScalarKernel.h.

◆ _Pref

template<bool is_ad>
const Moose::Functor<GenericReal<is_ad> >& IncompressibleEnergySPScalarKernelTempl< is_ad >::_Pref
protected

System reference pressure.

Definition at line 46 of file IncompressibleEnergySPScalarKernel.h.

◆ _Tdown

template<bool is_ad>
const VariableValue& IncompressibleEnergySPScalarKernelTempl< is_ad >::_Tdown
protected

Coupled temperature of the downstream segment.

Definition at line 40 of file IncompressibleEnergySPScalarKernel.h.

◆ _Tup

template<bool is_ad>
const VariableValue& IncompressibleEnergySPScalarKernelTempl< is_ad >::_Tup
protected

Coupled temperature of the upstream segment.

Definition at line 38 of file IncompressibleEnergySPScalarKernel.h.

◆ _Tw

template<bool is_ad>
const VariableValue& IncompressibleEnergySPScalarKernelTempl< is_ad >::_Tw
protected

Coupled temperature of the component wall.

Definition at line 42 of file IncompressibleEnergySPScalarKernel.h.


The documentation for this class was generated from the following files: