-
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
Generalize surface normal calc #539
base: main
Are you sure you want to change the base?
Generalize surface normal calc #539
Conversation
Conflicts: src/schemes/fluid/weakly_compressible_sph/system.jl
…vchb/TrixiParticles.jlOpen into generalize_surface_normal_calc
function initialize_colorfield!(system, ::BoundaryModelDummyParticles, neighborhood_search) | ||
system_coords = system.coordinates | ||
(; smoothing_kernel, smoothing_length) = system.boundary_model | ||
|
||
foreach_point_neighbor(system, system, | ||
system_coords, system_coords, | ||
neighborhood_search, | ||
points=eachparticle(system)) do particle, neighbor, pos_diff, | ||
distance | ||
system.boundary_model.cache.colorfield_bnd[particle] += kernel(smoothing_kernel, | ||
distance, | ||
smoothing_length) | ||
system.boundary_model.cache.neighbor_count[particle] += 1 | ||
end | ||
return system | ||
end |
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.
Please add a test.
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.
I have added a test but this test will change in all subsequent PRs
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.
I think that is better than reducing coverage here and potentially forgetting about it.
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.
return floor(Int, pi * compact_support^2 / particle_spacing^2) | ||
end | ||
|
||
@inline @fastpow function ideal_neighbor_count(::Val{3}, particle_spacing, compact_support) |
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.
Please check the codecov report. This is not covered, but the 2D version is.
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.
A test for this exists in #584
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.
Can you add it here or does it require other code from #584?
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.
Its indirectly tested since it is used in a tested function.
# Section 2.2 in Akinci et al. 2013 "Versatile Surface Tension and Adhesion for SPH Fluids" | ||
# Note: This is the simplest form of normal approximation commonly used in SPH and comes | ||
# with serious deficits in accuracy especially at corners, small neighborhoods and boundaries | ||
function calc_normal_akinci!(system, neighbor_system::BoundarySystem, u_system, v, |
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.
Please check Codecov report. This is missing tests.
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.
Testing this doesn't make much sense. Since there is no analytical value. And it will change in all subsequent PRs.
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.
Let me restate that there is a analytical value but the results will not be close. Just closer than without it.
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.
There must be some useful way to test this. Maybe with a high resolution and very large smoothing length?
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.
It should be noted that I am currently only working on a much different code. So I am completely confused.
Anyway this function is renamed in a future version since it is merged with the other normal method and then split because it became too long. The condition that is used here is also changed.
What I mean here is that the results close to the wall in all versions are not reliable anyway. So the test would break down to testing that a nonzero value exists in this version.
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.
A bunch of small remarks, otherwise this is ready to merge from my side.
"Systems" => [ | ||
"Discrete Element Method (Solid)" => joinpath("systems", | ||
"dem.md"), | ||
"Fluid Models" => joinpath("systems", "fluid.md"), | ||
"Discrete Element Method (Solid)" => joinpath("systems", "dem.md"), |
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.
Would it make more sense to make it like this:
- Systems
- Fluid Models
- Overview (with the new content that you added in "fluid.md")
- WCSPH
- EDAC
- DEM
- Fluid Models
Now we have "Fluid Models" on the same level as "WCSPH" and "EDAC", which is confusing to me, as these are fluid models.
The classical model is composed of the curvature minimization and cohesion force. | ||
|
||
#### Cohesion force | ||
The model calculates the cohesion force based on the distance between particles and the support radius ``h_c``. |
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.
The model calculates the cohesion force based on the distance between particles and the support radius ``h_c``. | |
The model calculates the cohesion force based on the support radius ``h_c`` and the distance between particles. |
I read this as "distance between (particles and support radius)".
The model calculates the cohesion force based on the distance between particles and the support radius ``h_c``. | ||
This force is determined using two distinct regimes within the support radius: | ||
- For particles closer than half the support radius, | ||
a repulsive force is calculated to prevent particle clustering too tightly, |
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.
a repulsive force is calculated to prevent particle clustering too tightly, | |
a repulsive force is calculated to prevent particles from clustering too tightly, |
gravity=gravity, tspan=tspan, density_diffusion=nothing, | ||
sound_speed=sound_speed, prefix="") |
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.
I'm confused. Why is the tspan
needed when sol = nothing
?
@@ -40,7 +40,7 @@ sphere2 = SphereShape(fluid_particle_spacing, sphere_radius, sphere2_center, | |||
|
|||
# ========================================================================================== | |||
# ==== Fluid | |||
fluid_smoothing_length = 1.0 * fluid_particle_spacing | |||
fluid_smoothing_length = 1.0 * fluid_particle_spacing - eps() |
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 is this necessary? It shouldn't be necessary, that would be confusing. Is this trixi-framework/PointNeighbors.jl#19?
@test isapprox(computed_normals[:, surface_particles], | ||
expected_normals[:, surface_particles], norm=x -> norm(x, Inf), | ||
atol=0.05) |
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.
@test isapprox(computed_normals[:, surface_particles], | |
expected_normals[:, surface_particles], norm=x -> norm(x, Inf), | |
atol=0.05) | |
@test isapprox.(computed_normals[:, surface_particles], | |
expected_normals[:, surface_particles], atol=0.05) |
My earlier suggestions were stupid.
# end | ||
end | ||
|
||
@testset "Sphere Surface Normals with wall" begin |
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.
@testset "Sphere Surface Normals with wall" begin | |
@testset "Sphere Surface Normals with Wall" begin |
|
||
# Boundary system | ||
bnd_color = bnd_system.boundary_model.cache.colorfield_bnd | ||
# this is only true since it assumed that the color is 1 |
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 only true since it assumed that the color is 1 | |
# This is only true since it assumed that the color is 1 |
@test isapprox(computed_normals[:, surface_particles], | ||
expected_normals[:, surface_particles], norm=x -> norm(x, Inf), | ||
atol=0.5) |
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.
@test isapprox(computed_normals[:, surface_particles], | |
expected_normals[:, surface_particles], norm=x -> norm(x, Inf), | |
atol=0.5) | |
@test isapprox.(computed_normals[:, surface_particles], | |
expected_normals[:, surface_particles], atol=0.5) |
# 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) | ||
# end |
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.
Can you add a comment then, please?
Depends on #599
extracted from #584