Skip to content

Commit

Permalink
Removed deprecated reconstruction::Load_Data function
Browse files Browse the repository at this point in the history
  • Loading branch information
bcaddy committed Feb 13, 2024
1 parent 5deb04f commit 3f9d772
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 138 deletions.
92 changes: 0 additions & 92 deletions src/reconstruction/reconstruction_internals.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,98 +128,6 @@ bool __device__ __host__ __inline__ Thread_Guard(int const &nx, int const &ny, i
}
// =====================================================================================================================

// =====================================================================================================================
/*!
* \brief Load the data for reconstruction
*
* \param[in] dev_conserved The conserved array
* \param[in] xid The xid of the cell to load data from
* \param[in] yid The yid of the cell to load data from
* \param[in] zid The zid of the cell to load data from
* \param[in] nx Size in the X direction
* \param[in] ny Size in the Y direction
* \param[in] n_cells The total number of cells
* \param[in] o1 Directional parameter
* \param[in] o2 Directional parameter
* \param[in] o3 Directional parameter
* \param[in] gamma The adiabatic index
* \return hydro_utilities::Primitive The loaded cell data
*/
hydro_utilities::Primitive __device__ __host__ __inline__ Load_Data(
Real const *dev_conserved, size_t const &xid, size_t const &yid, size_t const &zid, size_t const &nx,
size_t const &ny, size_t const &n_cells, size_t const &o1, size_t const &o2, size_t const &o3, Real const &gamma)
{ // Compute index
size_t const id = cuda_utilities::compute1DIndex(xid, yid, zid, nx, ny);

// Declare the variable we will return
hydro_utilities::Primitive loaded_data;

// Load hydro variables except pressure
loaded_data.density = dev_conserved[grid_enum::density * n_cells + id];
loaded_data.velocity.x = dev_conserved[o1 * n_cells + id] / loaded_data.density;
loaded_data.velocity.y = dev_conserved[o2 * n_cells + id] / loaded_data.density;
loaded_data.velocity.z = dev_conserved[o3 * n_cells + id] / loaded_data.density;

// Load MHD variables. Note that I only need the centered values for the transverse fields except for the initial
// computation of the primitive variables
#ifdef MHD
auto magnetic_centered = mhd::utils::cellCenteredMagneticFields(dev_conserved, id, xid, yid, zid, n_cells, nx, ny);
switch (o1) {
case grid_enum::momentum_x:
loaded_data.magnetic.x = magnetic_centered.x;
loaded_data.magnetic.y = magnetic_centered.y;
loaded_data.magnetic.z = magnetic_centered.z;
break;
case grid_enum::momentum_y:
loaded_data.magnetic.x = magnetic_centered.y;
loaded_data.magnetic.y = magnetic_centered.z;
loaded_data.magnetic.z = magnetic_centered.x;
break;
case grid_enum::momentum_z:
loaded_data.magnetic.x = magnetic_centered.z;
loaded_data.magnetic.y = magnetic_centered.x;
loaded_data.magnetic.z = magnetic_centered.y;
break;
}
#endif // MHD

// Load pressure accounting for duel energy if enabled
#ifdef DE // DE
Real const E = dev_conserved[grid_enum::Energy * n_cells + id];
Real const gas_energy = dev_conserved[grid_enum::GasEnergy * n_cells + id];

Real E_non_thermal = hydro_utilities::Calc_Kinetic_Energy_From_Velocity(
loaded_data.density, loaded_data.velocity.x, loaded_data.velocity.y, loaded_data.velocity.z);

#ifdef MHD
E_non_thermal += mhd::utils::computeMagneticEnergy(magnetic_centered.x, magnetic_centered.y, magnetic_centered.z);
#endif // MHD

loaded_data.pressure = hydro_utilities::Get_Pressure_From_DE(E, E - E_non_thermal, gas_energy, gamma);
loaded_data.gas_energy_specific = gas_energy / loaded_data.density;
#else // not DE
#ifdef MHD
loaded_data.pressure = hydro_utilities::Calc_Pressure_Primitive(
dev_conserved[grid_enum::Energy * n_cells + id], loaded_data.density, loaded_data.velocity.x,
loaded_data.velocity.y, loaded_data.velocity.z, gamma, loaded_data.magnetic.x, loaded_data.magnetic.y,
loaded_data.magnetic.z);
#else // not MHD
loaded_data.pressure = hydro_utilities::Calc_Pressure_Primitive(
dev_conserved[grid_enum::Energy * n_cells + id], loaded_data.density, loaded_data.velocity.x,
loaded_data.velocity.y, loaded_data.velocity.z, gamma);
#endif // MHD
#endif // DE

#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;
}
#endif // SCALAR

