https://mooseframework.inl.gov
Loading...
Searching...
No Matches
PCNSFVHLLC.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#include "PCNSFVHLLC.h"
11#include "NS.h"
13
15
18{
20 params.addRequiredParam<UserObjectName>(NS::fluid, "Fluid properties userobject");
21 params.set<unsigned short>("ghost_layers") = 2;
22 return params;
23}
24
26 : FVFluxKernel(params),
27 _fluid(UserObjectInterface::getUserObject<SinglePhaseFluidProperties>(NS::fluid)),
28 _specific_internal_energy_elem(getADMaterialProperty<Real>(NS::specific_internal_energy)),
29 _specific_internal_energy_neighbor(
30 getNeighborADMaterialProperty<Real>(NS::specific_internal_energy)),
31 _rho_et_elem(getADMaterialProperty<Real>(NS::total_energy_density)),
32 _rho_et_neighbor(getNeighborADMaterialProperty<Real>(NS::total_energy_density)),
33 _vel_elem(getADMaterialProperty<RealVectorValue>(NS::velocity)),
34 _vel_neighbor(getNeighborADMaterialProperty<RealVectorValue>(NS::velocity)),
35 _speed_elem(getADMaterialProperty<Real>(NS::speed)),
36 _speed_neighbor(getNeighborADMaterialProperty<Real>(NS::speed)),
37 _rho_elem(getADMaterialProperty<Real>(NS::density)),
38 _rho_neighbor(getNeighborADMaterialProperty<Real>(NS::density)),
39 _pressure_elem(getADMaterialProperty<Real>(NS::pressure)),
40 _pressure_neighbor(getNeighborADMaterialProperty<Real>(NS::pressure)),
41 _eps_elem(getMaterialProperty<Real>(NS::porosity)),
42 _eps_neighbor(getNeighborMaterialProperty<Real>(NS::porosity))
43{
44}
45
46std::array<ADReal, 3>
48 const ADRealVectorValue & vel_elem,
49 const ADReal & e_elem,
50 const Real eps_elem,
51 const ADReal & rho_neighbor,
52 const ADRealVectorValue & vel_neighbor,
53 const ADReal & e_neighbor,
54 const Real eps_neighbor,
55 const SinglePhaseFluidProperties & fluid,
56 const ADRealVectorValue & normal)
57{
58 using std::sqrt, std::min, std::max;
59
60 const auto & rho1 = rho_elem;
61 const auto u1 = vel_elem.norm();
62 const auto q1 = normal * vel_elem;
63 const auto v1 = 1.0 / rho1;
64 const auto & e1 = e_elem;
65 const auto et1 = e1 + 0.5 * u1 * u1;
66 const auto p1 = fluid.p_from_v_e(v1, e1);
67 const auto ht1 = et1 + p1 / rho1;
68 const auto c1 = fluid.c_from_v_e(v1, e1);
69 const auto eps1 = eps_elem;
70
71 const auto & rho2 = rho_neighbor;
72 const auto u2 = vel_neighbor.norm();
73 const auto q2 = normal * vel_neighbor;
74 const auto v2 = 1.0 / rho2;
75 const auto & e2 = e_neighbor;
76 const auto et2 = e2 + 0.5 * u2 * u2;
77 const auto p2 = fluid.p_from_v_e(v2, e2);
78 const auto ht2 = et2 + p2 / rho2;
79 const auto c2 = fluid.c_from_v_e(v2, e2);
80 const auto eps2 = eps_neighbor;
81
82 // compute Roe-averaged variables
83 const auto sqrt_rho1 = sqrt(rho1);
84 const auto sqrt_rho2 = sqrt(rho2);
85 const auto u_roe = (sqrt_rho1 * u1 + sqrt_rho2 * u2) / (sqrt_rho1 + sqrt_rho2);
86 const auto q_roe = (sqrt_rho1 * q1 + sqrt_rho2 * q2) / (sqrt_rho1 + sqrt_rho2);
87 const auto e_roe = (sqrt_rho1 * e1 + sqrt_rho2 * e2) / (sqrt_rho1 + sqrt_rho2);
88 const auto rho_roe = sqrt(rho1 * rho2);
89 const auto v_roe = 1.0 / rho_roe;
90 const auto c_roe = fluid.c_from_v_e(v_roe, e_roe);
91
92 // compute wave speeds
93 // I may want to change the estimate of these wave speeds!
94 auto SL = min(q1 - c1, q_roe - c_roe);
95 auto SR = max(q2 + c2, q_roe + c_roe);
96 auto SM = (eps2 * rho2 * q2 * (SR - q2) - eps1 * rho1 * q1 * (SL - q1) + eps1 * p1 - eps2 * p2) /
97 (eps2 * rho2 * (SR - q2) - eps1 * rho1 * (SL - q1));
98
99 return {{std::move(SL), std::move(SM), std::move(SR)}};
100}
101
102ADReal
104{
107 auto wave_speeds = waveSpeed(_rho_elem[_qp],
108 _vel_elem[_qp],
110 _eps_elem[_qp],
115 _fluid,
116 _normal);
117 _SL = std::move(wave_speeds[0]);
118 _SM = std::move(wave_speeds[1]);
119 _SR = std::move(wave_speeds[2]);
120 if (_SL >= 0)
121 return fluxElem();
122 else if (_SR <= 0)
123 return fluxNeighbor();
124 else
125 {
126 if (_SM >= 0)
127 {
129 return fluxElem() + _SL * (f * hllcElem() - conservedVariableElem());
130 }
131 else
132 {
133 ADReal f =
136 }
137 }
138 mooseError("Should never get here");
139}
DualNumber< Real, DNDerivativeType, true > ADReal
Real f(Real x)
Test function for Brents method.
static InputParameters validParams()
RealVectorValue _normal
const RealVectorValue & normal() const
const unsigned int _qp
void addRequiredParam(const std::string &name, const std::string &doc_string)
T & set(const std::string &name, bool quiet_mode=false)
void mooseError(Args &&... args) const
virtual ADReal computeQpResidual() override
Definition PCNSFVHLLC.C:103
virtual ADReal hllcElem()=0
HLLC modifications to flux for elem & neighbor, see Toro.
const ADMaterialProperty< Real > & _specific_internal_energy_neighbor
Definition PCNSFVHLLC.h:76
virtual ADReal fluxElem()=0
flux functions on elem & neighbor, i.e. standard left/right values of F
virtual ADReal hllcNeighbor()=0
static InputParameters validParams()
Definition PCNSFVHLLC.C:17
virtual ADReal conservedVariableElem()=0
ADReal _SR
Definition PCNSFVHLLC.h:63
const ADMaterialProperty< Real > & _specific_internal_energy_elem
internal energies left == elem, right == neighbor
Definition PCNSFVHLLC.h:75
const SinglePhaseFluidProperties & _fluid
fluid properties
Definition PCNSFVHLLC.h:72
const ADMaterialProperty< Real > & _rho_neighbor
Definition PCNSFVHLLC.h:96
const ADMaterialProperty< RealVectorValue > & _vel_neighbor
Definition PCNSFVHLLC.h:86
static std::array< ADReal, 3 > waveSpeed(const ADReal &rho_elem, const ADRealVectorValue &vel_elem, const ADReal &e_elem, Real eps_elem, const ADReal &rho_neighbor, const ADRealVectorValue &vel_neighbor, const ADReal &e_neighbor, Real eps_neighbor, const SinglePhaseFluidProperties &fluid, const ADRealVectorValue &normal)
helper function for computing wave speed
Definition PCNSFVHLLC.C:47
ADReal _SL
the wave speeds
Definition PCNSFVHLLC.h:61
const ADMaterialProperty< RealVectorValue > & _vel_elem
velocities left == elem, right == neighbor
Definition PCNSFVHLLC.h:85
ADReal _normal_speed_elem
speeds normal to the interface
Definition PCNSFVHLLC.h:67
const ADMaterialProperty< Real > & _rho_elem
densities left == elem, right == neighbor
Definition PCNSFVHLLC.h:95
ADReal _normal_speed_neighbor
Definition PCNSFVHLLC.h:68
const MaterialProperty< Real > & _eps_elem
porosities left == elem, right == neighbor
Definition PCNSFVHLLC.h:105
virtual ADReal fluxNeighbor()=0
ADReal _SM
Definition PCNSFVHLLC.h:62
virtual ADReal conservedVariableNeighbor()=0
PCNSFVHLLC(const InputParameters &params)
Definition PCNSFVHLLC.C:25
const MaterialProperty< Real > & _eps_neighbor
Definition PCNSFVHLLC.h:106
Common class for single phase fluid properties.
auto raw_value(const Eigen::Map< T > &in)
static const std::string fluid
Definition NS.h:88