Skip to content

Commit e970b59

Browse files
committed
Merge branch 'dev' of github.com:trixi-framework/TrixiParticles.jl into dev
2 parents e60a754 + 921bafc commit e970b59

24 files changed

Lines changed: 345 additions & 222 deletions

File tree

NEWS.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ used in the Julia ecosystem. Notable changes will be documented in this file for
2828
It is now possible to pass multiple `BoundaryZone`s to a single `OpenBoundarySystem`.
2929
Reference values are now assigned individually to each `BoundaryZone`. (#866)
3030

31+
- Rename keyword arguments `plane` and `plane_normal` for `BoundaryZone` to `boundary_face` and `face_normal` (#597).
32+
3133
- The argument of `TransportVelocityAdami` is now a keyword argument.
3234
`TransportVelocityAdami(1000.0)` now becomes
3335
`TransportVelocityAdami(background_pressure=1000.0)` (#884).

Project.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ RecipesBase = "3cdcf5f2-1ef4-517c-9805-6587b60abb01"
2727
Reexport = "189a3867-3050-52da-a836-e630ba90ab69"
2828
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
2929
StaticArrays = "90137ffa-7385-5640-81b9-e52037218182"
30+
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
3031
StrideArraysCore = "7792a7ef-975c-4747-a70f-980b88e8d1da"
3132
TimerOutputs = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f"
3233
TrixiBase = "9a0f1c46-06d5-4909-a5a3-ce25d3fa3284"

docs/src/systems/boundary.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,11 @@ Modules = [TrixiParticles]
233233
Pages = [joinpath("schemes", "boundary", "open_boundary", "boundary_zones.jl")]
234234
```
235235

236+
```@autodocs
237+
Modules = [TrixiParticles]
238+
Filter = t -> typeof(t) === typeof(TrixiParticles.planar_geometry_to_face)
239+
```
240+
236241
# [Open Boundary Models](@id open_boundary_models)
237242
We offer two models for open boundaries, with the choice depending on the specific problem and flow characteristics near the boundary:
238243
1. [**Method of characteristics**](@ref method_of_characteristics): The method of characteristics is typically used in problems where tracking of wave propagation

examples/fluid/pipe_flow_2d.jl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,9 @@ reference_velocity_in = velocity_function2d
113113
reference_pressure_in = nothing
114114
reference_density_in = nothing
115115
boundary_type_in = InFlow()
116-
plane_in = ([0.0, 0.0], [0.0, domain_size[2]])
117-
inflow = BoundaryZone(; plane=plane_in, plane_normal=flow_direction, open_boundary_layers,
118-
density=fluid_density, particle_spacing,
116+
face_in = ([0.0, 0.0], [0.0, domain_size[2]])
117+
inflow = BoundaryZone(; boundary_face=face_in, face_normal=flow_direction,
118+
open_boundary_layers, density=fluid_density, particle_spacing,
119119
reference_density=reference_density_in,
120120
reference_pressure=reference_pressure_in,
121121
reference_velocity=reference_velocity_in,
@@ -125,8 +125,8 @@ reference_velocity_out = nothing
125125
reference_pressure_out = nothing
126126
reference_density_out = nothing
127127
boundary_type_out = OutFlow()
128-
plane_out = ([min_coords_outlet[1], 0.0], [min_coords_outlet[1], domain_size[2]])
129-
outflow = BoundaryZone(; plane=plane_out, plane_normal=(-flow_direction),
128+
face_out = ([min_coords_outlet[1], 0.0], [min_coords_outlet[1], domain_size[2]])
129+
outflow = BoundaryZone(; boundary_face=face_out, face_normal=(-flow_direction),
130130
open_boundary_layers, density=fluid_density, particle_spacing,
131131
reference_density=reference_density_out,
132132
reference_pressure=reference_pressure_out,

examples/fluid/pipe_flow_3d.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ trixi_include(@__MODULE__, joinpath(examples_dir(), "fluid", "pipe_flow_2d.jl"),
4040
tspan=tspan, prescribed_velocity=prescribed_velocity,
4141
open_boundary_layers=open_boundary_layers, min_coords_inlet=min_coords_inlet,
4242
min_coords_outlet=min_coords_outlet,
43-
plane_in=([0.0, 0.0, 0.0], [0.0, domain_size[2], 0.0],
44-
[0.0, 0.0, domain_size[3]]),
45-
plane_out=([domain_size[1], 0.0, 0.0], [domain_size[1], domain_size[2], 0.0],
46-
[domain_size[1], 0.0, domain_size[3]]))
43+
face_in=([0.0, 0.0, 0.0], [0.0, domain_size[2], 0.0],
44+
[0.0, 0.0, domain_size[3]]),
45+
face_out=([domain_size[1], 0.0, 0.0], [domain_size[1], domain_size[2], 0.0],
46+
[domain_size[1], 0.0, domain_size[3]]))

src/TrixiParticles.jl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ using SciMLBase: CallbackSet, DiscreteCallback, DynamicalODEProblem, u_modified!
2727
get_du
2828
@reexport using StaticArrays: SVector
2929
using StaticArrays: @SMatrix, SMatrix, setindex
30+
using Statistics: Statistics
3031
using StrideArraysCore: PtrArray, StaticInt
3132
using TimerOutputs: TimerOutput, TimerOutputs, print_timer, reset_timer!, @notimeit
3233
using TrixiBase: @trixi_timeit, timer, timeit_debug_enabled,
@@ -92,7 +93,7 @@ export RectangularTank, RectangularShape, SphereShape, ComplexShape
9293
export ParticlePackingSystem, SignedDistanceField
9394
export WindingNumberHormann, WindingNumberJacobson
9495
export VoxelSphere, RoundSphere, reset_wall!, extrude_geometry, load_geometry,
95-
sample_boundary
96+
sample_boundary, planar_geometry_to_face
9697
export SourceTermDamping
9798
export ShepardKernelCorrection, KernelCorrection, AkinciFreeSurfaceCorrection,
9899
GradientCorrection, BlendedGradientCorrection, MixedKernelGradientCorrection

src/callbacks/post_process.jl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,10 @@ function (pp::PostprocessCallback)(integrator)
252252
system_index = system_indices(system, semi)
253253

254254
for (key, f) in pp.func
255-
result = custom_quantity(f, system, dv_ode, du_ode, v_ode, u_ode, semi, t)
256-
if result !== nothing
255+
result_ = custom_quantity(f, system, dv_ode, du_ode, v_ode, u_ode, semi, t)
256+
if result_ !== nothing
257+
# Transfer to CPU if data is on the GPU. Do nothing if already on CPU.
258+
result = transfer2cpu(result_)
257259
add_entry!(pp, string(key), t, result, filenames[system_index])
258260
new_data = true
259261
end

src/general/interpolation.jl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -628,6 +628,11 @@ end
628628
return (; velocity, jacobian, von_mises_stress, cauchy_stress)
629629
end
630630

631+
function interpolate_system!(cache, v, neighbor_system,
632+
point, neighbor, volume_b, W_ab, clip_negative_pressure)
633+
return cache
634+
end
635+
631636
@inline function interpolate_system!(cache, v, system::AbstractFluidSystem,
632637
point, neighbor, volume_b, W_ab,
633638
clip_negative_pressure)

src/io/io.jl

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,8 @@ function add_system_data!(system_data, system::OpenBoundarySystem)
135135
system_data["system_type"] = type2string(system)
136136
system_data["fluid_system_index"] = system.fluid_system_index[]
137137
system_data["smoothing_length"] = system.smoothing_length
138+
system_data["number_of_boundary_zones"] = length(system.boundary_zones)
138139
add_system_data!(system_data, system.boundary_model)
139-
140-
system_data["boundary_zones"] = Dict{String, Any}()
141-
for (indice, boundary_zone) in enumerate(system.boundary_zones)
142-
add_system_data!(system_data["boundary_zones"], boundary_zone, indice)
143-
end
144140
end
145141

146142
function add_system_data!(system_data, system::ParticlePackingSystem)
@@ -287,7 +283,7 @@ function add_system_data!(system_data, boundary_zone::BoundaryZone, indice)
287283
system_data[zone_name]["zone_origin"] = boundary_zone.zone_origin
288284
system_data[zone_name]["zone_width"] = boundary_zone.zone_width
289285
system_data[zone_name]["flow_direction"] = boundary_zone.flow_direction
290-
system_data[zone_name]["plane_normal"] = boundary_zone.plane_normal
286+
system_data[zone_name]["face_normal"] = boundary_zone.face_normal
291287
system_data[zone_name]["reference_values"] = boundary_zone.reference_values
292288
system_data[zone_name]["average_inflow_velocity"] = boundary_zone.average_inflow_velocity
293289
system_data[zone_name]["prescribed_density"] = boundary_zone.prescribed_density
@@ -299,8 +295,6 @@ function add_system_data!(system_data, motion::PrescribedMotion)
299295
system_data["prescribed_motion"] = Dict{String, Any}()
300296
system_data["prescribed_motion"]["model"] = type2string(motion)
301297
system_data["prescribed_motion"]["movement_function"] = type2string(motion.movement_function)
302-
system_data["prescribed_motion"]["is_moving"] = type2string(motion.is_moving)
303-
system_data["prescribed_motion"]["moving_particles"] = motion.moving_particles
304298
end
305299

306300
function add_system_data!(system_data, penalty_force::PenaltyForceGanzenmueller)

src/io/write_vtk.jl

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ function trixi2vtk(system_, dvdu_ode_, vu_ode_, semi_, t, periodic_box;
140140

141141
# Extract custom quantities for this system
142142
if !isempty(custom_quantities)
143-
dv_ode, du_ode = dvdu_ode_.x
144-
dv_ode, du_ode = transfer2cpu(dv_ode, du_ode)
143+
dv_ode_, du_ode_ = dvdu_ode_.x
144+
dv_ode, du_ode = transfer2cpu(dv_ode_, du_ode_)
145145

146146
for (key, quantity) in custom_quantities
147147
value = custom_quantity(quantity, system, dv_ode, du_ode, v_ode, u_ode,
@@ -173,8 +173,8 @@ function transfer2cpu(v_, u_, system_, semi_)
173173
end
174174

175175
function transfer2cpu(v_::AbstractGPUArray, u_)
176-
v = Adapt.adapt(Array, v_)
177-
u = Adapt.adapt(Array, u_)
176+
v = transfer2cpu(v_)
177+
u = transfer2cpu(u_)
178178

179179
return v, u
180180
end
@@ -183,6 +183,14 @@ function transfer2cpu(v_, u_)
183183
return v_, u_
184184
end
185185

186+
function transfer2cpu(a_::AbstractGPUArray)
187+
return Adapt.adapt(Array, a_)
188+
end
189+
190+
function transfer2cpu(a_)
191+
return a_
192+
end
193+
186194
function custom_quantity(quantity::AbstractArray, system, dv_ode, du_ode, v_ode, u_ode,
187195
semi, t)
188196
return quantity

0 commit comments

Comments
 (0)