https://mooseframework.inl.gov
Loading...
Searching...
No Matches
FVPorousFlowHeatAdvection.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
11#include "PorousFlowDictator.h"
12
14
17{
19 RealVectorValue g(0, 0, -9.81);
20 params.addParam<RealVectorValue>("gravity", g, "Gravity vector. Defaults to (0, 0, -9.81)");
21 params.addRequiredParam<UserObjectName>("PorousFlowDictator",
22 "The PorousFlowDictator UserObject");
23 params.set<unsigned short>("ghost_layers") = 2;
24 params.addClassDescription("Heat flux advected by the fluid");
25 return params;
26}
27
29 : FVFluxKernel(params),
30 _dictator(getUserObject<PorousFlowDictator>("PorousFlowDictator")),
31 _num_phases(_dictator.numPhases()),
32 _density(getADMaterialProperty<std::vector<Real>>("PorousFlow_fluid_phase_density_qp")),
33 _density_neighbor(
34 getNeighborADMaterialProperty<std::vector<Real>>("PorousFlow_fluid_phase_density_qp")),
35 _viscosity(getADMaterialProperty<std::vector<Real>>("PorousFlow_viscosity_qp")),
36 _viscosity_neighbor(
37 getNeighborADMaterialProperty<std::vector<Real>>("PorousFlow_viscosity_qp")),
38 _enthalpy(getADMaterialProperty<std::vector<Real>>("PorousFlow_fluid_phase_enthalpy_qp")),
39 _enthalpy_neighbor(
40 getNeighborADMaterialProperty<std::vector<Real>>("PorousFlow_fluid_phase_enthalpy_qp")),
41 _relperm(getADMaterialProperty<std::vector<Real>>("PorousFlow_relative_permeability_qp")),
42 _relperm_neighbor(
43 getNeighborADMaterialProperty<std::vector<Real>>("PorousFlow_relative_permeability_qp")),
44 _permeability(getADMaterialProperty<RealTensorValue>("PorousFlow_permeability_qp")),
45 _permeability_neighbor(
46 getNeighborADMaterialProperty<RealTensorValue>("PorousFlow_permeability_qp")),
47 _pressure(getADMaterialProperty<std::vector<Real>>("PorousFlow_porepressure_qp")),
48 _pressure_neighbor(
49 getNeighborADMaterialProperty<std::vector<Real>>("PorousFlow_porepressure_qp")),
50 _grad_p(getADMaterialProperty<std::vector<RealGradient>>("PorousFlow_grad_porepressure_qp")),
51 _gravity(getParam<RealVectorValue>("gravity"))
52{
53}
54
57{
58 ADReal flux = 0.0;
59 ADRealGradient pressure_grad;
60 ADRealTensorValue mobility;
61
62 for (const auto p : make_range(_num_phases))
63 {
64 // If we are on a boundary face, use the gradient computed in _grad_p
66 {
67 const auto & gradp = -_grad_p[_qp][p];
68 pressure_grad = gradp + _density[_qp][p] * _gravity;
69
70 mobility = _enthalpy[_qp][p] * _relperm[_qp][p] * _permeability[_qp] * _density[_qp][p] /
72 }
73 else
74 {
75 // If we are on an internal face, calculate the gradient explicitly
76 const auto & p_elem = _pressure[_qp][p];
77 const auto & p_neighbor = _pressure_neighbor[_qp][p];
78
79 const auto gradp = (p_elem - p_neighbor) * _face_info->eCN() / _face_info->dCNMag();
80
81 const auto mobility_element = _enthalpy[_qp][p] * _relperm[_qp][p] * _permeability[_qp] *
83
84 const auto mobility_neighbor = _enthalpy_neighbor[_qp][p] * _relperm_neighbor[_qp][p] *
87
88 pressure_grad = gradp + _density[_qp][p] * _gravity;
89
90 interpolate(Moose::FV::InterpMethod::Upwind,
91 mobility,
92 mobility_element,
93 mobility_neighbor,
94 pressure_grad,
96 true);
97 }
98
99 flux += mobility * pressure_grad * _normal;
100 }
101
102 return flux;
103}
DualNumber< Real, DNDerivativeType, true > ADReal
registerADMooseObject("PorousFlowApp", FVPorousFlowHeatAdvection)
const Real p
static InputParameters validParams()
RealVectorValue _normal
bool onBoundary(const FaceInfo &fi) const
const FaceInfo * _face_info
const unsigned int _qp
Advective flux of heat energy.
const ADMaterialProperty< RealTensorValue > & _permeability
Permeability.
const RealVectorValue & _gravity
Gravity vector.
const ADMaterialProperty< std::vector< Real > > & _relperm
Relative permeability.
const ADMaterialProperty< std::vector< Real > > & _viscosity_neighbor
const ADMaterialProperty< std::vector< Real > > & _density
Fluid density.
const ADMaterialProperty< std::vector< Real > > & _relperm_neighbor
const ADMaterialProperty< std::vector< Real > > & _enthalpy
Fluid enthalpy.
const ADMaterialProperty< std::vector< Real > > & _pressure
Fluid pressure.
const ADMaterialProperty< std::vector< Real > > & _density_neighbor
const ADMaterialProperty< std::vector< Real > > & _pressure_neighbor
const ADMaterialProperty< std::vector< RealGradient > > & _grad_p
const ADMaterialProperty< RealTensorValue > & _permeability_neighbor
FVPorousFlowHeatAdvection(const InputParameters &params)
const ADMaterialProperty< std::vector< Real > > & _viscosity
Fluid viscosity.
static InputParameters validParams()
virtual ADReal computeQpResidual() override
const ADMaterialProperty< std::vector< Real > > & _enthalpy_neighbor
const unsigned int _num_phases
Number of fluid phases present.
const Point & eCN() const
Real dCNMag() const
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)
T & set(const std::string &name, bool quiet_mode=false)
This holds maps between the nonlinear variables used in a PorousFlow simulation and the variable numb...