Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
53ec0dc
Add interpolate function and replace it in shallow-water examples
Sfonxu Jul 23, 2025
be4ec4b
Make interpolate JIT-compilable
Sfonxu Jul 23, 2025
d11158b
Syntax fixes
Sfonxu Jul 23, 2025
9f7f098
Disable too-few-public-methods warning in SWE example
Sfonxu Jul 23, 2025
85dde03
Make a simple JIT-compatible interpolate by hand
Sfonxu Jul 23, 2025
5a0d973
Add ati indexer, add support for multiple advectees in Solver, add un…
Sfonxu Jul 25, 2025
54e3144
Add multiple advectee-solver option, ante_step and JIT-compilable div…
Sfonxu Nov 2, 2025
f850584
Implement SWE fully with Numba
Sfonxu Nov 2, 2025
53edc2e
Linting fixes
Sfonxu Nov 2, 2025
56035b2
fix rhs calculation
Sfonxu Nov 4, 2025
31ce24f
Add JIT-ted functions to MPI shallow-water example
Sfonxu Nov 24, 2025
04ba8c9
MPI test temp change
Sfonxu Nov 24, 2025
b0e95ba
delete staticmethod decorator
Sfonxu Nov 24, 2025
40e1cbb
refactor: make_hooks (shared by examples and mpi_scenario code)
slayoo Nov 24, 2025
05dc99a
Add traversals_data as argument to stepper loop, disable mpi_dim=INNE…
Sfonxu Nov 28, 2025
09a1041
Pylint fixes
Sfonxu Nov 28, 2025
631d61c
Add pympdata-examples as a dependency for PyMPDATA-MPI tests
Sfonxu Nov 28, 2025
f667bd5
More linting...
Sfonxu Nov 28, 2025
5b9f157
More linting...
Sfonxu Nov 28, 2025
40e88b1
Merge branch 'interpolation_refactor' of github.com:open-atmos/PyMPDA…
Sfonxu Dec 3, 2025
89b7a4d
Reset notebook execution count
Sfonxu Dec 3, 2025
90b32b6
Fix collab header
Sfonxu Dec 3, 2025
9579834
Add PyMPDATA-examples as a dependency for PyMPDATA-MPI and the tests …
Sfonxu Dec 3, 2025
7457212
dependency modification cont.
Sfonxu Dec 3, 2025
166cf71
Fix typo in mpi.yml
Sfonxu Dec 3, 2025
dca2b80
More typos
Sfonxu Dec 3, 2025
92dcd71
Fix direcotry name for examples install
Sfonxu Dec 3, 2025
e4ff0d0
Update branch w/ new commits from main (#640)
Sfonxu Dec 3, 2025
400687c
Change pip install line in mpi.yml to match tests.yml, change version…
Sfonxu Dec 3, 2025
a7e28ca
Merge branch 'main' into interpolation_refactor
Sfonxu Dec 3, 2025
8adea7c
Update regex to catch "0.0" and such that appear on CI
Sfonxu Dec 3, 2025
dfd0cff
Merge branch 'interpolation_refactor' of github.com:open-atmos/PyMPDA…
Sfonxu Dec 3, 2025
91d6b56
Revert version checks changes
Sfonxu Dec 3, 2025
f7fe04a
Add intel-openmp for macos tests
Sfonxu Dec 3, 2025
f5c8037
Fix data access in _scenario and naming in shallow water scenario
Sfonxu Dec 4, 2025
431572a
Fix matrix.platform typo in tests.yml
Sfonxu Dec 4, 2025
be8ef57
Fix docstring of formulae divide
Sfonxu Dec 4, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/mpi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ jobs:
- if: steps.cache.outputs.cache-hit != 'true'
run: |
HDF5_MPI="ON" CC=mpicc pip install --no-binary=h5py h5py==3.13.0
pip install -e MPI[tests]
pip install -e .[tests] -e ./examples[tests] -e ./MPI[tests]
- run: pip show numpy
- id: cache-save
if: steps.cache.outputs.cache-hit != 'true'
Expand Down
3 changes: 3 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,9 @@ jobs:
python -We -c "import PyMPDATA"
python -m pip install $PIP_INSTALL_ARGS -e .[tests] -e ./examples

- if: startsWith(matrix.platform, 'macos-')
run: python -m pip install intel-openmp

- if: startsWith(matrix.platform, 'ubuntu-')
run: echo NUMBA_THREADING_LAYER=omp >> $GITHUB_ENV

Expand Down
3 changes: 2 additions & 1 deletion MPI/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ build-backend = "setuptools.build_meta"
name = "pympdata-mpi"
description = "PyMPDATA + numba-mpi coupler sandbox"
readme = "README.md"
requires-python = ">=3.10"
requires-python = ">=3.9"
keywords = ["MPI", "MPDATA", "Numba", "PyMPDATA"]
license = {text = "GPL-3.0"}
classifiers = [
Expand All @@ -32,6 +32,7 @@ dependencies = [
"numpy<1.25.0",
"numba_mpi>=0.30",
"PyMPDATA",
"PyMPDATA-examples",
"mpi4py==4.0.3",
"h5py",
]
Expand Down
62 changes: 62 additions & 0 deletions PyMPDATA/impl/formulae_divide.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
"""operation logic for dividing the field by a set divisor table and saving
the result to a temporary field. Requires 'dynmaic_advector' option to be enabled"""

import numba
import numpy as np

from .enumerations import INNER, MID3D, OUTER
from .meta import META_HALO_VALID


def make_divide_or_zero(options, traversals):
"""returns njit-ted function for use with given traversals"""

n_dims = traversals.n_dims

@numba.njit(**options.jit_flags)
# pylint: disable=too-many-arguments
def divide_or_zero(
out_outer_meta,
out_outer_data,
out_mid3d_meta,
out_mid3d_data,
out_inner_meta,
out_inner_data,
_,
dividend_outer,
__,
dividend_mid3d,
___,
dividend_inner,
____,
divisor,
time_step,
grid_step,
):
eps = 1e-7
for i in np.ndindex(out_inner_data.shape):
if n_dims > 1:
out_outer_data[i] = (
dividend_outer[i] / divisor[i] * time_step / grid_step[OUTER]
if divisor[i] > eps
else 0
)
if n_dims > 2:
out_mid3d_data[i] = (
dividend_mid3d[i] / divisor[i] * time_step / grid_step[MID3D]
if divisor[i] > eps
else 0
)
out_inner_data[i] = (
dividend_inner[i] / divisor[i] * time_step / grid_step[INNER]
if divisor[i] > eps
else 0
)

if n_dims > 1:
out_outer_meta[META_HALO_VALID] = False
if n_dims > 2:
out_mid3d_meta[META_HALO_VALID] = False
out_inner_meta[META_HALO_VALID] = False

return divide_or_zero
43 changes: 41 additions & 2 deletions PyMPDATA/impl/indexers.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,14 @@ def ats_1d(focus, arr, k, _=INVALID_INDEX, __=INVALID_INDEX):
def atv_1d(focus, arrs, k, _=INVALID_INDEX, __=INVALID_INDEX):
return arrs[INNER][focus[INNER] + int(k - 0.5)]

@staticmethod
@numba.njit(**jit_flags)
def ati_1d(focus, arrs, k, _=INVALID_INDEX, __=INVALID_INDEX):
return (
arrs[INNER][focus[INNER] + int(k - 0.5)]
+ arrs[INNER][focus[INNER] + int(k + 0.5)]
) / 2

@staticmethod
@numba.njit(**jit_flags)
def set(arr, _, __, k, value):
Expand Down Expand Up @@ -70,6 +78,30 @@ def atv_axis1(focus, arrs, k, i=0, _=INVALID_INDEX):
dim, _ii, _kk = OUTER, int(i - 0.5), int(k)
return arrs[dim][focus[OUTER] + _ii, focus[INNER] + _kk]

@staticmethod
@numba.njit(**jit_flags)
def ati_axis0(focus, arrs, i, k=0, _=INVALID_INDEX):
if _is_integral(i):
dim, _ii, _kk = INNER, int(i), int(k - 0.5)
else:
dim, _ii, _kk = OUTER, int(i - 0.5), int(k)
return (
arrs[dim][focus[OUTER] + _ii, focus[INNER] + _kk]
+ arrs[dim][focus[OUTER] + _ii + 1, focus[INNER] + _kk]
) / 2

@staticmethod
@numba.njit(**jit_flags)
def ati_axis1(focus, arrs, k, i=0, _=INVALID_INDEX):
if _is_integral(i):
dim, _ii, _kk = INNER, int(i), int(k - 0.5)
else:
dim, _ii, _kk = OUTER, int(i - 0.5), int(k)
return (
arrs[dim][focus[OUTER] + _ii, focus[INNER] + _kk]
+ arrs[dim][focus[OUTER] + _ii, focus[INNER] + _kk + 1]
) / 2

@staticmethod
@numba.njit(**jit_flags)
def set(arr, i, _, k, value):
Expand Down Expand Up @@ -140,24 +172,31 @@ def get(arr, i, j, k):
return arr[i, j, k]

Indexers = namedtuple( # pylint: disable=invalid-name
Path(__file__).stem + "_Indexers", ("ats", "atv", "set", "get", "n_dims")
Path(__file__).stem + "_Indexers", ("ats", "atv", "ati", "set", "get", "n_dims")
)

indexers = (
None,
Indexers(
(None, None, _1D.ats_1d), (None, None, _1D.atv_1d), _1D.set, _1D.get, 1
(None, None, _1D.ats_1d),
(None, None, _1D.atv_1d),
(None, None, _1D.ati_1d),
_1D.set,
_1D.get,
1,
),
Indexers(
(_2D.ats_axis0, None, _2D.ats_axis1),
(_2D.atv_axis0, None, _2D.atv_axis1),
(_2D.ati_axis0, None, _2D.ati_axis1),
_2D.set,
_2D.get,
2,
),
Indexers(
(_3D.ats_axis0, _3D.ats_axis1, _3D.ats_axis2),
(_3D.atv_axis0, _3D.atv_axis1, _3D.atv_axis2),
(None, None, None),
_3D.set,
_3D.get,
3,
Expand Down
7 changes: 7 additions & 0 deletions PyMPDATA/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ def __init__(
DPDC: bool = False, # pylint: disable=invalid-name
epsilon: float = 1e-15,
non_zero_mu_coeff: bool = False,
dynamic_advector: bool = False,
dimensionally_split: bool = False,
dtype: [np.float32, np.float64] = np.float64
):
Expand All @@ -44,6 +45,7 @@ def __init__(
"nonoscillatory": nonoscillatory,
"third_order_terms": third_order_terms,
"non_zero_mu_coeff": non_zero_mu_coeff,
"dynamic_advector": dynamic_advector,
"dimensionally_split": dimensionally_split,
"dtype": dtype,
"DPDC": DPDC,
Expand Down Expand Up @@ -131,6 +133,11 @@ def non_zero_mu_coeff(self) -> bool:
"""flag enabling handling of Fickian diffusion term"""
return self._values["non_zero_mu_coeff"]

@property
def dynamic_advector(self) -> bool:
"""flag enabling (todo desc)"""
return self._values["dynamic_advector"]

@property
def dimensionally_split(self) -> bool:
"""flag disabling cross-dimensional terms in antidiffusive velocities"""
Expand Down
Loading
Loading