Skip to content

Commit

Permalink
update smoothing length
Browse files Browse the repository at this point in the history
  • Loading branch information
LasNikas committed Nov 8, 2024
1 parent a635540 commit 732d705
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions src/multi_resolution/particle_refinement.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ function refinement!(semi, v_ode, u_ode, v_tmp, u_tmp, t)
# Correct the particles

# Update smoothing lengths
upate_smoothing_lengths!(semi, u_ode)

Check warning on line 44 in src/multi_resolution/particle_refinement.jl

View workflow job for this annotation

GitHub Actions / Spell Check with Typos

"upate" should be "update".

# Resize neighborhood search
foreach_system(semi) do system
Expand Down Expand Up @@ -102,6 +103,54 @@ end
return system
end

function upate_smoothing_lengths!(semi::Semidiscretization, u_ode)

Check warning on line 106 in src/multi_resolution/particle_refinement.jl

View workflow job for this annotation

GitHub Actions / Spell Check with Typos

"upate" should be "update".
foreach_system(semi) do system
u = wrap_u(u_ode, system, semi)
upate_smoothing_lengths!(system, semi, u)

Check warning on line 109 in src/multi_resolution/particle_refinement.jl

View workflow job for this annotation

GitHub Actions / Spell Check with Typos

"upate" should be "update".
end

return semi
end

upate_smoothing_lengths!(system, semi, u) = system

Check warning on line 115 in src/multi_resolution/particle_refinement.jl

View workflow job for this annotation

GitHub Actions / Spell Check with Typos

"upate" should be "update".

function upate_smoothing_lengths!(system::FluidSystem, semi, u)

Check warning on line 117 in src/multi_resolution/particle_refinement.jl

View workflow job for this annotation

GitHub Actions / Spell Check with Typos

"upate" should be "update".
upate_smoothing_lengths!(system, system.particle_refinement, semi, u)
end

upate_smoothing_lengths!(system, ::Nothing, semi, u) = system

function upate_smoothing_lengths!(system::FluidSystem, refinement, semi, u)
(; smoothing_length, smoothing_length_factor) = system.cache

neighborhood_search = get_neighborhood_search(system, semi)

system_coords = current_coordinates(u, system)

# TODO: Think about a solution when density is not constant in `initial_condition`
# Problem: Resized systems
rho_0 = first(system.initial_condition.density)

for particle in each_moving_particle(system)
mass_avg = zero(eltype(system))
counter_neighbors = 0

PointNeighbors.foreach_neighbor(system_coords, system_coords, neighborhood_search,
particle) do particle, neighbor, pos_diff, distance
mass_avg += system.mass[neighbor]

counter_neighbors += 1
end

mass_avg /= counter_neighbors

smoothing_length[particle] = smoothing_length_factor *
(mass_avg / rho_0)^(1 / ndims(system))
end

return system
end

@inline function min_max_avg_spacing(system, semi, system_coords, particle)
dp_min = Inf
dp_max = zero(eltype(system))
Expand Down

0 comments on commit 732d705

Please sign in to comment.