VoronoiFVM.jl: Tipps and Examples

5.3 μs

Grid generation

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

There are several ways to create a grid.

7.9 μs

1D grids

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

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

265 ms
3.0 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:

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

562 ms
251 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.

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

141 ms
1.8 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.5 μs
grid2d_b

InterruptException:

---

InterruptException:

---

2D Unstructured grids

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

5.5 μs

InterruptException:

---
builder

InterruptException:

---

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

2.3 μs

InterruptException:

---

Finally, we can create a grid from the builder:

2.1 μs
grid2d_c

InterruptException:

---

InterruptException:

---

Stationary scalar problems

2.1 μ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)
78.7 μ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
935 ms
127 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
2.6 ms
106 ms

Diffusion with Robin boundary conditions

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

3.2 μs
solve_diffproblem_robin (generic function with 1 method)
187 μ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
926 ms
71.0 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.3 ms
82.8 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.4 μs
solve_readiff (generic function with 1 method)
83.3 μ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.2 s
229 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.3 s
768 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.7 μs
transient_reaction_diffusion (generic function with 1 method)
109 μs
37.6 ms

time step number: 23

22.7 ms
64.4 ms
56.2 ms
93.0 ns
12.7 s
      Status `/tmp/jl_2UEMWi/Project.toml`
  [cfc395e8] ExtendableGrids v0.7.4
  [5eed8a63] GridVisualize v0.1.5
  [7f904dfe] PlutoUI v0.7.4
  [d330b81b] PyPlot v2.9.0
  [57bfcd06] SimplexGridFactory v0.5.1
  [f7e6ffb2] Triangulate v1.0.1
  [82b139dc] VoronoiFVM v0.10.9
6.2 ms