Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/literate/src/tut_custom_kernel.jl
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,13 @@ nothing # hide
# `examples/fluid/dam_break_2d.jl` with our custom kernel and the corresponding
# smoothing length.
# ```@cast @__NAME__; width=100, height=50, delay=0, loop=true, loop_delay=5
# trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid", "dam_break_2d.jl"),
# trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid", "dam_break_2d.jl");
# smoothing_kernel=MyGaussianKernel(),
# smoothing_length=smoothing_length);
# smoothing_length);
# ```
trixi_include(joinpath(examples_dir(), "fluid", "dam_break_2d.jl"), #!md
trixi_include(joinpath(examples_dir(), "fluid", "dam_break_2d.jl"); #!md
smoothing_kernel=MyGaussianKernel(), #!md
smoothing_length=smoothing_length) #!md
smoothing_length) #!md

# See [Visualization](@ref) for how to visualize the final solution.
# For the simplest visualization, we can use [Plots.jl](https://docs.juliaplots.org/stable/):
Expand Down
48 changes: 24 additions & 24 deletions docs/literate/src/tut_packing.jl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ signed_distance_field = SignedDistanceField(geometry, particle_spacing;
# We can also visualize the SDF by simply creating an `InitialCondition` from the sampled points and plot it.
# The color coding represents the signed distance to the geometry surface.
sdf_ic = InitialCondition(; coordinates=stack(signed_distance_field.positions),
density=1.0, particle_spacing=particle_spacing)
density=1.0, particle_spacing)

