Skip to content

Commit

Permalink
Remove _specific from struct member variables
Browse files Browse the repository at this point in the history
  • Loading branch information
bcaddy committed Jun 18, 2024
1 parent 79e1459 commit 2b940b2
Show file tree
Hide file tree
Showing 12 changed files with 123 additions and 141 deletions.
4 changes: 2 additions & 2 deletions src/reconstruction/pcm_cuda.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,11 @@ reconstruction::InterfaceState __device__ __host__ inline PCM_Reconstruction(Rea
interface_state.magnetic = conserved_data.magnetic;
#endif // MHD
#ifdef DE
interface_state.gas_energy_specific = primitive_data.gas_energy_specific;
interface_state.gas_energy = primitive_data.gas_energy;
#endif // DE
#ifdef SCALAR
for (size_t i = 0; i < grid_enum::nscalars; i++) {
interface_state.scalar_specific[i] = primitive_data.scalar_specific[i];
interface_state.scalar[i] = primitive_data.scalar[i];
}
#endif // SCALAR

Expand Down
12 changes: 6 additions & 6 deletions src/reconstruction/plmc_cuda.cu
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,8 @@ __global__ __launch_bounds__(TPB) void PLMC_cuda(Real *dev_conserved, Real *dev_
interface_L_iph.pressure = interface_L_iph.pressure - qx * del_m_i.pressure;

#ifdef DE
interface_R_imh.gas_energy_specific = interface_R_imh.gas_energy_specific + qx * del_m_i.gas_energy_specific;
interface_L_iph.gas_energy_specific = interface_L_iph.gas_energy_specific - qx * del_m_i.gas_energy_specific;
interface_R_imh.gas_energy = interface_R_imh.gas_energy + qx * del_m_i.gas_energy;
interface_L_iph.gas_energy = interface_L_iph.gas_energy - qx * del_m_i.gas_energy;
#endif // DE

#ifdef SCALAR
Expand Down Expand Up @@ -192,7 +192,7 @@ __global__ __launch_bounds__(TPB) void PLMC_cuda(Real *dev_conserved, Real *dev_
sum_2 += lamdiff * del_m_i.velocity.y();
sum_3 += lamdiff * del_m_i.velocity.z();
#ifdef DE
sum_ge += lamdiff * del_m_i.gas_energy_specific;
sum_ge += lamdiff * del_m_i.gas_energy;
#endif // DE
#ifdef SCALAR
for (int i = 0; i < NSCALARS; i++) {
Expand All @@ -216,7 +216,7 @@ __global__ __launch_bounds__(TPB) void PLMC_cuda(Real *dev_conserved, Real *dev_
interface_L_iph.velocity.z() += 0.5 * dtodx * sum_3;
interface_L_iph.pressure += 0.5 * dtodx * sum_4;
#ifdef DE
interface_L_iph.gas_energy_specific += 0.5 * dtodx * sum_ge;
interface_L_iph.gas_energy += 0.5 * dtodx * sum_ge;
#endif // DE
#ifdef SCALAR
for (int i = 0; i < NSCALARS; i++) {
Expand Down Expand Up @@ -249,7 +249,7 @@ __global__ __launch_bounds__(TPB) void PLMC_cuda(Real *dev_conserved, Real *dev_
sum_2 += lamdiff * del_m_i.velocity.y();
sum_3 += lamdiff * del_m_i.velocity.z();
#ifdef DE
sum_ge += lamdiff * del_m_i.gas_energy_specific;
sum_ge += lamdiff * del_m_i.gas_energy;
#endif // DE
#ifdef SCALAR
for (int i = 0; i < NSCALARS; i++) {
Expand All @@ -273,7 +273,7 @@ __global__ __launch_bounds__(TPB) void PLMC_cuda(Real *dev_conserved, Real *dev_
interface_R_imh.velocity.z() += 0.5 * dtodx * sum_3;
interface_R_imh.pressure += 0.5 * dtodx * sum_4;
#ifdef DE
interface_R_imh.gas_energy_specific += 0.5 * dtodx * sum_ge;
interface_R_imh.gas_energy += 0.5 * dtodx * sum_ge;
#endif // DE
#ifdef SCALAR
for (int i = 0; i < NSCALARS; i++) {
Expand Down
64 changes: 28 additions & 36 deletions src/reconstruction/ppmc_cuda.cu
Original file line number Diff line number Diff line change
Expand Up @@ -250,17 +250,15 @@ __global__ void PPMC_CTU(Real *dev_conserved, Real *dev_bounds_L, Real *dev_boun
Real const p_6 = 6.0 * (cell_i.pressure - 0.5 * (interface_R_imh.pressure + interface_L_iph.pressure));

#ifdef DE
del_m_i.gas_energy_specific = interface_L_iph.gas_energy_specific - interface_R_imh.gas_energy_specific;
Real const ge_6 = 6.0 * (cell_i.gas_energy_specific -
0.5 * (interface_R_imh.gas_energy_specific + interface_L_iph.gas_energy_specific));
del_m_i.gas_energy = interface_L_iph.gas_energy - interface_R_imh.gas_energy;
Real const ge_6 = 6.0 * (cell_i.gas_energy - 0.5 * (interface_R_imh.gas_energy + interface_L_iph.gas_energy));
#endif // DE

#ifdef SCALAR
Real scalar_6[NSCALARS];
for (int i = 0; i < NSCALARS; i++) {
del_m_i.scalar_specific[i] = interface_L_iph.scalar_specific[i] - interface_R_imh.scalar_specific[i];
scalar_6[i] = 6.0 * (cell_i.scalar_specific[i] -
0.5 * (interface_R_imh.scalar_specific[i] + interface_L_iph.scalar_specific[i]));
del_m_i.scalar[i] = interface_L_iph.scalar[i] - interface_R_imh.scalar[i];
scalar_6[i] = 6.0 * (cell_i.scalar[i] - 0.5 * (interface_R_imh.scalar[i] + interface_L_iph.scalar[i]));
}
#endif // SCALAR

Expand Down Expand Up @@ -319,24 +317,22 @@ __global__ void PPMC_CTU(Real *dev_conserved, Real *dev_bounds_L, Real *dev_boun
lambda_min * (0.5 * dtodx) * (del_m_i.pressure + (1.0 + (2.0 / 3.0) * lambda_min * dtodx) * p_6);

#ifdef DE
interface_L_iph.gas_energy_specific =
interface_L_iph.gas_energy_specific -
lambda_max * (0.5 * dtodx) * (del_m_i.gas_energy_specific - (1.0 - (2.0 / 3.0) * lambda_max * dtodx) * ge_6);
interface_R_imh.gas_energy_specific =
interface_R_imh.gas_energy_specific -
lambda_min * (0.5 * dtodx) * (del_m_i.gas_energy_specific + (1.0 + (2.0 / 3.0) * lambda_min * dtodx) * ge_6);
interface_L_iph.gas_energy =
interface_L_iph.gas_energy -
lambda_max * (0.5 * dtodx) * (del_m_i.gas_energy - (1.0 - (2.0 / 3.0) * lambda_max * dtodx) * ge_6);
interface_R_imh.gas_energy =
interface_R_imh.gas_energy -
lambda_min * (0.5 * dtodx) * (del_m_i.gas_energy + (1.0 + (2.0 / 3.0) * lambda_min * dtodx) * ge_6);
#endif // DE

#ifdef SCALAR
for (int i = 0; i < NSCALARS; i++) {
interface_L_iph.scalar_specific[i] =
interface_L_iph.scalar_specific[i] -
lambda_max * (0.5 * dtodx) *
(del_m_i.scalar_specific[i] - (1.0 - (2.0 / 3.0) * lambda_max * dtodx) * scalar_6[i]);
interface_R_imh.scalar_specific[i] =
interface_R_imh.scalar_specific[i] -
lambda_min * (0.5 * dtodx) *
(del_m_i.scalar_specific[i] + (1.0 + (2.0 / 3.0) * lambda_min * dtodx) * scalar_6[i]);
interface_L_iph.scalar[i] =
interface_L_iph.scalar[i] -
lambda_max * (0.5 * dtodx) * (del_m_i.scalar[i] - (1.0 - (2.0 / 3.0) * lambda_max * dtodx) * scalar_6[i]);
interface_R_imh.scalar[i] =
interface_R_imh.scalar[i] -
lambda_min * (0.5 * dtodx) * (del_m_i.scalar[i] + (1.0 + (2.0 / 3.0) * lambda_min * dtodx) * scalar_6[i]);
}
#endif // SCALAR

Expand Down Expand Up @@ -381,11 +377,11 @@ __global__ void PPMC_CTU(Real *dev_conserved, Real *dev_bounds_L, Real *dev_boun
Real const chi_4 = A * (del_m_i.velocity.z() - vz_6) + B * vz_6;
Real const chi_5 = A * (del_m_i.pressure - p_6) + B * p_6;
#ifdef DE
chi_ge = A * (del_m_i.gas_energy_specific - ge_6) + B * ge_6;
chi_ge = A * (del_m_i.gas_energy - ge_6) + B * ge_6;
#endif // DE
#ifdef SCALAR
for (int i = 0; i < NSCALARS; i++) {
chi_scalar[i] = A * (del_m_i.scalar_specific[i] - scalar_6[i]) + B * scalar_6[i];
chi_scalar[i] = A * (del_m_i.scalar[i] - scalar_6[i]) + B * scalar_6[i];
}
#endif // SCALAR

Expand Down Expand Up @@ -423,11 +419,11 @@ __global__ void PPMC_CTU(Real *dev_conserved, Real *dev_bounds_L, Real *dev_boun
interface_L_iph.velocity.z() += sum_4;
interface_L_iph.pressure += sum_5;
#ifdef DE
interface_L_iph.gas_energy_specific += sum_ge;
interface_L_iph.gas_energy += sum_ge;
#endif // DE
#ifdef SCALAR
for (int i = 0; i < NSCALARS; i++) {
interface_L_iph.scalar_specific[i] += sum_scalar[i];
interface_L_iph.scalar[i] += sum_scalar[i];
}
#endif // SCALAR

Expand Down Expand Up @@ -469,11 +465,11 @@ __global__ void PPMC_CTU(Real *dev_conserved, Real *dev_bounds_L, Real *dev_boun
Real const chi_4 = C * (del_m_i.velocity.z() + vz_6) + D * vz_6;
Real const chi_5 = C * (del_m_i.pressure + p_6) + D * p_6;
#ifdef DE
chi_ge = C * (del_m_i.gas_energy_specific + ge_6) + D * ge_6;
chi_ge = C * (del_m_i.gas_energy + ge_6) + D * ge_6;
#endif // DE
#ifdef SCALAR
for (int i = 0; i < NSCALARS; i++) {
chi_scalar[i] = C * (del_m_i.scalar_specific[i] + scalar_6[i]) + D * scalar_6[i];
chi_scalar[i] = C * (del_m_i.scalar[i] + scalar_6[i]) + D * scalar_6[i];
}
#endif // SCALAR

Expand Down Expand Up @@ -511,11 +507,11 @@ __global__ void PPMC_CTU(Real *dev_conserved, Real *dev_bounds_L, Real *dev_boun
interface_R_imh.velocity.z() += sum_4;
interface_R_imh.pressure += sum_5;
#ifdef DE
interface_R_imh.gas_energy_specific += sum_ge;
interface_R_imh.gas_energy += sum_ge;
#endif // DE
#ifdef SCALAR
for (int i = 0; i < NSCALARS; i++) {
interface_R_imh.scalar_specific[i] += sum_scalar[i];
interface_R_imh.scalar[i] += sum_scalar[i];
}
#endif // SCALAR

Expand Down Expand Up @@ -669,17 +665,13 @@ __global__ __launch_bounds__(TPB) void PPMC_VL(Real *dev_conserved, Real *dev_bo

// Compute the interfaces for the variables that don't have characteristics
#ifdef DE
reconstruction::PPM_Single_Variable(cell_im2.gas_energy_specific, cell_im1.gas_energy_specific,
cell_i.gas_energy_specific, cell_ip1.gas_energy_specific,
cell_ip2.gas_energy_specific, interface_L_iph.gas_energy_specific,
interface_R_imh.gas_energy_specific);
reconstruction::PPM_Single_Variable(cell_im2.gas_energy, cell_im1.gas_energy, cell_i.gas_energy, cell_ip1.gas_energy,
cell_ip2.gas_energy, interface_L_iph.gas_energy, interface_R_imh.gas_energy);
#endif // DE
#ifdef SCALAR
for (int i = 0; i < NSCALARS; i++) {
reconstruction::PPM_Single_Variable(cell_im2.scalar_specific[i], cell_im1.scalar_specific[i],
cell_i.scalar_specific[i], cell_ip1.scalar_specific[i],
cell_ip2.scalar_specific[i], interface_L_iph.scalar_specific[i],
interface_R_imh.scalar_specific[i]);
reconstruction::PPM_Single_Variable(cell_im2.scalar[i], cell_im1.scalar[i], cell_i.scalar[i], cell_ip1.scalar[i],
cell_ip2.scalar[i], interface_L_iph.scalar[i], interface_R_imh.scalar[i]);
}
#endif // SCALAR

Expand Down
41 changes: 18 additions & 23 deletions src/reconstruction/reconstruction_internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ hydro_utilities::Primitive __device__ __host__ __inline__ Load_Data(
#endif // MHD

loaded_data.pressure = hydro_utilities::Get_Pressure_From_DE(energy, energy - energy_non_thermal, gas_energy, gamma);
loaded_data.gas_energy_specific = gas_energy / loaded_data.density;
loaded_data.gas_energy = gas_energy / loaded_data.density;
#else // not DE
#ifdef MHD
loaded_data.pressure = hydro_utilities::Calc_Pressure_Primitive(
Expand All @@ -214,7 +214,7 @@ hydro_utilities::Primitive __device__ __host__ __inline__ Load_Data(

#ifdef SCALAR
for (size_t i = 0; i < grid_enum::nscalars; i++) {
loaded_data.scalar_specific[i] = dev_conserved[(grid_enum::scalar + i) * n_cells + id] / loaded_data.density;
loaded_data.scalar[i] = dev_conserved[(grid_enum::scalar + i) * n_cells + id] / loaded_data.density;
}
#endif // SCALAR

Expand Down Expand Up @@ -298,12 +298,12 @@ hydro_utilities::Primitive __device__ __host__ __inline__ Compute_Slope(hydro_ut
#endif // MHD

#ifdef DE
slopes.gas_energy_specific = coef * (right.gas_energy_specific - left.gas_energy_specific);
slopes.gas_energy = coef * (right.gas_energy - left.gas_energy);
#endif // DE

#ifdef SCALAR
for (size_t i = 0; i < grid_enum::nscalars; i++) {
slopes.scalar_specific[i] = coef * (right.scalar_specific[i] - left.scalar_specific[i]);
slopes.scalar[i] = coef * (right.scalar[i] - left.scalar[i]);
}
#endif // SCALAR

Expand Down Expand Up @@ -344,12 +344,12 @@ hydro_utilities::Primitive __device__ __host__ __inline__ Compute_Van_Leer_Slope
#endif // MHD

#ifdef DE
vl_slopes.gas_energy_specific = Calc_Vl_Slope(left_slope.gas_energy_specific, right_slope.gas_energy_specific);
vl_slopes.gas_energy = Calc_Vl_Slope(left_slope.gas_energy, right_slope.gas_energy);
#endif // DE

#ifdef SCALAR
for (size_t i = 0; i < grid_enum::nscalars; i++) {
vl_slopes.scalar_specific[i] = Calc_Vl_Slope(left_slope.scalar_specific[i], right_slope.scalar_specific[i]);
vl_slopes.scalar[i] = Calc_Vl_Slope(left_slope.scalar[i], right_slope.scalar[i]);
}
#endif // SCALAR

Expand Down Expand Up @@ -617,13 +617,11 @@ hydro_utilities::Primitive __device__ __inline__ Monotonize_Characteristic_Retur
Characteristic_To_Primitive(primitive, del_a_m, eigenvectors, sound_speed, sound_speed_squared, gamma);

#ifdef DE
output.gas_energy_specific = Monotonize(del_L.gas_energy_specific, del_R.gas_energy_specific,
del_C.gas_energy_specific, del_G.gas_energy_specific);
output.gas_energy = Monotonize(del_L.gas_energy, del_R.gas_energy, del_C.gas_energy, del_G.gas_energy);
#endif // DE
#ifdef SCALAR
for (int i = 0; i < NSCALARS; i++) {
output.scalar_specific[i] = Monotonize(del_L.scalar_specific[i], del_R.scalar_specific[i], del_C.scalar_specific[i],
del_G.scalar_specific[i]);
output.scalar[i] = Monotonize(del_L.scalar[i], del_R.scalar[i], del_C.scalar[i], del_G.scalar[i]);
}
#endif // SCALAR

Expand Down Expand Up @@ -694,13 +692,13 @@ void __device__ __host__ __inline__ Monotonize_Parabolic_Interface(hydro_utiliti
#endif // MHD

#ifdef DE
Monotonize(cell_i.gas_energy_specific, cell_im1.gas_energy_specific, cell_ip1.gas_energy_specific,
interface_L_iph.gas_energy_specific, interface_R_imh.gas_energy_specific);
Monotonize(cell_i.gas_energy, cell_im1.gas_energy, cell_ip1.gas_energy, interface_L_iph.gas_energy,
interface_R_imh.gas_energy);
#endif // DE
#ifdef SCALAR
for (int i = 0; i < NSCALARS; i++) {
Monotonize(cell_i.scalar_specific[i], cell_im1.scalar_specific[i], cell_ip1.scalar_specific[i],
interface_L_iph.scalar_specific[i], interface_R_imh.scalar_specific[i]);
Monotonize(cell_i.scalar[i], cell_im1.scalar[i], cell_ip1.scalar[i], interface_L_iph.scalar[i],
interface_R_imh.scalar[i]);
}
#endif // SCALAR
}
Expand Down Expand Up @@ -734,11 +732,11 @@ hydro_utilities::Primitive __device__ __host__ __inline__ Calc_Interface_Linear(
#endif // MHD

#ifdef DE
output.gas_energy_specific = interface(primitive.gas_energy_specific, slopes.gas_energy_specific);
output.gas_energy = interface(primitive.gas_energy, slopes.gas_energy);
#endif // DE
#ifdef SCALAR
for (int i = 0; i < NSCALARS; i++) {
output.scalar_specific[i] = interface(primitive.scalar_specific[i], slopes.scalar_specific[i]);
output.scalar[i] = interface(primitive.scalar[i], slopes.scalar[i]);
}
#endif // SCALAR

Expand Down Expand Up @@ -784,13 +782,11 @@ hydro_utilities::Primitive __device__ __host__ __inline__ Calc_Interface_Parabol
#endif // MHD

#ifdef DE
output.gas_energy_specific = interface(cell_i.gas_energy_specific, cell_im1.gas_energy_specific,
slopes_i.gas_energy_specific, slopes_im1.gas_energy_specific);
output.gas_energy = interface(cell_i.gas_energy, cell_im1.gas_energy, slopes_i.gas_energy, slopes_im1.gas_energy);
#endif // DE
#ifdef SCALAR
for (int i = 0; i < NSCALARS; i++) {
output.scalar_specific[i] = interface(cell_i.scalar_specific[i], cell_im1.scalar_specific[i],
slopes_i.scalar_specific[i], slopes_im1.scalar_specific[i]);
output.scalar[i] = interface(cell_i.scalar[i], cell_im1.scalar[i], slopes_i.scalar[i], slopes_im1.scalar[i]);
}
#endif // SCALAR

Expand Down Expand Up @@ -988,12 +984,11 @@ void __device__ __host__ __inline__ Write_Data(hydro_utilities::Primitive const
#endif // MHD

#ifdef DE
dev_interface[grid_enum::GasEnergy * n_cells + id] = interface_state.density * interface_state.gas_energy_specific;
dev_interface[grid_enum::GasEnergy * n_cells + id] = interface_state.density * interface_state.gas_energy;
#endif // DE
#ifdef SCALAR
for (int i = 0; i < NSCALARS; i++) {
dev_interface[(grid_enum::scalar + i) * n_cells + id] =
interface_state.density * interface_state.scalar_specific[i];
dev_interface[(grid_enum::scalar + i) * n_cells + id] = interface_state.density * interface_state.scalar[i];
}
#endif // SCALAR
}
Expand Down
16 changes: 8 additions & 8 deletions src/riemann_solvers/exact_cuda.cu
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,11 @@ __global__ void Calculate_Exact_Fluxes_CUDA(Real const *dev_conserved, Real cons
left_state.pressure = fmax(left_state.pressure, (Real)TINY_NUMBER);
#ifdef SCALAR
for (int i = 0; i < NSCALARS; i++) {
left_state.scalar_specific[i] = dev_bounds_L[(5 + i) * n_cells + tid] / left_state.density;
left_state.scalar[i] = dev_bounds_L[(5 + i) * n_cells + tid] / left_state.density;
}
#endif
#ifdef DE
left_state.gas_energy_specific = dge / left_state.density;
left_state.gas_energy = 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;
Expand All @@ -109,11 +109,11 @@ __global__ void Calculate_Exact_Fluxes_CUDA(Real const *dev_conserved, Real cons
right_state.pressure = fmax(right_state.pressure, (Real)TINY_NUMBER);
#ifdef SCALAR
for (int i = 0; i < NSCALARS; i++) {
right_state.scalar_specific[i] = dev_bounds_R[(5 + i) * n_cells + tid] / right_state.density;
right_state.scalar[i] = dev_bounds_R[(5 + i) * n_cells + tid] / right_state.density;
}
#endif
#ifdef DE
right_state.gas_energy_specific = dge / right_state.density;
right_state.gas_energy = dge / right_state.density;
#endif
}
// compute sounds speeds in left and right regions
Expand Down Expand Up @@ -144,11 +144,11 @@ __global__ void Calculate_Exact_Fluxes_CUDA(Real const *dev_conserved, Real cons
dev_flux[o3 * n_cells + tid] = ds * vs * left_state.velocity.z();
#ifdef SCALAR
for (int i = 0; i < NSCALARS; i++) {
dev_flux[(5 + i) * n_cells + tid] = ds * vs * left_state.scalar_specific[i];
dev_flux[(5 + i) * n_cells + tid] = ds * vs * left_state.scalar[i];
}
#endif
#ifdef DE
dev_flux[(n_fields - 1) * n_cells + tid] = ds * vs * left_state.gas_energy_specific;
dev_flux[(n_fields - 1) * n_cells + tid] = ds * vs * left_state.gas_energy;
#endif
Es = (ps / (gamma - 1.0)) + 0.5 * ds *
(vs * vs + left_state.velocity.y() * left_state.velocity.y() +
Expand All @@ -158,11 +158,11 @@ __global__ void Calculate_Exact_Fluxes_CUDA(Real const *dev_conserved, Real cons
dev_flux[o3 * n_cells + tid] = ds * vs * right_state.velocity.z();
#ifdef SCALAR
for (int i = 0; i < NSCALARS; i++) {
dev_flux[(5 + i) * n_cells + tid] = ds * vs * right_state.scalar_specific[i];
dev_flux[(5 + i) * n_cells + tid] = ds * vs * right_state.scalar[i];
}
#endif
#ifdef DE
dev_flux[(n_fields - 1) * n_cells + tid] = ds * vs * right_state.gas_energy_specific;
dev_flux[(n_fields - 1) * n_cells + tid] = ds * vs * right_state.gas_energy;
#endif
Es = (ps / (gamma - 1.0)) + 0.5 * ds *
(vs * vs + right_state.velocity.y() * right_state.velocity.y() +
Expand Down
Loading

0 comments on commit 2b940b2

Please sign in to comment.