Skip to content

Commit

Permalink
Make it work with EDAC
Browse files Browse the repository at this point in the history
  • Loading branch information
efaulhaber authored and LasNikas committed Nov 18, 2024
1 parent afb6e9f commit e99571f
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 19 deletions.
8 changes: 5 additions & 3 deletions src/general/semidiscretization.jl
Original file line number Diff line number Diff line change
Expand Up @@ -134,8 +134,8 @@ function create_neighborhood_search(neighborhood_search, system, neighbor)
end

@inline function compact_support(system, neighbor)
(; smoothing_kernel, smoothing_length) = system
return compact_support(smoothing_kernel, smoothing_length)
(; smoothing_kernel) = system
return compact_support(smoothing_kernel, smoothing_length(system, 1)) # TODO
end

@inline function compact_support(system::OpenBoundarySPHSystem, neighbor)
Expand Down Expand Up @@ -407,7 +407,9 @@ end
function calculate_dt(v_ode, u_ode, cfl_number, semi::Semidiscretization)
(; systems) = semi

return minimum(system -> calculate_dt(v_ode, u_ode, cfl_number, system), systems)
return 1.0
# TODO
# return minimum(system -> calculate_dt(v_ode, u_ode, cfl_number, system), systems)
end

function drift!(du_ode, v_ode, u_ode, semi, t)
Expand Down
6 changes: 5 additions & 1 deletion src/schemes/boundary/dummy_particles/dummy_particles.jl
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ function BoundaryModelDummyParticles(initial_density, hydrodynamic_mass,
smoothing_length, viscosity, correction, cache)
end

function smoothing_length(boundary_model::BoundaryModelDummyParticles, particle)
return boundary_model.smoothing_length
end

@doc raw"""
AdamiPressureExtrapolation(; pressure_offset=0.0)
Expand Down Expand Up @@ -480,7 +484,7 @@ end
resulting_acceleration = neighbor_system.acceleration -
current_acceleration(system, particle)

kernel_weight = smoothing_kernel(boundary_model, distance)
kernel_weight = smoothing_kernel(boundary_model, distance, particle)

pressure[particle] += (pressure_offset
+
Expand Down
39 changes: 26 additions & 13 deletions src/schemes/fluid/entropically_damped_sph/system.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,11 @@ See [Entropically Damped Artificial Compressibility for SPH](@ref edac) for more
gravity-like source terms.
"""
struct EntropicallyDampedSPHSystem{NDIMS, ELTYPE <: Real, IC, M, DC, K, V, TV,
PF, ST, B, C} <: FluidSystem{NDIMS, IC}
PF, ST, B, PR, C} <: FluidSystem{NDIMS, IC}
initial_condition :: IC
mass :: M # Vector{ELTYPE}: [particle]
density_calculator :: DC
smoothing_kernel :: K
smoothing_length :: ELTYPE
sound_speed :: ELTYPE
viscosity :: V
nu_edac :: ELTYPE
Expand All @@ -59,16 +58,19 @@ struct EntropicallyDampedSPHSystem{NDIMS, ELTYPE <: Real, IC, M, DC, K, V, TV,
transport_velocity :: TV
source_terms :: ST
buffer :: B
particle_refinement :: PR
cache :: C
end

function EntropicallyDampedSPHSystem(initial_condition, smoothing_kernel,
function EntropicallyDampedSPHSystem(initial_condition, smoothing_kernel,
smoothing_length, sound_speed;
pressure_acceleration=inter_particle_averaged_pressure,
density_calculator=SummationDensity(),
transport_velocity=nothing,
alpha=0.5, viscosity=nothing,
acceleration=ntuple(_ -> 0.0,
ndims(smoothing_kernel)),
particle_refinement=nothing,
source_terms=nothing, buffer_size=nothing)
buffer = isnothing(buffer_size) ? nothing :
SystemBuffer(nparticles(initial_condition), buffer_size)
Expand Down Expand Up @@ -98,17 +100,16 @@ struct EntropicallyDampedSPHSystem{NDIMS, ELTYPE <: Real, IC, M, DC, K, V, TV,

cache = create_cache_density(initial_condition, density_calculator)
cache = (; create_cache_edac(initial_condition, transport_velocity)..., cache...)

new{NDIMS, ELTYPE, typeof(initial_condition), typeof(mass),
typeof(density_calculator), typeof(smoothing_kernel), typeof(viscosity),
typeof(transport_velocity), typeof(pressure_acceleration), typeof(source_terms),
typeof(buffer),
typeof(cache)}(initial_condition, mass, density_calculator, smoothing_kernel,
smoothing_length, sound_speed, viscosity, nu_edac, acceleration_,
nothing, pressure_acceleration, transport_velocity, source_terms,
buffer, cache)
cache = (;
create_cache_refinement(particle_refinement, smoothing_length, ELTYPE, NDIMS,
nparticles(initial_condition))...,
cache...)

return EntropicallyDampedSPHSystem(initial_condition, mass, density_calculator, smoothing_kernel,
sound_speed, viscosity, nu_edac, acceleration_,
nothing, pressure_acceleration, transport_velocity, source_terms,
buffer, particle_refinement, cache)
end
end

function Base.show(io::IO, system::EntropicallyDampedSPHSystem)
@nospecialize system # reduce precompilation time
Expand Down Expand Up @@ -146,6 +147,18 @@ function Base.show(io::IO, ::MIME"text/plain", system::EntropicallyDampedSPHSyst
end
end

function smoothing_length(system::EntropicallyDampedSPHSystem, particle)
return smoothing_length(system, system.particle_refinement, particle)
end

function smoothing_length(system::EntropicallyDampedSPHSystem, ::Nothing, particle)
return system.cache.smoothing_length
end

function smoothing_length(system::EntropicallyDampedSPHSystem, refinement, particle)
return system.cache.smoothing_length[particle]
end

create_cache_edac(initial_condition, ::Nothing) = (;)

function create_cache_edac(initial_condition, ::TransportVelocityAdami)
Expand Down
2 changes: 1 addition & 1 deletion src/schemes/fluid/weakly_compressible_sph/system.jl
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ function WeaklyCompressibleSPHSystem(initial_condition,

return WeaklyCompressibleSPHSystem(initial_condition, mass, pressure,
density_calculator, state_equation,
smoothing_kernel, smoothing_length,
smoothing_kernel,
acceleration_, viscosity,
density_diffusion, correction,
pressure_acceleration, nothing,
Expand Down
2 changes: 1 addition & 1 deletion src/visualization/write2vtk.jl
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ function write2vtk!(vtk, v, u, t, system::FluidSystem; write_meta_data=true)
vtk["viscosity"] = type2string(system.viscosity)
write2vtk!(vtk, system.viscosity)
vtk["smoothing_kernel"] = type2string(system.smoothing_kernel)
vtk["smoothing_length"] = system.smoothing_length
# vtk["smoothing_length"] = system.smoothing_length TODO
vtk["density_calculator"] = type2string(system.density_calculator)

if system isa WeaklyCompressibleSPHSystem
Expand Down

0 comments on commit e99571f

Please sign in to comment.