Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix swarm block neighbor indexing in 1D, 2D #1184

Merged
merged 6 commits into from
Oct 5, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Current develop

### Added (new features/APIs/variables/...)
- [[PR 1184]](https://github.com/parthenon-hpc-lab/parthenon/pull/1184) Fix swarm block neighbor indexing in 1D, 2D
- [[PR 1183]](https://github.com/parthenon-hpc-lab/parthenon/pull/1183) Fix particle leapfrog example initialization data
- [[PR 1179]](https://github.com/parthenon-hpc-lab/parthenon/pull/1179) Make a global variable for whether simulation is a restart
- [[PR 1171]](https://github.com/parthenon-hpc-lab/parthenon/pull/1171) Add PARTHENON_USE_SYSTEM_PACKAGES build option
Expand Down
30 changes: 15 additions & 15 deletions src/interface/swarm_comms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,6 @@ void Swarm::SetNeighborIndices_() {
}
}

// Indicate which neighbor regions correspond to this meshblock
const int kmin = ndim < 3 ? 0 : 1;
const int kmax = ndim < 3 ? 3 : 2;
const int jmin = ndim < 2 ? 0 : 1;
const int jmax = ndim < 2 ? 3 : 2;
const int imin = 1;
const int imax = 2;
for (int k = kmin; k <= kmax; k++) {
for (int j = jmin; j <= jmax; j++) {
for (int i = imin; i <= imax; i++) {
neighbor_indices_h(k, j, i) = this_block_;
}
}
}

// Create a point in the center of each ghost halo region at maximum refinement level
// and then test whether each neighbor block includes that point.
const auto &bsize = pmb->block_size;
Expand Down Expand Up @@ -130,6 +115,21 @@ void Swarm::SetNeighborIndices_() {
}
}

// Indicate which neighbor regions correspond to this meshblock
const int kmin = ndim < 3 ? 0 : 1;
const int kmax = ndim < 3 ? 3 : 2;
const int jmin = ndim < 2 ? 0 : 1;
const int jmax = ndim < 2 ? 3 : 2;
const int imin = 1;
const int imax = 2;
for (int k = kmin; k <= kmax; k++) {
for (int j = jmin; j <= jmax; j++) {
for (int i = imin; i <= imax; i++) {
neighbor_indices_h(k, j, i) = this_block_;
}
}
}

neighbor_indices_.DeepCopy(neighbor_indices_h);
}

Expand Down
4 changes: 2 additions & 2 deletions src/interface/swarm_device_context.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ class SwarmDeviceContext {

// Ignore k,j indices as necessary based on problem dimension
if (ndim_ == 1) {
block_index_(n) = neighbor_indices_(0, 0, i);
block_index_(n) = neighbor_indices_(1, 1, i);
} else if (ndim_ == 2) {
block_index_(n) = neighbor_indices_(0, j, i);
block_index_(n) = neighbor_indices_(1, j, i);
} else {
block_index_(n) = neighbor_indices_(k, j, i);
}
Expand Down
Loading