Skip to content

Commit

Permalink
No testing for now
Browse files Browse the repository at this point in the history
  • Loading branch information
brryan committed Sep 6, 2024
1 parent ec61c9c commit 822adcf
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/interface/sparse_pack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,21 @@ class SparsePack : public SparsePackBase {
return bounds_h_(1, b, vidx);
}

KOKKOS_INLINE_FUNCTION int GetLevel(const int b, const int off3, const int off2,
const int off1) const {
return block_props_(b, 0, off3 - 1, off2 - 1, off1 - 1);
}

KOKKOS_INLINE_FUNCTION int GetGID(const int b) const {
return block_props_(b, 1, 1, 1, 1);
}

int GetLevelHost(const int b, const int off3, const int off2, const int off1) const {
return block_props_h_(b, 0, off3 - 1, off2 - 1, off1 - 1);
}

int GetGIDHost(const int b) const { return block_props_h_(b, 1, 1, 1, 1); }

// Number of components of a variable on a block
template <typename T>
KOKKOS_INLINE_FUNCTION int GetSize(const int b, const T &t) const {
Expand Down
18 changes: 18 additions & 0 deletions src/interface/sparse_pack_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ SparsePackBase SparsePackBase::Build(T *pmd, const PackDescriptor &desc,
pack.bounds_ = bounds_t("bounds", 2, nblocks, nvar + 1);
pack.bounds_h_ = Kokkos::create_mirror_view(pack.bounds_);

// This array stores refinement levels of current block and all neighboring blocks.
pack.block_props_ = block_props_t("block_props", nblocks, 2, 3, 3, 3);
pack.block_props_h_ = Kokkos::create_mirror_view(pack.block_props_);

pack.coords_ = coords_t("coords", desc.flat ? max_size : nblocks);
auto coords_h = Kokkos::create_mirror_view(pack.coords_);

Expand All @@ -183,6 +187,19 @@ SparsePackBase SparsePackBase::Build(T *pmd, const PackDescriptor &desc,
coords_h(b) = pmbd->GetBlockPointer()->coords_device;
}

// This block's refinement level stored in central (0, 1,1,1) element of block
// properties
pack.block_props_h_(blidx, 0, 1, 1, 1) = pmbd->GetBlockPointer()->loc.level();
// This block's gid stored in central (1, 1, 1, 1) element
pack.block_props_h_(blidx, 1, 1, 1, 1) = pmbd->GetBlockPointer()->gid;
for (auto &neighbor : pmbd->GetBlockPointer()->neighbors) {
// Multiple refined neighbors will write to the same index but they will always have
// the same refinement level.
pack.block_props_h_(blidx, 0, neighbor.offsets[2] + 1, neighbor.offsets[1] + 1,
neighbor.offsets[0] + 1) = neighbor.loc.level();
// Currently not storing neighbor gids
}

for (int i = 0; i < nvar; ++i) {
pack.bounds_h_(0, blidx, i) = idx;
for (const auto &[var_name, uid] : desc.var_groups[i]) {
Expand Down Expand Up @@ -281,6 +298,7 @@ SparsePackBase SparsePackBase::Build(T *pmd, const PackDescriptor &desc,
});
Kokkos::deep_copy(pack.pack_, pack.pack_h_);
Kokkos::deep_copy(pack.bounds_, pack.bounds_h_);
Kokkos::deep_copy(pack.block_props_, pack.block_props_h_);
Kokkos::deep_copy(pack.coords_, coords_h);

return pack;
Expand Down
4 changes: 4 additions & 0 deletions src/interface/sparse_pack_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ class SparsePackBase {
using pack_h_t = typename pack_t::HostMirror;
using bounds_t = ParArray3D<int>;
using bounds_h_t = typename bounds_t::HostMirror;
using block_props_t = ParArray5D<int>;
using block_props_h_t = typename block_props_t::HostMirror;
using coords_t = ParArray1D<ParArray0D<Coordinates_t>>;

// Returns a SparsePackBase object that is either newly created or taken
Expand Down Expand Up @@ -90,6 +92,8 @@ class SparsePackBase {
pack_h_t pack_h_;
bounds_t bounds_;
bounds_h_t bounds_h_;
block_props_t block_props_;
block_props_h_t block_props_h_;
coords_t coords_;

int flx_idx_;
Expand Down
1 change: 0 additions & 1 deletion src/outputs/parthenon_xdmf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,6 @@ void genXDMF(std::string hdfFile, Mesh *pm, SimTime *tm, IndexDomain domain, int
if (swarm_xdmf && all_swarm_info.all_info.size() > 0) {
std::string sfilename_aux = hdfFile + ".swarm.xdmf";
std::ofstream pxdmf;
hsize_t dims[H5_NDIM] = {0}; // zero-initialized

// open file
pxdmf = std::ofstream(sfilename_aux.c_str(), std::ofstream::trunc);
Expand Down

0 comments on commit 822adcf

Please sign in to comment.