-
Notifications
You must be signed in to change notification settings - Fork 15
Fix IC in open boundaries and add simple_advection_2d.jl
#852
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
Conversation
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 |
|
||
# ========================================================================================== | ||
# ==== 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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this just another pipe? Can't you base it on pipe_flow_2d.jl?
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.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
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.
Not the same style.
superseded by #866 |
The additional example
simple_advection_2d.jl
is to quickly test (new) open boundaries and also to benchmark potential new open boundary implementations.