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

Generalize surface normal calc #539

Open
wants to merge 250 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
250 commits
Select commit Hold shift + click to select a range
f90f017
Merge remote-tracking branch 'origin/main' into main
svchb Sep 5, 2023
372d67c
Merge branch 'trixi-framework:main' into main
svchb Sep 7, 2023
f564478
Merge branch 'main' of github.com:svchb/TrixiParticles.jl
svchb Sep 20, 2023
9c9e182
Merge branch 'trixi-framework:main' into main
svchb Sep 25, 2023
90897f6
Merge branch 'main' of github.com:svchb/TrixiParticles.jl
svchb Sep 29, 2023
1df6912
Merge branch 'main' of github.com:svchb/TrixiParticles.jl
svchb Oct 5, 2023
6449b5f
Merge branch 'main' of github.com:svchb/TrixiParticles.jl
svchb Oct 10, 2023
439210f
merge by hand
svchb Oct 11, 2023
b31640f
Merge branch 'HEAD' into ipf_surface_tension
svchb Jan 25, 2024
675c030
Merge branch 'HEAD' into ipf_surface_tension
svchb Jan 25, 2024
2b0b09c
Merge branch 'HEAD' into ipf_surface_tension
svchb Jan 25, 2024
b812869
Merge branch 'HEAD' into ipf_surface_tension
svchb Jan 25, 2024
c3884d7
Merge branch 'HEAD' into ipf_surface_tension
svchb Jan 25, 2024
45938eb
Merge branch 'HEAD' into ipf_surface_tension
svchb Jan 25, 2024
3bdfc20
Merge tag 'HEAD' into ipf_surface_tension
svchb Jan 25, 2024
de4f0e8
Merge branch 'conflict1'
svchb Jan 25, 2024
c49dd87
fix merge problems
svchb Jan 25, 2024
780cee3
fix merge
svchb Jan 25, 2024
7550c3d
fix merge
svchb Jan 25, 2024
87c21b9
fix merge
svchb Jan 25, 2024
9cab05f
fix merge
svchb Jan 25, 2024
896faef
fix merge
svchb Jan 25, 2024
b567c55
more merge fixes
svchb Jan 25, 2024
3de9a75
format
svchb Jan 25, 2024
06a1223
fix
svchb Jan 25, 2024
31d4404
fix
svchb Jan 25, 2024
a95a54a
fix
svchb Jan 25, 2024
ce74643
fix
svchb Jan 25, 2024
17da7ef
fix
svchb Jan 25, 2024
f002d2b
more fixes
svchb Jan 25, 2024
120eb80
fix
svchb Jan 25, 2024
31208ad
fix
svchb Jan 25, 2024
81591ad
fix
svchb Jan 25, 2024
066f967
more fixes
svchb Jan 25, 2024
df6e1ac
fix
svchb Jan 25, 2024
b58fbca
Merge branch 'main'
svchb Jan 25, 2024
df44891
fix
svchb Jan 25, 2024
bd8cd98
Merge branch 'main' into ipf_surface_tension
svchb Mar 21, 2024
23d72d8
format
svchb Mar 21, 2024
82d6b71
running
svchb Mar 21, 2024
3338a3f
update
svchb Mar 21, 2024
eae775c
update
svchb Mar 21, 2024
53e6afd
optimization
svchb Mar 22, 2024
75983ac
update
svchb Mar 22, 2024
3aec5c6
update
svchb Mar 22, 2024
651790c
update
svchb Mar 25, 2024
f721ac2
update
svchb Mar 25, 2024
e4b9a75
format
svchb Mar 25, 2024
66f2a03
up
svchb Mar 26, 2024
d4893fb
update
svchb Mar 27, 2024
e95151d
remove unused code
svchb Apr 2, 2024
8c8a3cc
Merge branch 'ipf_surface_tension' of github.com:svchb/TrixiParticles…
svchb Apr 2, 2024
4bd3c22
switch to support radius
svchb Apr 2, 2024
79fac64
update
svchb Apr 2, 2024
af7c748
fix doc
svchb Apr 2, 2024
ccde44a
add adhesion coefficient
svchb Apr 2, 2024
dd53390
update_broken
svchb Apr 3, 2024
7e504a9
update
svchb Apr 3, 2024
2d230bf
format
svchb Apr 4, 2024
d0d6408
add to examples
svchb Apr 4, 2024
6ddd51c
fix tests
svchb Apr 4, 2024
dbfc4db
Merge branch 'main' into ipf_surface_tension
svchb Apr 4, 2024
35a3e3e
fix merge
svchb Apr 4, 2024
43b45f4
fix typos
svchb Apr 4, 2024
a5e3ab1
add basic test
svchb Apr 4, 2024
4e2059d
format
svchb Apr 4, 2024
08c662e
rename
svchb Apr 4, 2024
a9a5b98
format
svchb Apr 4, 2024
6060b04
rename container system
svchb Apr 4, 2024
fb762b9
reduce example run time
svchb Apr 5, 2024
9685cdb
update news and readme
svchb Apr 5, 2024
a6892f4
format
svchb Apr 5, 2024
f598b98
fix test
svchb Apr 5, 2024
d2303ec
reduce run time
svchb Apr 5, 2024
bb68e90
format
svchb Apr 5, 2024
1fbc7cb
Merge branch 'main' into ipf_surface_tension
svchb Apr 19, 2024
5a59211
fix
svchb Apr 19, 2024
451e1e6
correct merge
svchb Apr 19, 2024
755e768
update doc test
svchb Apr 19, 2024
aaf3bd9
revert
svchb Apr 19, 2024
f50d436
Merge branch 'main'
svchb May 3, 2024
493c6ea
Merge branch 'main'
svchb May 3, 2024
c0c1227
fix tests
svchb May 3, 2024
8031c01
fix
svchb May 3, 2024
f9dfe29
Merge branch 'main' into ipf_surface_tension
svchb May 7, 2024
14c7999
fix
svchb May 7, 2024
a00f254
review comments
svchb May 7, 2024
367f2fa
fix
svchb May 7, 2024
e9be23a
fix
svchb May 7, 2024
4626383
correct some stuff
svchb May 7, 2024
03618b9
init with empty initial condition
svchb May 7, 2024
6a5f5ad
Merge branch 'main' into ipf_surface_tension
svchb May 10, 2024
ab72434
review update
svchb May 13, 2024
a4e3d92
rename function
svchb May 13, 2024
fc6432f
Merge branch 'ipf_surface_tension' of https://github.com/svchb/TrixiP…
svchb May 13, 2024
f5c59dd
remove unnecessary if
svchb May 13, 2024
702e833
docs
svchb May 13, 2024
89af7de
fix doc
svchb May 13, 2024
3e0ca33
revert one change
svchb May 13, 2024
050e42d
fix typo
svchb May 13, 2024
67630d6
update
svchb May 13, 2024
2f25b28
try to avoid allocs
svchb May 14, 2024
d0c5d2d
fix mem allocs
svchb May 15, 2024
069be49
review update
svchb May 16, 2024
4ba6e9c
update docs
svchb May 16, 2024
15a3446
update
svchb May 16, 2024
56678f4
Merge branch 'main' into ipf_surface_tension
svchb May 16, 2024
b8c4d89
Merge remote-tracking branch 'upstream/main'
svchb May 16, 2024
0409873
Merge branch 'main' into ipf_surface_tension
svchb May 17, 2024
ed1fca0
review
svchb May 22, 2024
414adcf
Merge branch 'main' into ipf_surface_tension
svchb May 23, 2024
cde0fa5
fix
svchb May 24, 2024
7d778a7
format
svchb May 24, 2024
fd523fc
Merge remote-tracking branch 'upstream/main'
svchb May 27, 2024
cc992b6
Merge branch 'ipf_surface_tension' of https://github.com/svchb/TrixiP…
svchb May 27, 2024
707c4ab
make examples smaller
svchb May 27, 2024
70ff163
reduce resolution
svchb May 27, 2024
4d1062f
review
svchb May 27, 2024
5a26313
rename
svchb May 27, 2024
760eddb
use trixi_include
svchb May 27, 2024
5c40040
format
svchb May 27, 2024
624d66f
use trixi_include
svchb May 27, 2024
1692242
update
svchb May 27, 2024
3c0f684
update
svchb May 27, 2024
c8cd876
review update
svchb May 27, 2024
a197fbe
Merge branch 'main' into ipf_surface_tension
svchb May 27, 2024
78e99e1
format
svchb May 27, 2024
dfbcf2b
Merge branch 'ipf_surface_tension' of https://github.com/svchb/TrixiP…
svchb May 27, 2024
51c2ec0
fix test errors
svchb May 27, 2024
8f78cd4
update
svchb May 27, 2024
a795fbc
fix
svchb May 28, 2024
b6a62d7
remove invalid surface normals
svchb May 28, 2024
63535a6
add
svchb May 28, 2024
7a2d704
Merge branch 'main' of github.com:svchb/TrixiParticles.jlOpen
svchb May 29, 2024
63537a6
Merge branch 'main'
svchb May 29, 2024
7bbb3a5
fix
svchb May 30, 2024
ff84aea
update
svchb May 30, 2024
7aa1e84
update
svchb Jun 18, 2024
06976eb
Merge branch 'main' into generalize_surface_normal_calc
svchb Jul 16, 2024
341886d
update
svchb Jul 16, 2024
61e3325
fix
svchb Jul 16, 2024
c53246d
update
svchb Jul 17, 2024
6bc5567
update
svchb Jul 18, 2024
c017b45
update
svchb Jul 22, 2024
6de5f70
remove unused
svchb Jul 22, 2024
3a083a6
remove unused
svchb Jul 22, 2024
f759fb3
format
svchb Jul 22, 2024
1c5d0aa
Merge branch 'main' into generalize_surface_normal_calc
svchb Jul 22, 2024
54dc3ed
fix tests
svchb Jul 22, 2024
0326b98
fix
svchb Jul 22, 2024
dbb9d75
Merge branch 'main' into generalize_surface_normal_calc
svchb Jul 26, 2024
643dfa8
fix
svchb Jul 26, 2024
50dc742
fix naming
svchb Jul 26, 2024
7a77c11
format
svchb Jul 26, 2024
1969525
fix test
svchb Jul 29, 2024
ed83ea1
set test up for 1.11
svchb Aug 8, 2024
5142d13
Merge branch 'main' into generalize_surface_normal_calc
svchb Aug 8, 2024
493e26b
Merge branch 'main' into prepare_for_1.11
svchb Aug 12, 2024
1c1cd58
Merge branch 'main' into generalize_surface_normal_calc
svchb Aug 12, 2024
612fd43
fix test
svchb Aug 13, 2024
35b7c4a
rename to number_density
svchb Aug 14, 2024
3733c21
back merge
svchb Aug 14, 2024
e1fc1bb
fix
svchb Aug 15, 2024
04595af
format
svchb Aug 15, 2024
7b91e09
fix
svchb Aug 15, 2024
0acdcc5
fix tests
svchb Aug 15, 2024
d14fd19
Merge branch 'main' into generalize_surface_normal_calc
svchb Sep 25, 2024
bb12fb8
back merge from #584
svchb Sep 27, 2024
f84cafa
move additonal changes from #584
svchb Sep 27, 2024
7cbfd72
add test
svchb Sep 27, 2024
528c2fd
add test
svchb Sep 30, 2024
a4381aa
format
svchb Sep 30, 2024
eab774a
Merge branch 'main' into generalize_surface_normal_calc
svchb Sep 30, 2024
31b2f75
Merge branch 'main' into prepare_for_1.11
svchb Oct 9, 2024
1d05304
Merge branch 'main' into prepare_for_1.11
svchb Oct 9, 2024
4ed0b91
Increase errors for 1.11
svchb Oct 9, 2024
1ce0460
Fix invalidations
svchb Oct 9, 2024
1774f5a
Fix tests
svchb Oct 9, 2024
4daf984
Update ci.yml
svchb Oct 9, 2024
ac2eb2c
revert
svchb Oct 9, 2024
258f2ba
Update ci.yml
svchb Oct 9, 2024
1a9f3f5
Update test/validation/validation.jl
svchb Oct 10, 2024
8946b45
Merge branch 'main' into generalize_surface_normal_calc
svchb Oct 10, 2024
ddfab3e
Merge remote-tracking branch 'origin/prepare_for_1.11' into generaliz…
svchb Oct 10, 2024
76e5354
Merge branch 'main' into generalize_surface_normal_calc
svchb Oct 11, 2024
e079dc0
Merge remote-tracking branch 'refs/remotes/origin/main'
svchb Nov 13, 2024
b4c5ace
format
svchb Nov 13, 2024
0b3043c
Update news and set to 0.2.4
svchb Nov 13, 2024
3335386
update
svchb Nov 13, 2024
7d4016c
fix MD format
svchb Nov 13, 2024
c47850b
Update NEWS.md
svchb Nov 14, 2024
d5e7c63
Merge branch 'main' into generalize_surface_normal_calc
svchb Nov 17, 2024
514ffcf
Merge branch 'main' into generalize_surface_normal_calc
svchb Nov 18, 2024
223bcd0
Merge branch 'main' into generalize_surface_normal_calc
svchb Nov 18, 2024
d9227bb
some fixes
svchb Nov 19, 2024
3c5fd08
add docs
svchb Nov 19, 2024
969dedd
review fixes
svchb Nov 19, 2024
c6371eb
remove independent setting of smoothing_kernel and smoothing_length
svchb Nov 19, 2024
4bf25e6
remove calls to surface_normal method smoothing kernel
svchb Nov 19, 2024
ebf6602
format
svchb Nov 19, 2024
8659850
Merge branch 'main' into generalize_surface_normal_calc
svchb Nov 19, 2024
5b0ed25
Merge branch 'generalize_surface_normal_calc' of https://github.com/s…
svchb Nov 19, 2024
7a6331e
update news
svchb Nov 19, 2024
3c80adf
typo
svchb Nov 19, 2024
d09b163
Update NEWS.md
svchb Nov 19, 2024
593c746
forgot some renames
svchb Nov 19, 2024
ba69a80
fix doc tests
svchb Nov 19, 2024
67d5b87
fix docs
svchb Nov 19, 2024
f276a7b
fix tests
svchb Nov 19, 2024
b17a629
format
svchb Nov 19, 2024
537df19
Merge branch 'main' into generalize_surface_normal_calc
svchb Nov 20, 2024
20b77d7
Update NEWS.md
svchb Nov 20, 2024
d7b6af1
fix tests
svchb Nov 20, 2024
01bddb0
Merge branch 'generalize_surface_normal_calc' of https://github.com/s…
svchb Nov 20, 2024
dc6fa70
Update NEWS.md
svchb Nov 20, 2024
ffc83d3
Merge branch 'main'
svchb Nov 20, 2024
e424cfa
Merge branch 'main' into generalize_surface_normal_calc
svchb Nov 20, 2024
041861e
fix
svchb Nov 20, 2024
21f08b2
fix
svchb Nov 21, 2024
0b63bca
fix
svchb Nov 21, 2024
b7f448c
fix
svchb Nov 21, 2024
f4fbbb3
Merge branch 'main' into generalize_surface_normal_calc
svchb Dec 2, 2024
589d416
review fixes
svchb Dec 2, 2024
1263e1a
Merge branch 'generalize_surface_normal_calc' of https://github.com/s…
svchb Dec 2, 2024
dd56f47
review comments
svchb Dec 4, 2024
306f96d
Merge branch 'generalize_surface_normal_calc' of https://github.com/s…
svchb Dec 4, 2024
93630aa
fix test
svchb Dec 4, 2024
9f758be
typo
svchb Dec 4, 2024
cd26885
Merge branch 'main' into generalize_surface_normal_calc
svchb Dec 12, 2024
80e51ba
review updates
svchb Dec 12, 2024
4721aec
review update
svchb Dec 12, 2024
98a5f6c
add boundary system
svchb Dec 13, 2024
e05edea
update
svchb Dec 13, 2024
36741d7
update
svchb Dec 13, 2024
ba8765f
format
svchb Dec 13, 2024
e174b1c
Merge branch 'main' into generalize_surface_normal_calc
svchb Jan 17, 2025
fa6274d
Merge branch 'main' into generalize_surface_normal_calc
svchb Jan 20, 2025
8a413d6
remove color since it is unused in this PR
svchb Jan 21, 2025
c737197
review comment
svchb Jan 21, 2025
5f3c7ed
format
svchb Jan 21, 2025
dafb7df
merge error
svchb Jan 21, 2025
1ce2af5
review comment
svchb Jan 21, 2025
73cfc8f
fix
svchb Jan 21, 2025
4b5a1ab
remove surface_normal_method()
svchb Jan 21, 2025
a7764d2
merge error
svchb Jan 21, 2025
ca0de6a
function was renamed in PN
svchb Jan 21, 2025
32f12de
format
svchb Jan 21, 2025
d64343a
fix test
svchb Jan 21, 2025
f7f8620
fix error
svchb Jan 22, 2025
e783541
fix
svchb Jan 22, 2025
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
20 changes: 19 additions & 1 deletion docs/src/systems/fluid.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# [Fluid Models](@id fluid_models)
In the following are common models for fluid effects that are used by both EDAC and WCSPH.
Currently available fluid methods are the [weakly compressible SPH method](@ref wcsph) and the [entropically damped artificial compressibility for SPH](@ref edac).
This page lists models and techniques that apply to both of these methods.