return loaded_data;
}
// =====================================================================================================================

// =====================================================================================================================
/*!
* \brief Compute a simple slope. Equation is `coef * (right - left)`.
Expand Down
46 changes: 0 additions & 46 deletions src/reconstruction/reconstruction_internals_tests.cu
Original file line number Diff line number Diff line change
Expand Up @@ -203,52 +203,6 @@ TEST(tALLReconstructionThreadGuard, CorrectInputExpectCorrectOutput)
}
}

TEST(tALLReconstructionLoadData, CorrectInputExpectCorrectOutput)
{
// Set up test and mock up grid
size_t const nx = 3, ny = 3, nz = 3;
size_t const n_cells = nx * ny * nz;
size_t const xid = 1, yid = 1, zid = 1;
size_t const o1 = grid_enum::momentum_x, o2 = grid_enum::momentum_y, o3 = grid_enum::momentum_z;
Real const gamma = 5. / 3.;

std::vector<Real> conserved(n_cells * grid_enum::num_fields);
std::iota(conserved.begin(), conserved.end(), 0.0);

// Up the energy part of the grid to avoid negative pressure
for (size_t i = grid_enum::Energy * n_cells; i < (grid_enum::Energy + 1) * n_cells; i++) {
conserved.at(i) *= 5.0E2;
}

// Get test data
auto const test_data = reconstruction::Load_Data(conserved.data(), xid, yid, zid, nx, ny, n_cells, o1, o2, o3, gamma);

// Check results
#ifdef MHD
hydro_utilities::Primitive const fiducial_data{
13, {3.0769230769230771, 5.1538461538461542, 7.2307692307692308}, 9662.3910256410272, {147.5, 173.5, 197.5}};
testing_utilities::Check_Results(fiducial_data.density, test_data.density, "density");
testing_utilities::Check_Results(fiducial_data.velocity.x, test_data.velocity.x, "velocity.x");
testing_utilities::Check_Results(fiducial_data.velocity.y, test_data.velocity.y, "velocity.y");
testing_utilities::Check_Results(fiducial_data.velocity.z, test_data.velocity.z, "velocity.z");
testing_utilities::Check_Results(fiducial_data.pressure, test_data.pressure, "pressure");
testing_utilities::Check_Results(fiducial_data.magnetic.x, test_data.magnetic.x, "magnetic.x");
testing_utilities::Check_Results(fiducial_data.magnetic.y, test_data.magnetic.y, "magnetic.y");
testing_utilities::Check_Results(fiducial_data.magnetic.z, test_data.magnetic.z, "magnetic.z");
#else // MHD
hydro_utilities::Primitive fiducial_data{
13, {3.0769230769230771, 5.1538461538461542, 7.2307692307692308}, 39950.641025641031};
#ifdef DE
fiducial_data.pressure = 39950.641025641031;
#endif // DE
testing_utilities::Check_Results(fiducial_data.density, test_data.density, "density");
testing_utilities::Check_Results(fiducial_data.velocity.x, test_data.velocity.x, "velocity.x");
testing_utilities::Check_Results(fiducial_data.velocity.y, test_data.velocity.y, "velocity.y");
testing_utilities::Check_Results(fiducial_data.velocity.z, test_data.velocity.z, "velocity.z");
testing_utilities::Check_Results(fiducial_data.pressure, test_data.pressure, "pressure");
#endif // MHD
}

TEST(tALLReconstructionComputeSlope, CorrectInputExpectCorrectOutput)
{
// Setup input data
Expand Down

0 comments on commit 3f9d772

Please sign in to comment.