Skip to content

Commit

Permalink
formatting (#163)
Browse files Browse the repository at this point in the history
  • Loading branch information
LasNikas authored May 26, 2023
1 parent e19b806 commit a4d4580
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 48 deletions.
3 changes: 1 addition & 2 deletions src/general/neighborhood_search.jl
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,7 @@ end
# `f(particle, neighbor, pos_diff, distance)` is called for every particle-neighbor pair.
# By default, loop over `each_moving_particle(system)`.
@inline function for_particle_neighbor(f, system, neighbor_system,
system_coords, neighbor_coords,
neighborhood_search;
system_coords, neighbor_coords, neighborhood_search;
particles=each_moving_particle(system))
@threaded for particle in particles
for_particle_neighbor_inner(f, system, neighbor_system,
Expand Down
31 changes: 12 additions & 19 deletions src/general/semidiscretization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ struct Semidiscretization{S, RU, RV, NS, DC}
for system in systems)

new{typeof(systems), typeof(ranges_u), typeof(ranges_v),
typeof(searches), typeof(damping_coefficient)}(systems, ranges_u,
ranges_v, searches,
damping_coefficient)
typeof(searches), typeof(damping_coefficient)}(systems, ranges_u, ranges_v,
searches, damping_coefficient)
end
end

Expand Down Expand Up @@ -93,8 +92,7 @@ end
return compact_support(smoothing_kernel, smoothing_length)
end