## [Viscosity](@id viscosity_wcsph)

TODO: Explain viscosity.

```@autodocs
Modules = [TrixiParticles]
Pages = [joinpath("schemes", "fluid", "viscosity.jl")]
```

## [Corrections](@id corrections)

```@autodocs
Modules = [TrixiParticles]
Pages = [joinpath("general", "corrections.jl")]
```



## [Surface Normals](@id surface_normal)
Expand Down
17 changes: 0 additions & 17 deletions docs/src/systems/weakly_compressible_sph.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,6 @@ Modules = [TrixiParticles]
Pages = [joinpath("schemes", "fluid", "weakly_compressible_sph", "state_equations.jl")]
```

## [Viscosity](@id viscosity_wcsph)

TODO: Explain viscosity.

```@autodocs
Modules = [TrixiParticles]
Pages = [joinpath("schemes", "fluid", "viscosity.jl")]
```

## [Density Diffusion](@id density_diffusion)

Density diffusion can be used with [`ContinuityDensity`](@ref) to remove the noise in the
Expand Down Expand Up @@ -118,11 +109,3 @@ term is very expensive and adds about 40--50% of computational cost.
Modules = [TrixiParticles]
Pages = [joinpath("schemes", "fluid", "weakly_compressible_sph", "density_diffusion.jl")]
```

