STLCutters.jl

Pere Antoni Martorell

1 Aug 2024

CIMNE UPC UPC Gridap

Outline

  • Why STLCutters.jl
  • What is STLCutters.jl
  • How to use and contribute
  • Future Work
  • Hands-on & Questions
P. A. Martorell | STLCutters.jl | 01-08-2024

Outline

  • Why STLCutters.jl
  • What is STLCutters.jl
  • How to use and contribute
  • Future Work
  • Hands-on & Questions
P. A. Martorell | STLCutters.jl | 01-08-2024

Unfitted Finite Elements

P. A. Martorell | STLCutters.jl | 01-08-2024

Unfitted Geometries

S. Badia, P. A. Martorell, F. Verdugo. Geometrical discretisations for unfitted finite elements on explicit boundary representations. J. Comput. Phys. 460 (2022): 111162.

P. A. Martorell | STLCutters.jl | 01-08-2024

Long term goals

Fluid-structure interaction (FSI) on unfitted FEM

  • Discretizations for real STL and CAD geometries
  • FSI solvers for unfitted FE
  • Large-scale computations

My PhD Thesis:

✅ Discretization on STL geometries
✅ High-order discretizations for CAD geometries (private repo)
✅ Space-time transient unfitted FE (private repo)
✅ Distributed memory parallelism

❌ Fluid-structure interaction (FSI) and multiphysics
❌ Adaptive mesh refinement (AMR)
❌ Large-scale computations

P. A. Martorell | STLCutters.jl | 01-08-2024

Outline

  • Why STLCutters.jl
  • What is STLCutters.jl
  • How to use and contribute
  • Future Work
  • Hands-on & Questions
P. A. Martorell | STLCutters.jl | 01-08-2024

Gridap and Julia

P. A. Martorell | STLCutters.jl | 01-08-2024

Cell-wise intersection

P. A. Martorell | STLCutters.jl | 01-08-2024

Achievements: Robustness

for 100% of 4726 STLs in Thingi10K

P. A. Martorell | STLCutters.jl | 01-08-2024

Achievements: Robustness

P. A. Martorell | STLCutters.jl | 01-08-2024

Achievements: Parallel Scalability

⚠️ Unpublished results!
P. A. Martorell | STLCutters.jl | 01-08-2024

Outline

  • Why STLCutters.jl
  • What is STLCutters.jl
  • How to use and contribute
  • Future Work
  • Hands-on & Questions
P. A. Martorell | STLCutters.jl | 01-08-2024

Using STLCutters.jl

  • Install
] add STLCutters                                     
  • Or download
git clone https://github.com/gridap/STLCutters.jl.git
  • Gridap & GridapEmbedded API

  • GridapDistributed & GridapP4est compatibility

P. A. Martorell | STLCutters.jl | 01-08-2024

Distributed usage

mpiexec -np 8 julia example.jl

] add GridapP4est

P. A. Martorell | STLCutters.jl | 01-08-2024

Distributed usage

P. A. Martorell | STLCutters.jl | 01-08-2024

Adaptive Mesh Refinement (AMR)

2:1 -balanced in p4est

flags = adapt_cut_cells(parts,cutgeo)
model, = Gridap.Adaptivity.adapt(model,flags)
cutgeo = cut(model,geo)

P. A. Martorell | STLCutters.jl | 01-08-2024

Coding style

  • Gridap-like coding style

  • Semantic Versioning: Julia registry, registered dependencies

  • GitHub Utilities: Issues, PRs, CI

  • Documentation: docstrings, documentation pages

P. A. Martorell | STLCutters.jl | 01-08-2024

Code structure

P. A. Martorell | STLCutters.jl | 01-08-2024

Code structure

P. A. Martorell | STLCutters.jl | 01-08-2024

Package files

src/: 5k code lines
├── STLCutters.jl: Main module with imports and exports
├── SubTriangulations.jl: Core of the package with main algorithms
├── STLs.jl: Load, clean and manage STL geometries
├── Polyhedra.jl: General polytope operations
├── SimplexFaces.jl: Geometrical operations on simplicies
├── Embedded.jl: Extending GridapEmbedded API
└── Distributed.jl: Extending distributed functions and algorithms

P. A. Martorell | STLCutters.jl | 01-08-2024

Core procedures

function subtriangulate(stl,bgmodel)
c_to_f = compute_cell_to_facets(bgmodel,stl)
submesh = _empty_submesh()
for cell in findall(!isempty,c_to_f)
    Γ = stl[c_to_f[cell]]
    P = compute_polyhedra(cell,bgmodel,Γ)
    save_cell_submesh!(submesh,cell,P...)
end
propagate_inout!(submesh)
delete_small_cells(submesh)
grids = compute_grids(submesh)
labels = SubtriangulationLabels(submesh)
return grids,labels
end
function compute_polyhedra(cell,bgmodel,Γ)
K = Polyhedron(bgmodel,cell)
Γk = clip(Γ,planes(K))  
Kin,Kout = refine(K,planes(Γk),reflex_planes(Γk))
return Kin,Kout,Γk
end
function save_cell_submesh!(submesh,cell,Kin,Kout,Γk)
_submesh,_face_submesh = submesh
append!(_submesh,cell,simplexify(Kin),simplexify(Kout))
append!(_face_submesh,cell,simplexify(Γk))
end

ℹ️ Some functions have been simplified for demonstration purposes

P. A. Martorell | STLCutters.jl | 01-08-2024

Outline

  • Why STLCutters.jl
  • What is STLCutters.jl
  • How to use and contribute
  • Future Work
  • Hands-on & Questions
P. A. Martorell | STLCutters.jl | 01-08-2024

Future Work

P. A. Martorell | STLCutters.jl | 01-08-2024

Acknowledgments

  • Special acknowledgments:

    • Supervisors: Santiago Badia & Francesc Verdugo
    • Contributors: STLCutters & Gridap ecosystem
    • Users
    • You
  • Thanks for giving a star on GitHub

P. A. Martorell | STLCutters.jl | 01-08-2024

Hands-on & Questions

git clone https://github.com/gridap/STLCutters.jl.git
code STLCutters.jl
julia> include("examples/LinearElasticity.jl")
julia> filename = "test/data/550964.stl"
julia> LinearElasticity.main(filename,n=50,force=(tand(5),0,-1),output="example4")
P. A. Martorell | STLCutters.jl | 01-08-2024

TODO: focus on FSI and large-scale