Semantic Versioning: Julia registry, registered dependencies
+
+
+
GitHub Utilities: Issues, PRs, CI
+
+
+
Documentation: docstrings, documentation pages
+
+
+
+
+
+
Code structure
+
+
+
+
+
+
+
Code structure
+
+
+
+
+
+
+
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
+
+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
+
+
+
+ℹ️ 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
+```