62 template <DeviceBackend B>
84 template <
class tUPrim,
class tDiffUPrim>
86 tUPrim &&UPrim, tDiffUPrim &&DiffUPrim,
int nVars,
111 template <
class tUPrim,
class tU>
113 tU &&U, tUPrim &&UPrim,
int nVars)
const
120 for (
int i = 1; i < nVarsFlow - 1; i++)
121 UPrim(i) = U(i) / rho, vSqr +=
sqr(UPrim(i));
123 real e = (E - rho * 0.5 * vSqr);
126 for (
int i = nVarsFlow; i < nVars; i++)
127 UPrim(i) = U(i) / rho;
148 template <
class tU,
class tUPrim,
class tDiffU,
class tDiffUPrim>
150 tU &&U, tUPrim &&UPrim, tDiffU &&DiffU, tDiffUPrim &&DiffUPrim,
int nVars)
const
153 for (
int d = 0; d < 3; d++)
154 DiffUPrim(d, 0) = DiffU(d, 0);
155 for (
int i = 1; i < I4; i++)
156 for (
int d = 0; d < 3; d++)
157 DiffUPrim(d, i) = (DiffU(d, i) - DiffUPrim(d, 0) * UPrim(i)) / UPrim(0);
160 for (
int i = 1; i < nVarsFlow - 1; i++)
161 vSqr +=
sqr(UPrim(i));
166 for (
int d = 0; d < 3; d++)
168 DiffUPrim(d, I4) = DiffU(d, I4) - 0.5 * DiffUPrim(d, 0) * vSqr;
169 for (
int i = 1; i < nVarsFlow - 1; i++)
170 DiffUPrim(d, I4) -= rho * DiffUPrim(d, i) * UPrim(i);
172 for (
int i = nVarsFlow; i < nVars; i++)
173 for (
int d = 0; d < 3; d++)
174 DiffUPrim(d, i) = (DiffU(d, i) - DiffUPrim(d, 0) * UPrim(i)) / UPrim(0);
192 template <
class tUPrim,
class tU>
194 tUPrim &&UPrim, tU &&U,
int nVars)
const
201 for (
int i = 1; i < nVarsFlow - 1; i++)
202 vSqr +=
sqr(UPrim(i)), U(i) = UPrim(i) * rho;
204 real E = (e + rho * 0.5 * vSqr);
207 for (
int i = nVarsFlow; i < nVars; i++)
208 U(i) = UPrim(i) * rho;
223 tU &&U,
int nVars)
const
230 for (
int i = 1; i < nVarsFlow - 1; i++)
234 real e = (E - 0.5 * rvSqr);
250 template <
class tUPrim>
252 tUPrim &&UPrim,
int nVars,
real T)
const
267 template <
class tUPrim>
269 tUPrim &&UPrim,
int nVars,
real p)
const
285 template <
class tUPrim>
287 tUPrim &&UPrim,
int nVars)
const
290 return UPrim(I4) / UPrim(0) /
params.
cp;
306 tU &&U,
int nVars,
real p)
const
325 tU &&U,
int nVars,
real H)
const
328 return H * U(0) - U(I4);
367 template <DeviceBackend B>
378 template <DeviceBackend B>
426 template <
typename TU,
typename TF,
class TVecN>
430 for (
int i = 0; i < nVars; i++)
431 F(i) += U(i) * (vn - vgn);
432 for (
int d = 0; d < 3; d++)
433 F(d + 1) += p *
n(d);
Core type aliases, constants, and metaprogramming utilities for the DNDS framework.
#define DNDS_DEVICE_CALLABLE
#define DNDS_DEVICE_TRIVIAL_COPY_DEFINE_NO_EMPTY_CTOR(T, T_Self)
Device memory abstraction layer with backend-specific storage and factory creation.
Assertion / error-handling macros and supporting helper functions.
#define DNDS_assert(expr)
Debug-only assertion (compiled out when DNDS_NDEBUG is defined). Prints the expression + file/line + ...
Core type definitions and utilities for the EulerP alternative Navier-Stokes evaluator module.
Shared ideal-gas thermodynamics and Roe-flux primitives.
JSON-to-Eigen conversion utilities and nlohmann_json helper macros.
Non-owning device-callable view {pointer, size} over a typed array.
Namespace for the EulerP alternative evaluator module with GPU support.
DNDS_DEVICE_CALLABLE void GasInviscidFlux_XY(TU &&U, int nVars, real vn, real vgn, TVecN &&n, real p, TF &F)
Computes the inviscid (Euler) flux projected onto a face normal direction.
Eigen::Vector< real, nVarsFlow > TU
Fixed-size 5-component conservative state vector (rho, rhoU, rhoV, rhoW, E).
DNDS_DEVICE_CALLABLE real Pressure_From_InternalEnergy(real e, real gamma)
Pressure from internal energy: p = (gamma - 1) * e.
DNDS_DEVICE_CALLABLE real Enthalpy(real E, real rho, real p)
Specific enthalpy from conservative state: H = (E + p) / rho.
DNDS_DEVICE_CALLABLE real SpeedOfSoundSqr(real gamma, real p, real rho)
Speed of sound squared: a^2 = gamma * p / rho.
DeviceBackend
Enumerates the backends a DeviceStorage / Array can live on.
@ Unknown
Unset / sentinel.
constexpr T sqr(const T &a)
a * a, constexpr. Works for all arithmetic types.
double real
Canonical floating-point scalar used throughout DNDSR (double precision).
Device-callable view of physics parameters providing thermodynamic operations.
vector_DeviceView< B, real, int32_t > reference_values
Device-resident reference values (e.g., freestream quantities).
DNDS_DEVICE_CALLABLE void Cons2PrimDiff(tU &&U, tUPrim &&UPrim, tDiffU &&DiffU, tDiffUPrim &&DiffUPrim, int nVars) const
Converts conservative variable gradients to primitive variable gradients.
DNDS_DEVICE_CALLABLE auto Prim2GammaAcousticSpeed(tUPrim &&UPrim, int nVars, real p) const
Computes the ratio of specific heats and the acoustic speed of sound.
DNDS_DEVICE_CALLABLE real Pressure2Enthalpy(tU &&U, int nVars, real p) const
Computes specific total enthalpy from conservative state and pressure.
DNDS_DEVICE_CALLABLE void Prim2Cons(tUPrim &&UPrim, tU &&U, int nVars) const
Converts primitive state to conservative state.
DNDS_DEVICE_CALLABLE real Cons2EInternal(tU &&U, int nVars) const
Extracts internal energy from a conservative state vector.
DNDS_DEVICE_CALLABLE void Cons2Prim(tU &&U, tUPrim &&UPrim, int nVars) const
Converts conservative state to primitive state.
DNDS_DEVICE_CALLABLE real getMuTot(tUPrim &&UPrim, tDiffUPrim &&DiffUPrim, int nVars, real p, real T) const
Computes the total dynamic viscosity.
DNDS_DEVICE_CALLABLE real Prim2Temperature(tUPrim &&UPrim, int nVars) const
Computes temperature from the primitive state.
PhysicsParams params
Gas physical parameters (copied to device).
DNDS_DEVICE_CALLABLE real Prim2Pressure(tUPrim &&UPrim, int nVars, real T) const
Computes pressure from the primitive state using the ideal gas law.
DNDS_DEVICE_CALLABLE real Enthalpy2Pressure(tU &&U, int nVars, real H) const
Recovers pressure from specific total enthalpy and conservative state.
POD struct holding gas physical properties for the ideal gas model.
real mu0
Dynamic viscosity coefficient. Default: effectively inviscid.
real TRef
Reference temperature [K] for viscosity models.
real gamma
only simple data here allowed
real cv
Specific heat at constant volume.
real Rg
Specific gas constant (Cp - Cv).
int muModel
Viscosity model selector (0 = constant viscosity).
real cp
Specific heat at constant pressure.
DNDS_NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_ORDERED_AND_UNORDERED_JSON(PhysicsParams, gamma, mu0, cp, Rg, TRef, muModel)
Host-side physics object managing gas parameters and device-transferable reference values.
void to_device(DeviceBackend B)
Transfers reference values to the specified device backend.
void setPerfectGas(real Rg, real gamma)
Configures the physics for a calorically perfect ideal gas.
PhysicsDeviceView< B > t_deviceView
Device view type alias parameterized by backend.
DNDS_NLOHMANN_DEFINE_TYPE_INTRUSIVE_WITH_ORDERED_AND_UNORDERED_JSON(Physics, reference_values, params) void to_host()
Transfers reference values to host memory.
PhysicsParams params
Gas physical parameters.
DeviceBackend device()
Returns the current device backend where reference values reside.
t_deviceView< B > deviceView()
Creates a device-callable view of this Physics object.
host_device_vector< real > reference_values
Reference values (e.g., freestream state) for non-dimensionalization.
Eigen::Vector3d n(1.0, 0.0, 0.0)