From 12383a8a6d228d615800b1e5a2584b5aa4673413 Mon Sep 17 00:00:00 2001 From: Niklas Neher <73897120+LasNikas@users.noreply.github.com> Date: Mon, 13 Nov 2023 16:03:45 +0100 Subject: [PATCH] qualify `create_cache` functions (#283) --- .../boundary/dummy_particles/dummy_particles.jl | 16 ++++++++-------- src/schemes/boundary/system.jl | 6 +++--- .../fluid/weakly_compressible_sph/system.jl | 16 ++++++++-------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/schemes/boundary/dummy_particles/dummy_particles.jl b/src/schemes/boundary/dummy_particles/dummy_particles.jl index 7f1900de5..4689920c3 100644 --- a/src/schemes/boundary/dummy_particles/dummy_particles.jl +++ b/src/schemes/boundary/dummy_particles/dummy_particles.jl @@ -93,8 +93,8 @@ struct BoundaryModelDummyParticles{ELTYPE <: Real, SE, DC, K, V, C} n_particles = length(initial_density) - cache = (; create_cache(viscosity, n_particles, ndims(smoothing_kernel))..., - create_cache(initial_density, density_calculator)...) + cache = (; create_cache_model(viscosity, n_particles, ndims(smoothing_kernel))..., + create_cache_model(initial_density, density_calculator)...) new{eltype(initial_density), typeof(state_equation), typeof(density_calculator), typeof(smoothing_kernel), typeof(viscosity), @@ -298,29 +298,29 @@ end grad_kernel end -function create_cache(initial_density, - ::Union{SummationDensity, PressureMirroring, PressureZeroing}) +function create_cache_model(initial_density, + ::Union{SummationDensity, PressureMirroring, PressureZeroing}) density = copy(initial_density) return (; density) end -function create_cache(initial_density, ::ContinuityDensity) +function create_cache_model(initial_density, ::ContinuityDensity) return (; initial_density) end -function create_cache(initial_density, ::AdamiPressureExtrapolation) +function create_cache_model(initial_density, ::AdamiPressureExtrapolation) density = copy(initial_density) volume = similar(initial_density) return (; density, volume) end -function create_cache(viscosity::NoViscosity, n_particles, n_dims) +function create_cache_model(viscosity::NoViscosity, n_particles, n_dims) return (;) end -function create_cache(viscosity::ViscosityAdami, n_particles, n_dims) +function create_cache_model(viscosity::ViscosityAdami, n_particles, n_dims) ELTYPE = eltype(viscosity.nu) wall_velocity = zeros(ELTYPE, n_dims, n_particles) diff --git a/src/schemes/boundary/system.jl b/src/schemes/boundary/system.jl index 6f898896b..ca4bcb3eb 100644 --- a/src/schemes/boundary/system.jl +++ b/src/schemes/boundary/system.jl @@ -19,7 +19,7 @@ struct BoundarySPHSystem{BM, NDIMS, ELTYPE <: Real, M, C} <: System{NDIMS} NDIMS = size(coordinates, 1) ismoving = zeros(Bool, 1) - cache = create_cache(movement, inititial_condition) + cache = create_cache_boundary(movement, inititial_condition) return new{typeof(model), NDIMS, eltype(coordinates), typeof(movement), typeof(cache)}(coordinates, model, movement, @@ -58,9 +58,9 @@ struct BoundaryMovement{MF, IM} end end -create_cache(::Nothing, inititial_condition) = (;) +create_cache_boundary(::Nothing, inititial_condition) = (;) -function create_cache(::BoundaryMovement, inititial_condition) +function create_cache_boundary(::BoundaryMovement, inititial_condition) initial_coordinates = copy(inititial_condition.coordinates) velocity = similar(inititial_condition.velocity) acceleration = similar(inititial_condition.velocity) diff --git a/src/schemes/fluid/weakly_compressible_sph/system.jl b/src/schemes/fluid/weakly_compressible_sph/system.jl index dc2af798d..fe0d1dbb5 100644 --- a/src/schemes/fluid/weakly_compressible_sph/system.jl +++ b/src/schemes/fluid/weakly_compressible_sph/system.jl @@ -68,10 +68,10 @@ struct WeaklyCompressibleSPHSystem{NDIMS, ELTYPE <: Real, DC, SE, K, V, COR, C} throw(ArgumentError("`ShepardKernelCorrection` cannot be used with `ContinuityDensity`")) end - cache = create_cache(n_particles, ELTYPE, density_calculator) + cache = create_cache_wcsph(n_particles, ELTYPE, density_calculator) cache = (; - create_cache(correction, initial_condition.density, NDIMS, n_particles)..., - cache...) + create_cache_wcsph(correction, initial_condition.density, NDIMS, + n_particles)..., cache...) return new{NDIMS, ELTYPE, typeof(density_calculator), typeof(state_equation), typeof(smoothing_kernel), typeof(viscosity), @@ -83,24 +83,24 @@ struct WeaklyCompressibleSPHSystem{NDIMS, ELTYPE <: Real, DC, SE, K, V, COR, C} end end -create_cache(correction, density, NDIMS, nparticles) = (;) +create_cache_wcsph(correction, density, NDIMS, nparticles) = (;) -function create_cache(::ShepardKernelCorrection, density, NDIMS, n_particles) +function create_cache_wcsph(::ShepardKernelCorrection, density, NDIMS, n_particles) (; kernel_correction_coefficient=similar(density)) end -function create_cache(::KernelGradientCorrection, density, NDIMS, n_particles) +function create_cache_wcsph(::KernelGradientCorrection, density, NDIMS, n_particles) dw_gamma = Array{Float64}(undef, NDIMS, n_particles) (; kernel_correction_coefficient=similar(density), dw_gamma) end -function create_cache(n_particles, ELTYPE, ::SummationDensity) +function create_cache_wcsph(n_particles, ELTYPE, ::SummationDensity) density = Vector{ELTYPE}(undef, n_particles) return (; density) end -function create_cache(n_particles, ELTYPE, ::ContinuityDensity) +function create_cache_wcsph(n_particles, ELTYPE, ::ContinuityDensity) # Density in this case is added to the end of 'v' and allocated by modifying 'v_nvariables'. return (;) end