diff --git a/docs/make.jl b/docs/make.jl index 7dd95bd7..2199dc04 100644 --- a/docs/make.jl +++ b/docs/make.jl @@ -9,7 +9,8 @@ makedocs(; "Introduction" => "index.md", "Usage" => "usage.md", "Distributed" => "distributed.md", - "Reference" => ["public_api.md","types.md","functions.md"] + "Contributing" => "contributing.md", + "Reference" => ["public_api.md","types.md","functions.md"], ], sitename="STLCutters.jl", ) diff --git a/docs/src/assets/slides-2024-08-01/figures/509317.png b/docs/src/assets/slides-2024-08-01/figures/509317.png new file mode 100644 index 00000000..ce357052 Binary files /dev/null and b/docs/src/assets/slides-2024-08-01/figures/509317.png differ diff --git a/docs/src/assets/slides-2024-08-01/figures/abstraction-levels-explain.png b/docs/src/assets/slides-2024-08-01/figures/abstraction-levels-explain.png new file mode 100644 index 00000000..46c15ce9 Binary files /dev/null and b/docs/src/assets/slides-2024-08-01/figures/abstraction-levels-explain.png differ diff --git a/docs/src/assets/slides-2024-08-01/figures/abstraction-levels-explain.svg b/docs/src/assets/slides-2024-08-01/figures/abstraction-levels-explain.svg new file mode 100644 index 00000000..627990b2 --- /dev/null +++ b/docs/src/assets/slides-2024-08-01/figures/abstraction-levels-explain.svg @@ -0,0 +1,211 @@ + + + + + + + + + + + 0. User Level + 1. Advanced User + 2. Main Workflow + 3. Kernels + 4. Internals & Helpers + + + + + + + + GridapEmbedded API + Interface between STLCutters and GridapEmbedded + Algorithms in Publications + Geometrical operations + Other procedures + + diff --git a/docs/src/assets/slides-2024-08-01/figures/abstraction-levels.png b/docs/src/assets/slides-2024-08-01/figures/abstraction-levels.png new file mode 100644 index 00000000..ba4c50e2 Binary files /dev/null and b/docs/src/assets/slides-2024-08-01/figures/abstraction-levels.png differ diff --git a/docs/src/assets/slides-2024-08-01/figures/abstraction-levels.svg b/docs/src/assets/slides-2024-08-01/figures/abstraction-levels.svg new file mode 100644 index 00000000..8d2f7c71 --- /dev/null +++ b/docs/src/assets/slides-2024-08-01/figures/abstraction-levels.svg @@ -0,0 +1,398 @@ + + + + + + + + + + + cut + STLGeometry + subtriangulate + download_thingi_10k + check_requisites + 0. User Level + 1. Advanced User + 2. Main Workflow + 3. Kernels + 4. Internals & Helpers + + + + + + + clip + simplexify + send_to_ref_space + read_stl + compute_stl_model + compute_cell_to_facets + save_cell_submesh! + compute_polyhedra! + get_reflex_planes + refine + propagate_inout! + distance + closest_point + projection + intersection_point + has_intersection_point + _* + + + diff --git a/docs/src/assets/slides-2024-08-01/figures/amr.png b/docs/src/assets/slides-2024-08-01/figures/amr.png new file mode 100644 index 00000000..baf15858 Binary files /dev/null and b/docs/src/assets/slides-2024-08-01/figures/amr.png differ diff --git a/docs/src/assets/slides-2024-08-01/figures/arc_trimph_lic_flow.png b/docs/src/assets/slides-2024-08-01/figures/arc_trimph_lic_flow.png new file mode 100644 index 00000000..7b9c6a85 Binary files /dev/null and b/docs/src/assets/slides-2024-08-01/figures/arc_trimph_lic_flow.png differ diff --git a/docs/src/assets/slides-2024-08-01/figures/arc_triomph_elasticity.png b/docs/src/assets/slides-2024-08-01/figures/arc_triomph_elasticity.png new file mode 100644 index 00000000..6d071625 Binary files /dev/null and b/docs/src/assets/slides-2024-08-01/figures/arc_triomph_elasticity.png differ diff --git a/docs/src/assets/slides-2024-08-01/figures/dependency-graph.png b/docs/src/assets/slides-2024-08-01/figures/dependency-graph.png new file mode 100644 index 00000000..d58d67d2 Binary files /dev/null and b/docs/src/assets/slides-2024-08-01/figures/dependency-graph.png differ diff --git a/docs/src/assets/slides-2024-08-01/figures/dependency-graph.svg b/docs/src/assets/slides-2024-08-01/figures/dependency-graph.svg new file mode 100644 index 00000000..e1a5577c --- /dev/null +++ b/docs/src/assets/slides-2024-08-01/figures/dependency-graph.svg @@ -0,0 +1,943 @@ + + + +STLCutters.jlGridap.jlGridapEmbedded.jlPartitionedArrays.jlGridapDistributed.jlMPI.jlSparseArraysLinearAlgebraWriteVTK.jlStaticArrays.jlJulia Core:Julia Pkgs:...... diff --git a/docs/src/assets/slides-2024-08-01/figures/give-star.svg b/docs/src/assets/slides-2024-08-01/figures/give-star.svg new file mode 100644 index 00000000..f7cb82f9 --- /dev/null +++ b/docs/src/assets/slides-2024-08-01/figures/give-star.svg @@ -0,0 +1,371 @@ + + + + diff --git a/docs/src/assets/slides-2024-08-01/figures/global-algorithm.png b/docs/src/assets/slides-2024-08-01/figures/global-algorithm.png new file mode 100644 index 00000000..390fb328 Binary files /dev/null and b/docs/src/assets/slides-2024-08-01/figures/global-algorithm.png differ diff --git a/docs/src/assets/slides-2024-08-01/figures/gridap-distributed-p4est.png b/docs/src/assets/slides-2024-08-01/figures/gridap-distributed-p4est.png new file mode 100644 index 00000000..32eee9f3 Binary files /dev/null and b/docs/src/assets/slides-2024-08-01/figures/gridap-distributed-p4est.png differ diff --git a/docs/src/assets/slides-2024-08-01/figures/gridap-distributed-p4est.svg b/docs/src/assets/slides-2024-08-01/figures/gridap-distributed-p4est.svg new file mode 100644 index 00000000..9c7d40b5 --- /dev/null +++ b/docs/src/assets/slides-2024-08-01/figures/gridap-distributed-p4est.svg @@ -0,0 +1,2752 @@ + + + + diff --git a/docs/src/assets/slides-2024-08-01/figures/gridap-distributed.png b/docs/src/assets/slides-2024-08-01/figures/gridap-distributed.png new file mode 100644 index 00000000..b90341ba Binary files /dev/null and b/docs/src/assets/slides-2024-08-01/figures/gridap-distributed.png differ diff --git a/docs/src/assets/slides-2024-08-01/figures/gridap-distributed.svg b/docs/src/assets/slides-2024-08-01/figures/gridap-distributed.svg new file mode 100644 index 00000000..718194c3 --- /dev/null +++ b/docs/src/assets/slides-2024-08-01/figures/gridap-distributed.svg @@ -0,0 +1,2053 @@ + + + + diff --git a/docs/src/assets/slides-2024-08-01/figures/parallel-scalability.png b/docs/src/assets/slides-2024-08-01/figures/parallel-scalability.png new file mode 100644 index 00000000..97cb30b4 Binary files /dev/null and b/docs/src/assets/slides-2024-08-01/figures/parallel-scalability.png differ diff --git a/docs/src/assets/slides-2024-08-01/figures/partitions.png b/docs/src/assets/slides-2024-08-01/figures/partitions.png new file mode 100644 index 00000000..79b2f899 Binary files /dev/null and b/docs/src/assets/slides-2024-08-01/figures/partitions.png differ diff --git a/docs/src/assets/slides-2024-08-01/figures/rotation.png b/docs/src/assets/slides-2024-08-01/figures/rotation.png new file mode 100644 index 00000000..7dda39de Binary files /dev/null and b/docs/src/assets/slides-2024-08-01/figures/rotation.png differ diff --git a/docs/src/assets/slides-2024-08-01/figures/thingi10k-robustness.png b/docs/src/assets/slides-2024-08-01/figures/thingi10k-robustness.png new file mode 100644 index 00000000..a104e131 Binary files /dev/null and b/docs/src/assets/slides-2024-08-01/figures/thingi10k-robustness.png differ diff --git a/docs/src/assets/slides-2024-08-01/figures/thingi10k-robustness.svg b/docs/src/assets/slides-2024-08-01/figures/thingi10k-robustness.svg new file mode 100644 index 00000000..0ba8c904 --- /dev/null +++ b/docs/src/assets/slides-2024-08-01/figures/thingi10k-robustness.svg @@ -0,0 +1,111 @@ + + + + diff --git a/docs/src/assets/slides-2024-08-01/figures/thingi10k_screenshot.png b/docs/src/assets/slides-2024-08-01/figures/thingi10k_screenshot.png new file mode 100644 index 00000000..56a6d8ad Binary files /dev/null and b/docs/src/assets/slides-2024-08-01/figures/thingi10k_screenshot.png differ diff --git a/docs/src/assets/slides-2024-08-01/figures/unfitted-geometries.png b/docs/src/assets/slides-2024-08-01/figures/unfitted-geometries.png new file mode 100644 index 00000000..e6d96295 Binary files /dev/null and b/docs/src/assets/slides-2024-08-01/figures/unfitted-geometries.png differ diff --git a/docs/src/assets/slides-2024-08-01/figures/unfitted-ref.png b/docs/src/assets/slides-2024-08-01/figures/unfitted-ref.png new file mode 100644 index 00000000..81644cb6 Binary files /dev/null and b/docs/src/assets/slides-2024-08-01/figures/unfitted-ref.png differ diff --git a/docs/src/assets/slides-2024-08-01/figures/unfitted.png b/docs/src/assets/slides-2024-08-01/figures/unfitted.png new file mode 100644 index 00000000..5398fe44 Binary files /dev/null and b/docs/src/assets/slides-2024-08-01/figures/unfitted.png differ diff --git a/docs/src/assets/slides-2024-08-01/figures/user-api.png b/docs/src/assets/slides-2024-08-01/figures/user-api.png new file mode 100644 index 00000000..4828180a Binary files /dev/null and b/docs/src/assets/slides-2024-08-01/figures/user-api.png differ diff --git a/docs/src/assets/slides-2024-08-01/figures/user-api.svg b/docs/src/assets/slides-2024-08-01/figures/user-api.svg new file mode 100644 index 00000000..a406369d --- /dev/null +++ b/docs/src/assets/slides-2024-08-01/figures/user-api.svg @@ -0,0 +1,1622 @@ + + + + diff --git a/docs/src/assets/slides-2024-08-01/figures/volume-error.png b/docs/src/assets/slides-2024-08-01/figures/volume-error.png new file mode 100644 index 00000000..c8282110 Binary files /dev/null and b/docs/src/assets/slides-2024-08-01/figures/volume-error.png differ diff --git a/docs/src/assets/slides-2024-08-01/logos/AGAUR_cabecera.png b/docs/src/assets/slides-2024-08-01/logos/AGAUR_cabecera.png new file mode 100644 index 00000000..2d91f8b2 Binary files /dev/null and b/docs/src/assets/slides-2024-08-01/logos/AGAUR_cabecera.png differ diff --git a/docs/src/assets/slides-2024-08-01/logos/Fempar_logo_color_1.png b/docs/src/assets/slides-2024-08-01/logos/Fempar_logo_color_1.png new file mode 100644 index 00000000..7b4149e4 Binary files /dev/null and b/docs/src/assets/slides-2024-08-01/logos/Fempar_logo_color_1.png differ diff --git a/docs/src/assets/slides-2024-08-01/logos/LSSC_logo_color_2.png b/docs/src/assets/slides-2024-08-01/logos/LSSC_logo_color_2.png new file mode 100644 index 00000000..3fe39f3a Binary files /dev/null and b/docs/src/assets/slides-2024-08-01/logos/LSSC_logo_color_2.png differ diff --git a/docs/src/assets/slides-2024-08-01/logos/Monash-logo.png b/docs/src/assets/slides-2024-08-01/logos/Monash-logo.png new file mode 100644 index 00000000..5e4bba6b Binary files /dev/null and b/docs/src/assets/slides-2024-08-01/logos/Monash-logo.png differ diff --git a/docs/src/assets/slides-2024-08-01/logos/cimne-so.png b/docs/src/assets/slides-2024-08-01/logos/cimne-so.png new file mode 100644 index 00000000..df8a03a0 Binary files /dev/null and b/docs/src/assets/slides-2024-08-01/logos/cimne-so.png differ diff --git a/docs/src/assets/slides-2024-08-01/logos/gridap.png b/docs/src/assets/slides-2024-08-01/logos/gridap.png new file mode 100644 index 00000000..0cacb063 Binary files /dev/null and b/docs/src/assets/slides-2024-08-01/logos/gridap.png differ diff --git a/docs/src/assets/slides-2024-08-01/logos/logo_Escola_Camins.png b/docs/src/assets/slides-2024-08-01/logos/logo_Escola_Camins.png new file mode 100644 index 00000000..5e451aaa Binary files /dev/null and b/docs/src/assets/slides-2024-08-01/logos/logo_Escola_Camins.png differ diff --git a/docs/src/assets/slides-2024-08-01/logos/upc-complet.png b/docs/src/assets/slides-2024-08-01/logos/upc-complet.png new file mode 100644 index 00000000..b3165030 Binary files /dev/null and b/docs/src/assets/slides-2024-08-01/logos/upc-complet.png differ diff --git a/docs/src/assets/slides-2024-08-01/logos/upc.png b/docs/src/assets/slides-2024-08-01/logos/upc.png new file mode 100644 index 00000000..da27ab37 Binary files /dev/null and b/docs/src/assets/slides-2024-08-01/logos/upc.png differ diff --git a/docs/src/assets/slides-2024-08-01/main.html b/docs/src/assets/slides-2024-08-01/main.html new file mode 100644 index 00000000..2099a885 --- /dev/null +++ b/docs/src/assets/slides-2024-08-01/main.html @@ -0,0 +1,1183 @@ +STLCutters.jl
+

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

