-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
128 additions
and
17 deletions.
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,43 @@ | ||
abstract type RefinementCriteria end | ||
|
||
struct SpatialRefinementCriterion <: RefinementCriteria end | ||
|
||
struct SolutionRefinementCriterion <: RefinementCriteria end | ||
|
||
@inline function (criterion::SpatialRefinementCriterion)(system, semi, v_ode, u_ode) | ||
u = wrap_u(u_ode, system, semi) | ||
system_coords = current_coordinates(u, system) | ||
|
||
foreach_system(semi) do neighbor_system | ||
set_particle_spacing!(system, neighbor_system, system_coords) | ||
end | ||
return system | ||
end | ||
|
||
@inline set_particle_spacing!(system, neighbor_system, system_coords) = system | ||
|
||
@inline function set_particle_spacing!(particle_system, | ||
neighbor_system::Union{BoundarySPHSystem, | ||
TotalLagrangianSPHSystem}, | ||
system_coords) | ||
(; smoothing_length, smoothing_length_factor) = particle_system.cache | ||
|
||
neighborhood_search = get_neighborhood_search(particle_system, neighbor_system, semi) | ||
u_neighbor_system = wrap_u(u_ode, neighbor_system, semi) | ||
neighbor_coords = current_coordinates(u_neighbor_system, neighbor_system) | ||
|
||
# Loop over all pairs of particles and neighbors within the kernel cutoff. | ||
foreach_point_neighbor(particle_system, neighbor_system, | ||
system_coords, neighbor_coords, | ||
neighborhood_search) do particle, neighbor, pos_diff, distance | ||
# Only consider particles with a distance > 0. | ||
distance < sqrt(eps()) && return | ||
|
||
dp_neighbor = particle_spacing(neighbor_system, neighbor) | ||
dp_particle = smoothing_length[particle] / smoothing_length_factor | ||
|
||
smoothing_length[particle] = smoothing_length_factor * min(dp_neighbor, dp_particle) | ||
end | ||
|
||
return particle_system | ||
end |