plot(sdf_ic, zcolor=signed_distance_field.distances, label=nothing, color=:coolwarm)
plot!(geometry, linestyle=:dash, label=nothing, showaxis=false, color=:black,
Expand All @@ -64,7 +64,7 @@ signed_distance_field = SignedDistanceField(geometry, particle_spacing;

# We can see in the plot that the SDF has been extended outwards to twice `max_signed_distance`.
sdf_ic = InitialCondition(; coordinates=stack(signed_distance_field.positions),
density=1.0, particle_spacing=particle_spacing)
density=1.0, particle_spacing)

plot(sdf_ic, zcolor=signed_distance_field.distances, label=nothing, color=:coolwarm)

Expand Down Expand Up @@ -105,7 +105,7 @@ point_in_geometry_algorithm = WindingNumberJacobson(; geometry)
# This function creates an [`InitialCondition`](@ref InitialCondition) for the interior particles.
# Here, we need to specify `particle_spacing` and `density`. For further arguments, please refer to
# the documentation of [ComplexShape](@ref ComplexShape) or [InitialCondition](@ref InitialCondition).
shape_sampled = ComplexShape(geometry; particle_spacing, density=density,
shape_sampled = ComplexShape(geometry; particle_spacing, density,
point_in_geometry_algorithm)

# If we want to assign the mass of each sampled particle consistently with its density,
Expand Down Expand Up @@ -147,8 +147,8 @@ smoothing_length = 0.8 * particle_spacing
# Now we can create the packing system. For learning purposes, let’s first try
# passing no signed distance field (SDF) and see what happens.
packing_system = ParticlePackingSystem(shape_sampled;
smoothing_kernel=smoothing_kernel,
smoothing_length=smoothing_length,
smoothing_kernel,
smoothing_length,
signed_distance_field=nothing, background_pressure)

# We now proceed with the familiar steps
Expand All @@ -164,7 +164,7 @@ callbacks = CallbackSet(UpdateCallback())
time_integrator = RDPK3SpFSAL35()

sol = solve(ode, time_integrator;
abstol=1e-7, reltol=1e-4, save_everystep=false, maxiters=maxiters,
abstol=1e-7, reltol=1e-4, save_everystep=false, maxiters,
callback=callbacks)

packed_ic = InitialCondition(sol, packing_system, semi)
Expand All @@ -177,8 +177,8 @@ plot!(geometry, seriestype=:path, linewidth=2, color=:black, label=nothing)

# We therefore add an SDF for the geometry and repeat the same procedure.
packing_system = ParticlePackingSystem(shape_sampled;
smoothing_kernel=smoothing_kernel,
smoothing_length=smoothing_length,
smoothing_kernel,
smoothing_length,
signed_distance_field,
background_pressure)

Expand All @@ -193,7 +193,7 @@ callbacks = CallbackSet(UpdateCallback())
time_integrator = RDPK3SpFSAL35()

sol = solve(ode, time_integrator;
abstol=1e-7, reltol=1e-4, save_everystep=false, maxiters=maxiters,
abstol=1e-7, reltol=1e-4, save_everystep=false, maxiters,
callback=callbacks)

packed_ic = InitialCondition(sol, packing_system, semi)
Expand All @@ -216,8 +216,8 @@ plot!(geometry, seriestype=:path, color=:black, label=nothing, linewidth=2)
# geometry size in this example, we will choose `0.7`.
boundary_system = ParticlePackingSystem(boundary_sampled;
is_boundary=true,
smoothing_kernel=smoothing_kernel,
smoothing_length=smoothing_length,
smoothing_kernel,
smoothing_length,
boundary_compress_factor=0.7,
signed_distance_field, background_pressure)

Expand All @@ -232,7 +232,7 @@ callbacks = CallbackSet(UpdateCallback())
time_integrator = RDPK3SpFSAL35()

sol = solve(ode, time_integrator;
abstol=1e-7, reltol=1e-4, save_everystep=false, maxiters=maxiters,
abstol=1e-7, reltol=1e-4, save_everystep=false, maxiters,
callback=callbacks)

packed_ic = InitialCondition(sol, packing_system, semi)
Expand All @@ -255,8 +255,8 @@ plot!(geometry, seriestype=:path, color=:black, linestyle=:dash, linewidth=2, la
# Therefore, we set `fixed_system=true` so that this system is not integrated further
# but instead serves as a static boundary for the packing of other domains.
fixed_system = ParticlePackingSystem(packed_ic;
smoothing_kernel=smoothing_kernel,
smoothing_length=smoothing_length,
smoothing_kernel,
smoothing_length,
signed_distance_field=nothing,
background_pressure,
fixed_system=true)
Expand All @@ -274,8 +274,8 @@ plot(sampled_outer_domain, packed_ic)

# Next, we create a packing system for the outer domain.
packing_system = ParticlePackingSystem(sampled_outer_domain;
smoothing_kernel=smoothing_kernel,
smoothing_length=smoothing_length,
smoothing_kernel,
smoothing_length,
signed_distance_field=nothing,
background_pressure)

Expand All @@ -294,7 +294,7 @@ callbacks = CallbackSet(UpdateCallback())
time_integrator = RDPK3SpFSAL35()

sol_1 = solve(ode, time_integrator; abstol=1e-7, reltol=1e-4,
save_everystep=false, maxiters=maxiters, callback=callbacks)
save_everystep=false, maxiters, callback=callbacks)

packed_outer_domain = InitialCondition(sol_1, packing_system, semi)

Expand Down Expand Up @@ -324,21 +324,21 @@ plot(pack_domain, fixed_domain, packed_ic)
# We can now treat the particles outside the window, along with the already
# finalized configuration of the complex geometry, as fixed systems:
fixed_system_1 = ParticlePackingSystem(fixed_domain;
smoothing_kernel=smoothing_kernel,
smoothing_length=smoothing_length,
smoothing_kernel,
smoothing_length,
signed_distance_field=nothing,
background_pressure, fixed_system=true)

fixed_system_2 = ParticlePackingSystem(packed_ic;
smoothing_kernel=smoothing_kernel,
smoothing_length=smoothing_length,
smoothing_kernel,
smoothing_length,
signed_distance_field=nothing,
background_pressure, fixed_system=true)

# The window that we want to pack is passed to a moving packing system:
packing_system = ParticlePackingSystem(pack_domain;
smoothing_kernel=smoothing_kernel,
smoothing_length=smoothing_length,
smoothing_kernel,
smoothing_length,
signed_distance_field=nothing,
background_pressure)

Expand All @@ -352,7 +352,7 @@ callbacks = CallbackSet(UpdateCallback())
time_integrator = RDPK3SpFSAL35()

sol_2 = solve(ode, time_integrator; abstol=1e-7, reltol=1e-4,
save_everystep=false, maxiters=maxiters, callback=callbacks)
save_everystep=false, maxiters, callback=callbacks)

packed_fluid_domain = InitialCondition(sol_2, packing_system, semi)

Expand Down
37 changes: 20 additions & 17 deletions docs/literate/src/tut_rigid_body_fsi.jl
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ sound_speed = 100.0
state_equation = StateEquationCole(; sound_speed, reference_density=fluid_density,
exponent=1)

tank = RectangularTank(fluid_particle_spacing, initial_fluid_size, tank_size, fluid_density,
n_layers=boundary_layers, spacing_ratio=spacing_ratio,
tank = RectangularTank(fluid_particle_spacing, initial_fluid_size, tank_size, fluid_density;
n_layers=boundary_layers, spacing_ratio,
faces=(true, true, true, false),
acceleration=(0.0, -gravity), state_equation=state_equation)
acceleration=(0.0, -gravity), state_equation)
nothing # hide

# ## Rigid body geometry
Expand Down Expand Up @@ -97,10 +97,13 @@ fluid_density_calculator = ContinuityDensity()
viscosity = ArtificialViscosityMonaghan(alpha=0.02, beta=0.0)
density_diffusion = DensityDiffusionMolteniColagrossi(delta=0.1)

fluid_system = WeaklyCompressibleSPHSystem(tank.fluid, fluid_density_calculator,
state_equation, fluid_smoothing_kernel,
fluid_smoothing_length, viscosity=viscosity,
density_diffusion=density_diffusion,
fluid_system = WeaklyCompressibleSPHSystem(tank.fluid;
smoothing_kernel=fluid_smoothing_kernel,
smoothing_length=fluid_smoothing_length,
density_calculator=fluid_density_calculator,
state_equation,
viscosity,
density_diffusion,
acceleration=(0.0, -gravity))
nothing # hide

Expand Down Expand Up @@ -166,10 +169,10 @@ nothing # hide
boundary_density_calculator = AdamiPressureExtrapolation()
tank_boundary_model = BoundaryModelDummyParticles(tank.boundary.density,
tank.boundary.mass,
state_equation=state_equation,
boundary_density_calculator,
fluid_smoothing_kernel,
fluid_smoothing_length)
fluid_smoothing_length;
state_equation)

boundary_system = WallBoundarySystem(tank.boundary, tank_boundary_model)
nothing # hide
Expand All @@ -180,10 +183,10 @@ function rigid_body_boundary_model(shape)
structure_particle_spacing^ndims(fluid_system)

return BoundaryModelDummyParticles(hydrodynamic_densities, hydrodynamic_masses,
state_equation=state_equation,
boundary_density_calculator,
fluid_smoothing_kernel,
fluid_smoothing_length)
fluid_smoothing_length;
state_equation)
end

