diff --git a/src/schemes/boundary/dummy_particles/dummy_particles.jl b/src/schemes/boundary/dummy_particles/dummy_particles.jl index 3e3abcbd9..d6ca717ef 100644 --- a/src/schemes/boundary/dummy_particles/dummy_particles.jl +++ b/src/schemes/boundary/dummy_particles/dummy_particles.jl @@ -58,18 +58,15 @@ function BoundaryModelDummyParticles(initial_density, hydrodynamic_mass, pressure = initial_boundary_pressure(initial_density, density_calculator, state_equation) NDIMS = ndims(smoothing_kernel) - n_particles = length(initial_density) cache = (; create_cache_model(viscosity, n_particles, NDIMS)..., - create_cache_model(initial_density, density_calculator)...) - cache = (; create_cache_model(correction, initial_density, NDIMS, - n_particles)..., cache...) + create_cache_model(initial_density, density_calculator)..., + create_cache_model(correction, initial_density, NDIMS, n_particles)...) - return BoundaryModelDummyParticles(pressure, hydrodynamic_mass, - state_equation, density_calculator, - smoothing_kernel, smoothing_length, - viscosity, correction, cache) + return BoundaryModelDummyParticles(pressure, hydrodynamic_mass, state_equation, + density_calculator, smoothing_kernel, + smoothing_length, viscosity, correction, cache) end @doc raw""" @@ -105,7 +102,7 @@ struct PressureMirroring end """ struct PressureZeroing end -create_cache_model(correction, density, NDIMS, nparticles) = (;) +@inline create_cache_model(correction, density, NDIMS, nparticles) = (;) function create_cache_model(::ShepardKernelCorrection, density, NDIMS, n_particles) return (; kernel_correction_coefficient=similar(density)) @@ -135,9 +132,7 @@ function create_cache_model(initial_density, return (; density) end -function create_cache_model(initial_density, ::ContinuityDensity) - return (; initial_density) -end +@inline create_cache_model(initial_density, ::ContinuityDensity) = (; initial_density) function create_cache_model(initial_density, ::AdamiPressureExtrapolation) density = copy(initial_density) @@ -146,9 +141,7 @@ function create_cache_model(initial_density, ::AdamiPressureExtrapolation) return (; density, volume) end -function create_cache_model(viscosity::Nothing, n_particles, n_dims) - return (;) -end +@inline create_cache_model(viscosity::Nothing, n_particles, n_dims) = (;) function create_cache_model(viscosity, n_particles, n_dims) ELTYPE = eltype(viscosity.epsilon) @@ -306,10 +299,9 @@ end boundary_model.pressure[particle] = max(boundary_model.state_equation(density), 0.0) end -function compute_pressure!(boundary_model, ::AdamiPressureExtrapolation, - system, v, u, v_ode, u_ode, semi) - (; pressure, state_equation, cache, viscosity) = boundary_model - (; volume, density) = cache +function compute_pressure!(boundary_model, ::AdamiPressureExtrapolation, system, v, u, + v_ode, u_ode, semi) + (; pressure, cache, viscosity) = boundary_model set_zero!(pressure) @@ -386,6 +378,13 @@ function compute_pressure!(boundary_model, ::Union{PressureMirroring, PressureZe return boundary_model end +@inline function adami_pressure_extrapolation_neighbor!(boundary_model, system, + neighbor_system, system_coords, + neighbor_coords, v_neighbor_system, + neighborhood_search) + return boundary_model +end + @inline function adami_pressure_extrapolation_neighbor!(boundary_model, system, neighbor_system::FluidSystem, system_coords, neighbor_coords, @@ -401,17 +400,15 @@ end pos_diff, distance # Since neighbor and particle are switched pos_diff = -pos_diff - adami_pressure_inner!(boundary_model, system, neighbor_system::FluidSystem, + adami_pressure_inner!(boundary_model, system, neighbor_system, v_neighbor_system, particle, neighbor, pos_diff, distance, viscosity, cache, pressure) end end -@inline function adami_pressure_extrapolation_neighbor!(boundary_model, system, - neighbor_system, - system_coords, neighbor_coords, - v_neighbor_system, - neighborhood_search) +@inline function adami_pressure_extrapolation!(boundary_model, system, neighbor_system, + system_coords, neighbor_coords, + v_neighbor_system, neighborhood_search) return boundary_model end @@ -433,14 +430,7 @@ end end end -@inline function adami_pressure_extrapolation!(boundary_model, system, neighbor_system, - system_coords, neighbor_coords, - v_neighbor_system, neighborhood_search) - return boundary_model -end - -@inline function adami_pressure_inner!(boundary_model, system, - neighbor_system::FluidSystem, +@inline function adami_pressure_inner!(boundary_model, system, neighbor_system, v_neighbor_system, particle, neighbor, pos_diff, distance, viscosity, cache, pressure) density_neighbor = particle_density(v_neighbor_system, neighbor_system, neighbor) @@ -510,8 +500,7 @@ end return density end -@inline function smoothing_kernel_grad(system::BoundarySystem, pos_diff, - distance, particle) +@inline function smoothing_kernel_grad(system::BoundarySystem, pos_diff, distance, particle) (; smoothing_kernel, smoothing_length, correction) = system.boundary_model return corrected_kernel_grad(smoothing_kernel, pos_diff, distance, diff --git a/src/visualization/write2vtk.jl b/src/visualization/write2vtk.jl index b5235e772..07651d2c7 100644 --- a/src/visualization/write2vtk.jl +++ b/src/visualization/write2vtk.jl @@ -353,36 +353,14 @@ function write2vtk!(vtk, v, u, t, model::BoundaryModelDummyParticles, system; vtk["smoothing_length"] = system.boundary_model.smoothing_length vtk["density_calculator"] = type2string(system.boundary_model.density_calculator) vtk["state_equation"] = type2string(system.boundary_model.state_equation) + vtk["viscosity_model"] = type2string(model.viscosity) end - write2vtk!(vtk, v, u, t, model, model.viscosity, system, - write_meta_data=write_meta_data) -end - -function write2vtk!(vtk, v, u, t, model::BoundaryModelDummyParticles, viscosity, system; - write_meta_data=true) vtk["hydrodynamic_density"] = [particle_density(v, system, particle) for particle in eachparticle(system)] vtk["pressure"] = model.pressure - if write_meta_data - vtk["viscosity_model"] = type2string(viscosity) + if model.viscosity isa ViscosityAdami + vtk["wall_velocity"] = view(model.cache.wall_velocity, 1:ndims(system), :) end - - return vtk -end - -function write2vtk!(vtk, v, u, t, model::BoundaryModelDummyParticles, - viscosity::ViscosityAdami, system; - write_meta_data=true) - vtk["hydrodynamic_density"] = [particle_density(v, system, particle) - for particle in eachparticle(system)] - vtk["pressure"] = model.pressure - vtk["wall_velocity"] = view(model.cache.wall_velocity, 1:ndims(system), :) - - if write_meta_data - vtk["viscosity_model"] = type2string(viscosity) - end - - return vtk end