-
Notifications
You must be signed in to change notification settings - Fork 12
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
Plane interpolation #306
Merged
Merged
Plane interpolation #306
Changes from all commits
Commits
Show all changes
67 commits
Select commit
Hold shift + click to select a range
e541ce8
add interpolation
svchb d09e779
basic working
svchb fd3c98b
support periodic
svchb 118585b
allow to define different smoothing_length
svchb a4e306d
more precisely identify system regions
svchb d0d4e85
to improve accuracy calc shepard
svchb 7f11ce6
add support for multiple points
svchb 2d7334c
add line interpolation
svchb 0a5a580
add doc
svchb 2c10d6c
format
svchb 69e8ddf
add test
svchb 567e1fb
Merge branch 'main' into add_interpolation
svchb 27065cc
small change to doc
svchb 238671e
revert accidental change
svchb 1512816
fix
svchb 959e36e
another fix
svchb a0c9694
format
svchb b0a22e4
format
svchb 9f3b68b
also interpolate pressure and velocity
svchb c83061e
lower tolerance
svchb f9b8bef
add example plot
svchb 54ffa68
missing dependency
svchb 9d2b15e
format
svchb 51567d6
add func
svchb a7786fd
add doc
svchb 4278910
add test
svchb fcfb065
add another test
svchb 9106912
comment out example
svchb 363bfcb
remove pyplot again
svchb 5a89022
fix
svchb 589f7b3
format
svchb 3351d74
small update improve accuracy
svchb a995d03
Merge branch 'main' into plane_interpolation
svchb 6044f55
Merge branch 'plane_interpolation' of github.com:svchb/TrixiParticles…
svchb cd8ddc5
update
svchb f6b3829
up
svchb 7a5c42e
fix
svchb c6165f0
format
svchb 9226364
Merge branch 'main' into plane_interpolation
svchb 6136f7d
fix plots
svchb 8cddffa
fix plots.jl plot
svchb f4c2204
cleanup
svchb fb16b70
fix tests
svchb 1b450dd
cleanup
svchb babdde0
cleanup
svchb 3025102
fix docs
svchb bb57d18
fix doc
svchb a865c41
remove unused func
svchb 073558c
remove unused code
svchb 6b9bb14
fix
svchb 497bcd4
fix viscosity
svchb 9486a04
working 3d example for plane interpolation
svchb 586f639
add 2d plot as well for 3d case
svchb 8659c44
add docs
svchb e2f991d
fix tests
svchb cf5558f
fix
svchb e62453c
fix plot
svchb 699beaa
fix comments
svchb 3e7ad09
fix comment
svchb 971be6f
update
svchb db52b69
format
svchb e47ae70
add Plots
svchb 86837d1
fix
svchb 12ff4ef
adjust plot
svchb 010ddb9
reduce time
svchb 626712c
Update interpolation.jl
svchb 78d20e3
Update interpolation_plane.jl
svchb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
using TrixiParticles | ||
|
||
trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid", "rectangular_tank_2d.jl"), | ||
fluid_particle_spacing=0.05, initial_fluid_size=(1.0, 1.0, 0.9), | ||
tank_size=(1.0, 1.0, 1.2), acceleration=(0.0, 0.0, -9.81), | ||
smoothing_kernel=SchoenbergCubicSplineKernel{3}(), tspan=(0.0, 1.0), | ||
maxiters=10^5, fluid_density_calculator=ContinuityDensity(), | ||
clip_negative_pressure=false) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# Example for using interpolation | ||
svchb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
####################################################################################### | ||
using TrixiParticles | ||
using Plots | ||
using Plots.PlotMeasures | ||
|
||
trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid", "rectangular_tank_2d.jl"), | ||
tspan=(0.0, 0.1)) | ||
|
||
# Interpolation parameters | ||
interpolation_start = [0.0, 0.0] | ||
interpolation_end = [1.0, 1.0] | ||
resolution = 0.005 | ||
|
||
# We can interpolate a plane by providing the lower left and top right coordinates of a plane. | ||
# Per default the same `smoothing_length` will be used as during the simulation. | ||
original_plane = interpolate_plane_2d(interpolation_start, interpolation_end, resolution, | ||
semi, fluid_system, sol) | ||
original_x = [point[1] for point in original_plane.coord] | ||
original_y = [point[2] for point in original_plane.coord] | ||
original_density = original_plane.density | ||
|
||
# Plane with double smoothing length | ||
# Utilizing a higher `smoothing_length` in SPH interpolation increases the amount of smoothing, | ||
# thereby reducing the visibility of disturbances. It also increases the distance | ||
# from free surfaces where the fluid is cut off. This adjustment in `smoothing_length` | ||
# can affect both the accuracy and smoothness of the interpolated results. | ||
double_smoothing_plane = interpolate_plane_2d(interpolation_start, interpolation_end, | ||
resolution, semi, fluid_system, sol, | ||
smoothing_length=2.0 * smoothing_length) | ||
double_x = [point[1] for point in double_smoothing_plane.coord] | ||
double_y = [point[2] for point in double_smoothing_plane.coord] | ||
double_density = double_smoothing_plane.density | ||
|
||
# Plane with half smoothing length | ||
svchb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
# Employing a lower `smoothing_length` in SPH interpolation reduces the amount of smoothing, | ||
# consequently increasing the visibility of disturbances. Simultaneously, it allows for a more | ||
# precise cutoff of the fluid at free surfaces. This change in `smoothing_length` can impact the | ||
# balance between the detail of disturbances captured and the precision of fluid representation near surfaces. | ||
half_smoothing_plane = interpolate_plane_2d(interpolation_start, interpolation_end, | ||
resolution, | ||
semi, fluid_system, sol, | ||
smoothing_length=0.5 * smoothing_length) | ||
half_x = [point[1] for point in half_smoothing_plane.coord] | ||
half_y = [point[2] for point in half_smoothing_plane.coord] | ||
half_density = half_smoothing_plane.density | ||
|
||
scatter1 = scatter(original_x, original_y, zcolor=original_density, marker=:circle, | ||
markersize=2, markercolor=:viridis, markerstrokewidth=0) | ||
scatter2 = scatter(double_x, double_y, zcolor=double_density, marker=:circle, markersize=2, | ||
markercolor=:viridis, markerstrokewidth=0) | ||
scatter3 = scatter(half_x, half_y, zcolor=half_density, marker=:circle, markersize=2, | ||
markercolor=:viridis, markerstrokewidth=0) | ||
|
||
plot1 = plot(scatter1, xlabel="X Coordinate", ylabel="Y Coordinate", | ||
title="Density Distribution", colorbar_title="Density", ylim=(0.0, 1.0), | ||
svchb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
legend=false, clim=(1000, 1010), colorbar=true) | ||
plot2 = plot(scatter2, xlabel="X Coordinate", ylabel="Y Coordinate", | ||
title="Density with 2x Smoothing Length", colorbar_title="Density", | ||
ylim=(0.0, 1.0), legend=false, clim=(1000, 1010), colorbar=true) | ||
plot3 = plot(scatter3, xlabel="X Coordinate", ylabel="Y Coordinate", | ||
title="Density with 0.5x Smoothing Length", colorbar_title="Density", | ||
ylim=(0.0, 1.0), legend=false, clim=(1000, 1010), colorbar=true) | ||
|
||
trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid", "rectangular_tank_3d.jl"), | ||
tspan=(0.0, 0.01), initial_fluid_size=(2.0, 1.0, 0.9), | ||
tank_size=(2.0, 1.0, 1.2)) | ||
|
||
# Interpolation parameters | ||
p1 = [0.0, 0.0, 0.0] | ||
p2 = [1.0, 1.0, 0.1] | ||
p3 = [1.0, 0.5, 0.2] | ||
resolution = 0.025 | ||
|
||
# We can also interpolate a 3D plane but in this case we have to provide 3 points instead! | ||
original_plane = interpolate_plane_3d(p1, p2, p3, resolution, semi, | ||
fluid_system, sol) | ||
original_x = [point[1] for point in original_plane.coord] | ||
original_y = [point[2] for point in original_plane.coord] | ||
original_z = [point[3] for point in original_plane.coord] | ||
original_density = original_plane.density | ||
|
||
scatter_3d = scatter3d(original_x, original_y, original_z, marker_z=original_density, | ||
color=:viridis, markerstrokewidth=0) | ||
|
||
plot_3d = plot(scatter_3d, xlabel="X", ylabel="Y", zlabel="Z", | ||
svchb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
title="3D Scatter Plot with Density Coloring", legend=false, | ||
clim=(1000, 1010), colorbar=false) | ||
|
||
combined_plot = plot(plot1, plot2, plot3, plot_3d, layout=(2, 2), | ||
size=(1000, 1500), margin=3mm) |
1 change: 1 addition & 0 deletions
1
examples/postprocessing/interpolation.jl → ...ostprocessing/interpolation_point_line.jl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why use no-slip boundaries? This should be our simplest example file. No moving fluid, no density diffusion, free-slip boundaries.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not covered currently since no-slip is only used with EDAC at the moment. In my tutorial writing I have added a variation of this testcase which is even simpler and is called minimal.jl.