Skip to content

Commit

Permalink
Merge branch 'main' into particle-packing
Browse files Browse the repository at this point in the history
  • Loading branch information
svchb authored Jan 17, 2025
2 parents 70af80c + 7c537a3 commit 9f97047
Show file tree
Hide file tree
Showing 9 changed files with 61 additions and 81 deletions.
50 changes: 24 additions & 26 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,40 +27,35 @@ on:
- 'docs/**'
workflow_dispatch:

# Cancel redundant CI tests automatically
# Skip intermediate builds: always.
# Cancel intermediate builds: only if it is a pull request build.
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
cancel-in-progress: ${{ startsWith(github.ref, 'refs/pull/') }}

jobs:
build:
name: Run Tests (Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }})
runs-on: ubuntu-latest
name: Run Tests (Julia ${{ matrix.version }} - ${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
# Don't cancel all running jobs when one job fails
fail-fast: false
matrix:
version:
- '1.9'
- '1.10'
- '1'
os:
- ubuntu-latest
arch:
- x64
include:
# Also run tests on Windows and macOS-ARM, but only with the latest Julia version and 1.10
- version: '1.10'
os: windows-latest
arch: x64
- version: '1.10'
os: macos-14
arch: arm64
- version: '1'
os: windows-latest
arch: x64
- version: '1'
os: macos-14
arch: arm64
version:
- '1.10'
- '1'
os:
- ubuntu-latest
include:
# Also run tests on Windows and macOS-ARM, but only with the latest Julia release and minimum supported version
- version: 'min'
os: windows-latest
- version: 'min'
os: macos-14
- version: '1'
os: windows-latest
- version: '1'
os: macos-14

steps:
- name: Check out project
Expand All @@ -71,6 +66,9 @@ jobs:
with:
version: ${{ matrix.version }}

- name: Display Julia version
run: julia -e 'using InteractiveUtils; versioninfo(verbose=true)'

- uses: julia-actions/cache@v2

- name: Build package
Expand Down
12 changes: 6 additions & 6 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "TrixiParticles"
uuid = "66699cd8-9c01-4e9d-a059-b96c86d16b3a"
authors = ["erik.faulhaber <[email protected]>"]
version = "0.2.4"
version = "0.2.5-dev"

[deps]
Adapt = "79e6a3ab-5dfb-504d-930d-738a2a938a0e"
Expand Down Expand Up @@ -32,19 +32,19 @@ TrixiBase = "9a0f1c46-06d5-4909-a5a3-ce25d3fa3284"
WriteVTK = "64499a7a-5c06-52f2-abe2-ccb03c286192"

[compat]
Adapt = "3, 4"
Adapt = "4"
CSV = "0.10"
DataFrames = "1.6"
DelimitedFiles = "1"
DiffEqCallbacks = "2, 3, 4"
DiffEqCallbacks = "4"
FastPow = "0.1"
FileIO = "1"
ForwardDiff = "0.10"
GPUArraysCore = "0.1, 0.2"
GPUArraysCore = "0.2"
JSON = "0.21"
KernelAbstractions = "0.9"
MuladdMacro = "0.2"
PointNeighbors = "0.4.2"
PointNeighbors = "0.4.7"
Polyester = "0.7.10"
RecipesBase = "1"
Reexport = "1"
Expand All @@ -54,4 +54,4 @@ StrideArrays = "0.1"
TimerOutputs = "0.5.25"
TrixiBase = "0.1.3"
WriteVTK = "1"
julia = "1.9"
julia = "1.10"
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ TrixiParticles.jl focuses on the following use cases:
- Development of new particle-based methods and models.
- Easy setup of accessible simulations for educational purposes, including student projects, coursework, and thesis work.

It offers intuitive configuration, robust pre- and post-processing, and vendor-agnostic GPU-support based on the Julia package [KernelAbstractions.jl](https://github.com/JuliaGPU/KernelAbstractions.jl).
It offers intuitive configuration, robust pre- and post-processing, and vendor-agnostic GPU-support based on the Julia package [KernelAbstractions.jl](https://github.com/JuliaGPU/KernelAbstractions.jl).

[![YouTube](https://github.com/user-attachments/assets/dc2be627-a799-4bfd-9226-2077f737c4b0)](https://www.youtube.com/watch?v=V7FWl4YumcA&t=4667s)

Expand Down Expand Up @@ -66,7 +66,7 @@ We provide several example simulation setups in the `examples` folder (which can
## Installation
If you have not yet installed Julia, please [follow the instructions for your
operating system](https://julialang.org/downloads/platform/). TrixiParticles.jl works
with Julia v1.9 and newer. We recommend using the latest stable release of Julia.
with Julia v1.10 and newer. We recommend using the latest stable release of Julia.

### For users
TrixiParticles.jl is a registered Julia package.
Expand Down
2 changes: 1 addition & 1 deletion docs/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@ Documenter = "1"
DocumenterCitations = "1"
OrdinaryDiffEq = "6"
Plots = "1"
PointNeighbors = "0.4"
PointNeighbors = "0.4.7"
TrixiBase = "0.1"
2 changes: 1 addition & 1 deletion docs/src/install.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## Setting up Julia
If you have not yet installed Julia, please [follow the instructions on the
official website](https://julialang.org/downloads/). TrixiParticles.jl works
with Julia v1.9 and newer. We recommend using the latest stable release of Julia.
with Julia v1.10 and newer. We recommend using the latest stable release of Julia.

## For users
TrixiParticles.jl is a registered Julia package.
Expand Down
46 changes: 9 additions & 37 deletions src/callbacks/solution_saving.jl
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,7 @@ function SolutionSavingCallback(; interval::Integer=0, dt=0.0,
-1, Ref("UnknownVersion"))

if length(save_times) > 0
# See the large comment below for an explanation why we use `finalize` here.
# When support for Julia 1.9 is dropped, the `finalize` argument can be removed.
return PresetTimeCallback(save_times, solution_callback, finalize=solution_callback)
return PresetTimeCallback(save_times, solution_callback)
elseif dt > 0
# Add a `tstop` every `dt`, and save the final solution
return PeriodicCallback(solution_callback, dt,
Expand Down Expand Up @@ -198,41 +196,22 @@ end
# When `interval` is used, this is
# `DiscreteCallback{<:SolutionSavingCallback,
# <:SolutionSavingCallback,
# typeof(TrixiParticles.initialize_save_cb!),
# typeof(SciMLBase.FINALIZE_DEFAULT)}`.
# typeof(TrixiParticles.initialize_save_cb!)}`.
#
# When `dt` is used, this is
# `DiscreteCallback{DiffEqCallbacks.var"#99#103"{...},
# DiffEqCallbacks.PeriodicCallbackAffect{<:SolutionSavingCallback},
# DiffEqCallbacks.var"#100#104"{...}
# typeof(SciMLBase.FINALIZE_DEFAULT)}`.
# DiffEqCallbacks.var"#100#104"{...}}`.
#
# When `save_times` is used, this is
# `DiscreteCallback{DiffEqCallbacks.var"#115#117"{...},
# <:SolutionSavingCallback,
# DiffEqCallbacks.var"#116#118"{...},
# typeof(SciMLBase.FINALIZE_DEFAULT)}}`.
# DiffEqCallbacks.var"#116#118"{...}}`.
#
# So we can unambiguously dispatch on
# - `DiscreteCallback{<:SolutionSavingCallback, <:SolutionSavingCallback}`,
# - `DiscreteCallback{<:Any, <:PeriodicCallbackAffect{<:SolutionSavingCallback}}`,
# - `DiscreteCallback{<:Any, <:SolutionSavingCallback}`.
#
# WORKAROUND FOR JULIA 1.9:
# When `save_times` is used, the `affect!` is also wrapped in an anonymous function:
# `DiscreteCallback{DiffEqCallbacks.var"#110#113"{...},
# DiffEqCallbacks.var"#111#114"{<:SolutionSavingCallback},
# DiffEqCallbacks.var"#116#118"{...},
# typeof(SciMLBase.FINALIZE_DEFAULT)}}`.
#
# To dispatch here, we set `finalize` to the callback itself, so that the fourth parameter
# becomes `<:SolutionSavingCallback`. This is only used in Julia 1.9. 1.10 and later uses
# a newer version of DiffEqCallbacks.jl that does not have this issue.
#
# To use the callback as `finalize`, we have to define the following function.
# `finalize` is set to `FINALIZE_DEFAULT` by default in the `PresetTimeCallback`,
# which is a function that just returns `nothing`.
# We define the `SolutionSavingCallback` to do the same when called with these arguments.
function (finalize::SolutionSavingCallback)(c, u, t, integrator)
return nothing
end
Expand All @@ -256,17 +235,12 @@ function Base.show(io::IO,
print(io, "SolutionSavingCallback(dt=", solution_saving.interval, ")")
end

# With `save_times`, also working in Julia 1.9.
# When support for Julia 1.9 is dropped, this can be changed to
# `DiscreteCallback{<:Any, <:SolutionSavingCallback}`, and the `finalize` argument
# in the constructor of `SolutionSavingCallback` can be removed.
# With `save_times`
function Base.show(io::IO,
cb::DiscreteCallback{<:Any, <:Any, <:Any, <:SolutionSavingCallback})
cb::DiscreteCallback{<:Any, <:SolutionSavingCallback})
@nospecialize cb # reduce precompilation time

# This has to be changed to `cb.affect!` when support for Julia 1.9 is dropped
# and finalize is removed from the constructor of `SolutionSavingCallback`.
solution_saving = cb.finalize
solution_saving = cb.affect!
print(io, "SolutionSavingCallback(save_times=", solution_saving.save_times, ")")
end

Expand Down Expand Up @@ -323,15 +297,13 @@ end

# With `save_times`. See comments above.
function Base.show(io::IO, ::MIME"text/plain",
cb::DiscreteCallback{<:Any, <:Any, <:Any, <:SolutionSavingCallback})
cb::DiscreteCallback{<:Any, <:SolutionSavingCallback})
@nospecialize cb # reduce precompilation time

if get(io, :compact, false)
show(io, cb)
else
# This has to be changed to `cb.affect!` when support for Julia 1.9 is dropped
# and finalize is removed from the constructor of `SolutionSavingCallback`.
solution_saving = cb.finalize
solution_saving = cb.affect!
cq = collect(solution_saving.custom_quantities)

setup = [
Expand Down
2 changes: 1 addition & 1 deletion test/Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
CSV = "0.10"
CairoMakie = "0.13"
CairoMakie = "0.12"
DataFrames = "1.6"
GLM = "1.9"
Glob = "1.3"
Expand Down
2 changes: 2 additions & 0 deletions test/count_allocations.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ struct NoUpdateNeighborhoodSearch{NHS}
nhs::NHS
end

@inline Base.ndims(nhs::NoUpdateNeighborhoodSearch) = ndims(nhs.nhs)

# Copy a `Semidiscretization`, but wrap the neighborhood searches with
# `NoUpdateNeighborhoodSearch`.
function copy_semi_with_no_update_nhs(semi)
Expand Down
22 changes: 15 additions & 7 deletions test/validation/validation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,18 +47,26 @@
@test sol.retcode == ReturnCode.Success
@test count_rhs_allocations(sol, semi) == 0

if VERSION == v"1.10"
if Sys.ARCH === :aarch64
# MacOS ARM produces slightly different pressure values than x86.
# Note that pressure values are in the order of 1e5.
@test isapprox(error_edac_P1, 0, atol=8e-10)
@test isapprox(error_edac_P2, 0, atol=7e-12)
@test isapprox(error_wcsph_P1, 0, atol=18.0)
@test isapprox(error_wcsph_P2, 0, atol=0.004)
elseif VERSION == v"1.10"
# Reference values are computed with 1.10
@test isapprox(error_edac_P1, 0, atol=eps())
@test isapprox(error_edac_P2, 0, atol=eps())
@test isapprox(error_wcsph_P1, 0, atol=eps())
@test isapprox(error_wcsph_P2, 0, atol=eps())
else
# 1.9 causes a large difference in the solution
# TODO 1.11 requires a performance hotfix which will likely change these results again
@test isapprox(error_edac_P1, 0, atol=4e-9)
@test isapprox(error_edac_P2, 0, atol=3e-11)
@test isapprox(error_wcsph_P1, 0, atol=26.3)
@test isapprox(error_wcsph_P2, 0, atol=8.2e-3)
# 1.11 produces slightly different pressure values than 1.10.
# Note that pressure values are in the order of 1e5.
@test isapprox(error_edac_P1, 0, atol=eps())
@test isapprox(error_edac_P2, 0, atol=eps())
@test isapprox(error_wcsph_P1, 0, atol=0.07)
@test isapprox(error_wcsph_P2, 0, atol=8e-6)
end

# Ignore method redefinitions from duplicate `include("../validation_util.jl")`
Expand Down

0 comments on commit 9f97047

Please sign in to comment.