Nektar++
Loading...
Searching...
No Matches
Public Member Functions | List of all members
Nektar::detail::LaxFriedrichsSolverKernel< ExecSpace, EqnOfStParams, NDIM > Struct Template Reference

The Lax-Friedrichs flux through the trace normal, in Cartesian components (as the legacy LaxFriedrichsSolver): the central flux of the two states through normal less the jump scaled by the largest normal wave speed of the Roe-averaged state. More...

#include <LaxFriedrichsSolverKernels.hpp>

Public Member Functions

template<typename TData >
NEK_HOSTDEVICE_INLINE void operator() (const EqnOfStParams EoS, const size_t blksize, const TData *fwd, const TData *bwd, const TData *normal, TData *flux)
 

Detailed Description

template<typename ExecSpace, typename EqnOfStParams, unsigned int NDIM>
struct Nektar::detail::LaxFriedrichsSolverKernel< ExecSpace, EqnOfStParams, NDIM >

The Lax-Friedrichs flux through the trace normal, in Cartesian components (as the legacy LaxFriedrichsSolver): the central flux of the two states through normal less the jump scaled by the largest normal wave speed of the Roe-averaged state.

Definition at line 53 of file LaxFriedrichsSolverKernels.hpp.

Member Function Documentation

◆ operator()()

template<typename ExecSpace , typename EqnOfStParams , unsigned int NDIM>
template<typename TData >
NEK_HOSTDEVICE_INLINE void Nektar::detail::LaxFriedrichsSolverKernel< ExecSpace, EqnOfStParams, NDIM >::operator() ( const EqnOfStParams  EoS,
const size_t  blksize,
const TData *  fwd,
const TData *  bwd,
const TData *  normal,
TData *  flux 
)
inline
Parameters
blksizeComponent stride, in TData (a scalar or a SIMD vector of points): component c of the states, the normal and the flux lies at offset c * blksize.
normalThe unit trace normal, NDIM components.

Definition at line 62 of file LaxFriedrichsSolverKernels.hpp.

66 {
67 using std::abs;
68 using std::sqrt;
69
70 const TData oneHalf = 0.5;
71
72 // Layout: [rho | m0 | m1 | m2 | E] but only first (NDIM) moment exist.
73 const TData rhoL = fwd[0];
74 const TData rhoR = bwd[0];
75
76 // Velocities, normal velocities and kinetic energy terms.
77 TData n[NDIM], mL[NDIM], mR[NDIM], uL[NDIM], uR[NDIM];
78 TData unL = 0.0, unR = 0.0, qL2 = 0.0, qR2 = 0.0;
79#pragma unroll
80 for (unsigned int d = 0; d < NDIM; ++d)
81 {
82 n[d] = normal[d * blksize];
83 mL[d] = fwd[(1u + d) * blksize];
84 mR[d] = bwd[(1u + d) * blksize];
85 uL[d] = mL[d] / rhoL;
86 uR[d] = mR[d] / rhoR;
87 unL += uL[d] * n[d];
88 unR += uR[d] * n[d];
89 qL2 += mL[d] * uL[d];
90 qR2 += mR[d] * uR[d];
91 }
92
93 // Internal energy per unit mass, pressure and enthalpy.
94 const TData EL = fwd[(1u + NDIM) * blksize];
95 const TData ER = bwd[(1u + NDIM) * blksize];
96 const TData eL = (EL - oneHalf * qL2) / rhoL;
97 const TData eR = (ER - oneHalf * qR2) / rhoR;
98 const TData pL = GetPressure(EoS, rhoL, eL);
99 const TData pR = GetPressure(EoS, rhoR, eR);
100 const TData hL = (EL + pL) / rhoL;
101 const TData hR = (ER + pR) / rhoR;
102
103 // Roe averages.
104 const TData srL = sqrt(rhoL);
105 const TData srR = sqrt(rhoR);
106 const TData srLR = srL + srR;
107 TData unRoe = 0.0, URoe2 = 0.0;
108#pragma unroll
109 for (unsigned int d = 0; d < NDIM; ++d)
110 {
111 const TData uRoe = (srL * uL[d] + srR * uR[d]) / srLR;
112 unRoe += uRoe * n[d];
113 URoe2 += uRoe * uRoe;
114 }
115 const TData hRoe = (srL * hL + srR * hR) / srLR;
116 const TData cRoe = GetRoeSoundSpeed(EoS, rhoL, pL, eL, hL, srL, rhoR,
117 pR, eR, hR, srR, hRoe, URoe2, srLR);
118
119 // Largest wave speed through the normal.
120 const TData a = abs(unRoe) + cRoe;
121
122 // Mass, momentum and energy: the central flux through n less the
123 // dissipation of the jump.
124 flux[0] = oneHalf * (rhoL * unL + rhoR * unR - a * (rhoR - rhoL));
125#pragma unroll
126 for (unsigned int d = 0; d < NDIM; ++d)
127 {
128 flux[(1u + d) * blksize] =
129 oneHalf * (mL[d] * unL + mR[d] * unR + (pL + pR) * n[d] -
130 a * (mR[d] - mL[d]));
131 }
132 flux[(1u + NDIM) * blksize] =
133 oneHalf * (unL * (EL + pL) + unR * (ER + pR) - a * (ER - EL));
134 }
std::vector< double > d(NPUPPER *NPUPPER)
NEK_HOSTDEVICE_INLINE TData GetRoeSoundSpeed(const IdealGasEoS< TScalar > &EoS, const TData &rhoL, const TData &pL, const TData &eL, const TData &HL, const TData &srL, const TData &rhoR, const TData &pR, const TData &eR, const TData &HR, const TData &srR, const TData &HRoe, const TData &URoe2, const TData &srLR)
NEK_HOSTDEVICE_INLINE TData GetPressure(const IdealGasEoS< TScalar > &EoS, const TData &rho, const TData &e)
Ideal gas equation of state Helper function p = rho * R * T.
scalarT< T > abs(scalarT< T > in)
Definition scalar.hpp:294
scalarT< T > sqrt(scalarT< T > in)
Definition scalar.hpp:289

References tinysimd::abs(), Nektar::detail::GetPressure(), Nektar::detail::GetRoeSoundSpeed(), and tinysimd::sqrt().