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 : // Navier-Stokes includes 11 : #include "RhoFromPTFunctorMaterial.h" 12 : #include "NS.h" 13 : 14 : // FluidProperties includes 15 : #include "SinglePhaseFluidProperties.h" 16 : 17 : registerMooseObject("NavierStokesApp", RhoFromPTFunctorMaterial); 18 : 19 : InputParameters 20 595 : RhoFromPTFunctorMaterial::validParams() 21 : { 22 595 : auto params = FunctorMaterial::validParams(); 23 595 : params.addRequiredParam<UserObjectName>(NS::fluid, "fluid userobject"); 24 595 : params.addClassDescription( 25 : "Computes the density from coupled pressure and temperature functors (variables, " 26 : "functions, functor material properties"); 27 595 : params.addRequiredParam<MooseFunctorName>(NS::temperature, "temperature functor"); 28 595 : params.addRequiredParam<MooseFunctorName>(NS::pressure, "pressure functor"); 29 1190 : params.addParam<MooseFunctorName>( 30 : "density_name", NS::density, "name to use to declare the density functor"); 31 1190 : params.addParam<bool>("neglect_derivatives_of_density_time_derivative", 32 1190 : false, 33 : "Whether to neglect the derivatives with regards to nonlinear variables " 34 : "of the density time derivatives"); 35 595 : return params; 36 0 : } 37 : 38 332 : RhoFromPTFunctorMaterial::RhoFromPTFunctorMaterial(const InputParameters & parameters) 39 : : FunctorMaterial(parameters), 40 332 : _pressure(getFunctor<ADReal>(NS::pressure)), 41 332 : _temperature(getFunctor<ADReal>(NS::temperature)), 42 332 : _fluid(getUserObject<SinglePhaseFluidProperties>(NS::fluid)), 43 664 : _density_name(getParam<MooseFunctorName>("density_name")) 44 : { 45 996 : addFunctorProperty<ADReal>(_density_name, 46 41562099 : [this](const auto & r, const auto & t) -> ADReal 47 41562099 : { return _fluid.rho_from_p_T(_pressure(r, t), _temperature(r, t)); }); 48 664 : if (getParam<bool>("neglect_derivatives_of_density_time_derivative")) 49 0 : addFunctorProperty<ADReal>( 50 0 : NS::time_deriv(_density_name), 51 0 : [this](const auto & r, const auto & t) -> ADReal 52 : { 53 : Real rho, drho_dp, drho_dT; 54 0 : _fluid.rho_from_p_T( 55 0 : _pressure(r, t).value(), _temperature(r, t).value(), rho, drho_dp, drho_dT); 56 0 : return drho_dp * _pressure.dot(r, t) + drho_dT * _temperature.dot(r, t); 57 : }); 58 : else 59 996 : addFunctorProperty<ADReal>( 60 332 : NS::time_deriv(_density_name), 61 2772432 : [this](const auto & r, const auto & t) -> ADReal 62 : { 63 : ADReal rho, drho_dp, drho_dT; 64 2772432 : _fluid.rho_from_p_T(_pressure(r, t), _temperature(r, t), rho, drho_dp, drho_dT); 65 8317296 : return drho_dp * _pressure.dot(r, t) + drho_dT * _temperature.dot(r, t); 66 : }); 67 996 : }