https://mooseframework.inl.gov
Loading...
Searching...
No Matches
CNSFVHLLCBase.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 "CNSFVHLLCBase.h"
11#include "NS.h"
12#include "HLLCUserObject.h"
14
15namespace nms = NS;
17
20{
22 params.addRequiredParam<UserObjectName>(nms::fluid, "Fluid properties userobject");
23 return params;
24}
25
27 : FVFluxKernel(params),
28 _fluid(dynamic_cast<FEProblemBase *>(&_subproblem)
29 ->getUserObject<SinglePhaseFluidProperties>(nms::fluid)),
30 _specific_internal_energy_elem(getADMaterialProperty<Real>(nms::specific_internal_energy)),
31 _specific_internal_energy_neighbor(
32 getNeighborADMaterialProperty<Real>(nms::specific_internal_energy)),
33 _rho_et_elem(getADMaterialProperty<Real>(nms::total_energy_density)),
34 _rho_et_neighbor(getNeighborADMaterialProperty<Real>(nms::total_energy_density)),
35 _vel_elem(getADMaterialProperty<RealVectorValue>(nms::velocity)),
36 _vel_neighbor(getNeighborADMaterialProperty<RealVectorValue>(nms::velocity)),
37 _speed_elem(getADMaterialProperty<Real>(nms::speed)),
38 _speed_neighbor(getNeighborADMaterialProperty<Real>(nms::speed)),
39 _rho_elem(getADMaterialProperty<Real>(nms::density)),
40 _rho_neighbor(getNeighborADMaterialProperty<Real>(nms::density)),
41 _pressure_elem(getADMaterialProperty<Real>(nms::pressure)),
42 _pressure_neighbor(getNeighborADMaterialProperty<Real>(nms::pressure))
43{
44}
45
57
58std::array<ADReal, 3>
59CNSFVHLLCBase::waveSpeed(const HLLCData & hllc_data, const ADRealVectorValue & normal)
60{
61 using std::sqrt, std::min, std::max;
62
63 const ADReal & rho1 = hllc_data.rho_elem;
64 const ADReal u1 = hllc_data.vel_elem.norm();
65 const ADReal q1 = normal * hllc_data.vel_elem;
66 const ADReal v1 = 1.0 / rho1;
67 const ADReal & e1 = hllc_data.e_elem;
68 const ADReal E1 = e1 + 0.5 * u1 * u1;
69 const ADReal p1 = hllc_data.fluid.p_from_v_e(v1, e1);
70 const ADReal H1 = E1 + p1 / rho1;
71 const ADReal c1 = hllc_data.fluid.c_from_v_e(v1, e1);
72
73 const ADReal & rho2 = hllc_data.rho_neighbor;
74 const ADReal u2 = hllc_data.vel_neighbor.norm();
75 const ADReal q2 = normal * hllc_data.vel_neighbor;
76 const ADReal v2 = 1.0 / rho2;
77 const ADReal & e2 = hllc_data.e_neighbor;
78 const ADReal E2 = e2 + 0.5 * u2 * u2;
79 const ADReal p2 = hllc_data.fluid.p_from_v_e(v2, e2);
80 const ADReal H2 = E2 + p2 / rho2;
81 const ADReal c2 = hllc_data.fluid.c_from_v_e(v2, e2);
82
83 // compute Roe-averaged variables
84 const ADReal sqrt_rho1 = sqrt(rho1);
85 const ADReal sqrt_rho2 = sqrt(rho2);
86 const ADReal u_roe = (sqrt_rho1 * u1 + sqrt_rho2 * u2) / (sqrt_rho1 + sqrt_rho2);
87 const ADReal q_roe = (sqrt_rho1 * q1 + sqrt_rho2 * q2) / (sqrt_rho1 + sqrt_rho2);
88 const ADReal H_roe = (sqrt_rho1 * H1 + sqrt_rho2 * H2) / (sqrt_rho1 + sqrt_rho2);
89 const ADReal h_roe = H_roe - 0.5 * u_roe * u_roe;
90 const ADReal rho_roe = sqrt(rho1 * rho2);
91 const ADReal v_roe = 1.0 / rho_roe;
92 const ADReal e_roe = hllc_data.fluid.e_from_v_h(v_roe, h_roe);
93 const ADReal c_roe = hllc_data.fluid.c_from_v_e(v_roe, e_roe);
94
95 // compute wave speeds
96 ADReal SL = min(q1 - c1, q_roe - c_roe);
97 ADReal SR = max(q2 + c2, q_roe + c_roe);
98 ADReal SM = (rho2 * q2 * (SR - q2) - rho1 * q1 * (SL - q1) + p1 - p2) /
99 (rho2 * (SR - q2) - rho1 * (SL - q1));
100
101 return {{std::move(SL), std::move(SM), std::move(SR)}};
102}
DualNumber< Real, DNDerivativeType, true > ADReal
const SinglePhaseFluidProperties & _fluid
fluid properties
CNSFVHLLCBase(const InputParameters &params)
const ADMaterialProperty< Real > & _specific_internal_energy_elem
internal energies left == elem, right == neighbor
const ADMaterialProperty< Real > & _rho_elem
densities left == elem, right == neighbor
const ADMaterialProperty< Real > & _rho_neighbor
static std::array< ADReal, 3 > waveSpeed(const HLLCData &hllc_data, const ADRealVectorValue &normal)
helper function for computing wave speed
HLLCData hllcData() const
const ADMaterialProperty< RealVectorValue > & _vel_elem
velocities left == elem, right == neighbor
const ADMaterialProperty< Real > & _specific_internal_energy_neighbor
static InputParameters validParams()
const ADMaterialProperty< RealVectorValue > & _vel_neighbor
static InputParameters validParams()
const RealVectorValue & normal() const
const unsigned int _qp
void addRequiredParam(const std::string &name, const std::string &doc_string)
Common class for single phase fluid properties.
auto raw_value(const Eigen::Map< T > &in)
static const std::string fluid
Definition NS.h:88
Helper structure for holding data necessary for computing HLLC fluxes.
const ADReal & e_neighbor
const SinglePhaseFluidProperties & fluid
fluid properties
const ADRealVectorValue & vel_neighbor
const ADReal & rho_elem
densities left == elem, right == neighbor
const ADReal & e_elem
internal energies left == elem, right == neighbor
const ADRealVectorValue & vel_elem
velocities left == elem, right == neighbor
const ADReal & rho_neighbor