From d36a2f5e2f0937833a913338b1956000fc0c0c5d Mon Sep 17 00:00:00 2001 From: adam reyes Date: Tue, 21 May 2024 01:14:49 +0200 Subject: [PATCH 1/2] fill flux pack for X3 edges in 2D --- src/interface/variable_pack.hpp | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/interface/variable_pack.hpp b/src/interface/variable_pack.hpp index 3bd098c33ea4..fba75750f691 100644 --- a/src/interface/variable_pack.hpp +++ b/src/interface/variable_pack.hpp @@ -452,9 +452,14 @@ class VariableFluxPack : public VariablePack { // host only inline auto flux_alloc_status() const { return flux_alloc_status_; } - KOKKOS_FORCEINLINE_FUNCTION - const ViewOfParArrays &flux(const int dir) const { - assert(dir > 0 && dir <= this->ndim_); + template + KOKKOS_FORCEINLINE_FUNCTION const ViewOfParArrays &flux(const int dir) const { + assert(dir > 0); + if constexpr (TT == TopologicalType::Edge) { + assert(dir <= this->ndim_ || (this->ndim_ == 2 && dir == 3)); + } else { + assert(dir <= this->ndim_); + } return f_[dir - 1]; } @@ -471,10 +476,11 @@ class VariableFluxPack : public VariablePack { constexpr bool IsFluxAllocated(const int /*n*/) const { return true; } #endif - KOKKOS_FORCEINLINE_FUNCTION - T &flux(const int dir, const int n, const int k, const int j, const int i) const { + template + KOKKOS_FORCEINLINE_FUNCTION T &flux(const int dir, const int n, const int k, + const int j, const int i) const { assert(IsFluxAllocated(n)); - return flux(dir)(n)(k, j, i); + return flux(dir)(n)(k, j, i); } private: @@ -681,9 +687,15 @@ void FillFluxViews(const VariableVector &vars, const int ndim, for (int i = 0; i < v->GetDim(4); i++) { host_al(vindex) = v->IsAllocated(); if (v->IsAllocated()) { - host_f1(vindex) = v->data.Get(0, k, j, i); - if (ndim >= 2) host_f2(vindex) = v->data.Get(1, k, j, i); - if (ndim >= 3) host_f3(vindex) = v->data.Get(2, k, j, i); + if (v->IsSet(Metadata::Edge)) { + if (ndim >= 2) host_f3(vindex) = v->data.Get(2, k, j, i); + if (ndim >= 3) host_f2(vindex) = v->data.Get(1, k, j, i); + if (ndim >= 3) host_f1(vindex) = v->data.Get(0, k, j, i); + } else { + host_f1(vindex) = v->data.Get(0, k, j, i); + if (ndim >= 2) host_f2(vindex) = v->data.Get(1, k, j, i); + if (ndim >= 3) host_f3(vindex) = v->data.Get(2, k, j, i); + } } vindex++; From a400534fc0d0af6d37dc24f03043971f0bf29b68 Mon Sep 17 00:00:00 2001 From: Adam C Reyes Date: Tue, 21 May 2024 17:06:01 +0200 Subject: [PATCH 2/2] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index f80b56f73e3e..42ae7e0c5407 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ - [[PR 1004]](https://github.com/parthenon-hpc-lab/parthenon/pull/1004) Allow parameter modification from an input file for restarts ### Fixed (not changing behavior/API/variables/...) +- [[PR 1083]](https://github.com/parthenon-hpc-lab/parthenon/pull/1083) Correctly fill VariableFluxPack for edge fluxes in 2D - [[PR 1071]](https://github.com/parthenon-hpc-lab/parthenon/pull/1070) Fix bug in static mesh refinement related to redefinition of Mesh::root_level - [[PR 1073]](https://github.com/parthenon-hpc-lab/parthenon/pull/1073) Fix bug in AMR and sparse restarts - [[PR 1070]](https://github.com/parthenon-hpc-lab/parthenon/pull/1070) Correctly exclude flux vars from searches by default