Skip to content

Commit

Permalink
Merge branch 'develop' into lroberts36/add-sparse-vector-wave-test
Browse files Browse the repository at this point in the history
  • Loading branch information
brryan authored Nov 6, 2024
2 parents b77c052 + ddc6500 commit dea0d0c
Show file tree
Hide file tree
Showing 35 changed files with 464 additions and 315 deletions.
13 changes: 8 additions & 5 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,12 @@ on:
jobs:
docs:
name: build and deploy docs
runs-on: ubuntu-latest
# not using latest due to issues with pip user packages, see
# https://github.com/actions/runner-images/issues/10781 and
# https://github.com/actions/runner-images/issues/10636
runs-on: ubuntu-22.04

steps:
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
Expand All @@ -23,9 +26,9 @@ jobs:
run: export DEBIAN_FRONTEND=noninteractive
- name: install dependencies
run: |
pip install --break-system-packages sphinx
pip install --break-system-packages sphinx-rtd-theme
pip install --break-system-packages sphinx-multiversion
pip install sphinx
pip install sphinx-rtd-theme
pip install sphinx-multiversion
- name: build docs
run: |
echo "Repo = ${GITHUB_REPOSITORY}"
Expand Down
8 changes: 6 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@
- [[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/...)
- [[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
- [[PR 1186]](https://github.com/parthenon-hpc-lab/parthenon/pull/1186) Bump Kokkos submodule to 4.4.1
- [[Issue 1165]](https://github.com/parthenon-hpc-lab/parthenon/issues/1165) Bump Kokkos submodule to 4.4.1
- [[PR 1171]](https://github.com/parthenon-hpc-lab/parthenon/pull/1171) Add PARTHENON_USE_SYSTEM_PACKAGES build option
- [[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 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 All @@ -27,7 +31,7 @@


### Incompatibilities (i.e. breaking changes)

- [[PR1177]](https://github.com/parthenon-hpc-lab/parthenon/pull/1177) Make mesh-level boundary conditions usable without the "user" flag

## Release 24.08
Date: 2024-08-30
Expand Down
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,13 @@ if (Kokkos_ENABLE_CUDA)
if(CHECK_REGISTRY_PRESSURE)
add_compile_options(-Xptxas=-v)
endif()

# Async malloc are enabled by default until Kokkos <= 4.4.1 but
# cause issues with IPCs and MPI,
# see https://github.com/parthenon-hpc-lab/athenapk/pull/114#issuecomment-2358981857
# Given that it's also not expected to be a significant performance gain
# it's hard disabled now.
set(Kokkos_ENABLE_IMPL_CUDA_MALLOC_ASYNC OFF CACHE BOOL "Disable Cuda async malloc (to address MPI/IPC issues)")
endif()
# Note that these options may not play nice with nvcc wrapper
if (TEST_INTEL_OPTIMIZATION)
Expand Down
33 changes: 22 additions & 11 deletions doc/sphinx/src/boundary_conditions.rst
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.. _sphinx-doc:
.. _boundary-conds:

Boundary Conditions
===================
Expand All @@ -10,7 +10,6 @@ Natively, Parthenon supports three kinds of boundary conditions:

- ``periodic``
- ``outflow``
- ``reflecting``

which are all imposed on variables with the ``Metadata::FillGhost``
metadata flag. To set the boundaries in each direction, set the
Expand All @@ -22,8 +21,8 @@ metadata flag. To set the boundaries in each direction, set the
ix1_bc = outflow
ox1_bc = outflow

ix2_bc = reflecting
ox2_bc = reflecting
ix2_bc = outflow
ox2_bc = outflow

ix3_bc = periodic
ox3_bc = periodic
Expand All @@ -40,7 +39,9 @@ for your ``parthenon_manager``. e.g.,

.. code:: c++

pman.app_input->boundary_conditions[parthenon::BoundaryFace::inner_x1] = MyBoundaryInnerX1;
pman.app_input->RegisterBoundaryCondition(
parthenon::BoundaryFace::inner_x1,
"my_bc_name", MyBoundaryInnerX1);

where ``BoundaryFace`` is an enum defined in ``defs.hpp`` as

Expand All @@ -58,13 +59,13 @@ where ``BoundaryFace`` is an enum defined in ``defs.hpp`` as
outer_x3 = 5
};

You can then set this boundary condition via the ``user`` flag in the
input file:
You can then set this boundary condition by using the name you
registered in the input file:

::

<parthenon/mesh>
ix1_bc = user
ix1_bc = my_bc_name

Boundary conditions so defined should look roughly like

Expand Down Expand Up @@ -100,9 +101,19 @@ Other than these requirements, the ``Boundary`` object can do whatever
you like. Reference implementations of the standard boundary conditions
are available `here <https://github.com/parthenon-hpc-lab/parthenon/blob/develop/src/bvals/boundary_conditions.cpp>`__.

.. note::

Per package user-defined boundary conditions
--------------------------------------------
A per-variable reflecting boundary condition is available, but you
must register it manually. To do so, simply call
``app_in->RegisterDefaultReflectingBoundaryConditions()`` and it
will be available as a mesh boundary with the name ``reflecting``.
The reason manual registration is required is to support custom
reflecting boundary conditions in the case where a single variable
is used as the state vector.


Per package user-defined boundary conditions.
---------------------------------

In addition to user defined *global* boundary conditions, Parthenon also supports
registration of boundary conditions at the *per package* level. These per package
Expand Down Expand Up @@ -133,4 +144,4 @@ for a more complete example):
pkg->UserBoundaryFunctions[BF::inner_x1].push_back(GetMyBC<X1DIR, BCSide::Inner>());
pkg->UserBoundaryFunctions[BF::inner_x2].push_back(GetMyBC<X2DIR, BCSide::Inner>());
...
}
}
1 change: 1 addition & 0 deletions example/advection/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ int main(int argc, char *argv[]) {
pman.app_input->ProblemGenerator = advection_example::ProblemGenerator;
pman.app_input->UserWorkAfterLoop = advection_example::UserWorkAfterLoop;
pman.app_input->UserMeshWorkBeforeOutput = advection_example::UserMeshWorkBeforeOutput;
pman.app_input->RegisterDefaultReflectingBoundaryConditions();

// call ParthenonInit to initialize MPI and Kokkos, parse the input deck, and set up
auto manager_status = pman.ParthenonInitEnv(argc, argv);
Expand Down
16 changes: 8 additions & 8 deletions example/boundary_exchange/boundary_exchange_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,23 @@ int main(int argc, char *argv[]) {
ar3_t{1.0, 1.0, 1.0});
// forest_def.AddFace(0, {n[0], n[1], n[3], n[2]}, ar3_t{0.0, 0.0, 0.0},
// ar3_t{1.0, 1.0, 1.0});
forest_def.AddBC(edge_t({n[0], n[1]}), parthenon::BoundaryFlag::outflow);
forest_def.AddBC(edge_t({n[0], n[3]}), parthenon::BoundaryFlag::outflow);
forest_def.AddBC(edge_t({n[0], n[1]}));
forest_def.AddBC(edge_t({n[0], n[3]}));

forest_def.AddFace(1, {n[1], n[4], n[2], n[5]}, ar3_t{2.0, 0.0, 0.0},
ar3_t{3.0, 1.0, 1.0});
forest_def.AddBC(edge_t({n[1], n[4]}), parthenon::BoundaryFlag::outflow);
forest_def.AddBC(edge_t({n[4], n[5]}), parthenon::BoundaryFlag::outflow);
forest_def.AddBC(edge_t({n[1], n[4]}));
forest_def.AddBC(edge_t({n[4], n[5]}));

forest_def.AddFace(3, {n[3], n[2], n[6], n[7]}, ar3_t{0.0, 2.0, 0.0},
ar3_t{1.0, 3.0, 1.0});
forest_def.AddBC(edge_t({n[6], n[7]}), parthenon::BoundaryFlag::outflow);
forest_def.AddBC(edge_t({n[3], n[6]}), parthenon::BoundaryFlag::outflow);
forest_def.AddBC(edge_t({n[6], n[7]}));
forest_def.AddBC(edge_t({n[3], n[6]}));

forest_def.AddFace(4, {n[2], n[5], n[7], n[8]}, ar3_t{2.0, 2.0, 0.0},
ar3_t{3.0, 3.0, 1.0});
forest_def.AddBC(edge_t({n[5], n[8]}), parthenon::BoundaryFlag::outflow);
forest_def.AddBC(edge_t({n[7], n[8]}), parthenon::BoundaryFlag::outflow);
forest_def.AddBC(edge_t({n[5], n[8]}));
forest_def.AddBC(edge_t({n[7], n[8]}));

forest_def.AddInitialRefinement(parthenon::LogicalLocation(0, 1, 0, 0, 0));
pman.ParthenonInitPackagesAndMesh(forest_def);
Expand Down
14 changes: 8 additions & 6 deletions example/particles/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@ int main(int argc, char *argv[]) {

// Redefine parthenon defaults
pman.app_input->ProcessPackages = particles_example::ProcessPackages;
pman.app_input->boundary_conditions[BoundaryFace::inner_x1] =
parthenon::BoundaryFunction::OutflowInnerX1;
pman.app_input->boundary_conditions[BoundaryFace::outer_x1] =
parthenon::BoundaryFunction::OutflowOuterX1;
pman.app_input->swarm_boundary_conditions[BoundaryFace::inner_x1] = SwarmUserInnerX1;
pman.app_input->swarm_boundary_conditions[BoundaryFace::outer_x1] = SwarmUserOuterX1;
pman.app_input->RegisterBoundaryCondition(BoundaryFace::inner_x1,
parthenon::BoundaryFunction::OutflowInnerX1);
pman.app_input->RegisterBoundaryCondition(BoundaryFace::outer_x1,
parthenon::BoundaryFunction::OutflowOuterX1);
pman.app_input->RegisterSwarmBoundaryCondition(BoundaryFace::inner_x1,
SwarmUserInnerX1);
pman.app_input->RegisterSwarmBoundaryCondition(BoundaryFace::outer_x1,
SwarmUserOuterX1);
// Note that this example does not use a ProblemGenerator
pman.ParthenonInitPackagesAndMesh();

Expand Down
30 changes: 16 additions & 14 deletions example/particles/particles.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,17 +288,18 @@ TaskStatus CreateSomeParticles(MeshBlock *pmb, const double t0) {
} while (r > 0.5);

// Randomly sample direction perpendicular to origin
Real theta = acos(2. * rng_gen.drand() - 1.);
Real phi = 2. * M_PI * rng_gen.drand();
v(0, n) = sin(theta) * cos(phi);
v(1, n) = sin(theta) * sin(phi);
v(2, n) = cos(theta);
const Real mu = 2.0 * rng_gen.drand() - 1.0;
const Real phi = 2. * M_PI * rng_gen.drand();
const Real stheta = std::sqrt(1.0 - mu * mu);
v(0, n) = stheta * cos(phi);
v(1, n) = stheta * sin(phi);
v(2, n) = mu;
// Project v onto plane normal to sphere
Real vdN = v(0, n) * x(n) + v(1, n) * y(n) + v(2, n) * z(n);
Real NdN = r * r;
v(0, n) = v(0, n) - vdN / NdN * x(n);
v(1, n) = v(1, n) - vdN / NdN * y(n);
v(2, n) = v(2, n) - vdN / NdN * z(n);
Real inverse_NdN = 1. / (r * r);
v(0, n) = v(0, n) - vdN * inverse_NdN * x(n);
v(1, n) = v(1, n) - vdN * inverse_NdN * y(n);
v(2, n) = v(2, n) - vdN * inverse_NdN * z(n);

// Normalize
Real v_tmp = sqrt(v(0, n) * v(0, n) + v(1, n) * v(1, n) + v(2, n) * v(2, n));
Expand Down Expand Up @@ -335,11 +336,12 @@ TaskStatus CreateSomeParticles(MeshBlock *pmb, const double t0) {
z(n) = minx_k + nx_k * dx_k * rng_gen.drand();

// Randomly sample direction on the unit sphere, fixing speed
Real theta = acos(2. * rng_gen.drand() - 1.);
Real phi = 2. * M_PI * rng_gen.drand();
v(0, n) = vel * sin(theta) * cos(phi);
v(1, n) = vel * sin(theta) * sin(phi);
v(2, n) = vel * cos(theta);
const Real mu = 2.0 * rng_gen.drand() - 1.0;
const Real phi = 2. * M_PI * rng_gen.drand();
const Real stheta = std::sqrt(1.0 - mu * mu);
v(0, n) = vel * stheta * cos(phi);
v(1, n) = vel * stheta * sin(phi);
v(2, n) = vel * mu;

// Create particles at the beginning of the timestep
t(n) = t0;
Expand Down
1 change: 1 addition & 0 deletions example/sparse_advection/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ int main(int argc, char *argv[]) {
pman.app_input->ProblemGenerator = sparse_advection_example::ProblemGenerator;
pman.app_input->PostStepDiagnosticsInLoop =
sparse_advection_example::PostStepDiagnosticsInLoop;
pman.app_input->RegisterDefaultReflectingBoundaryConditions();

// call ParthenonInit to initialize MPI and Kokkos, parse the input deck, and set up
auto manager_status = pman.ParthenonInitEnv(argc, argv);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,17 @@ def compare_metadata(f0, f1, quiet=False, one=False, check_input=False, tol=1.0e
if one:
return ret_code

# Compare the names of attributes in /Info, except "Time"
# Compare the names of attributes in /Info, except those we know
# may vary safely
f0_Info = {
key: value
for key, value in f0.Info.items()
if key != "Time"
and key != "BlocksPerPE"
and key != "WallTime"
and key != "OutputFormatVersion"
and key != "BoundaryConditions"
and key != "SwarmBoundaryConditions"
}
f1_Info = {
key: value
Expand All @@ -227,6 +230,8 @@ def compare_metadata(f0, f1, quiet=False, one=False, check_input=False, tol=1.0e
and key != "BlocksPerPE"
and key != "WallTime"
and key != "OutputFormatVersion"
and key != "BoundaryConditions"
and key != "SwarmBoundaryConditions"
}
if sorted(f0_Info.keys()) != sorted(f1_Info.keys()):
print("Names of attributes in '/Info' of differ")
Expand Down
3 changes: 3 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ set(COORDINATE_TYPE UniformCartesian) # TODO: Make this an option when more are
configure_file(config.hpp.in generated/config.hpp @ONLY)

add_library(parthenon
application_input.cpp
application_input.hpp

bvals/comms/bvals_in_one.hpp
bvals/comms/bvals_utils.hpp
bvals/comms/build_boundary_buffers.cpp
Expand Down
Loading

0 comments on commit dea0d0c

Please sign in to comment.