85 lines
2.4 KiB
Plaintext
85 lines
2.4 KiB
Plaintext
// CelerisLab – boundary/inlet/common.cuh
|
||
// Shared helpers for west velocity inlet source-state generation.
|
||
//
|
||
// Important semantic contract in this solver:
|
||
// - x=0 inlet cells are SOLID|BC_INLET ghost source nodes
|
||
// - they generate the state later pulled by the first interior fluid column
|
||
// - inlet methods therefore construct a source state, not a textbook fluid-node
|
||
// boundary update in isolation
|
||
// ============================================================================
|
||
|
||
#ifndef CELERIS_BOUNDARY_INLET_COMMON_CUH
|
||
#define CELERIS_BOUNDARY_INLET_COMMON_CUH
|
||
|
||
#ifndef INLET_PROFILE
|
||
#define INLET_PROFILE 1
|
||
#endif
|
||
|
||
#ifndef INLET_SCHEME
|
||
#define INLET_SCHEME 0
|
||
#endif
|
||
|
||
#ifndef INLET_TRT_NEQ_DAMP
|
||
#define INLET_TRT_NEQ_DAMP 0.50f
|
||
#endif
|
||
|
||
#ifndef INLET_REGULARIZED_NEQ_DAMP
|
||
#define INLET_REGULARIZED_NEQ_DAMP 0.50f
|
||
#endif
|
||
|
||
__device__ __forceinline__ float inlet_target_u(float y_coord, unsigned int ny, float velocity) {
|
||
#if INLET_PROFILE == 0
|
||
return velocity;
|
||
#else
|
||
const float y_clamped = fminf((float)(ny - 2), fmaxf(1.0f, y_coord));
|
||
const float H = fmaxf((float)(ny - 2), 1.0f);
|
||
const float eta = (y_clamped - 0.5f) / H;
|
||
const float shape = fmaxf(0.0f, 4.0f * eta * (1.0f - eta));
|
||
return velocity * 1.5f * shape;
|
||
#endif
|
||
}
|
||
|
||
__device__ __forceinline__ float inlet_target_u(float y_coord) {
|
||
return inlet_target_u(y_coord, NY, U0);
|
||
}
|
||
|
||
#if LATTICE_MODEL == LATTICE_D2Q9
|
||
__device__ __forceinline__ float west_velocity_rho_closure_d2q9(
|
||
const float* __restrict__ f,
|
||
float ux_target)
|
||
{
|
||
float rho_num = f[0] + f[3] + f[4] + 2.0f * (f[2] + f[6] + f[8]);
|
||
#if USE_DDF_SHIFTING
|
||
// Sum of the descriptor weights in this closure (including doubles).
|
||
rho_num += 1.0f;
|
||
#endif
|
||
return rho_num / (1.0f - ux_target);
|
||
}
|
||
#endif
|
||
|
||
#if LATTICE_MODEL == LATTICE_D3Q19
|
||
__device__ __forceinline__ float west_velocity_rho_closure_d3q19(
|
||
const float* __restrict__ f,
|
||
float ux_target)
|
||
{
|
||
float rho_num = f[0] + f[3] + f[4] + f[5] + f[6] + f[11] + f[12] + f[17] + f[18]
|
||
+ 2.0f * (f[2] + f[8] + f[10] + f[14] + f[16]);
|
||
#if USE_DDF_SHIFTING
|
||
// Sum of the descriptor weights in this closure (including doubles).
|
||
rho_num += 1.0f;
|
||
#endif
|
||
return rho_num / (1.0f - ux_target);
|
||
}
|
||
#endif
|
||
|
||
__device__ __forceinline__ bool inlet_scheme_uses_post_collision_ghost()
|
||
{
|
||
#if INLET_SCHEME == 0
|
||
return true;
|
||
#else
|
||
return false;
|
||
#endif
|
||
}
|
||
|
||
#endif // CELERIS_BOUNDARY_INLET_COMMON_CUH
|