Skip to content

Commit

Permalink
Merge branch 'main' into change_defaults_of_nhs
Browse files Browse the repository at this point in the history
  • Loading branch information
svchb authored Dec 17, 2024
2 parents e147e3b + f051b55 commit c825bfc
Show file tree
Hide file tree
Showing 7 changed files with 225 additions and 120 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/SpellCheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ jobs:
- name: Checkout Actions Repository
uses: actions/checkout@v4
- name: Check spelling
uses: crate-ci/typos@v1.26.8
uses: crate-ci/typos@v1.28.1
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ jobs:
- name: Upload coverage report to Codecov
# Only run coverage in one Job (Ubuntu and latest Julia version)
if: matrix.os == 'ubuntu-latest' && matrix.version == '1'
uses: codecov/codecov-action@v4
uses: codecov/codecov-action@v5
with:
files: lcov.info
fail_ci_if_error: true
Expand Down
7 changes: 6 additions & 1 deletion examples/fluid/taylor_green_vortex_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,18 @@ background_pressure = sound_speed^2 * fluid_density
smoothing_length = 1.0 * particle_spacing
smoothing_kernel = SchoenbergQuinticSplineKernel{2}()

# To be set via `trixi_include`
perturb_coordinates = true
fluid = RectangularShape(particle_spacing, (n_particles_xy, n_particles_xy), (0.0, 0.0),
coordinates_perturbation=0.2, # To avoid stagnant streamlines when not using TVF.
# Perturb particle coordinates to avoid stagnant streamlines without TVF
coordinates_perturbation=perturb_coordinates ? 0.2 : nothing, # To avoid stagnant streamlines when not using TVF.
density=fluid_density, pressure=initial_pressure_function,
velocity=initial_velocity_function)

density_calculator = SummationDensity()
fluid_system = EntropicallyDampedSPHSystem(fluid, smoothing_kernel, smoothing_length,
sound_speed,
density_calculator=density_calculator,
transport_velocity=TransportVelocityAdami(background_pressure),
viscosity=ViscosityAdami(; nu))

Expand Down
34 changes: 31 additions & 3 deletions src/visualization/recipes_plots.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ RecipesBase.@recipe function f(sol::TrixiParticlesODESolution)
end

RecipesBase.@recipe function f(v_ode, u_ode, semi::Semidiscretization;
size=(600, 400)) # Default size
size=(600, 400), # Default size
xlims=(-Inf, Inf), ylims=(-Inf, Inf))
systems_data = map(semi.systems) do system
u = wrap_u(u_ode, system, semi)
coordinates = active_coordinates(u, system)
Expand All @@ -25,14 +26,23 @@ RecipesBase.@recipe function f(v_ode, u_ode, semi::Semidiscretization;
x_min, y_min = minimum(coordinates, dims=2) .- 0.5particle_spacing
x_max, y_max = maximum(coordinates, dims=2) .+ 0.5particle_spacing

# `x_min`, `x_max`, etc. are used to automatically set the marker size.
# When `xlims` or `ylims` are passed explicitly, we have to update these to get the correct marker size.
isfinite(first(xlims)) && (x_min = xlims[1])
isfinite(last(xlims)) && (x_max = xlims[2])

isfinite(first(ylims)) && (y_min = ylims[1])
isfinite(last(ylims)) && (y_max = ylims[2])

return (; x, y, x_min, x_max, y_min, y_max, particle_spacing,
label=timer_name(system))
end

return (semi, systems_data...)
end

RecipesBase.@recipe function f((initial_conditions::InitialCondition)...)
RecipesBase.@recipe function f((initial_conditions::InitialCondition)...;
xlims=(Inf, Inf), ylims=(Inf, Inf))
idx = 0
ics = map(initial_conditions) do ic
x = collect(ic.coordinates[1, :])
Expand All @@ -46,6 +56,14 @@ RecipesBase.@recipe function f((initial_conditions::InitialCondition)...)
x_min, y_min = minimum(ic.coordinates, dims=2) .- 0.5particle_spacing
x_max, y_max = maximum(ic.coordinates, dims=2) .+ 0.5particle_spacing

# `x_min`, `x_max`, etc. are used to automatically set the marker size.
# When `xlims` or `ylims` are passed explicitly, we have to update these to get the correct marker size.
isfinite(first(xlims)) && (x_min = xlims[1])
isfinite(last(xlims)) && (x_max = xlims[2])

isfinite(first(ylims)) && (y_min = ylims[1])
isfinite(last(ylims)) && (y_max = ylims[2])

idx += 1

return (; x, y, x_min, x_max, y_min, y_max, particle_spacing,
Expand All @@ -56,12 +74,22 @@ RecipesBase.@recipe function f((initial_conditions::InitialCondition)...)
end

RecipesBase.@recipe function f(::Union{InitialCondition, Semidiscretization},
data...; zcolor=nothing, size=(600, 400), colorbar_title="")
data...; zcolor=nothing, size=(600, 400), colorbar_title="",
xlims=(Inf, Inf), ylims=(Inf, Inf))
x_min = minimum(obj.x_min for obj in data)
x_max = maximum(obj.x_max for obj in data)

y_min = minimum(obj.y_min for obj in data)
y_max = maximum(obj.y_max for obj in data)

# `x_min`, `x_max`, etc. are used to automatically set the marker size.
# When `xlims` or `ylims` are passed explicitly, we have to update these to get the correct marker size.
isfinite(first(xlims)) && (x_min = xlims[1])
isfinite(last(xlims)) && (x_max = xlims[2])

isfinite(first(ylims)) && (y_min = ylims[1])
isfinite(last(ylims)) && (y_max = ylims[2])

# Note that this assumes the plot area to be ~10% smaller than `size`,
# which is the case when showing a single plot with the legend inside.
# With the legend outside, this is no longer the case, so the `markersize` has to be
Expand Down
12 changes: 12 additions & 0 deletions test/callbacks/postprocess.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
@testset verbose=true "PostprocessCallback" begin
@testset verbose=true "errors" begin
error_str1 = "`funcs` cannot be empty"
@test_throws ArgumentError(error_str1) PostprocessCallback(interval=10,
write_file_interval=0)

error_str2 = "setting both `interval` and `dt` is not supported"
@test_throws ArgumentError(error_str2) PostprocessCallback(interval=10,
write_file_interval=0,
dt=0.1,
another_function=(v, u, t, system) -> 1)
end

@testset verbose=true "show" begin
function example_function(v, u, t, system)
return 0
Expand Down
Loading

0 comments on commit c825bfc

Please sign in to comment.