Fix IC in open boundaries and add simple_advection_2d.jl#852
Fix IC in open boundaries and add simple_advection_2d.jl#852LasNikas wants to merge 6 commits intotrixi-framework:mainfrom
simple_advection_2d.jl#852Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #852 +/- ##
==========================================
+ Coverage 70.47% 70.50% +0.03%
==========================================
Files 106 106
Lines 6893 6897 +4
==========================================
+ Hits 4858 4863 +5
+ Misses 2035 2034 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
/run-gpu-tests |
|
|
||
| # ========================================================================================== | ||
| # ==== Resolution | ||
| particle_spacing = 0.01 | ||
|
|
||
| # 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 = 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 = 1.0 | ||
|
|
||
| boundary_size = (domain_size[1] + 2 * particle_spacing * open_boundary_layers, | ||
| domain_size[2]) | ||
|
|
||
| fluid_density = 1000.0 | ||
|
|
||
| sound_speed = 10 * prescribed_velocity | ||
|
|
||
| state_equation = nothing | ||
|
|
||
| pipe = RectangularTank(particle_spacing, domain_size, boundary_size, fluid_density, | ||
| velocity=[prescribed_velocity, 0.0], | ||
| 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 | ||
|
|
||
| NDIMS = ndims(pipe.fluid) | ||
|
|
||
| n_buffer_particles = pipe.n_particles_per_dimension[2]^(NDIMS - 1) | ||
|
|
||
| # ========================================================================================== | ||
| # ==== Fluid | ||
| wcsph = true | ||
|
|
||
| smoothing_length = 1.2 * particle_spacing | ||
| smoothing_kernel = SchoenbergQuinticSplineKernel{NDIMS}() | ||
|
|
||
| fluid_density_calculator = ContinuityDensity() | ||
|
|
||
| kinematic_viscosity = prescribed_velocity * domain_size[2] / reynolds_number | ||
|
|
||
| viscosity = ViscosityAdami(nu=kinematic_viscosity) | ||
|
|
||
| # Alternatively the WCSPH scheme can be used | ||
| if wcsph | ||
| state_equation = StateEquationCole(; sound_speed, reference_density=fluid_density, | ||
| exponent=1) | ||
|
|
||
| density_diffusion = DensityDiffusionMolteniColagrossi(delta=0.1) | ||
|
|
||
| fluid_system = WeaklyCompressibleSPHSystem(pipe.fluid, fluid_density_calculator, | ||
| state_equation, smoothing_kernel, | ||
| density_diffusion=density_diffusion, | ||
| smoothing_length, viscosity=viscosity, | ||
| buffer_size=n_buffer_particles) | ||
| else | ||
| fluid_system = EntropicallyDampedSPHSystem(pipe.fluid, smoothing_kernel, | ||
| smoothing_length, | ||
| sound_speed, viscosity=viscosity, | ||
| density_calculator=fluid_density_calculator, | ||
| buffer_size=n_buffer_particles) | ||
| end | ||
|
|
||
| # ========================================================================================== | ||
| # ==== Open Boundary | ||
|
|
||
| velocity_function2d(pos, t) = SVector(prescribed_velocity, 0.0) | ||
|
|
||
| open_boundary_model = BoundaryModelTafuni() | ||
|
|
||
| boundary_type_in = InFlow() | ||
| plane_in = ([0.0, 0.0], [0.0, domain_size[2]]) | ||
| inflow = BoundaryZone(; plane=plane_in, plane_normal=flow_direction, open_boundary_layers, | ||
| density=fluid_density, particle_spacing, | ||
| boundary_type=boundary_type_in) | ||
|
|
||
| open_boundary_in = OpenBoundarySPHSystem(inflow; fluid_system, | ||
| boundary_model=open_boundary_model, | ||
| buffer_size=n_buffer_particles, | ||
| reference_velocity=velocity_function2d) | ||
|
|
||
| boundary_type_out = OutFlow() | ||
| plane_out = ([domain_size[1], 0.0], [domain_size[1], domain_size[2]]) | ||
| outflow = BoundaryZone(; plane=plane_out, plane_normal=(-flow_direction), | ||
| open_boundary_layers, density=fluid_density, particle_spacing, | ||
| boundary_type=boundary_type_out) | ||
| open_boundary_out = OpenBoundarySPHSystem(outflow; fluid_system, | ||
| boundary_model=open_boundary_model, | ||
| buffer_size=n_buffer_particles, | ||
| reference_velocity=velocity_function2d) | ||
|
|
||
| # ========================================================================================== | ||
| # ==== Boundary | ||
| boundary_model = BoundaryModelDummyParticles(pipe.boundary.density, pipe.boundary.mass, | ||
| AdamiPressureExtrapolation(), | ||
| state_equation=state_equation, | ||
| smoothing_kernel, smoothing_length) | ||
|
|
||
| boundary_system = BoundarySPHSystem(pipe.boundary, boundary_model) | ||
|
|
||
| # ========================================================================================== | ||
| # ==== Simulation | ||
| min_corner = minimum(pipe.boundary.coordinates .- particle_spacing, dims=2) | ||
| max_corner = maximum(pipe.boundary.coordinates .+ particle_spacing, dims=2) | ||
|
|
||
| nhs = GridNeighborhoodSearch{NDIMS}(; cell_list=FullGridCellList(; min_corner, max_corner), | ||
| update_strategy=ParallelUpdate()) | ||
|
|
||
| semi = Semidiscretization(fluid_system, open_boundary_in, open_boundary_out, | ||
| boundary_system, neighborhood_search=nhs, | ||
| parallelization_backend=PolyesterBackend()) | ||
|
|
||
| ode = semidiscretize(semi, tspan) | ||
|
|
||
| info_callback = InfoCallback(interval=100) | ||
| saving_callback = SolutionSavingCallback(dt=0.02, prefix="") | ||
|
|
||
| particle_shifting = nothing | ||
|
|
||
| extra_callback = nothing | ||
|
|
||
| callbacks = CallbackSet(info_callback, saving_callback, UpdateCallback(), | ||
| particle_shifting, extra_callback) | ||
|
|
||
| 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); |
There was a problem hiding this comment.
Isn't this just another pipe? Can't you base it on pipe_flow_2d.jl?
There was a problem hiding this comment.
I want a clean, simple example for the open boundaries. I've run into issues with trixi_include so many times and ended up with unnecessarily frustrating bugs: you simply forget to enable or disable something. For complexity reasons, it's also better for beginners to have a simple example.
There was a problem hiding this comment.
I think this is more a problem with the structure of our setup files. But anyway I think it would be better to further simplify pipe_flow_2d and base your setup on that.
ec13ba7 to
7f74e25
Compare
| # This is a simple advection example with open boundaries. The setup is similar to | ||
| # `periodic_channel_2d.jl`, but uses open boundaries instead of periodic ones. |
|
superseded by #866 |
* swap extrapolation * swap density pressure * adapt docs * rm example * fix missing nhs update * implement different mirror methods * add docs * fix tests * fix typos * add docs * add tests * apply formatter * add `average_velocity!` for `BoundaryModelLastiwka` * fix * add interpolation functions * restructure again * fix gpu bugs * remove unnecessary argument * fix gpu again * fix gpu * implement suggestions * fix * add comments * implement suggestions * first prototype: NOT VALIDATED YET * fix avg vel in LastiwkaModel * fix avg in mirroring * fix tests * adapt example file * fix allocations * fix gpu * first GPU working prototype * improve API * fix tests * rm export * fix * fix type stability * implement suggestions * rm ref * format * Rename 'tlsph' to 'place_on_shell' (#814) * rename * format * forgot some * format * naming * forgot some more * fix test * incorporate review comments * format --------- Co-authored-by: Niklas Neher <73897120+LasNikas@users.noreply.github.com> * fix merge bugs * supersede #852 * supersede #850 * fix * rename boundary models * fix? * fix tests * Rename 'tlsph' to 'place_on_shell' (#814) * rename * format * forgot some * format * naming * forgot some more * fix test * incorporate review comments * format --------- Co-authored-by: Niklas Neher <73897120+LasNikas@users.noreply.github.com> * fix characteristics * revise pipe flow example * fix include bug * Rename 'tlsph' to 'place_on_shell' (#814) * rename * format * forgot some * format * naming * forgot some more * fix test * incorporate review comments * format --------- Co-authored-by: Niklas Neher <73897120+LasNikas@users.noreply.github.com> * Combine PST and TVF into a unified framework (#884) * Combine PST and TVF into a unified framework * Require update callback for PST * Fix WCSPH * Update PST only in callback * Fix EDAC * Update docs * Fix alle example files * Fix tests * Fix periodic channel * Fix docs * Update news * Fix tests * Fix example file * add doc strings * implement suggestions * remove duplicated system * rm unnecessary variable * apply formatter * set pressure for WCSPH * setter for open boundary * rename reference values * fix gpu tests * fix sign * implement suggestions * fix unit tests * revise doc strings * add NEWS entry * update NEWS --------- Co-authored-by: LasNikas <niklas.nehe@web.de> Co-authored-by: Sven Berger <berger.sven@gmail.com> Co-authored-by: Erik Faulhaber <44124897+efaulhaber@users.noreply.github.com>
The additional example
simple_advection_2d.jlis to quickly test (new) open boundaries and also to benchmark potential new open boundary implementations.