Skip to content

Commit

Permalink
Add check for variables not initialized
Browse files Browse the repository at this point in the history
  • Loading branch information
pgrete committed Sep 12, 2021
1 parent af1972f commit 023ddf1
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
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 558]](https://github.com/lanl/parthenon/pull/558) Boundary bugfix(es) incl. regression tests and exposing FluxDiv_ interface
- [[PR 563]](https://github.com/lanl/parthenon/pull/563) Physical boundary options for particles
- [[PR 582]](https://github.com/lanl/parthenon/pull/582) Adding global reductions and basic functionality needed for solvers.
- [[PR 556]](https://github.com/lanl/parthenon/pull/556) Introduce iterative tasks and regionally dependent tasks
Expand Down
20 changes: 20 additions & 0 deletions example/advection/advection_package.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "defs.hpp"
#include "kokkos_abstraction.hpp"
#include "reconstruct/dc_inline.hpp"
#include "utils/error_checking.hpp"

using namespace parthenon::package::prelude;

Expand Down Expand Up @@ -315,6 +316,25 @@ void SquareIt(MeshBlockData<Real> *rc) {
KOKKOS_LAMBDA(const int n, const int k, const int j, const int i) {
v(out + n, k, j, i) = v(in + n, k, j, i) * v(in + n, k, j, i);
});

// The following block/logic is also just added for regression testing.
// More specifically, the "smooth_gaussian" profile is initially != 0 everywhere, but
// initialializes IndexDomain::interior.
// FillDerived (here, SquareIt) is called after the ghost cells are exchanged and over
// IndexDomain::entire.
// Thus, no 0 (from initializing Kokkos views) should be left if all faces/corners/edges
// are correct, which is what we check in the loop below.
auto pkg = pmb->packages.Get("advection_package");
const auto &profile = pkg->Param<std::string>("profile");
if (profile == "smooth_gaussian") {
const auto &advected = rc->Get("advected").data;
pmb->par_for(
"advection_package::SquareIt bval check", 0, num_vars - 1, kb.s, kb.e, jb.s, jb.e,
ib.s, ib.e, KOKKOS_LAMBDA(const int n, const int k, const int j, const int i) {
PARTHENON_REQUIRE(advected(n, k, j, i) != 0.0,
"Advected not properly initialized.");
});
}
}

// demonstrate usage of a "post" fill derived routine
Expand Down

0 comments on commit 023ddf1

Please sign in to comment.