Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 15 additions & 10 deletions examples/preprocessing/complex_shape_3d.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
#
# This example demonstrates how to:
# 1. Load a 3D geometry from an STL file (e.g., a sphere).
# 2. Sample particles either as a fluid volume within this geometry or as a boundary layer.
# 3. Optionally create a Signed Distance Field (SDF) from the geometry.
# 2. Sample particles as a fluid volume within this geometry and as a boundary layer around it.
# 3. Use a Signed Distance Field (SDF) to sample the boundary layer.
# 4. Export the results to VTK files for visualization.
#
# The Winding Number algorithm is typically used for robust point-in-volume tests in 3D.
Expand All @@ -19,15 +19,20 @@ file = joinpath("examples", "preprocessing", "data", filename * ".stl")

geometry = load_geometry(file)

point_in_geometry_algorithm = WindingNumberJacobson(; geometry,
# winding_number_factor=0.4,
hierarchical_winding=true)
point_in_geometry_algorithm = WindingNumberJacobson(; geometry)
Comment thread
svchb marked this conversation as resolved.
Resolved

# Returns `InitialCondition`
shape_sampled = ComplexShape(geometry; particle_spacing, density=1.0,
boundary_thickness=5 * particle_spacing,
create_signed_distance_field=true,
sample_boundary=false, point_in_geometry_algorithm)
point_in_geometry_algorithm)

trixi2vtk(shape_sampled.initial_condition, filename="initial_condition_fluid")
trixi2vtk(shape_sampled.signed_distance_field)
# Boundary particles can be sampled in a layer of thickness `boundary_thickness`
# around the geometry by using a signed distance field (SDF).
boundary_thickness = 5 * particle_spacing
signed_distance_field = SignedDistanceField(geometry, particle_spacing;
use_for_boundary_packing=true,
max_signed_distance=boundary_thickness)
boundary_sampled = sample_boundary(signed_distance_field; boundary_density=1.0,
boundary_thickness)

trixi2vtk(shape_sampled)
trixi2vtk(boundary_sampled, filename="boundary_sampled")
9 changes: 9 additions & 0 deletions test/examples/examples.jl
Original file line number Diff line number Diff line change
Expand Up @@ -670,6 +670,15 @@
joinpath(examples_dir(), "preprocessing",
"packing_3d.jl"))
end
@trixi_testset "preprocessing/complex_shape_3d.jl" begin
@trixi_test_nowarn trixi_include(@__MODULE__,
joinpath(examples_dir(), "preprocessing",
"complex_shape_3d.jl"),
file=joinpath(examples_dir(), "preprocessing",
"data", "sphere.stl"))
@test nparticles(shape_sampled) > 0
@test nparticles(boundary_sampled) > 0
end
end

@testset verbose=true "DEM" begin
Expand Down
Loading