https://mooseframework.inl.gov
Loading...
Searching...
No Matches
RhoFromPTFunctorMaterial.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// Navier-Stokes includes
12#include "NS.h"
13
14// FluidProperties includes
16
18
21{
22 auto params = FunctorMaterial::validParams();
23 params.addRequiredParam<UserObjectName>(NS::fluid, "fluid userobject");
24 params.addClassDescription(
25 "Computes the density from coupled pressure and temperature functors (variables, "
26 "functions, functor material properties");
27 params.addRequiredParam<MooseFunctorName>(NS::temperature, "temperature functor");
28 params.addRequiredParam<MooseFunctorName>(NS::pressure, "pressure functor");
29 params.addParam<MooseFunctorName>(
30 "density_name", NS::density, "name to use to declare the density functor");
31 params.addParam<bool>("neglect_derivatives_of_density_time_derivative",
32 false,
33 "Whether to neglect the derivatives with regards to nonlinear variables "
34 "of the density time derivatives");
35 return params;
36}
37
39 : FunctorMaterial(parameters),
40 _pressure(getFunctor<ADReal>(NS::pressure)),
41 _temperature(getFunctor<ADReal>(NS::temperature)),
42 _fluid(getUserObject<SinglePhaseFluidProperties>(NS::fluid)),
43 _density_name(getParam<MooseFunctorName>("density_name"))
44{
45 addFunctorProperty<ADReal>(_density_name,
46 [this](const auto & r, const auto & t) -> ADReal
47 { return _fluid.rho_from_p_T(_pressure(r, t), _temperature(r, t)); });
48 if (getParam<bool>("neglect_derivatives_of_density_time_derivative"))
49 addFunctorProperty<ADReal>(
51 [this](const auto & r, const auto & t) -> ADReal
52 {
53 Real rho, drho_dp, drho_dT;
54 _fluid.rho_from_p_T(
55 _pressure(r, t).value(), _temperature(r, t).value(), rho, drho_dp, drho_dT);
56 return drho_dp * _pressure.dot(r, t) + drho_dT * _temperature.dot(r, t);
57 });
58 else
59 addFunctorProperty<ADReal>(
61 [this](const auto & r, const auto & t) -> ADReal
62 {
63 ADReal rho, drho_dp, drho_dT;
64 _fluid.rho_from_p_T(_pressure(r, t), _temperature(r, t), rho, drho_dp, drho_dT);
65 return drho_dp * _pressure.dot(r, t) + drho_dT * _temperature.dot(r, t);
66 });
67}
DualNumber< Real, DNDerivativeType, true > ADReal
const double rho
registerMooseObject("NavierStokesApp", RhoFromPTFunctorMaterial)
static InputParameters validParams()
Computes the density using the fluid properties at a specified location.
const Moose::Functor< ADReal > & _pressure
pressure
const SinglePhaseFluidProperties & _fluid
fluid properties user object
const MooseFunctorName _density_name
name of the density functor declared
const Moose::Functor< ADReal > & _temperature
temperature
RhoFromPTFunctorMaterial(const InputParameters &parameters)
static InputParameters validParams()
Common class for single phase fluid properties.
static const std::string density
Definition NS.h:34
static const std::string temperature
Definition NS.h:60
std::string time_deriv(const std::string &var)
Definition NS.h:98
static const std::string fluid
Definition NS.h:88
static const std::string pressure
Definition NS.h:57