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

Add interpolation functions #304

Merged
merged 75 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
e541ce8
add interpolation
svchb Nov 29, 2023
d09e779
basic working
svchb Nov 30, 2023
fd3c98b
support periodic
svchb Nov 30, 2023
118585b
allow to define different smoothing_length
svchb Nov 30, 2023
a4e306d
more precisely identify system regions
svchb Nov 30, 2023
d0d4e85
to improve accuracy calc shepard
svchb Dec 1, 2023
7f11ce6
add support for multiple points
svchb Dec 1, 2023
2d7334c
add line interpolation
svchb Dec 1, 2023
0a5a580
add doc
svchb Dec 1, 2023
2c10d6c
format
svchb Dec 1, 2023
69e8ddf
add test
svchb Dec 1, 2023
567e1fb
Merge branch 'main' into add_interpolation
svchb Dec 1, 2023
27065cc
small change to doc
svchb Dec 1, 2023
238671e
revert accidental change
svchb Dec 1, 2023
1512816
fix
svchb Dec 1, 2023
959e36e
another fix
svchb Dec 1, 2023
a0c9694
format
svchb Dec 1, 2023
b0a22e4
format
svchb Dec 1, 2023
9f3b68b
also interpolate pressure and velocity
svchb Dec 1, 2023
c83061e
lower tolerance
svchb Dec 1, 2023
f9b8bef
add example plot
svchb Dec 1, 2023
54ffa68
missing dependency
svchb Dec 1, 2023
9d2b15e
format
svchb Dec 1, 2023
b034713
comment out example
svchb Dec 1, 2023
1bf954b
remove pyplot again
svchb Dec 1, 2023
897add2
fix
svchb Dec 1, 2023
98cabcb
small update improving accuracy
svchb Dec 12, 2023
a49d45e
Merge branch 'main' into add_interpolation
svchb Dec 12, 2023
99938dc
fix tests
svchb Dec 12, 2023
69c8ece
Merge branch 'add_interpolation' of github.com:svchb/TrixiParticles.j…
svchb Dec 12, 2023
c5a9cb0
remove line
svchb Dec 12, 2023
ee8fbf3
fix
svchb Dec 13, 2023
e01cb04
format
svchb Dec 13, 2023
7f067a2
fix
svchb Dec 13, 2023
596dc21
merge
svchb Dec 13, 2023
2af76d4
Merge branch 'main' into add_interpolation
svchb Dec 13, 2023
f16ca92
Merge branch 'main' into add_interpolation
svchb Jan 4, 2024
8a47ef4
optimization
svchb Jan 4, 2024
3361096
fix result format
svchb Jan 4, 2024
095032d
Merge branch 'main' into add_interpolation
svchb Jan 4, 2024
fd222a9
update test
svchb Jan 4, 2024
ef2c7c2
fix
svchb Jan 5, 2024
c7be103
fix docs
svchb Jan 5, 2024
ab25212
rename to copy_neighborhood_search
svchb Jan 5, 2024
eb0c70c
review fixes
svchb Jan 5, 2024
11d1361
Merge branch 'main' into add_interpolation
svchb Jan 5, 2024
73473a7
format
svchb Jan 5, 2024
d358cb1
Merge branch 'main' into add_interpolation
svchb Jan 5, 2024
cc912b0
bs
svchb Jan 6, 2024
b46a1e1
tests
svchb Jan 9, 2024
715c703
more tests
svchb Jan 9, 2024
7e6d92b
fix all tests
svchb Jan 9, 2024
b8f9294
Merge branch 'main' into add_interpolation
svchb Jan 9, 2024
e029e3d
fix
svchb Jan 9, 2024
2182166
Merge branch 'add_interpolation' of github.com:svchb/TrixiParticles.j…
svchb Jan 9, 2024
e830efc
fix tests
svchb Jan 9, 2024
6dc6d5c
increase error since it passes locally but not on github
svchb Jan 9, 2024
fdefb39
fix
svchb Jan 10, 2024
3de97d5
fix
svchb Jan 10, 2024
ab4c2d2
review comments
svchb Jan 11, 2024
30ccff4
Merge branch 'main' into add_interpolation
svchb Jan 11, 2024
97f8b61
fix docs
svchb Jan 11, 2024
ca434c1
format
svchb Jan 11, 2024
61ea44f
add interpolation.jl to doc gen
svchb Jan 11, 2024
5ed40ce
review
svchb Jan 11, 2024
407f166
update
svchb Jan 11, 2024
d197fb7
add Plots version
svchb Jan 11, 2024
611c123
improve plot
svchb Jan 12, 2024
548d9fc
remove other dispatch
svchb Jan 12, 2024
5dd4ca8
fix
svchb Jan 12, 2024
f48effe
fix docs
svchb Jan 15, 2024
1994220
Merge branch 'main' into add_interpolation
svchb Jan 15, 2024
393e9e1
merge
svchb Jan 15, 2024
cf4aef3
remove background pressure
svchb Jan 16, 2024
274a31c
fix comment
svchb Jan 16, 2024
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
4 changes: 2 additions & 2 deletions examples/postprocessing/interpolation.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Example for using interpolation
#######################################################################################
using TrixiParticles
using Plots

trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid", "rectangular_tank_2d.jl"))

Expand Down Expand Up @@ -34,6 +35,7 @@ result_endpoint = interpolate_line([1.0, -0.05], [1.0, 1.0], 10, semi, fluid_sys
walldistance = [coord[2] for coord in result.coord]
walldistance_endpoint = [coord[2] for coord in result_endpoint.coord]

# Alternatively, to using Plots.jl one can also use PythonPlot which uses matplotlib
svchb marked this conversation as resolved.
Show resolved Hide resolved
# using PythonPlot

# figure()
Expand All @@ -48,8 +50,6 @@ walldistance_endpoint = [coord[2] for coord in result_endpoint.coord]

# plotshow()

using Plots

p = plot(walldistance, result.density, marker=:circle, color=:blue, markerstrokecolor=:blue,
linewidth=2, label="With Endpoint")

Expand Down
4 changes: 2 additions & 2 deletions src/general/interpolation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ but does not include these points.
- This function is particularly useful for analyzing gradients or creating visualizations
along a specified line in the SPH simulation domain.
- The interpolation accuracy is subject to the density of particles and the chosen smoothing length.
- With `cut_off_bnd` is used a density-based estimation of the surface is used which is not as
- With `cut_off_bnd`, a density-based estimation of the surface is used which is not as
accurate as a real surface reconstruction.

# Examples
Expand Down Expand Up @@ -96,7 +96,7 @@ results = interpolate_point(points, semi, ref_system, sol)
- This function is particularly useful for analyzing gradients or creating visualizations
along a specified line in the SPH simulation domain.
- The interpolation accuracy is subject to the density of particles and the chosen smoothing length.
- With `cut_off_bnd` is used a density-based estimation of the surface is used which is not as
- With `cut_off_bnd`, a density-based estimation of the surface is used which is not as
accurate as a real surface reconstruction.
"""
function interpolate_point(points_coords::AbstractArray{<:AbstractArray}, semi, ref_system,
Expand Down
9 changes: 5 additions & 4 deletions test/general/interpolation.jl
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include("../test_util.jl")
@testset verbose=true "SPH Interpolation" begin
function compare_interpolation_result(actual, expected; tolerance=1e-8)
@test length(actual.density) == length(expected.density)
Expand Down Expand Up @@ -79,8 +80,8 @@
smoothing_kernel = SchoenbergCubicSplineKernel{2}()
sound_speed = 10 * sqrt(9.81 * 0.9)

state_equation = StateEquationCole(sound_speed, 7, 1000, 100000.0,
background_pressure=100000.0,
state_equation = StateEquationCole(; sound_speed, reference_density=1000.0,
exponent=7, background_pressure=100000.0,
svchb marked this conversation as resolved.
Show resolved Hide resolved
clip_negative_pressure=false)

fluid = rectangular_patch(particle_spacing, (nx, ny), seed=1,
Expand Down Expand Up @@ -581,8 +582,8 @@
smoothing_kernel = SchoenbergCubicSplineKernel{3}()
sound_speed = 10 * sqrt(9.81 * 0.9)

state_equation = StateEquationCole(sound_speed, 7, 1000, 100000.0,
background_pressure=100000.0,
state_equation = StateEquationCole(; sound_speed, reference_density=1000.0,
exponent=7, background_pressure=100000.0,
svchb marked this conversation as resolved.
Show resolved Hide resolved
clip_negative_pressure=false)

fluid = rectangular_patch(particle_spacing, (nx, ny, nz), seed=1,
Expand Down