Skip to content

Commit afe2196

Browse files
committed
adapt for tests
1 parent 226e23f commit afe2196

File tree

5 files changed

+56
-45
lines changed

5 files changed

+56
-45
lines changed

src/TrixiParticles.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ include("general/system.jl")
4040
# `util.jl` needs to be next because of the macros `@trixi_timeit` and `@threaded`
4141
include("util.jl")
4242
include("preprocessing/preprocessing.jl")
43-
include("multi_resolution/multi_resolution.jl")
4443
include("callbacks/callbacks.jl")
4544
include("general/general.jl")
4645
include("setups/setups.jl")
@@ -52,6 +51,7 @@ include("general/semidiscretization.jl")
5251
include("general/gpu.jl")
5352
include("visualization/write2vtk.jl")
5453
include("visualization/recipes_plots.jl")
54+
include("multi_resolution/multi_resolution.jl")
5555

5656
export Semidiscretization, semidiscretize, restart_with!
5757
export InitialCondition
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
include("resize.jl")
2+
include("particle_refinement.jl")
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
struct ParticleRefinement
2+
n_particles_before_resize :: Ref{Int}
3+
n_new_particles :: Ref{Int}
4+
end
5+
6+
function ParticleRefinement()
7+
return ParticleRefinement(Ref(0), Ref(0))
8+
end

src/multi_resolution/resize.jl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,22 +77,24 @@ resize!(system, ::Nothing, capacity_system) = system
7777
function resize!(system::WeaklyCompressibleSPHSystem, refinement, capacity_system::Int)
7878
(; mass, pressure, cache, density_calculator) = system
7979

80-
refinement.n_particles_before_resize = nparticles(system)
80+
refinement.n_particles_before_resize[] = nparticles(system)
8181

8282
resize!(mass, capacity_system)
8383
resize!(pressure, capacity_system)
8484
resize_density!(system, capacity_system, density_calculator)
85-
resize_cache!(system, cache, n)
85+
# TODO
86+
# resize_cache!(system, cache, n)
8687
end
8788

8889
function resize!(system::EntropicallyDampedSPHSystem, refinement, capacity_system::Int)
8990
(; mass, cache, density_calculator) = system
9091

91-
refinement.n_particles_before_resize = nparticles(system)
92+
refinement.n_particles_before_resize[] = nparticles(system)
9293

9394
resize!(mass, capacity_system)
9495
resize_density!(system, capacity_system, density_calculator)
95-
resize_cache!(system, capacity_system)
96+
# TODO
97+
# resize_cache!(system, capacity_system)
9698

9799
return system
98100
end
@@ -166,5 +168,5 @@ end
166168
@inline capacity(system, ::Nothing) = nparticles(system)
167169

168170
@inline function capacity(system, particle_refinement)
169-
return particle_refinement.n_new_particles + nparticles(system)
171+
return particle_refinement.n_new_particles[] + nparticles(system)
170172
end

