Skip to content

Commit

Permalink
advection of rho corrections for manifold models
Browse files Browse the repository at this point in the history
  • Loading branch information
baperry2 committed Sep 17, 2024
1 parent 5011423 commit 2670304
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 12 deletions.
19 changes: 7 additions & 12 deletions Source/PeleLMeX_Advection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,9 +488,8 @@ PeleLM::computeScalarAdvTerms(std::unique_ptr<AdvanceAdvData>& advData)
afrac] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
rho_ed(i, j, k) = 0.0;
if (afrac(i, j, k) > 0.0) { // Uncovered faces
for (int n = 0; n < NUM_SPECIES; n++) {
rho_ed(i, j, k) += rhoY_ed(i, j, k, n);
}
pele::physics::PhysicsType::eos_type::RY2R(
array4_to_array(i, j, k, rhoY_ed).data(), rho_ed(i, j, k));
}
});
} else // Regular boxes
Expand All @@ -499,10 +498,8 @@ PeleLM::computeScalarAdvTerms(std::unique_ptr<AdvanceAdvData>& advData)
amrex::ParallelFor(
ebx,
[rho_ed, rhoY_ed] AMREX_GPU_DEVICE(int i, int j, int k) noexcept {
rho_ed(i, j, k) = 0.0;
for (int n = 0; n < NUM_SPECIES; n++) {
rho_ed(i, j, k) += rhoY_ed(i, j, k, n);
}
pele::physics::PhysicsType::eos_type::RY2R(
array4_to_array(i, j, k, rhoY_ed).data(), rho_ed(i, j, k));
});
}
}
Expand Down Expand Up @@ -751,11 +748,9 @@ PeleLM::computeScalarAdvTerms(std::unique_ptr<AdvanceAdvData>& advData)
amrex::ParallelFor(
advData->AofS[lev],
[=] AMREX_GPU_DEVICE(int box_no, int i, int j, int k) noexcept {
aofsma[box_no](i, j, k, DENSITY) = 0.0;
for (int n = 0; n < NUM_SPECIES; n++) {
aofsma[box_no](i, j, k, DENSITY) +=
aofsma[box_no](i, j, k, FIRSTSPEC + n);
}
pele::physics::PhysicsType::eos_type::RY2R(
array4_to_array(i, j, k, aofsma[box_no], FIRSTSPEC).data(),
aofsma[box_no](i, j, k, DENSITY));
});
}
Gpu::streamSynchronize();
Expand Down
13 changes: 13 additions & 0 deletions Source/PeleLMeX_Utils.H
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#ifndef PELELM_UTILS_H
#define PELELM_UTILS_H

template <class T>
amrex::Gpu::DeviceVector<T>
convertToDeviceVector(amrex::Vector<T> v)
Expand All @@ -13,4 +14,16 @@ convertToDeviceVector(amrex::Vector<T> v)
#endif
return v_d;
}

template <typename T = amrex::Real, unsigned int N = NUM_SPECIES>
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE amrex::GpuArray<T, N>
array4_to_array(int i, int j, int k, amrex::Array4<T> array, int start_comp = 0)
{
amrex::GpuArray<T, N> celldata;
for (unsigned int n = start_comp; n < N; i++) {
celldata[n] = array(i, j, k, n);
}
return celldata;
}

#endif

0 comments on commit 2670304

Please sign in to comment.