## [Corrections](@id corrections)

```@autodocs
Modules = [TrixiParticles]
Pages = [joinpath("general", "corrections.jl")]
```

48 changes: 18 additions & 30 deletions test/schemes/fluid/surface_normal_sph.jl
Original file line number Diff line number Diff line change
@@ -1,28 +1,19 @@
function create_fluid_system(coordinates, velocity, mass, density, particle_spacing;
buffer_size=0, NDIMS=2, smoothing_length=1.0)
smoothing_kernel = SchoenbergCubicSplineKernel{NDIMS}()
sound_speed = 20.0
fluid_density = 1000.0
exponent = 1
clip_negative_pressure = false
density_calculator = SummationDensity()
surface_normal_method = ColorfieldSurfaceNormal()
reference_particle_spacing = particle_spacing
NDIMS=2, smoothing_length=1.0)
tspan = (0.0, 0.01)

fluid = InitialCondition(coordinates=coordinates, velocity=velocity, mass=mass,
density=density, particle_spacing=particle_spacing)

state_equation = StateEquationCole(sound_speed=sound_speed,
reference_density=fluid_density,
exponent=exponent,
clip_negative_pressure=clip_negative_pressure)
state_equation = StateEquationCole(sound_speed=10.0,
reference_density=1000.0,
exponent=1)