square1_boundary_model = rigid_body_boundary_model(square1)
Expand Down Expand Up @@ -236,12 +239,12 @@ nothing # hide

rigid_body_system_1_step3 = RigidBodySystem(square1;
boundary_model=square1_boundary_model,
contact_model=contact_model,
contact_model,
acceleration=(0.0, -gravity),
particle_spacing=structure_particle_spacing)
rigid_body_system_2_step3 = RigidBodySystem(square2;
boundary_model=square2_boundary_model,
contact_model=contact_model,
contact_model,
acceleration=(0.0, -gravity),
particle_spacing=structure_particle_spacing)
nothing # hide
Expand Down Expand Up @@ -303,12 +306,12 @@ nothing # hide

rigid_body_system_1_step4 = RigidBodySystem(circle1;
boundary_model=circle1_boundary_model,
contact_model=contact_model,
contact_model,
acceleration=(0.0, -gravity),
particle_spacing=structure_particle_spacing)
rigid_body_system_2_step4 = RigidBodySystem(circle2;
boundary_model=circle2_boundary_model,
contact_model=contact_model,
contact_model,
acceleration=(0.0, -gravity),
particle_spacing=structure_particle_spacing)
nothing # hide
Expand Down Expand Up @@ -361,7 +364,7 @@ small_sphere_systems = [begin
sphere_boundary_model = rigid_body_boundary_model(sphere)
RigidBodySystem(sphere;
boundary_model=sphere_boundary_model,
contact_model=contact_model,
contact_model,
acceleration=(0.0, -gravity),
particle_spacing=structure_particle_spacing)
end
Expand Down Expand Up @@ -420,7 +423,7 @@ hexagon_boundary_model = rigid_body_boundary_model(hexagon_shape)

hexagon_system = RigidBodySystem(hexagon_shape;
boundary_model=hexagon_boundary_model,
contact_model=contact_model,
contact_model,
acceleration=(0.0, -gravity),
particle_spacing=structure_particle_spacing)
#
Expand Down
18 changes: 10 additions & 8 deletions docs/literate/src/tut_setup.jl
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ nothing # hide
# fluid inside a rectangular tank, and supports a hydrostatic pressure gradient
# by passing a gravitational acceleration and a state equation (see above).
tank = RectangularTank(fluid_particle_spacing, initial_fluid_size, tank_size,
fluid_density, n_layers=boundary_layers,
acceleration=(0.0, -gravity), state_equation=state_equation)
fluid_density; n_layers=boundary_layers,
acceleration=(0.0, -gravity), state_equation)
nothing # hide
# A `RectangularTank` consists of two [`InitialCondition`](@ref)s, `tank.fluid` and `tank.boundary`.
# We can plot these initial conditions to visualize the initial setup.
Expand Down Expand Up @@ -120,10 +120,12 @@ nothing # hide
# The simulation quality greatly benefits from using [density diffusion](@ref density_diffusion).
fluid_density_calculator = ContinuityDensity()
density_diffusion = DensityDiffusionMolteniColagrossi(delta=0.1)
fluid_system = WeaklyCompressibleSPHSystem(tank.fluid, fluid_density_calculator,
state_equation, smoothing_kernel,
smoothing_length, viscosity=viscosity,
density_diffusion=density_diffusion,
fluid_system = WeaklyCompressibleSPHSystem(tank.fluid;
smoothing_kernel, smoothing_length,
density_calculator=fluid_density_calculator,
state_equation,
viscosity,
density_diffusion,
acceleration=(0.0, -gravity))
nothing # hide

Expand All @@ -136,9 +138,9 @@ nothing # hide
# We will use the [`BoundaryModelDummyParticles`](@ref) with [`AdamiPressureExtrapolation`](@ref).
# See [here](@ref boundary_models) for a comprehensive overview over boundary models.
boundary_model = BoundaryModelDummyParticles(tank.boundary.density, tank.boundary.mass,
state_equation=state_equation,
AdamiPressureExtrapolation(),
smoothing_kernel, smoothing_length)
smoothing_kernel, smoothing_length;
state_equation)
boundary_system = WallBoundarySystem(tank.boundary, boundary_model)
nothing # hide

