LevelSetEvolution
In GridapTopOpt, the level set is evolved and reinitialised using a LevelSetEvolution
method. The most standard of these is the Hamilton-Jacobi evolution equation solved using a first order upwind finite difference scheme. A forward Euler in time method is provided below via HamiltonJacobiEvolution <: LevelSetEvolution
along with an upwind finite difference stencil for the spatial discretisation via FirstOrderStencil
.
This can be extended in several ways. For example, higher order spatial stencils can be implemented by extending the Stencil
interface below. In addition, more advanced ODE solvers could be implemented (e.g., Runge–Kutta methods) or entirely different level set evolution methods by extending the LevelSetEvolution
interface below.
HamiltonJacobiEvolution
GridapTopOpt.HamiltonJacobiEvolution
— Typestruct HamiltonJacobiEvolution{O}
A standard forward Euler in time finite difference method for solving the Hamilton-Jacobi evolution equation and reinitialisation equation on order O
finite elements in serial or parallel.
Based on the scheme by Osher and Fedkiw (link).
Parameters
stencil::Stencil
: Spatial finite difference stencil for a single step HJ equation and reinitialisation equation.model
: ACartesianDiscreteModel
.space
: FE space for level-set functionperm
: A permutation vectorparams
: Tuple of additional paramscache
: Stencil cache
GridapTopOpt.HamiltonJacobiEvolution
— TypeHamiltonJacobiEvolution(stencil::Stencil,model,space,tol,max_steps,max_steps_reinit)
Create an instance of HamiltonJacobiEvolution
given a stencil, model, FE space, and additional optional arguments. This automatically creates the DoF permutation to handle high-order finite elements.
GridapTopOpt.evolve!
— Functionevolve!(::LevelSetEvolution,φ,args...)
Evolve the level set function φ according to an evolution method LevelSetEvolution.
evolve!(::Stencil,φ,vel,Δt,Δx,isperiodic,caches) -> φ
Single finite difference step of the Hamilton-Jacobi evoluation equation for a given Stencil
.
evolve!(s::HamiltonJacobiEvolution{O},φ,vel,γ) where O
Solve the Hamilton-Jacobi evolution equation using the HamiltonJacobiEvolution
.
Hamilton-Jacobi evolution equation
$\frac{\partial\phi}{\partial t} + V(\boldsymbol{x})\lVert\boldsymbol{\nabla}\phi\rVert = 0,$
with $\phi(0,\boldsymbol{x})=\phi_0(\boldsymbol{x})$ and $\boldsymbol{x}\in D,~t\in(0,T)$.
Arguments
s::HamiltonJacobiEvolution{O}
: Methodφ
: level set function as a vector of degrees of freedomvel
: the normal velocity as a vector of degrees of freedomγ
: coeffient on the time step size.
GridapTopOpt.reinit!
— Functionreinit!(::LevelSetEvolution,φ,args...)
Reinitialise the level set function φ according to an evolution method LevelSetEvolution.
reinit!(::Stencil,φ_new,φ,vel,Δt,Δx,isperiodic,caches) -> φ
Single finite difference step of the reinitialisation equation for a given Stencil
.
reinit!(s::HamiltonJacobiEvolution{O},φ,γ) where O
Solve the reinitialisation equation using the HamiltonJacobiEvolution
.
Reinitialisation equation
$\frac{\partial\phi}{\partial t} + \mathrm{sign}(\phi_0)(\lVert\boldsymbol{\nabla}\phi\rVert-1) = 0,$
with $\phi(0,\boldsymbol{x})=\phi_0(\boldsymbol{x})$ and $\boldsymbol{x}\in D,~t\in(0,T)$.
Arguments
s::HamiltonJacobiEvolution{O}
: Methodφ
: level set function as a vector of degrees of freedomγ
: coeffient on the time step size.
GridapTopOpt.get_dof_Δ
— Methodget_dof_Δ(m::HamiltonJacobiEvolution)
Return the distance betweem degree of freedom
Spatial stencils for HamiltonJacobiEvolution
GridapTopOpt.FirstOrderStencil
— Typestruct FirstOrderStencil{D,T} <: Stencil end
A first order upwind difference scheme based on Osher and Fedkiw (link).
Custom Stencil
GridapTopOpt.Stencil
— Typeabstract type Stencil
Finite difference stencil for a single step of the Hamilton-Jacobi evolution equation and reinitialisation equation.
Your own spatial stencil can be implemented by extending the methods below.
GridapTopOpt.evolve!
— Methodevolve!(::Stencil,φ,vel,Δt,Δx,isperiodic,caches) -> φ
Single finite difference step of the Hamilton-Jacobi evoluation equation for a given Stencil
.
GridapTopOpt.reinit!
— Methodreinit!(::Stencil,φ_new,φ,vel,Δt,Δx,isperiodic,caches) -> φ
Single finite difference step of the reinitialisation equation for a given Stencil
.
GridapTopOpt.allocate_caches
— Methodallocate_caches(::Stencil,φ,vel)
Allocate caches for a given Stencil
.
GridapTopOpt.check_order
— Functioncheck_order(::Stencil,order)
Throw error if insufficient reference element order to implement stencil in parallel.
Custom LevelSetEvolution
To implement a custom level set evolution method, we can extend the methods below. For example, one could consider Reaction-Diffusion-based evolution of the level set function. This can be solved with a finite element method and so we can implement a new type that inherits from LevelSetEvolution
independently of the Stencil
types.
GridapTopOpt.LevelSetEvolution
— Typeabstract type LevelSetEvolution
Your own evolution method can be implemented by implementing concrete functionality of the below.
GridapTopOpt.evolve!
— Methodevolve!(::LevelSetEvolution,φ,args...)
Evolve the level set function φ according to an evolution method LevelSetEvolution.
GridapTopOpt.reinit!
— Methodreinit!(::LevelSetEvolution,φ,args...)
Reinitialise the level set function φ according to an evolution method LevelSetEvolution.
GridapTopOpt.get_dof_Δ
— Methodget_dof_Δ(::LevelSetEvolution)
Return the distance betweem degree of freedom