system = WeaklyCompressibleSPHSystem(fluid, density_calculator, state_equation,
smoothing_kernel, smoothing_length;
surface_normal_method=surface_normal_method,
reference_particle_spacing=reference_particle_spacing,
buffer_size=buffer_size)
system = WeaklyCompressibleSPHSystem(fluid, SummationDensity(), state_equation,
SchoenbergCubicSplineKernel{NDIMS}(),
smoothing_length;
surface_normal_method=ColorfieldSurfaceNormal(),
reference_particle_spacing=particle_spacing)

semi = Semidiscretization(system)
ode = semidiscretize(semi, tspan)
Expand All @@ -33,26 +24,23 @@ function create_fluid_system(coordinates, velocity, mass, density, particle_spac
end

function compute_and_test_surface_normals(system, semi, ode; NDIMS=2)
# Set values within the function if they are not changed
surface_tension = SurfaceTensionAkinci()

v0_ode, u0_ode = ode.u0.x
v = TrixiParticles.wrap_v(v0_ode, system, semi)
u = TrixiParticles.wrap_u(u0_ode, system, semi)

# Compute the surface normals
TrixiParticles.compute_surface_normal!(system, surface_tension, v, u, v0_ode, u0_ode,
semi, 0.0)

# After computation, check that surface normals have been computed
# After computation, check that surface normals have been computed and are not NaN or Inf
@test all(isfinite.(system.cache.surface_normal))
@test all(isfinite.(system.cache.neighbor_count))
svchb marked this conversation as resolved.
Show resolved Hide resolved
@test size(system.cache.surface_normal, 1) == NDIMS

# Use actual neighbor counts instead of random values
nparticles = size(u, 2)

# Ensure the threshold is reasonable
# check the threshold has been applied correctly
svchb marked this conversation as resolved.
Show resolved Hide resolved
threshold = 2^ndims(system) + 1

# Test the surface normals based on neighbor counts
Expand Down Expand Up @@ -84,7 +72,7 @@ end

system, semi, ode = create_fluid_system(coordinates, velocity, mass, density,
particle_spacing;
buffer_size=0, NDIMS=NDIMS)
NDIMS=NDIMS)

