-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* implement `ExtrudeFace` * use `sample_face` in `interpolate_plane_3d` * add docs * add tests * fix bug * create `OpenBoundarySPHSystem` * export OpenBoundarySPHSystem * fix bug * add `tlsph=true` * fix tuple bug * fix typo * fix again * fix for tests * fix layers * calculate particle spacing differently * add show-tests * add `within_boundary_zone` * change `floor` to `ceil` * boundary zone tests * add `evaluate_characteristics` * add tests * add reference functions * add `update_quantities!` * add buffer * add `SystemBuffer` tests * cosmetic change in tests * change `round` to `isapprox` * add update callback * add `UpdateCallback` * add `update_open_boundaries` * fix bugs * add timers * write prescribed quantities * improve dispatching * add example `pipe_flow_2d.jl` * add docs `UpdateCallback` * add `UpdateCallback` * fix typo * apply formatter * modify system buffer * add docstring * add docs * fix tests * fix typos * apply formatter * fix tests * add comment * fix tests * remove update bool * adapt docstring * implement suggestions * fix test * add check if callback is used * add comments in example file * generic types * merge main * undo combining compact support with DEM * remove density and pressure setter * implement suggestions * fix tests * Revert "remove density and pressure setter" This reverts commit 0203a3a. * implement suggestions * rework in- and outflow * rename setter functions * rename function * adapt tests * add docs * rename function * apply formatter * fix tests * fix bug in plot recipes * apply formatter * implement suggestions for `boundary_zone.jl` * rename kwarg * implement suggestions * implement suggestions * modify `check_domain!` * add comments and check for fluid system with buffer * modify error message * fix tests * fix `callback_used` * using Measurements * fix tests * sqrt(eps()) * fix tests again * add doc to `boundary.md` * link single fluid system * fix tests * implement suggestions * fix tests * change the order of functions * modify example * fix tests * fix test again * implement doc suggestions * modify dos * fix typos * implement suggestions * implement suggestions * add EDAC to the example * implement suggestions * modify tests * adapt docs * add `initial_callback_flag` * add to `NEWS.md` and `README.md` * implement suggestions * fix typo
- Loading branch information
Showing
39 changed files
with
1,913 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
# 2D channel flow simulation with open boundaries. | ||
|
||
using TrixiParticles | ||
using OrdinaryDiffEq | ||
|
||
# ========================================================================================== | ||
# ==== Resolution | ||
particle_spacing = 0.05 | ||
|
||
# Make sure that the kernel support of fluid particles at a boundary is always fully sampled | ||
boundary_layers = 3 | ||
|
||
# Make sure that the kernel support of fluid particles at an open boundary is always | ||
# fully sampled. | ||
# Note: Due to the dynamics at the inlets and outlets of open boundaries, | ||
# it is recommended to use `open_boundary_layers > boundary_layers` | ||
open_boundary_layers = 6 | ||
|
||
# ========================================================================================== | ||
# ==== Experiment Setup | ||
tspan = (0.0, 2.0) | ||
|
||
# Boundary geometry and initial fluid particle positions | ||
domain_size = (1.0, 0.4) | ||
|
||
flow_direction = [1.0, 0.0] | ||
reynolds_number = 100 | ||
const prescribed_velocity = 2.0 | ||
|
||
boundary_size = (domain_size[1] + 2 * particle_spacing * open_boundary_layers, | ||
domain_size[2]) | ||
|
||
fluid_density = 1000.0 | ||
|
||
# For this particular example, it is necessary to have a background pressure. | ||
# Otherwise the suction at the outflow is to big and the simulation becomes unstable. | ||
pressure = 1000.0 | ||
|
||
sound_speed = 10 * prescribed_velocity | ||
|
||
state_equation = StateEquationCole(; sound_speed, reference_density=fluid_density, | ||
exponent=7, background_pressure=pressure) | ||
|
||
pipe = RectangularTank(particle_spacing, domain_size, boundary_size, fluid_density, | ||
pressure=pressure, n_layers=boundary_layers, | ||
faces=(false, false, true, true)) | ||
|
||
# Shift pipe walls in negative x-direction for the inflow | ||
pipe.boundary.coordinates[1, :] .-= particle_spacing * open_boundary_layers | ||
|
||
n_buffer_particles = 4 * pipe.n_particles_per_dimension[2] | ||
|
||
# ========================================================================================== | ||
# ==== Fluid | ||
smoothing_length = 3.0 * particle_spacing | ||
smoothing_kernel = WendlandC2Kernel{2}() | ||
|
||
fluid_density_calculator = ContinuityDensity() | ||
|
||
kinematic_viscosity = prescribed_velocity * domain_size[2] / reynolds_number | ||
|
||
viscosity = ViscosityAdami(nu=kinematic_viscosity) | ||
|
||
fluid_system = EntropicallyDampedSPHSystem(pipe.fluid, smoothing_kernel, smoothing_length, | ||
sound_speed, viscosity=viscosity, | ||
density_calculator=fluid_density_calculator, | ||
buffer_size=n_buffer_particles) | ||
|
||
# Alternatively the WCSPH scheme can be used | ||
# alpha = 8 * kinematic_viscosity / (smoothing_length * sound_speed) | ||
# viscosity = ArtificialViscosityMonaghan(; alpha, beta=0.0) | ||
|
||
# fluid_system = WeaklyCompressibleSPHSystem(pipe.fluid, fluid_density_calculator, | ||
# state_equation, smoothing_kernel, | ||
# smoothing_length, viscosity=viscosity, | ||
# buffer_size=n_buffer_particles) | ||
|
||
# ========================================================================================== | ||
# ==== Open Boundary | ||
function velocity_function(pos, t) | ||
# Use this for a time-dependent inflow velocity | ||
# return SVector(0.5prescribed_velocity * sin(2pi * t) + prescribed_velocity, 0) | ||
|
||
return SVector(prescribed_velocity, 0.0) | ||
end | ||
|
||
inflow = InFlow(; plane=([0.0, 0.0], [0.0, domain_size[2]]), flow_direction, | ||
open_boundary_layers, density=fluid_density, particle_spacing) | ||
|
||
open_boundary_in = OpenBoundarySPHSystem(inflow; sound_speed, fluid_system, | ||
buffer_size=n_buffer_particles, | ||
reference_pressure=pressure, | ||
reference_velocity=velocity_function) | ||
|
||
outflow = OutFlow(; plane=([domain_size[1], 0.0], [domain_size[1], domain_size[2]]), | ||
flow_direction, open_boundary_layers, density=fluid_density, | ||
particle_spacing) | ||
|
||
open_boundary_out = OpenBoundarySPHSystem(outflow; sound_speed, fluid_system, | ||
buffer_size=n_buffer_particles, | ||
reference_pressure=pressure, | ||
reference_velocity=velocity_function) | ||
|
||
# ========================================================================================== | ||
# ==== Boundary | ||
|
||
boundary_model = BoundaryModelDummyParticles(pipe.boundary.density, pipe.boundary.mass, | ||
AdamiPressureExtrapolation(), | ||
state_equation=state_equation, | ||
#viscosity=ViscosityAdami(nu=1e-4), | ||
smoothing_kernel, smoothing_length) | ||
|
||
boundary_system = BoundarySPHSystem(pipe.boundary, boundary_model) | ||
|
||
# ========================================================================================== | ||
# ==== Simulation | ||
semi = Semidiscretization(fluid_system, open_boundary_in, open_boundary_out, | ||
boundary_system) | ||
|
||
ode = semidiscretize(semi, tspan) | ||
|
||
info_callback = InfoCallback(interval=100) | ||
saving_callback = SolutionSavingCallback(dt=0.02, prefix="") | ||
|
||
callbacks = CallbackSet(info_callback, saving_callback, UpdateCallback()) | ||
|
||
sol = solve(ode, RDPK3SpFSAL35(), | ||
abstol=1e-5, # Default abstol is 1e-6 (may need to be tuned to prevent boundary penetration) | ||
reltol=1e-3, # Default reltol is 1e-3 (may need to be tuned to prevent boundary penetration) | ||
dtmax=1e-2, # Limit stepsize to prevent crashing | ||
save_everystep=false, callback=callbacks); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.