Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New slicing backend (nearest neighbors interpolation) for use with moving mesh #182

Merged
merged 23 commits into from
Mar 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 5 additions & 1 deletion docs/source/visualisation/slice.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ The :mod:`swiftsimio.visualisation.slice` sub-module provides an interface
to render SWIFT data onto a slice. This takes your 3D data and finds the 3D
density at fixed z-position, slicing through the box.

This effectively solves the equation:
The default :code:`"sph"` backend effectively solves the equation:

:math:`\tilde{A}_i = \sum_j A_j W_{ij, 3D}`

Expand All @@ -14,6 +14,10 @@ with :math:`\tilde{A}_i` the smoothed quantity in pixel :math:`i`, and
Here we use the Wendland-C2 kernel. Note that here we take the kernel
at a fixed z-position.

There is also an alternative :code:`"nearest_neighbours"` backend, which uses
nearest-neighbour interpolation to compute the densities at each pixel.
This backend is more suited for use with moving-mesh hydrodynamics schemes.

The primary function here is
:meth:`swiftsimio.visualisation.slice.slice_gas`, which allows you to
create a gas slice of any field. See the example below.
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[tool.setuptools]
packages = ["swiftsimio", "swiftsimio.initial_conditions", "swiftsimio.metadata", "swiftsimio.metadata.cosmology", "swiftsimio.metadata.metadata", "swiftsimio.metadata.particle", "swiftsimio.metadata.unit", "swiftsimio.metadata.writer", "swiftsimio.visualisation", "swiftsimio.visualisation.projection_backends", "swiftsimio.visualisation.tools"]
packages = ["swiftsimio", "swiftsimio.initial_conditions", "swiftsimio.metadata", "swiftsimio.metadata.cosmology", "swiftsimio.metadata.metadata", "swiftsimio.metadata.particle", "swiftsimio.metadata.unit", "swiftsimio.metadata.writer", "swiftsimio.visualisation", "swiftsimio.visualisation.projection_backends", "swiftsimio.visualisation.slice_backends", "swiftsimio.visualisation.tools"]

[project]
name = "swiftsimio"
Expand Down
6 changes: 6 additions & 0 deletions swiftsimio/objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
expm1,
log1p,
sqrt,
# cbrt, # TODO: Needs upstream (unyt) support first
square,
reciprocal,
sin,
Expand Down Expand Up @@ -220,6 +221,10 @@ def _square_cosmo_factor(ca_cf, **kwargs):
return _power_cosmo_factor(ca_cf, (False, None), power=2)


def _cbrt_cosmo_factor(ca_cf, **kwargs):
return _power_cosmo_factor(ca_cf, (False, None), power=1.0 / 3.0)


def _divide_cosmo_factor(ca_cf1, ca_cf2, **kwargs):
ca1, cf1 = ca_cf1
ca2, cf2 = ca_cf2
Expand Down Expand Up @@ -640,6 +645,7 @@ class cosmo_array(unyt_array):
log1p: _return_without_cosmo_factor,
sqrt: _sqrt_cosmo_factor,
square: _square_cosmo_factor,
# cbrt: _cbrt_cosmo_factor, # TODO: Needs upstream (unyt) support first
reciprocal: _reciprocal_cosmo_factor,
sin: _return_without_cosmo_factor,
cos: _return_without_cosmo_factor,
Expand Down
2 changes: 1 addition & 1 deletion swiftsimio/visualisation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
from .projection import scatter, project_gas, project_gas_pixel_grid
from .slice import slice_scatter as slice
from .slice import slice_gas, slice_gas_pixel_grid
from .smoothing_length_generation import generate_smoothing_lengths
from .smoothing_length import generate_smoothing_lengths
Loading
Loading