]add https://github.com/mancellin/FiniteVolumes.jl
The main interface of this package is the FiniteVolumes.div
function, meant to compute the discrete divergence operator with a Finite Volume scheme on a given mesh.
using FiniteVolumes
mesh = CartesianMesh(10, 10) # A 2D mesh of 10 cells × 10 cells
F(u) = u * [1.0, 0.5] # Flux function of the linear advection flux in direction (1.0, 0.5)
dudt(U) = -FiniteVolumes.div(F, mesh, U, (Upwind(), NeumannBC()))
U = [sin(2π*x*y) for (x, y) in cell_centers(mesh)] # A scalar field
# A basic explicit Euler time step to solve the advection PDE ∂_t u + div (c u) = 0
Δt = 0.01
U += Δt * dudt(U)
The library is minimalistic, in the sense that it only implements the least common denominator of most Finite Volume methods. The number of meshes and methods directly provided is very limited, but the library is also extensible, in the sense that it should be easy to add new methods or use methods defined in other packages.
As an example, the package only include a basic explicit Euler integrator for time integration, but can be coupled with OrdinaryDiffEq.jl
for more advanced methods.