Skip to content

Commit

Permalink
Formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
bcaddy committed Apr 29, 2024
1 parent 38b1e99 commit b0a50d4
Show file tree
Hide file tree
Showing 4 changed files with 137 additions and 132 deletions.
56 changes: 29 additions & 27 deletions src/riemann_solvers/exact_cuda.cu
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,19 @@ __global__ void Calculate_Exact_Fluxes_CUDA(Real const *dev_conserved, Real cons
left_state.velocity.y() = dev_bounds_L[o2 * n_cells + tid] / left_state.density;
left_state.velocity.z() = dev_bounds_L[o3 * n_cells + tid] / left_state.density;
#ifdef DE // PRESSURE_DE
E = dev_bounds_L[4 * n_cells + tid];
E_kin = 0.5 * left_state.density *
(left_state.velocity.x() * left_state.velocity.x() + left_state.velocity.y() * left_state.velocity.y() +
left_state.velocity.z() * left_state.velocity.z());
dge = dev_bounds_L[(n_fields - 1) * n_cells + tid];
left_state.pressure = hydro_utilities::Get_Pressure_From_DE(E, E - E_kin, dge, gamma);
E = dev_bounds_L[4 * n_cells + tid];
E_kin = 0.5 * left_state.density *
(left_state.velocity.x() * left_state.velocity.x() + left_state.velocity.y() * left_state.velocity.y() +
left_state.velocity.z() * left_state.velocity.z());
dge = dev_bounds_L[(n_fields - 1) * n_cells + tid];
left_state.pressure = hydro_utilities::Get_Pressure_From_DE(E, E - E_kin, dge, gamma);
#else
left_state.pressure = (dev_bounds_L[4 * n_cells + tid] - 0.5 * left_state.density *
(left_state.velocity.x() * left_state.velocity.x() +
left_state.velocity.y() * left_state.velocity.y() +
left_state.velocity.z() * left_state.velocity.z())) *
(gamma - 1.0);
left_state.pressure =
(dev_bounds_L[4 * n_cells + tid] -
0.5 * left_state.density *
(left_state.velocity.x() * left_state.velocity.x() + left_state.velocity.y() * left_state.velocity.y() +
left_state.velocity.z() * left_state.velocity.z())) *
(gamma - 1.0);
#endif // PRESSURE_DE
left_state.pressure = fmax(left_state.pressure, (Real)TINY_NUMBER);
#ifdef SCALAR
Expand All @@ -84,24 +85,25 @@ __global__ void Calculate_Exact_Fluxes_CUDA(Real const *dev_conserved, Real cons
#ifdef DE
left_state.gas_energy_specific = dge / left_state.density;
#endif
right_state.density = dev_bounds_R[tid];
right_state.velocity.x() = dev_bounds_R[o1 * n_cells + tid] / right_state.density;
right_state.velocity.y() = dev_bounds_R[o2 * n_cells + tid] / right_state.density;
right_state.velocity.z() = dev_bounds_R[o3 * n_cells + tid] / right_state.density;
right_state.density = dev_bounds_R[tid];
right_state.velocity.x() = dev_bounds_R[o1 * n_cells + tid] / right_state.density;
right_state.velocity.y() = dev_bounds_R[o2 * n_cells + tid] / right_state.density;
right_state.velocity.z() = dev_bounds_R[o3 * n_cells + tid] / right_state.density;
#ifdef DE // PRESSURE_DE
E = dev_bounds_R[4 * n_cells + tid];
E_kin = 0.5 * right_state.density *
(right_state.velocity.x() * right_state.velocity.x() + right_state.velocity.y() * right_state.velocity.y() +
right_state.velocity.z() * right_state.velocity.z());
dge = dev_bounds_R[(n_fields - 1) * n_cells + tid];
right_state.pressure = hydro_utilities::Get_Pressure_From_DE(E, E - E_kin, dge, gamma);
E = dev_bounds_R[4 * n_cells + tid];
E_kin =
0.5 * right_state.density *
(right_state.velocity.x() * right_state.velocity.x() + right_state.velocity.y() * right_state.velocity.y() +
right_state.velocity.z() * right_state.velocity.z());
dge = dev_bounds_R[(n_fields - 1) * n_cells + tid];
right_state.pressure = hydro_utilities::Get_Pressure_From_DE(E, E - E_kin, dge, gamma);
#else
right_state.pressure =
(dev_bounds_R[4 * n_cells + tid] - 0.5 * right_state.density *
(right_state.velocity.x() * right_state.velocity.x() +
right_state.velocity.y() * right_state.velocity.y() +
right_state.velocity.z() * right_state.velocity.z())) *
(gamma - 1.0);
right_state.pressure =
(dev_bounds_R[4 * n_cells + tid] - 0.5 * right_state.density *
(right_state.velocity.x() * right_state.velocity.x() +
right_state.velocity.y() * right_state.velocity.y() +
right_state.velocity.z() * right_state.velocity.z())) *
(gamma - 1.0);
#endif // PRESSURE_DE
right_state.pressure = fmax(right_state.pressure, (Real)TINY_NUMBER);
#ifdef SCALAR
Expand Down
83 changes: 42 additions & 41 deletions src/riemann_solvers/hll_cuda.cu
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ __global__ void Calculate_HLL_Fluxes_CUDA(Real const *dev_conserved, Real const
left_state.gas_energy_specific = dev_bounds_L[(n_fields - 1) * n_cells + tid];
#endif

right_state.density = dev_bounds_R[tid];
right_state.momentum.x() = dev_bounds_R[o1 * n_cells + tid];
right_state.momentum.y() = dev_bounds_R[o2 * n_cells + tid];
right_state.momentum.z() = dev_bounds_R[o3 * n_cells + tid];
right_state.energy = dev_bounds_R[4 * n_cells + tid];
right_state.density = dev_bounds_R[tid];
right_state.momentum.x() = dev_bounds_R[o1 * n_cells + tid];
right_state.momentum.y() = dev_bounds_R[o2 * n_cells + tid];
right_state.momentum.z() = dev_bounds_R[o3 * n_cells + tid];
right_state.energy = dev_bounds_R[4 * n_cells + tid];
#ifdef SCALAR
for (int i = 0; i < NSCALARS; i++) {
right_state.scalar_specific[i] = dev_bounds_R[(5 + i) * n_cells + tid];
Expand All @@ -92,47 +92,48 @@ __global__ void Calculate_HLL_Fluxes_CUDA(Real const *dev_conserved, Real const
right_state.gas_energy_specific = dev_bounds_R[(n_fields - 1) * n_cells + tid];
#endif

// calculate primitive variables
left_state.velocity.x() = left_state.momentum.x() / left_state.density;
left_state.velocity.y() = left_state.momentum.y() / left_state.density;
left_state.velocity.z() = left_state.momentum.z() / left_state.density;
// calculate primitive variables
left_state.velocity.x() = left_state.momentum.x() / left_state.density;
left_state.velocity.y() = left_state.momentum.y() / left_state.density;
left_state.velocity.z() = left_state.momentum.z() / left_state.density;
#ifdef DE // PRESSURE_DE
E_kin = 0.5 * left_state.density *
(left_state.velocity.x() * left_state.velocity.x() + left_state.velocity.y() * left_state.velocity.y() +
left_state.velocity.z() * left_state.velocity.z());
left_state.pressure = hydro_utilities::Get_Pressure_From_DE(left_state.energy, left_state.energy - E_kin,
left_state.gas_energy_specific, gamma);
E_kin = 0.5 * left_state.density *
(left_state.velocity.x() * left_state.velocity.x() + left_state.velocity.y() * left_state.velocity.y() +
left_state.velocity.z() * left_state.velocity.z());
left_state.pressure = hydro_utilities::Get_Pressure_From_DE(left_state.energy, left_state.energy - E_kin,
left_state.gas_energy_specific, gamma);
#else
left_state.pressure = (left_state.energy - 0.5 * left_state.density *
(left_state.velocity.x() * left_state.velocity.x() +
left_state.velocity.y() * left_state.velocity.y() +
left_state.velocity.z() * left_state.velocity.z())) *
(gamma - 1.0);
left_state.pressure = (left_state.energy - 0.5 * left_state.density *
(left_state.velocity.x() * left_state.velocity.x() +
left_state.velocity.y() * left_state.velocity.y() +
left_state.velocity.z() * left_state.velocity.z())) *
(gamma - 1.0);
#endif // DE
left_state.pressure = fmax(left_state.pressure, (Real)TINY_NUMBER);
// #ifdef SCALAR
// for (int i=0; i<NSCALARS; i++) {
// scl[i] = left_state.scalar_specific[i] / left_state.density;
// }
// #endif
// #ifdef DE
// gel = left_state.gas_energy_specific / left_state.density;
// #endif
right_state.velocity.x() = right_state.momentum.x() / right_state.density;
right_state.velocity.y() = right_state.momentum.y() / right_state.density;
right_state.velocity.z() = right_state.momentum.z() / right_state.density;
left_state.pressure = fmax(left_state.pressure, (Real)TINY_NUMBER);
// #ifdef SCALAR
// for (int i=0; i<NSCALARS; i++) {
// scl[i] = left_state.scalar_specific[i] / left_state.density;
// }
// #endif
// #ifdef DE
// gel = left_state.gas_energy_specific / left_state.density;
// #endif
right_state.velocity.x() = right_state.momentum.x() / right_state.density;
right_state.velocity.y() = right_state.momentum.y() / right_state.density;
right_state.velocity.z() = right_state.momentum.z() / right_state.density;
#ifdef DE // PRESSURE_DE
E_kin = 0.5 * right_state.density *
(right_state.velocity.x() * right_state.velocity.x() + right_state.velocity.y() * right_state.velocity.y() +
right_state.velocity.z() * right_state.velocity.z());
right_state.pressure = hydro_utilities::Get_Pressure_From_DE(right_state.energy, right_state.energy - E_kin,
right_state.gas_energy_specific, gamma);
E_kin =
0.5 * right_state.density *
(right_state.velocity.x() * right_state.velocity.x() + right_state.velocity.y() * right_state.velocity.y() +
right_state.velocity.z() * right_state.velocity.z());
right_state.pressure = hydro_utilities::Get_Pressure_From_DE(right_state.energy, right_state.energy - E_kin,
right_state.gas_energy_specific, gamma);
#else
right_state.pressure = (right_state.energy - 0.5 * right_state.density *
(right_state.velocity.x() * right_state.velocity.x() +
right_state.velocity.y() * right_state.velocity.y() +
right_state.velocity.z() * right_state.velocity.z())) *
(gamma - 1.0);
right_state.pressure = (right_state.energy - 0.5 * right_state.density *
(right_state.velocity.x() * right_state.velocity.x() +
right_state.velocity.y() * right_state.velocity.y() +
right_state.velocity.z() * right_state.velocity.z())) *
(gamma - 1.0);
#endif // DE
right_state.pressure = fmax(right_state.pressure, (Real)TINY_NUMBER);
}
Expand Down
65 changes: 33 additions & 32 deletions src/riemann_solvers/hllc_cuda.cu
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ __global__ void Calculate_HLLC_Fluxes_CUDA(Real const *dev_conserved, Real const
Real gas_energy_left = dev_bounds_L[(n_fields - 1) * n_cells + tid];
#endif

right_state.density = dev_bounds_R[tid];
right_state.momentum.x() = dev_bounds_R[o1 * n_cells + tid];
right_state.momentum.y() = dev_bounds_R[o2 * n_cells + tid];
right_state.momentum.z() = dev_bounds_R[o3 * n_cells + tid];
right_state.energy = dev_bounds_R[4 * n_cells + tid];
right_state.density = dev_bounds_R[tid];
right_state.momentum.x() = dev_bounds_R[o1 * n_cells + tid];
right_state.momentum.y() = dev_bounds_R[o2 * n_cells + tid];
right_state.momentum.z() = dev_bounds_R[o3 * n_cells + tid];
right_state.energy = dev_bounds_R[4 * n_cells + tid];
#ifdef SCALAR
for (int i = 0; i < NSCALARS; i++) {
dscr[i] = dev_bounds_R[(5 + i) * n_cells + tid];
Expand All @@ -98,22 +98,22 @@ __global__ void Calculate_HLLC_Fluxes_CUDA(Real const *dev_conserved, Real const
Real gas_energy_right = dev_bounds_R[(n_fields - 1) * n_cells + tid];
#endif

// calculate primitive variables
left_state.velocity.x() = left_state.momentum.x() / left_state.density;
left_state.velocity.y() = left_state.momentum.y() / left_state.density;
left_state.velocity.z() = left_state.momentum.z() / left_state.density;
// calculate primitive variables
left_state.velocity.x() = left_state.momentum.x() / left_state.density;
left_state.velocity.y() = left_state.momentum.y() / left_state.density;
left_state.velocity.z() = left_state.momentum.z() / left_state.density;
#ifdef DE // PRESSURE_DE
E_kin = 0.5 * left_state.density *
(left_state.velocity.x() * left_state.velocity.x() + left_state.velocity.y() * left_state.velocity.y() +
left_state.velocity.z() * left_state.velocity.z());
left_state.pressure =
hydro_utilities::Get_Pressure_From_DE(left_state.energy, left_state.energy - E_kin, dgel, gamma);
E_kin = 0.5 * left_state.density *
(left_state.velocity.x() * left_state.velocity.x() + left_state.velocity.y() * left_state.velocity.y() +
left_state.velocity.z() * left_state.velocity.z());
left_state.pressure =
hydro_utilities::Get_Pressure_From_DE(left_state.energy, left_state.energy - E_kin, dgel, gamma);
#else
left_state.pressure = (left_state.energy - 0.5 * left_state.density *
(left_state.velocity.x() * left_state.velocity.x() +
left_state.velocity.y() * left_state.velocity.y() +
left_state.velocity.z() * left_state.velocity.z())) *
(gamma - 1.0);
left_state.pressure = (left_state.energy - 0.5 * left_state.density *
(left_state.velocity.x() * left_state.velocity.x() +
left_state.velocity.y() * left_state.velocity.y() +
left_state.velocity.z() * left_state.velocity.z())) *
(gamma - 1.0);
#endif // PRESSURE_DE
left_state.pressure = fmax(left_state.pressure, (Real)TINY_NUMBER);
#ifdef SCALAR
Expand All @@ -124,21 +124,22 @@ __global__ void Calculate_HLLC_Fluxes_CUDA(Real const *dev_conserved, Real const
#ifdef DE
left_state.gas_energy_specific = gas_energy_left / left_state.density;
#endif
right_state.velocity.x() = right_state.momentum.x() / right_state.density;
right_state.velocity.y() = right_state.momentum.y() / right_state.density;
right_state.velocity.z() = right_state.momentum.z() / right_state.density;
right_state.velocity.x() = right_state.momentum.x() / right_state.density;
right_state.velocity.y() = right_state.momentum.y() / right_state.density;
right_state.velocity.z() = right_state.momentum.z() / right_state.density;
#ifdef DE // PRESSURE_DE
E_kin = 0.5 * right_state.density *
(right_state.velocity.x() * right_state.velocity.x() + right_state.velocity.y() * right_state.velocity.y() +
right_state.velocity.z() * right_state.velocity.z());
right_state.pressure =
hydro_utilities::Get_Pressure_From_DE(right_state.energy, right_state.energy - E_kin, dger, gamma);
E_kin =
0.5 * right_state.density *
(right_state.velocity.x() * right_state.velocity.x() + right_state.velocity.y() * right_state.velocity.y() +
right_state.velocity.z() * right_state.velocity.z());
right_state.pressure =
hydro_utilities::Get_Pressure_From_DE(right_state.energy, right_state.energy - E_kin, dger, gamma);
#else
right_state.pressure = (right_state.energy - 0.5 * right_state.density *
(right_state.velocity.x() * right_state.velocity.x() +
right_state.velocity.y() * right_state.velocity.y() +
right_state.velocity.z() * right_state.velocity.z())) *
(gamma - 1.0);
right_state.pressure = (right_state.energy - 0.5 * right_state.density *
(right_state.velocity.x() * right_state.velocity.x() +
right_state.velocity.y() * right_state.velocity.y() +
right_state.velocity.z() * right_state.velocity.z())) *
(gamma - 1.0);
#endif // PRESSURE_DE
right_state.pressure = fmax(right_state.pressure, (Real)TINY_NUMBER);
#ifdef SCALAR
Expand Down
Loading

0 comments on commit b0a50d4

Please sign in to comment.