src/schemes/fluid/entropically_damped_sph/system.jl

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ See [Entropically Damped Artificial Compressibility for SPH](@ref edac) for more
4444
gravity-like source terms.
4545
"""
4646
struct EntropicallyDampedSPHSystem{NDIMS, ELTYPE <: Real, IC, M, DC, K, V, TV,
47-
PF, ST, B, C} <: FluidSystem{NDIMS, IC}
47+
PF, ST, B, PR, C} <: FluidSystem{NDIMS, IC}
4848
initial_condition :: IC
4949
mass :: M # Vector{ELTYPE}: [particle]
5050
density_calculator :: DC
@@ -59,55 +59,55 @@ struct EntropicallyDampedSPHSystem{NDIMS, ELTYPE <: Real, IC, M, DC, K, V, TV,
5959
transport_velocity :: TV
6060
source_terms :: ST
6161
buffer :: B
62+
particle_refinement :: PR
6263
cache :: C
64+
end
6365

64-
function EntropicallyDampedSPHSystem(initial_condition, smoothing_kernel,
65-
smoothing_length, sound_speed;
66-
pressure_acceleration=inter_particle_averaged_pressure,
67-
density_calculator=SummationDensity(),
68-
transport_velocity=nothing,
69-
alpha=0.5, viscosity=nothing,
70-
acceleration=ntuple(_ -> 0.0,
71-
ndims(smoothing_kernel)),
72-
source_terms=nothing, buffer_size=nothing)
73-
buffer = isnothing(buffer_size) ? nothing :
74-
SystemBuffer(nparticles(initial_condition), buffer_size)
66+
function EntropicallyDampedSPHSystem(initial_condition, smoothing_kernel,
67+
smoothing_length, sound_speed;
68+
pressure_acceleration=inter_particle_averaged_pressure,
69+
density_calculator=SummationDensity(),
70+
transport_velocity=nothing,
71+
alpha=0.5, viscosity=nothing,
72+
acceleration=ntuple(_ -> 0.0,
73+
ndims(smoothing_kernel)),
74+
particle_refinement=nothing,
75+
source_terms=nothing, buffer_size=nothing)
76+
buffer = isnothing(buffer_size) ? nothing :
77+
SystemBuffer(nparticles(initial_condition), buffer_size)
7578

76-
initial_condition = allocate_buffer(initial_condition, buffer)
79+
initial_condition = allocate_buffer(initial_condition, buffer)
7780

78-
NDIMS = ndims(initial_condition)
79-
ELTYPE = eltype(initial_condition)
81+
NDIMS = ndims(initial_condition)
82+
ELTYPE = eltype(initial_condition)
8083

81-
mass = copy(initial_condition.mass)
84+
mass = copy(initial_condition.mass)
8285

83-
if ndims(smoothing_kernel) != NDIMS
84-
throw(ArgumentError("smoothing kernel dimensionality must be $NDIMS for a $(NDIMS)D problem"))
85-
end
86+
if ndims(smoothing_kernel) != NDIMS
87+
throw(ArgumentError("smoothing kernel dimensionality must be $NDIMS for a $(NDIMS)D problem"))
88+
end
8689

87-
acceleration_ = SVector(acceleration...)
88-
if length(acceleration_) != NDIMS
89-
throw(ArgumentError("`acceleration` must be of length $NDIMS for a $(NDIMS)D problem"))
90-
end
90+
acceleration_ = SVector(acceleration...)
91+
if length(acceleration_) != NDIMS
92+
throw(ArgumentError("`acceleration` must be of length $NDIMS for a $(NDIMS)D problem"))
93+
end
9194

92-
pressure_acceleration = choose_pressure_acceleration_formulation(pressure_acceleration,
93-
density_calculator,
94-
NDIMS, ELTYPE,
95-
nothing)
95+
pressure_acceleration = choose_pressure_acceleration_formulation(pressure_acceleration,
96+
density_calculator,
97+
NDIMS, ELTYPE,
98+
nothing)
9699

97-
nu_edac = (alpha * smoothing_length * sound_speed) / 8
100+
nu_edac = (alpha * smoothing_length * sound_speed) /
101+
(2 * ndims(initial_condition) + 4)
98102

99-
cache = create_cache_density(initial_condition, density_calculator)
100-
cache = (; create_cache_edac(initial_condition, transport_velocity)..., cache...)
103+
cache = create_cache_density(initial_condition, density_calculator)
104+
cache = (; create_cache_edac(initial_condition, transport_velocity)..., cache...)
101105

102-
new{NDIMS, ELTYPE, typeof(initial_condition), typeof(mass),
103-
typeof(density_calculator), typeof(smoothing_kernel), typeof(viscosity),
104-
typeof(transport_velocity), typeof(pressure_acceleration), typeof(source_terms),
105-
typeof(buffer),
106-
typeof(cache)}(initial_condition, mass, density_calculator, smoothing_kernel,
107-
smoothing_length, sound_speed, viscosity, nu_edac, acceleration_,
108-
nothing, pressure_acceleration, transport_velocity, source_terms,
109-
buffer, cache)
110-
end
106+
return EntropicallyDampedSPHSystem(initial_condition, mass, density_calculator,
107+
smoothing_kernel, smoothing_length, sound_speed,
108+
viscosity, nu_edac, acceleration_, nothing,
109+
pressure_acceleration, transport_velocity,
110+
source_terms, buffer, particle_refinement, cache)
111111
end
112112

113113
function Base.show(io::IO, system::EntropicallyDampedSPHSystem)

0 commit comments

Comments
 (0)