-
Notifications
You must be signed in to change notification settings - Fork 21
Add vortex street example file #1221
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
efaulhaber
wants to merge
9
commits into
trixi-framework:main
Choose a base branch
from
efaulhaber:vortex-street
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+173
−0
Open
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
18195a5
Add vortex street example file
efaulhaber 0b86be4
Reformat
efaulhaber f373295
Implement copilot suggestion
efaulhaber fe2c37c
Merge branch 'main' into vortex-street
LasNikas f56b8b9
Implement suggestions
efaulhaber cd64dd2
Implement suggestions
efaulhaber 08e758d
Merge branch 'main' into vortex-street
LasNikas 9641b78
Merge branch 'main' into vortex-street
efaulhaber 8f6ab68
Merge branch 'vortex-street' of github.com:efaulhaber/TrixiParticles.…
efaulhaber File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,164 @@ | ||
| # ========================================================================================== | ||
| # 2D Vortex Street | ||
| # | ||
| # Based on: | ||
| # A. Tafuni, J. M. Domínguez, R. Vacondio, A. J. C. Crespo. | ||
| # "A versatile algorithm for the treatment of open boundary conditions in smoothed | ||
| # particle hydrodynamics GPU models". | ||
| # Computer Methods in Applied Mechanics and Engineering, Volume 342 (2018), pages 604-624. | ||
| # https://doi.org/10.1016/j.cma.2018.08.004 | ||
| # ========================================================================================== | ||
|
|
||
| using TrixiParticles | ||
| using OrdinaryDiffEqLowStorageRK | ||
|
|
||
| # ========================================================================================== | ||
| # ==== Resolution | ||
| particle_spacing_factor = 0.1 # Resolution in the paper is `0.01` (5M particles) | ||
|
|
||
| cylinder_diameter = 0.1 | ||
| particle_spacing = particle_spacing_factor * cylinder_diameter | ||
|
|
||
| # Make sure that the kernel support of fluid particles at a boundary is always fully sampled | ||
| boundary_layers = 4 | ||
|
|
||
| # 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 = 8 | ||
|
|
||
| # ========================================================================================== | ||
| # ==== Experiment Setup | ||
| tspan = (0.0, 4.0) | ||
|
|
||
| # We use a smaller domain for a faster runtime. The original domain size in the paper is | ||
| # domain_size = (25 * cylinder_diameter, 20 * cylinder_diameter) | ||
| domain_size = (20 * cylinder_diameter, 10 * cylinder_diameter) | ||
| open_boundary_size = (particle_spacing * open_boundary_layers, domain_size[2]) | ||
|
|
||
| flow_direction = SVector(1.0, 0.0) | ||
| reynolds_number = 200 | ||
| prescribed_velocity = 1.0 | ||
| fluid_density = 1000.0 | ||
| # Maximum velocity observed in the vortex street is typically around 1.5 | ||
| v_max = 1.5 | ||
| sound_speed = 10 * v_max | ||
|
|
||
| pipe = RectangularTank(particle_spacing, domain_size, domain_size, fluid_density; | ||
| n_layers=boundary_layers, | ||
| velocity=prescribed_velocity * flow_direction, | ||
| faces=(false, false, true, true), | ||
| coordinates_eltype=Float64) | ||
|
|
||
| min_coords_inlet = (-open_boundary_layers * particle_spacing, 0.0) | ||
| inlet = RectangularTank(particle_spacing, open_boundary_size, open_boundary_size, | ||
| fluid_density; n_layers=boundary_layers, | ||
| velocity=prescribed_velocity * flow_direction, | ||
| min_coordinates=min_coords_inlet, | ||
| faces=(false, false, true, true), | ||
| coordinates_eltype=Float64) | ||
|
|
||
| min_coords_outlet = (pipe.fluid_size[1], 0.0) | ||
| outlet = RectangularTank(particle_spacing, open_boundary_size, open_boundary_size, | ||
| fluid_density; n_layers=boundary_layers, | ||
| velocity=prescribed_velocity * flow_direction, | ||
| min_coordinates=min_coords_outlet, | ||
| faces=(false, false, true, true), | ||
| coordinates_eltype=Float64) | ||
|
|
||
| n_buffer_particles = nparticles(inlet.fluid) | ||
|
|
||
| cylinder_center = (5 * cylinder_diameter, domain_size[2] / 2) | ||
| cylinder = SphereShape(particle_spacing, cylinder_diameter / 2, | ||
| cylinder_center, fluid_density; sphere_type=RoundSphere()) | ||
|
|
||
| fluid = setdiff(pipe.fluid, cylinder) | ||
|
|
||
| # ========================================================================================== | ||
| # ==== Fluid | ||
| smoothing_length = 1.5 * particle_spacing | ||
| smoothing_kernel = WendlandC2Kernel{2}() | ||
|
|
||
| fluid_density_calculator = ContinuityDensity() | ||
|
|
||
| kinematic_viscosity = prescribed_velocity * cylinder_diameter / reynolds_number | ||
|
|
||
| state_equation = StateEquationCole(; sound_speed, reference_density=fluid_density, | ||
| exponent=1) | ||
| viscosity = ViscosityAdami(nu=kinematic_viscosity) | ||
| density_diffusion = DensityDiffusionMolteniColagrossi(delta=0.1) | ||
|
|
||
| shifting_technique = ParticleShiftingTechnique(; sound_speed_factor=0.2, v_max_factor=0) | ||
|
|
||
| fluid_system = WeaklyCompressibleSPHSystem(fluid; smoothing_kernel, smoothing_length, | ||
| density_calculator=fluid_density_calculator, | ||
| state_equation, density_diffusion, viscosity, | ||
| pressure_acceleration=tensile_instability_control, | ||
| shifting_technique, | ||
| buffer_size=n_buffer_particles) | ||
|
|
||
| # ========================================================================================== | ||
| # ==== Open Boundary | ||
| open_boundary_model = BoundaryModelMirroringTafuni(; mirror_method=ZerothOrderMirroring()) | ||
|
|
||
| face_in = ([0.0, 0.0], [0.0, domain_size[2]]) | ||
| inflow = BoundaryZone(; boundary_face=face_in, face_normal=flow_direction, | ||
|
efaulhaber marked this conversation as resolved.
|
||
| open_boundary_layers, density=fluid_density, particle_spacing, | ||
| reference_velocity=prescribed_velocity * flow_direction, | ||
| initial_condition=inlet.fluid) | ||
|
|
||
| face_out = ([min_coords_outlet[1], 0.0], [min_coords_outlet[1], domain_size[2]]) | ||
| outflow = BoundaryZone(; boundary_face=face_out, face_normal=(-flow_direction), | ||
| open_boundary_layers, density=fluid_density, particle_spacing, | ||
| initial_condition=outlet.fluid) | ||
|
|
||
| open_boundary = OpenBoundarySystem(inflow, outflow; fluid_system, | ||
| boundary_model=open_boundary_model, | ||
| pressure_acceleration=TrixiParticles.inter_particle_averaged_pressure, | ||
| buffer_size=n_buffer_particles) | ||
|
|
||
| # ========================================================================================== | ||
| # ==== Boundary | ||
| wall = union(pipe.boundary, inlet.boundary, outlet.boundary) | ||
| # Free-slip boundary condition for the wall. | ||
| boundary_model_wall = BoundaryModelDummyParticles(wall.density, wall.mass, | ||
| AdamiPressureExtrapolation(), | ||
| smoothing_kernel, smoothing_length; | ||
| state_equation) | ||
|
efaulhaber marked this conversation as resolved.
|
||
|
|
||
| boundary_system_wall = WallBoundarySystem(wall, boundary_model_wall) | ||
|
|
||
| # No-slip boundary condition for the cylinder. | ||
| boundary_model_cylinder = BoundaryModelDummyParticles(cylinder.density, cylinder.mass, | ||
| AdamiPressureExtrapolation(), | ||
| smoothing_kernel, smoothing_length; | ||
| state_equation, viscosity) | ||
|
|
||
| boundary_system_cylinder = WallBoundarySystem(cylinder, boundary_model_cylinder) | ||
|
efaulhaber marked this conversation as resolved.
|
||
|
|
||
| # ========================================================================================== | ||
| # ==== Simulation | ||
| min_corner = minimum(wall.coordinates .- particle_spacing, dims=2) | ||
| max_corner = maximum(wall.coordinates .+ particle_spacing, dims=2) | ||
|
|
||
| nhs = GridNeighborhoodSearch{2}(; cell_list=FullGridCellList(; min_corner, max_corner), | ||
| update_strategy=ParallelUpdate()) | ||
|
|
||
| semi = Semidiscretization(fluid_system, open_boundary, boundary_system_wall, | ||
| boundary_system_cylinder; neighborhood_search=nhs, | ||
| parallelization_backend=PolyesterBackend()) | ||
|
|
||
| ode = semidiscretize(semi, tspan) | ||
|
|
||
| info_callback = InfoCallback(interval=50) | ||
| saving_callback = SolutionSavingCallback(dt=0.02, prefix="") | ||
|
|
||
| extra_callback = nothing | ||
|
|
||
| callbacks = CallbackSet(info_callback, saving_callback, UpdateCallback(), extra_callback) | ||
|
|
||
| sol = solve(ode, RDPK3SpFSAL35(), | ||
| abstol=1e-6, # May need tuning to prevent boundary penetration | ||
| reltol=1e-4, # May need tuning to prevent boundary penetration | ||
| save_everystep=false, callback=callbacks); | ||
This file contains hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move down to where it is used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the "Experiment Setup" section. We always define values like flow direction and Reynolds number there.