Expand Down
8 changes: 4 additions & 4 deletions examples/dem/collapsing_sand_pile_3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ boundary_particles = floor_particles
contact_model = LinearContactModel(1e6)
damping_coefficient = 0.00001

sand_system = DEMSystem(sand_particles, contact_model;
damping_coefficient=damping_coefficient,
acceleration=acceleration, radius=0.4 * particle_spacing)
sand_system = DEMSystem(sand_particles; contact_model,
damping_coefficient,
acceleration, radius=0.4 * particle_spacing)

boundary_stiffness = 1.0e5
boundary_system = BoundaryDEMSystem(boundary_particles, boundary_stiffness)
boundary_system = BoundaryDEMSystem(boundary_particles; normal_stiffness=boundary_stiffness)

# ==========================================================================================
# ==== Simulation
Expand Down
4 changes: 2 additions & 2 deletions examples/dem/rectangular_tank_2d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ contact_model = HertzContactModel(10e9, 0.3)
# contact_model = LinearContactModel(2 * 10e5)

# Construct the rock system using the new DEMSystem signature.
rock_system = DEMSystem(tank.fluid, contact_model; damping_coefficient=0.0001,
rock_system = DEMSystem(tank.fluid; contact_model, damping_coefficient=0.0001,
acceleration=(0.0, gravity), radius=0.4 * particle_spacing)

# Construct the boundary system for the tank walls.
boundary_system = BoundaryDEMSystem(tank.boundary, 10e7)
boundary_system = BoundaryDEMSystem(tank.boundary; normal_stiffness=10e7)

# ==========================================================================================
# ==== Simulation
Expand Down
Loading
Loading