VoronoiFVM.jl: Tipps and Examples

5.0 μs

Grid generation

VoronoiFVM works on simplicial grids provided by the package ExtendableGrids.jl

There are several ways to create a grid.

8.1 μs

1D grids

1D grids are created from a vector of monotonicaly increasing x-axis positions.

6.0 μs
X
104 ms
grid1d_a
ExtendableGrids.ExtendableGrid{Float64, Int32};
dim: 1 nodes: 21 cells: 20 bfaces: 2

247 ms
2.6 s

As we see, the grid is chacracterized by interior points, and boundary points. Each grid cell is endowed with a region number (for allowing different physics, parameters etc. for different regions). Each boundary node has a boundary region number, which is meant to be used to distinguish different boundary conditions.

More sophisticated grids can be created, as we see in the following example:

31.3 μs
grid1d_b
ExtendableGrids.ExtendableGrid{Float64, Int32};
dim: 1 nodes: 53 cells: 52 bfaces: 3

527 ms
236 ms

2D Tensor product grids

These are created from two vectors of x and y coordinates, respectively. This results in the creation of a grid of quadrilaterals. Then, each of them is subdivided into two triangles, resulting in a boundary conforming Delaunay grid.

5.3 μs
grid2d_a
ExtendableGrids.ExtendableGrid{Float64, Int32};
dim: 2 nodes: 121 cells: 200 bfaces: 40

136 ms
1.7 s

Once again, we see a default distrbution of cell regions and boundary regions. This can be modified in a similar manner as in the 1D case.

2.4 μs
grid2d_b
ExtendableGrids.ExtendableGrid{Float64, Int32};
dim: 2 nodes: 121 cells: 200 bfaces: 56, edges: 320

905 ms
117 ms

2D Unstructured grids

These can be created using the mesh generator Triangle (by J. Shewchuk) via the packages Triangulate.jl and SimplexGridFactory.jl.

5.4 μs
builder2d (generic function with 1 method)
59.6 μs
builder
345 ms

For debugging purposes, the current state of the builder and its possible output can be visualized:

2.1 μs
1.4 s

Finally, we can create a grid from the builder:

2.0 μs
grid2d_c
ExtendableGrids.ExtendableGrid{Float64, Int32};
dim: 2 nodes: 230 cells: 381 bfaces: 77

335 ms
206 ms

Stationary scalar problems

2.4 μs

Diffusion with Dirichlet boundary conditions

This is mathematically similar to heat conduction and other problems.

Du=10uΓeast=0uΓwest=1Dun|Ω(ΓeastΓwest)=0

Besides of the domain and its boundary it is characterize by a flux term and a source term.

3.4 μs
solve_diffproblem_dirichlet (generic function with 1 method)
69.9 μs
solution1d_a
1×21 Matrix{Float64}:
 6.0e-30  0.2875  0.55  0.7875  1.0  …  1.6875  1.6  1.4875  1.35  1.1875  1.0
1.5 s
397 ms
solution2d_a
1×121 Matrix{Float64}:
 3.0e-31  0.55  1.0  1.35  1.6  1.75  1.8  …  1.6  1.75  1.8  1.75  1.6  1.35  1.0
33.3 ms
516 ms

Diffusion with Robin boundary conditions

Du=10Dun+au=0onΓeastDun+au=aonΓeastDun|Ω(ΓeastΓwest)=0

4.1 μs
solve_diffproblem_robin (generic function with 1 method)
76.4 μs
solution1d_robin
1×21 Matrix{Float64}:
 5.33333  5.5875  5.81667  6.02083  6.2  …  6.4  6.25417  6.08333  5.8875  5.66667
880 ms
60.6 ms
solution2d_robin
1×121 Matrix{Float64}:
 5.33333  5.81667  6.2  6.48333  6.66667  …  6.73333  6.61667  6.4  6.08333  5.66667
2.4 ms
74.3 ms

Stationary Reaction-Diffusion problem

Here, we regard two species u1,u2, and a reaction converting u1 into u2. Dirichlet boundary conditions "inject" u1 an "remove" u2.

D1u1+r(u1)=0D2u2r(u1)=0r(u1)=ku1u1|Γwest=1u2|Γeast=0

Boundary conditons not specified are assumed to be homogeneous Neumann.

4.9 μs
solve_readiff (generic function with 1 method)
87.7 μs
solution_readiff_1d
2×21 Matrix{Float64}:
 1.0      0.854464  0.730289  0.624372  …  0.0890498  0.0858439  0.0847841
 2.24551  2.23301   2.19915   2.14703      0.311807   0.156976   3.16072e-30
1.3 s
264 ms
solution_readiff_2d
2×121 Matrix{Float64}:
 1.0      0.884085  0.785851  0.703335  0.634885  …  0.478053  0.464174  0.459578
 0.71873  0.70873   0.681048  0.63765   0.580184     0.233355  0.121319  6.29576e-32
1.2 s
228 ms

Transient Reaction-Diffusion problem

Here, we regard two species u1,u2, and a reaction converting u1 into u2. Dirichlet boundary conditions "inject" u1 an "remove" u2.

tu1D1u1+r(u1)=0tu2D2u2r(u1)=0r(u1)=ku1u1|Γwest=1u2|Γeast=0u1|t=0=0u2|t=0=0

Boundary conditons not specified are assumed to be homogeneous Neumann.

6.6 μs
evolution (generic function with 1 method)
32.4 μs
transient_reaction_diffusion (generic function with 1 method)
158 μs
tsol_readiff
1.4 s

time=

27.0 ms
326 ms
43.0 ns
16.1 s
      Status `/tmp/jl_SKqLWP/Project.toml`
  [cfc395e8] ExtendableGrids v0.7.4
  [5eed8a63] GridVisualize v0.1.3
  [7f904dfe] PlutoUI v0.7.2
  [d330b81b] PyPlot v2.9.0
  [57bfcd06] SimplexGridFactory v0.5.1
  [f7e6ffb2] Triangulate v1.0.1
  [82b139dc] VoronoiFVM v0.10.5
559 ms