-
Notifications
You must be signed in to change notification settings - Fork 358
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
EBData: New class containing Array4's for all EB data
This can make the code cleaner because we can get access to all available EB data in one object. This also reduces many GPU kernels' register pressure because the GPU device lambdas are much smaller without the need to capture multiple Array4's. For example, the 3D EBABecLap's gsrb kernel's number of registers reduces from 198 to 130. Add a new function that returns a random point on EB for WarpX.
- Loading branch information
1 parent
b98eaaf
commit c759d7d
Showing
9 changed files
with
232 additions
and
99 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#ifndef AMREX_EB_DATA_H_ | ||
#define AMREX_EB_DATA_H_ | ||
#include <AMReX_Config.H> | ||
|
||
#include <AMReX_EBCellFlag.H> | ||
|
||
namespace amrex | ||
{ | ||
|
||
enum struct EBData_t : int | ||
{ | ||
levelset, // level set | ||
volfrac, // volume fraction | ||
centroid, // volume centroid | ||
bndrycent, // boundary centroid | ||
bndrynorm, // boundary normal | ||
bndryarea, // boundary area | ||
AMREX_D_DECL(apx, apy, apz), // area fraction | ||
AMREX_D_DECL(fcx, fcy, fcz), // face centroid | ||
AMREX_D_DECL(ecx, ecy, ecz), // edge centroid | ||
cellflag // EBCellFlag | ||
}; | ||
|
||
struct EBData | ||
{ | ||
template <EBData_t T> | ||
[[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE | ||
auto get (int i, int j, int k) const noexcept | ||
{ | ||
if constexpr (T == EBData_t::cellflag) { | ||
return (*m_cell_flag)(i,j,k); | ||
} else { | ||
return m_real_data[static_cast<int>(T)](i,j,k); | ||
} | ||
} | ||
|
||
template <EBData_t T, std::enable_if_t< T == EBData_t::centroid | ||
|| T == EBData_t::bndrycent | ||
|| T == EBData_t::bndrynorm | ||
AMREX_D_TERM(|| T==EBData_t::fcx, | ||
|| T==EBData_t::fcy, | ||
|| T==EBData_t::fcz), int> = 0> | ||
[[nodiscard]] AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE | ||
auto get (int i, int j, int k, int n) const noexcept | ||
{ | ||
return m_real_data[static_cast<int>(T)](i,j,k,n); | ||
} | ||
|
||
static constexpr int real_data_size = static_cast<int>(EBData_t::cellflag); | ||
|
||
Array4<EBCellFlag const> const* m_cell_flag = nullptr; | ||
Array4<Real const> const* m_real_data = nullptr; | ||
}; | ||
|
||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.