compute_and_test_surface_normals(system, semi, ode; NDIMS=NDIMS)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only tests that normals outside the threshold are zero, right?
Can you please add some test for the other normals, to check that they are not completely arbitrary?
Otherwise, this test only tests that everything runs without errors.

end
Expand All @@ -96,18 +84,18 @@ end
center = (0.0, 0.0)
NDIMS = 2

# Create a SphereShape (which is a circle in 2D)
# Create a `SphereShape`, which is a circle in 2D
svchb marked this conversation as resolved.
Show resolved Hide resolved
sphere_ic = SphereShape(particle_spacing, radius, center, 1000.0)

coordinates = sphere_ic.coordinates
velocity = zeros(NDIMS, size(coordinates, 2))
mass = sphere_ic.mass
density = sphere_ic.density

# To get some what accurate normals we increase the smoothing length unrealistically
# To get somewhat accurate normals we increase the smoothing length unrealistically
system, semi, ode = create_fluid_system(coordinates, velocity, mass, density,
particle_spacing;
buffer_size=0, NDIMS=NDIMS,
NDIMS=NDIMS,
smoothing_length=3.0 * particle_spacing)

compute_and_test_surface_normals(system, semi, ode; NDIMS=NDIMS)
Expand All @@ -119,9 +107,10 @@ end
# Compute expected normals and identify surface particles
for i in 1:nparticles
pos = coordinates[:, i]
r = pos - SVector(center...)
r = pos .- center
norm_r = norm(r)

# If particle is on the circumference of the circle
if abs(norm_r - radius) < particle_spacing
svchb marked this conversation as resolved.
Show resolved Hide resolved
expected_normals[:, i] = -r / norm_r

Expand All @@ -142,9 +131,8 @@ end

# Compare computed normals to expected normals for surface particles
for i in surface_particles
@test isapprox(computed_normals[:, i], expected_normals[:, i], atol=0.05)
@test isapprox(computed_normals[:, i], expected_normals[:, i], atol=0.04)
end

# Optionally, check that normals for interior particles are zero
# for i in setdiff(1:nparticles, surface_particles)
# @test isapprox(norm(system.cache.surface_normal[:, i]), 0.0, atol=1e-4)
Expand Down
Loading