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 : #include "PorousFlowFluidPropertyIC.h" 11 : #include "SinglePhaseFluidProperties.h" 12 : 13 : registerMooseObject("PorousFlowApp", PorousFlowFluidPropertyIC); 14 : 15 : InputParameters 16 171 : PorousFlowFluidPropertyIC::validParams() 17 : { 18 171 : InputParameters params = InitialCondition::validParams(); 19 342 : params.addRequiredCoupledVar("porepressure", "Fluid porepressure"); 20 342 : params.addRequiredCoupledVar("temperature", "Fluid temperature"); 21 342 : MooseEnum unit_choice("Kelvin=0 Celsius=1", "Kelvin"); 22 342 : params.addParam<MooseEnum>( 23 : "temperature_unit", unit_choice, "The unit of the temperature variable"); 24 342 : params.addRequiredParam<UserObjectName>("fp", "The name of the user object for the fluid"); 25 342 : MooseEnum property_enum("enthalpy internal_energy density"); 26 342 : params.addRequiredParam<MooseEnum>( 27 : "property", property_enum, "The fluid property that this initial condition is to calculate"); 28 171 : params.addClassDescription("An initial condition to calculate one fluid property (such as " 29 : "enthalpy) from pressure and temperature"); 30 171 : return params; 31 171 : } 32 : 33 90 : PorousFlowFluidPropertyIC::PorousFlowFluidPropertyIC(const InputParameters & parameters) 34 : : InitialCondition(parameters), 35 90 : _porepressure(coupledValue("porepressure")), 36 90 : _temperature(coupledValue("temperature")), 37 180 : _property_enum(getParam<MooseEnum>("property").getEnum<PropertyEnum>()), 38 90 : _fp(getUserObject<SinglePhaseFluidProperties>("fp")), 39 330 : _T_c2k(getParam<MooseEnum>("temperature_unit") == 0 ? 0.0 : 273.15) 40 : { 41 90 : } 42 : 43 : Real 44 1092 : PorousFlowFluidPropertyIC::value(const Point & /*p*/) 45 : { 46 : // The FluidProperties userobject uses temperature in K 47 1092 : const Real Tk = _temperature[_qp] + _T_c2k; 48 : 49 : // The fluid property 50 : Real property = 0.0; 51 : 52 1092 : switch (_property_enum) 53 : { 54 996 : case PropertyEnum::ENTHALPY: 55 996 : property = _fp.h_from_p_T(_porepressure[_qp], Tk); 56 996 : break; 57 : 58 48 : case PropertyEnum::INTERNAL_ENERGY: 59 48 : property = _fp.e_from_p_T(_porepressure[_qp], Tk); 60 48 : break; 61 : 62 48 : case PropertyEnum::DENSITY: 63 48 : property = _fp.rho_from_p_T(_porepressure[_qp], Tk); 64 48 : break; 65 : } 66 : 67 1092 : return property; 68 : }