@inline function compact_support(system::Union{TotalLagrangianSPHSystem,
BoundarySPHSystem},
@inline function compact_support(system::Union{TotalLagrangianSPHSystem, BoundarySPHSystem},
neighbor)
return compact_support(system, system.boundary_model, neighbor)
end
Expand Down Expand Up @@ -124,8 +122,7 @@ function nhs_init_function(system::TotalLagrangianSPHSystem,
return i -> initial_coords(neighbor, i)
end

function nhs_init_function(system::Union{TotalLagrangianSPHSystem,
BoundarySPHSystem},
function nhs_init_function(system::Union{TotalLagrangianSPHSystem, BoundarySPHSystem},
neighbor)
return nhs_init_function(system, system.boundary_model, neighbor)
end
Expand Down Expand Up @@ -274,15 +271,13 @@ function kick!(dv_ode, v_ode, u_ode, semi, t)
@trixi_timeit timer() "kick!" begin
@trixi_timeit timer() "reset ∂v/∂t" set_zero!(dv_ode)

@trixi_timeit timer() "update systems and nhs" update_systems_and_nhs(v_ode,
u_ode,
@trixi_timeit timer() "update systems and nhs" update_systems_and_nhs(v_ode, u_ode,
semi, t)

@trixi_timeit timer() "gravity and damping" gravity_and_damping!(dv_ode, v_ode,
semi)

@trixi_timeit timer() "system interaction" system_interaction!(dv_ode,
v_ode, u_ode,
@trixi_timeit timer() "system interaction" system_interaction!(dv_ode, v_ode, u_ode,
semi)
end

Expand Down Expand Up @@ -374,8 +369,7 @@ end

@inline add_acceleration!(dv, particle, system::BoundarySPHSystem) = dv

@inline function add_damping_force!(dv, damping_coefficient::Float64, v, particle,
system)
@inline function add_damping_force!(dv, damping_coefficient::Float64, v, particle, system)
for i in 1:ndims(system)
dv[i, particle] -= damping_coefficient * v[i, particle]
end
Expand Down Expand Up @@ -414,8 +408,8 @@ function update1!(system, system_index, v, u, v_ode, u_ode, semi, t)
return system
end

function update1!(system::TotalLagrangianSPHSystem, system_index, v, u,
v_ode, u_ode, semi, t)
function update1!(system::TotalLagrangianSPHSystem, system_index, v, u, v_ode, u_ode,
semi, t)
# Only update solid systems
update!(system, system_index, v, u, v_ode, u_ode, semi, t)
end
Expand All @@ -424,8 +418,8 @@ function update2!(system, system_index, v, u, v_ode, u_ode, semi, t)
return system
end

function update2!(system::WeaklyCompressibleSPHSystem, system_index, v, u,
v_ode, u_ode, semi, t)
function update2!(system::WeaklyCompressibleSPHSystem, system_index, v, u, v_ode, u_ode,
semi, t)
# Only update fluid systems
update!(system, system_index, v, u, v_ode, u_ode, semi, t)
end
Expand All @@ -443,8 +437,7 @@ function update3!(system::TotalLagrangianSPHSystem, system_index, v, u, v_ode, u
update!(boundary_model, system, system_index, v, u, v_ode, u_ode, semi)
end

function update3!(system::WeaklyCompressibleSPHSystem, system_index, v, u, v_ode,
u_ode,
function update3!(system::WeaklyCompressibleSPHSystem, system_index, v, u, v_ode, u_ode,
semi, t)
return system
end
Expand Down
10 changes: 3 additions & 7 deletions src/schemes/boundary/rhs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ end
# Boundary-fluid interaction with dummy particles model
function interact!(dv, v_particle_system, u_particle_system,
v_neighbor_system, u_neighbor_system, neighborhood_search,
particle_system::BoundarySPHSystem{
<:BoundaryModelDummyParticles
},
particle_system::BoundarySPHSystem{<:BoundaryModelDummyParticles},
neighbor_system::WeaklyCompressibleSPHSystem)
@unpack density_calculator = particle_system.boundary_model

Expand All @@ -23,16 +21,14 @@ end

function interact!(dv, v_particle_system, u_particle_system,
v_neighbor_system, u_neighbor_system, neighborhood_search,
particle_system::BoundarySPHSystem,
neighbor_system, density_calculator)
particle_system::BoundarySPHSystem, neighbor_system, density_calculator)
return dv
end

# With `ContinuityDensity` solve the continuity equation
function interact!(dv, v_particle_system, u_particle_system,
v_neighbor_system, u_neighbor_system, neighborhood_search,
particle_system::BoundarySPHSystem,
neighbor_system, ::ContinuityDensity)
particle_system::BoundarySPHSystem, neighbor_system, ::ContinuityDensity)
@unpack boundary_model = particle_system

system_coords = current_coordinates(u_particle_system, particle_system)
Expand Down
17 changes: 7 additions & 10 deletions src/schemes/boundary/system.jl
Original file line number Diff line number Diff line change
Expand Up @@ -355,13 +355,11 @@ end
return n_moving_particles(system, system.boundary_model.density_calculator)
end

@inline function n_moving_particles(system::BoundarySPHSystem,
density_calculator)
@inline function n_moving_particles(system::BoundarySPHSystem, density_calculator)
return 0
end

@inline function n_moving_particles(system::BoundarySPHSystem,
::ContinuityDensity)
@inline function n_moving_particles(system::BoundarySPHSystem, ::ContinuityDensity)
nparticles(system)
end

Expand Down Expand Up @@ -393,8 +391,7 @@ end
return hydrodynamic_mass[particle] / boundary_particle_spacing^ndims(system)
end

@inline function particle_density(v, model::BoundaryModelDummyParticles, system,
particle)
@inline function particle_density(v, model::BoundaryModelDummyParticles, system, particle)
return particle_density(v, model.density_calculator, system, particle)
end

Expand All @@ -409,8 +406,7 @@ end
return system.boundary_model.hydrodynamic_mass[particle]
end

function update!(system::BoundarySPHSystem, system_index,
v, u, v_ode, u_ode, semi, t)
function update!(system::BoundarySPHSystem, system_index, v, u, v_ode, u_ode, semi, t)
@unpack coordinates, movement_function, boundary_model = system

system.ismoving[1] = move_boundary_particles!(movement_function, coordinates, t)
Expand All @@ -423,10 +419,11 @@ end
function move_boundary_particles!(movement_function, coordinates, t)
movement_function(coordinates, t)
end

move_boundary_particles!(movement_function::Nothing, coordinates, t) = false

@inline function update!(boundary_model::BoundaryModelMonaghanKajtar, system,
system_index, v, u, v_ode, u_ode, semi)
@inline function update!(boundary_model::BoundaryModelMonaghanKajtar,
system, system_index, v, u, v_ode, u_ode, semi)
# Nothing to do in the update step
return boundary_model
end
Expand Down
3 changes: 1 addition & 2 deletions src/schemes/fluid/weakly_compressible_sph/rhs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ end
function interact!(dv, v_particle_system, u_particle_system,
v_neighbor_system, u_neighbor_system, neighborhood_search,
particle_system::WeaklyCompressibleSPHSystem,
neighbor_system::Union{BoundarySPHSystem,
TotalLagrangianSPHSystem})
neighbor_system::Union{BoundarySPHSystem, TotalLagrangianSPHSystem})
@unpack density_calculator, state_equation, viscosity,
smoothing_length = particle_system
@unpack sound_speed = state_equation
Expand Down
9 changes: 3 additions & 6 deletions src/schemes/fluid/weakly_compressible_sph/system.jl
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,7 @@ end
# Nothing to initialize for this system
initialize!(system::WeaklyCompressibleSPHSystem, neighborhood_search) = system

function update!(system::WeaklyCompressibleSPHSystem, system_index, v, u, v_ode,
u_ode,
function update!(system::WeaklyCompressibleSPHSystem, system_index, v, u, v_ode, u_ode,
semi, t)
@unpack density_calculator = system

Expand All @@ -120,13 +119,11 @@ function update!(system::WeaklyCompressibleSPHSystem, system_index, v, u, v_ode,
return system
end

function compute_quantities(v, u, ::ContinuityDensity, system, system_index, u_ode,
semi)
function compute_quantities(v, u, ::ContinuityDensity, system, system_index, u_ode, semi)
compute_pressure!(system, v)
end

function compute_quantities(v, u, ::SummationDensity, system, system_index, u_ode,
semi)
function compute_quantities(v, u, ::SummationDensity, system, system_index, u_ode, semi)
@unpack systems, neighborhood_searches = semi
@unpack cache = system
@unpack density = cache # Density is in the cache for SummationDensity
Expand Down
4 changes: 2 additions & 2 deletions src/schemes/solid/total_lagrangian_sph/system.jl
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,8 @@ function calc_correction_matrix!(corr_matrix, neighborhood_search, system)
return corr_matrix
end

function update!(system::TotalLagrangianSPHSystem, system_index, v, u,
v_ode, u_ode, semi, t)
function update!(system::TotalLagrangianSPHSystem, system_index, v, u, v_ode, u_ode,
semi, t)
@unpack neighborhood_searches = semi

# Update current coordinates
Expand Down

0 comments on commit a4d4580

Please sign in to comment.