Skip to content

Commit

Permalink
Merge branch 'develop' into bprather/flat-set-bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
brryan authored Nov 14, 2024
2 parents 4f00d0e + cad5ccd commit 5af568a
Show file tree
Hide file tree
Showing 21 changed files with 685 additions and 435 deletions.
5 changes: 5 additions & 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 1103]](https://github.com/parthenon-hpc-lab/parthenon/pull/1103) Add sparsity to vector wave equation test
- [[PR 1185]](https://github.com/parthenon-hpc-lab/parthenon/pull/1185/files) Bugfix to particle defragmentation
- [[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
Expand All @@ -11,6 +12,8 @@
- [[PR 1161]](https://github.com/parthenon-hpc-lab/parthenon/pull/1161) Make flux field Metadata accessible, add Metadata::CellMemAligned flag, small perfomance upgrades

### Changed (changing behavior/API/variables/...)
- [[PR 1209]](https://github.com/parthenon-hpc-lab/parthenon/pull/1209) Ordered history output
- [[PR 1206]](https://github.com/parthenon-hpc-lab/parthenon/pull/1206) Leapfrog fix
- [[PR1203]](https://github.com/parthenon-hpc-lab/parthenon/pull/1203) Pin Ubuntu CI image
- [[PR1177]](https://github.com/parthenon-hpc-lab/parthenon/pull/1177) Make mesh-level boundary conditions usable without the "user" flag
- [[PR 1187]](https://github.com/parthenon-hpc-lab/parthenon/pull/1187) Make DataCollection::Add safer and generalize MeshBlockData::Initialize
Expand All @@ -19,6 +22,8 @@
- [[PR 1172]](https://github.com/parthenon-hpc-lab/parthenon/pull/1172) Make parthenon manager robust against external MPI init and finalize calls

### Fixed (not changing behavior/API/variables/...)
- [[PR 1188]](https://github.com/parthenon-hpc-lab/parthenon/pull/1188) Fix hdf5 output issue for metadata none variables, update test.
- [[PR 1170]](https://github.com/parthenon-hpc-lab/parthenon/pull/1170) Fixed incorrect initialization of array by a const not constexpr
- [[PR 1189]](https://github.com/parthenon-hpc-lab/parthenon/pull/1189) Address CUDA MPI/ICP issue with Kokkos <=4.4.1
- [[PR 1178]](https://github.com/parthenon-hpc-lab/parthenon/pull/1178) Fix issue with mesh pointer when using relative residual tolerance in BiCGSTAB solver.
- [[PR 1173]](https://github.com/parthenon-hpc-lab/parthenon/pull/1173) Make debugging easier by making parthenon throw an error if ParameterInput is different on multiple MPI ranks.
Expand Down
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ include(cmake/Format.cmake)
include(cmake/Lint.cmake)

# regression test reference data
set(REGRESSION_GOLD_STANDARD_VER 24 CACHE STRING "Version of gold standard to download and use")
set(REGRESSION_GOLD_STANDARD_VER 25 CACHE STRING "Version of gold standard to download and use")
set(REGRESSION_GOLD_STANDARD_HASH
"SHA512=e220df92a335131131e42ddb52dc221a6dbd6bb56361483b4af0292620eeb82ffb21ef3b95fd9a7c5cc158fb754da0bf1a1015bec98b5bbad05f4bceb1ee99bc"
"SHA512=314dc8312366d81ba33d1fde25812e9a7697b2f529de29e22662df0d458f1c4bc5b5bb4e649888170f66ffec0df1be20a9cf401944531c1c1ad835e26eaad28f"
CACHE STRING "Hash of default gold standard file to download")
option(REGRESSION_GOLD_STANDARD_SYNC "Automatically sync gold standard files." ON)

Expand Down
4 changes: 3 additions & 1 deletion doc/sphinx/src/outputs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,9 @@ block might look like

This will produce a text file (``.hst``) output file every 1 units of
simulation time. The content of the file is determined by the functions
enrolled by specific packages, see :ref:`state history output`.
enrolled by specific packages, see :ref:`state history output`. Per-package history
outputs will always be in alphabetical order by package name, which may not match
the order in which packages were added to a simulation.

Histograms
----------
Expand Down
33 changes: 33 additions & 0 deletions example/advection/advection_package.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,20 @@ std::shared_ptr<StateDescriptor> Initialize(ParameterInput *pin) {
m = Metadata({Metadata::Cell, Metadata::OneCopy}, std::vector<int>({1}));
pkg->AddField("my_derived_var", m);

// Create a Metadata::None variable for IO testing purposes.
// Only load if test_metadata_none is specified in the Advection block
auto test_metadata_none =
pin->GetOrAddBoolean("Advection", "test_metadata_none", false);
pkg->AddParam<bool>("test_metadata_none", test_metadata_none);
if (test_metadata_none) {
const int nx1 = pin->GetOrAddInteger("parthenon/meshblock", "nx1", 1);
const int nx2 = pin->GetOrAddInteger("parthenon/meshblock", "nx2", 1);
const int nx3 = pin->GetOrAddInteger("parthenon/meshblock", "nx3", 1);
std::vector<int> test_shape = {nx1 + 1, nx2 + 1, nx3 + 1, 3};
m = Metadata({Metadata::OneCopy, Metadata::None}, test_shape);
pkg->AddField("metadata_none_var", m);
}

// List (vector) of HistoryOutputVar that will all be enrolled as output variables
parthenon::HstVar_list hst_vars = {};
// Now we add a couple of callback functions
Expand Down Expand Up @@ -281,6 +295,7 @@ AmrTag CheckRefinement(MeshBlockData<Real> *rc) {
void PreFill(MeshBlockData<Real> *rc) {
auto pmb = rc->GetBlockPointer();
auto pkg = pmb->packages.Get("advection_package");
const bool test_metadata_none = pkg->Param<bool>("test_metadata_none");
bool fill_derived = pkg->Param<bool>("fill_derived");

if (fill_derived) {
Expand All @@ -302,6 +317,24 @@ void PreFill(MeshBlockData<Real> *rc) {
v(out + n, k, j, i) = 1.0 - v(in + n, k, j, i);
});
}

// Fill the metadata::None var with index gymnastics.
if (test_metadata_none) {
const int nx1 = pmb->cellbounds.ncellsi(IndexDomain::interior);
const int nx2 = pmb->cellbounds.ncellsj(IndexDomain::interior);
const int nx3 = pmb->cellbounds.ncellsk(IndexDomain::interior);

// packing in principle unnecessary/convoluted here and just done for demonstration
std::vector<std::string> vars({"metadata_none_var"});
PackIndexMap imap;
const auto &v = rc->PackVariables(vars, imap);

pmb->par_for(
PARTHENON_AUTO_LABEL, 0, 2, 0, nx3, 0, nx2, 0, nx1,
KOKKOS_LAMBDA(const int n, const int k, const int j, const int i) {
v(n, k, j, i) = n + k + j + i;
});
}
}

// this is the package registered function to fill derived
Expand Down
62 changes: 42 additions & 20 deletions example/fine_advection/advection_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "amr_criteria/refinement_package.hpp"
#include "bvals/comms/bvals_in_one.hpp"
#include "interface/metadata.hpp"
#include "interface/state_descriptor.hpp"
#include "interface/update.hpp"
#include "mesh/meshblock_pack.hpp"
#include "parthenon/driver.hpp"
Expand Down Expand Up @@ -72,6 +73,12 @@ TaskCollection AdvectionDriver::MakeTaskCollection(BlockList_t &blocks, const in
TaskCollection tc;
TaskID none(0);

std::shared_ptr<parthenon::StateDescriptor> pkg =
pmesh->packages.Get("advection_package");
const auto do_regular_advection = pkg->Param<bool>("do_regular_advection");
const auto do_fine_advection = pkg->Param<bool>("do_fine_advection");
const auto do_CT_advection = pkg->Param<bool>("do_CT_advection");

// Build MeshBlockData containers that will be included in MeshData containers. It is
// gross that this has to be done by hand.
const auto &stage_name = integrator->stage_name;
Expand Down Expand Up @@ -118,35 +125,49 @@ TaskCollection AdvectionDriver::MakeTaskCollection(BlockList_t &blocks, const in
auto flx = none;
auto flx_fine = none;
for (auto face : faces) {
flx = flx | tl.AddTask(none, advection_package::CalculateFluxes<pack_desc_t>, desc,
face, parthenon::CellLevel::same, mc0.get());
flx_fine = flx_fine |
tl.AddTask(none, advection_package::CalculateFluxes<pack_desc_fine_t>,
desc_fine, face, parthenon::CellLevel::fine, mc0.get());
if (do_regular_advection) {
flx = flx | tl.AddTask(none, advection_package::CalculateFluxes<pack_desc_t>,
desc, face, parthenon::CellLevel::same, mc0.get());
}
if (do_fine_advection) {
flx_fine = flx_fine |
tl.AddTask(none, advection_package::CalculateFluxes<pack_desc_fine_t>,
desc_fine, face, parthenon::CellLevel::fine, mc0.get());
}
}

auto vf_dep = none;
for (auto edge : std::vector<TE>{TE::E1, TE::E2, TE::E3}) {
vf_dep = tl.AddTask(vf_dep, advection_package::CalculateVectorFluxes<C, D>, edge,
parthenon::CellLevel::same, 1.0, mc0.get());
vf_dep = tl.AddTask(vf_dep, advection_package::CalculateVectorFluxes<D, C>, edge,
parthenon::CellLevel::same, -1.0, mc0.get());
if (do_CT_advection) {
for (auto edge : std::vector<TE>{TE::E1, TE::E2, TE::E3}) {
vf_dep = tl.AddTask(vf_dep, advection_package::CalculateVectorFluxes<C, D>, edge,
parthenon::CellLevel::same, 1.0, mc0.get());
vf_dep = tl.AddTask(vf_dep, advection_package::CalculateVectorFluxes<D, C>, edge,
parthenon::CellLevel::same, -1.0, mc0.get());
}
}

auto set_flx = parthenon::AddFluxCorrectionTasks(
start_flxcor | flx | flx_fine | vf_dep, tl, mc0, pmesh->multilevel);

auto update =
AddUpdateTasks(set_flx, tl, parthenon::CellLevel::same, TT::Cell, beta, dt, desc,
mbase.get(), mc0.get(), mdudt.get(), mc1.get());
auto update = set_flx;
if (do_regular_advection) {
update = AddUpdateTasks(set_flx, tl, parthenon::CellLevel::same, TT::Cell, beta, dt,
desc, mbase.get(), mc0.get(), mdudt.get(), mc1.get());
}

auto update_fine =
AddUpdateTasks(set_flx, tl, parthenon::CellLevel::fine, TT::Cell, beta, dt,
desc_fine, mbase.get(), mc0.get(), mdudt.get(), mc1.get());
auto update_fine = set_flx;
if (do_fine_advection) {
update_fine =
AddUpdateTasks(set_flx, tl, parthenon::CellLevel::fine, TT::Cell, beta, dt,
desc_fine, mbase.get(), mc0.get(), mdudt.get(), mc1.get());
}

auto update_vec =
AddUpdateTasks(set_flx, tl, parthenon::CellLevel::same, TT::Face, beta, dt,
desc_vec, mbase.get(), mc0.get(), mdudt.get(), mc1.get());
auto update_vec = set_flx;
if (do_CT_advection) {
update_vec =
AddUpdateTasks(set_flx, tl, parthenon::CellLevel::same, TT::Face, beta, dt,
desc_vec, mbase.get(), mc0.get(), mdudt.get(), mc1.get());
}

auto boundaries = parthenon::AddBoundaryExchangeTasks(
update | update_vec | update_fine | start_send, tl, mc1, pmesh->multilevel);
Expand All @@ -155,7 +176,8 @@ TaskCollection AdvectionDriver::MakeTaskCollection(BlockList_t &blocks, const in
tl.AddTask(boundaries, parthenon::Update::FillDerived<MeshData<Real>>, mc1.get());

if (stage == integrator->nstages) {
auto new_dt = tl.AddTask(fill_derived, EstimateTimestep<MeshData<Real>>, mc1.get());
auto dealloc = tl.AddTask(fill_derived, SparseDealloc, mc1.get());
auto new_dt = tl.AddTask(dealloc, EstimateTimestep<MeshData<Real>>, mc1.get());
if (pmesh->adaptive) {
auto tag_refine =
tl.AddTask(new_dt, parthenon::Refinement::Tag<MeshData<Real>>, mc1.get());
Expand Down
Loading

0 comments on commit 5af568a

Please sign in to comment.