\ No newline at end of file diff --git a/docs/src/assets/slides-2024-08-01/main.md b/docs/src/assets/slides-2024-08-01/main.md new file mode 100644 index 00000000..bd05ab84 --- /dev/null +++ b/docs/src/assets/slides-2024-08-01/main.md @@ -0,0 +1,518 @@ +--- +theme: gaia +paginate: true +marp: true +author: Pere Antoni Martorell +backgroundColor: white +title: STLCutters.jl +backgroundPosition: center +footer: P. A. Martorell | STLCutters.jl | 01-08-2024 +style: | + .columns { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 1rem; + } + .image-row { + display: flex; + justify-content: space-between; /* this will add equal space between each image + */ + } + .outline { + padding-top:50px; + padding-left:100px; + font-size:40px; + } + +--- + + + + + + + + + + +
+ +# 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 + +
+ +--- + + +# Outline + +
+ +- **Why STLCutters.jl** +- What is STLCutters.jl +- How to use and contribute +- Future Work +- Hands-on & Questions + +
+ +--- + + +# Unfitted Finite Elements + +
+ +![w:1150](figures/unfitted.png) + +
+ +![w:500](figures/unfitted-ref.png) + + + +--- + +# Unfitted Geometries + +
+ +![w:1000](figures/unfitted-geometries.png) + +
+ + +
+ +S. Badia, P. A. Martorell, F. Verdugo. _Geometrical discretisations for unfitted finite elements on explicit boundary representations._ J. Comput. Phys. 460 (2022): 111162. + +
+ +--- + +# 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 + +
+
+ + + +--- +# Outline + +
+ + +- Why STLCutters.jl +- **What is STLCutters.jl** +- How to use and contribute +- Future Work +- Hands-on & Questions + +
+ +--- + +# Gridap and Julia + +![w:1100](figures/dependency-graph.png) + +--- +# Cell-wise intersection + +![w:1100](figures/global-algorithm.png) + +--- + +# Achievements: Robustness + + + + +$\epsilon _v = | V_\mathrm{in} + V_\mathrm{out} - V_\mathrm{box} | / V_\mathrm{box} < 10^{-10}$ for 100% of 4726 STLs in [Thingi10K](https://ten-thousand-models.appspot.com/results.html?q=is+solid%2C+is+manifold) + + + + + +![w:1100](figures/thingi10k-robustness.png) + + +--- + +# Achievements: Robustness + + +
+ +![w:1000](figures/rotation.png) + +
+ +--- + +# Achievements: Parallel Scalability + + + + +
+ +![w:900](figures/parallel-scalability.png) + +
+ +
+ +⚠️ Unpublished results! + +
+ +--- + +# Outline + +
+ +- Why STLCutters.jl +- What is STLCutters.jl +- **How to use and contribute** +- Future Work +- Hands-on & Questions + +
+ +--- + +# Using STLCutters.jl + +
+
+ +- Install + +```julia +] add STLCutters +``` +- Or download +```bash +git clone https://github.com/gridap/STLCutters.jl.git +``` + +- Gridap & GridapEmbedded API + +- GridapDistributed & GridapP4est compatibility + +
+
+ +![](figures/user-api.png) + +
+
+ + + +--- + +# Distributed usage + + +
+
+ +```bash +mpiexec -np 8 julia example.jl +``` + +![w:550](figures/gridap-distributed.png) + +
+
+ +```julia +] add GridapP4est +``` + +![w:550px](figures/gridap-distributed-p4est.png) + + +
+
+ +--- + +# Distributed usage + + +
+ + +![w:1100](figures/partitions.png) + +
+ +--- + +# Adaptive Mesh Refinement (AMR) + + +
+
+ +2:1 $k$-balanced in `p4est` + +```julia +flags = adapt_cut_cells(parts,cutgeo) +model, = Gridap.Adaptivity.adapt(model,flags) +cutgeo = cut(model,geo) +``` + +
+
+ + +![w:650](figures/amr.png) + +
+
+ +--- +# Coding style + +- Gridap-like coding style + +- Semantic Versioning: Julia registry, registered dependencies + +- GitHub Utilities: Issues, PRs, CI + +- Documentation: _docstrings_, documentation pages + + + +--- + +# Code structure + +
+ +![w:1100](figures/abstraction-levels-explain.png) + +
+ +--- + +# Code structure + +
+ +![w:1100](figures/abstraction-levels.png) + +
+ +--- + +# 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 + + +--- + +# Core procedures + + + +
+
+ +```julia +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 +``` + +
+
+ +```julia +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 +``` +```julia +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 + + +--- + +# Outline + +
+ +- Why STLCutters.jl +- What is STLCutters.jl +- How to use and contribute +- **Future Work** +- Hands-on & Questions + +
+ +--- + +# Future Work + +- Extract mesh of general polytopes [STLCutters.jl#37](https://github.com/gridap/STLCutters.jl/issues/37) +- Reduce memory allocations [STLCutters.jl#38](https://github.com/gridap/STLCutters.jl/issues/38) +- Deal with disconnected subdomains [STLCutters.jl](https://github.com/gridap/STLCutters.jl) +- Distribute space-time methods [STLCutters.jl](https://github.com/gridap/STLCutters.jl) +- AMR with unfitted AgFEM [GridapEmbedded.jl](https://github.com/gridap/GridapEmbedded.jl) +- Fix moment fitting in parallel [GridapEmbedded.jl#94](https://github.com/gridap/GridapEmbedded.jl/issues/94) +- Solve void subdomains [GridapDistributed.jl](https://github.com/gridap/GridapDistributed.jl) + +- Test distributed solvers on unfitted FSI + +--- + +# Acknowledgments + +- Special acknowledgments: + - Supervisors: Santiago Badia & Francesc Verdugo + - Contributors: STLCutters & Gridap ecosystem + - Users + - You + + - Thanks for giving a star on GitHub + + ![w:1100](figures/give-star.svg) + +--- + +# Hands-on & Questions + + +- Visit the GitHub page: https://github.com/gridap/STLCutters.jl + +- Check the documentation: https://gridap.github.io/STLCutters.jl + +- Locally navigate the repository & run examples: +```bash +git clone https://github.com/gridap/STLCutters.jl.git +code STLCutters.jl +``` +```julia +julia> include("examples/LinearElasticity.jl") +julia> filename = "test/data/550964.stl" +julia> LinearElasticity.main(filename,n=50,force=(tand(5),0,-1),output="example4") +``` diff --git a/docs/src/contributing.md b/docs/src/contributing.md new file mode 100644 index 00000000..f86f26b5 --- /dev/null +++ b/docs/src/contributing.md @@ -0,0 +1,6 @@ +# Contributing + +You are welcome to contribute to the development of `STLCutters.jl`. Please, follow the +[Gridap contributing guidelines](https://github.com/gridap/Gridap.jl/blob/master/CONTRIBUTING.md) + +In these [slides](assets/slides-2024-08-01/main.html) you can find a presentation with more details of the package and guidelines for contributing. diff --git a/docs/src/distributed.md b/docs/src/distributed.md index 4455190d..578f137c 100644 --- a/docs/src/distributed.md +++ b/docs/src/distributed.md @@ -33,6 +33,15 @@ Here, we provide a basic example of solving the Poisson equation with distribute mpiexec -np 8 julia poisson.jl ``` +!!! note + Instead of running `mpiexec -np 8 julia poisson.jl`, it is recommended to use the `mpiexec` function from the `MPI.jl` package. + ```julia + using MPI + mpiexec() do cmd + run(`$cmd -np 8 $(Base.julia_cmd()) --project=$(Base.active_project()) poisson.jl`) + end + ``` + Where `poisson.jl` is the following code. ```julia @@ -41,12 +50,9 @@ using Gridap using GridapEmbedded using GridapDistributed using PartitionedArrays -using MPI - parts = (2,2,2) cells = (10,10,10) filename = "stl_file_path.stl" - with_mpi() do distribute ranks = distribute(LinearIndices((prod(parts),))) # Domain and discretization @@ -90,6 +96,7 @@ end !!! note It is recommended to use `with_debug()` instead of `with_mpi()` for debugging in serialized execution, see more details in [`PartitionedArrays`](https://www.francescverdugo.com/PartitionedArrays.jl/stable). + !!! note One can consider a different stabilization of the small cut-cell problem instead of AgFEM. Then, the `aggregate` and `AgFEMSpace` need to be removed. See more examples in [`GridapEmbedded`](https://github.com/gridap/GridapEmbedded.jl) @@ -99,7 +106,110 @@ end Even though the distributed algorithms are proven to be efficient for large-scale weak scaling tests [Martorell, 2024](https://www.tdx.cat/handle/10803/690625). The performance of this implementation is not tested. +## Usage with `p4est` + +The implementation is general for all the `Gridap.jl` triangulations. Thus, we can use `p4est` through `GridapP4est.jl` in order to exploit its features. With `p4est`, we can take advantage of adaptive mesh refinement (AMR) and redistribution. + +### Redistribute with `p4est` + +The following example is using `redistribute` to improve the load balancing of the subdomains. + +```julia +using STLCutters +using Gridap +using GridapEmbedded +using GridapDistributed +using PartitionedArrays +using GridapP4est +parts = 8 +cells = (2,2,2) +filename = "stl_file_path.stl" +with_mpi() do distribute + ranks = distribute(LinearIndices((prod(parts),))) + # Domain and discretization + geo = STLGeometry(filename) + pmin,pmax = get_bounding_box(geo) + coarse_model = CartesianDiscreteModel(pmin,pmax,cells) + model = OctreeDistributedDiscreteModel(ranks,coarse_model,2) + cutgeo = cut(model,geo) + # Redistribute to avoid void subdmoains + weights = compute_resdistribute_weights(cutgeo) + model, = GridapDistributed.redistribute(model,weights=weights) + # Re-compute discretization + cutgeo = cut(model,geo) + # Cell aggregation + model,cutgeo,aggregates = aggregate(AggregateAllCutCells(),cutgeo) + # Triangulations + Ω_act = Triangulation(cutgeo,ACTIVE) + Ω = Triangulation(cutgeo) + Γ = EmbeddedBoundary(cutgeo) + nΓ = get_normal_vector(Γ) + dΩ = Measure(Ω,2) + dΓ = Measure(Γ,2) + # FE spaces + Vstd = TestFESpace(Ω_act,ReferenceFE(lagrangian,Float64,1)) + V = AgFEMSpace(model,Vstd,aggregates) + U = TrialFESpace(V) + # Weak form + γ = 10.0 + h = (pmax - pmin)[1] / cells[1] + ud(x) = x[1] - x[2] + f = 0 + a(u,v) = + ∫( ∇(v)⋅∇(u) )dΩ + + ∫( (γ/h)*v*u - v*(nΓ⋅∇(u)) - (nΓ⋅∇(v))*u )dΓ + l(v) = + ∫( v*f )dΩ + + ∫( (γ/h)*v*ud - (nΓ⋅∇(v))*ud )dΓ + # Solve + op = AffineFEOperator(a,l,U,V) + uh = solve(op) + writevtk(Ω,"results",cellfields=["uh"=>uh]) +end +``` + +!!! note + For compatibility reasons, we are not interested on adding `GridapP4est` as a dependency. The interested can add it to its own driver. + +### Adaptive mesh refinement with `p4est` +The `p4est` library is designed to provide AMR. In the following example, we can `adapt` a mesh using the `STLCutters.jl` output and generate a new discretization on the refined mesh. Using `STLCutters.jl` works out-of-the-box with 2:1 balanced adapted meshes. The user can use this discretization to solve partial differential equations and combine them with `redistribute`. +```julia +using STLCutters +using Gridap +using GridapEmbedded +using GridapDistributed +using PartitionedArrays +using GridapP4est +parts = 8 +cells = (16,16,16) +filename = "stl_file_path.stl" +with_mpi() do distribute + ranks = distribute(LinearIndices((prod(parts),))) + # Domain and discretization + geo = STLGeometry(filename) + pmin,pmax = get_bounding_box(geo) + coarse_model = CartesianDiscreteModel(pmin,pmax,cells) + model = OctreeDistributedDiscreteModel(ranks,coarse_model,2) + cutgeo = cut(model,geo) + # Redistribute to avoid void subdmoains + weights = compute_adaptive_flags(cutgeo) + model, = Gridap.Adaptivity.adapt(model,weights=weights) + model = get_model(model.dmodel) + # Re-compute discretization + cutgeo = cut(model,geo) + Ωin = Triangulation(cutgeo,PHYSICAL_IN) + Ωout = Triangulation(cutgeo,PHYSICAL_OUT) + Ωbg = Triangulation(model) + dΩin = Measure(Ωin,2) + dΩout = Measure(Ωout,2) + dΩbg = Measure(Ωbg,2) + e = ∑( ∫(1)dΩin ) + ∑( ∫(1)dΩout ) - ∑( ∫(1)dΩbg ) + i_am_main(ranks) && println("Volume error: $e") + writevtk(Ωin,"trian") + writevtk(Ωbg,"trian_bg") +end +```