MOLE: Mimetic Operators Library Enhanced

MOLE is a library that implements high-order mimetic operators to solve partial differential equations. This site provides documentation for the Julia implementation of MOLE. More information can be found on the main documentation site and the GitHub repository.

Getting Started

MOLE.jl is not yet available in the Julia's package manager. For now, this repository needs to be cloned locally in order to use the library.

Using MOLE.jl

In order to use the MOLE.jl library, first navigate to the location where the repository has been cloned to. Then, go to the mole/julia/MOLE.jl sub-directory. From here, you can access the library via the REPL or the command line.

From the REPL

In mole/julia/MOLE.jl, start Julia using the command julia --project=.. Next, the package library needs to be instantiated and pre-compiled. Enter the pkg mode by pressing ], then type the commands instantiate and precompile (one at a time). This should activate the MOLE.jl package and install the necessary dependencies.

Then, to run a script such as myScript.jl, you can use the following command in the REPL:

include("path/to/myScript.jl")

From the command line

In mole/julia/MOLE.jl, use the following commands to instatiate and precompile the MOLE package:

julia --project=. -e 'using Pkg; Pkg.instantiate()'
julia --project=. -e 'using Pkg; Pkg.precompile()'

Then, to run a script such as myScript.jl, use the command

julia --project=. path/to/myScript.jl

Running the test suite

To run the unit tests, first enter the Julia REPL as in the above section (that is, by running the command julia --project=. from the directory mole/julia/MOLE.jl). Next, enter the pkg mode by pressing ], then type the command test. The results of the unit tests should be displayed to your console.

Building the documentation

MOLE.jl uses Documenter.jl to build its Julia implementation documentation. From the mole/julia/MOLE.jl directory, navigate to the docs/ directory, with

cd docs/

From the REPL

To build the documentation from the docs/ directory, start Julia with the command julia --project=.. You should see the Julia REPL starting with the (docs) environment. Next, enter the pkg mode by pressing ], and then type the commands instantiate and precompile (one at a time). This should activate the docs environment (specific to build the documentation) and install the necessary dependencies.

Then, to build the documentation you can use the following command in the REPL:

include("make.jl")

From the command line

To build the documentation from the docs/ directory, use the following commands to instatiate and precompile the documentation environment:

julia --project=. -e 'using Pkg; Pkg.instantiate()'
julia --project=. -e 'using Pkg; Pkg.precompile()'

Then build the documentation with the command

julia --project=. make.jl

Preview the documentation

Once you have built the documentation (either from the REPL or the command line), you can inspect the documentation in docs/build with the index.html file as the homepage.

Functions

Operators

MOLE.Operators.divMethod
div(k, m, dx; dc, nc)

Returns a one-dimensional mimetic divergence operator. Default is non periodic.

Arguments

  • k::Int: Order of accuracy
  • m::Int: Number of cells
  • dx::T: Step size
  • dc::NTuple{2,T}: Dirichlet coefficients of left and right boundaries (optional)
  • nc::NTuple{2,T}: Neumann coefficients of left and right boundaries (optional)
source
MOLE.Operators.divMethod
div(k, ticks)

Returns a m + 2 by m + 1 non-uniform mimetic divergence operator

Arguments

  • k::Int: Order of accuracy
  • ticks::AbstractArray: Edges' ticks e.g. [0 0.1 0.15 0.2 0.3 0.4 0.45]
source
MOLE.Operators.divMethod
div(k, m, dx, n, dy; dc, nc)

Returns a two-dimensional mimetic divergence operator. Default is non periodic.

Arguments

  • k::Int: Order of accuracy
  • m::Int: Number of cells in x-direction
  • dx::T: Step size in x-direction
  • n::Int: Number of cells in y-direction
  • dy::T: Step size in y-direction
  • dc::NTuple{4,T}: Dirichlet coefficients of left, right, bottom, and top boundaries (optional)
  • nc::NTuple{4,T}: Neumann coefficients of left, right, bottom, and top boundaries (optional)
source
MOLE.Operators.divMethod
div(k, xticks, yticks)

Returns a two-dimensional non-uniform mimetic divergence operator.

Arguments

  • k::Int: Order of accuracy
  • xticks::AbstractVector: Edges' ticks (x-axis)
  • yticks::AbstractVector: Edges' ticks (y-axis)
source
MOLE.Operators.gradMethod
grad(k, m, dx; dc, nc)

Returns a one-dimensional mimetic gradient operator. Default is non periodic.

Arguments

  • k::Int: Order of accuracy
  • m::Int: Number of cells
  • dx::T: Step size
  • dc::NTuple{2,T}: Dirichlet coefficients of the left and right boundaries (optional)
  • nc::NTuple{2,T}: Neumann coefficients of the left and right boundaries (optional)
source
MOLE.Operators.gradMethod
grad(k, ticks)

Returns a m + 1 by m + 2 one-dimensional non-uniform mimetic gradient operator

Arguments

  • k::Int: Order of accuracy
  • ticks::AbstractVector: Centers' ticks e.g. (0 0.5 1 3 5 7 9 9.5 10) (including the boundaries!)
source
MOLE.Operators.gradMethod
grad(k, m, dx, n, dy; dc, nc)

Returns a two-dimensional mimetic gradient operator. Default is non periodic.

Arguments

  • k::Int: Order of accuracy
  • m::Int: Number of cells in x-direction
  • dx::T: Step size in x-direction
  • n::Int: Number of cells in y-direction
  • dy::T: Step size in y-direction
  • dc::NTuple{4,T}: Dirichlet coefficients of the left, right, bottom, and top boundaries (optional)
  • nc::NTuple{4,T}: Neumann coefficients of the left, right, bottom, and top boundaries (optional)
source
MOLE.Operators.gradMethod
grad(k, xticks, yticks)

Returns a two-dimensional non-uniform mimetic gradient operator

Arguments

  • k::Int: Order of accuracy
  • xticks::AbstractVector: Centers' ticks (x-axis) (includint the boundaries!)
  • yticks::AbstractVector: Centers' ticks (y-axis) (includint the boundaries!)
source
MOLE.Operators.lapMethod
lap(k, m, dx; dc, nc)

Returns a m+2 by m+2 one-dimensional mimetic laplacian operator. Default is non periodic.

Arguments

  • k::Int: Order of accuracy
  • m::Int: Number of cells
  • dx::T: Step size
  • dc::NTuple{2,T}: Dirichlet coefficients of the left and right boundaries (optional)
  • nc::NTuple{2,T}: Neumann coefficients of the left and right boundaries (optional)
source
MOLE.Operators.lapMethod
lap(k, m, dx, n, dy; dc, nc)

Returns a two-dimensional mimetic laplacian operator. Default is non periodic.

Arguments

  • k::Int: Order of accuracy
  • m::Int: Number of cells in x-direction
  • dx::T: Step size in x-direction
  • n::Int: Number of cells in y-direction
  • dy::T: Step size in y-direction
  • dc::NTuple{4,T}: Dirichlet coefficients of the left and right boundaries (optional)
  • nc::NTuple{4,T}: Neumann coefficients of the left and right boundaries (optional)
source
MOLE.Operators.interpolMethod
interpol(m, c)

Returns a (m+1)×(m+2) one-dimensional interpolator of 2nd-order

Arguments

  • m::Int : number of cells
  • c::Float: left interpolation coefficient
source

Utilities

MOLE.BCs.robinBCMethod
robinBC(k, m, dx, a, b)

Returns a m+2 by m+2 one-dimensional mimetic boundary operator that imposes a boundary condition of Robin's type.

Arguments

  • k::Int: Order of accuracy
  • m::Int: Number of cells
  • dx: Step size
  • a: Dirichlet Coefficient
  • b: Neumann Coefficient
source
MOLE.BCs.ScalarBC1DType
Concrete scalar BC description for 1D.

Fields mirror the MATLAB function:
- dc: Dirichlet coefficients (left,right)
- nc: Neumann/Robin coefficients (left,right)
- v:  prescribed boundary value g (left,right)
source
MOLE.BCs.ScalarBC2DType
Concrete scalar BC description for 2D.

Fields mirror the MATLAB function:
- dc: Dirichlet coefficients (left, right, bottom, top)
- nc: Neumann/Robin coefficients (left, right, bottom, top)
- vc: prescribed boundary value g (left, right, bottom, top)
source
MOLE.BCs.addScalarBC!Method
1D BC applicator. Mirrors MATLAB addScalarBC1D.
Signature keeps the discretization params (`k,m,dx`) separate from `bc`.
source
MOLE.BCs.addScalarBC!Method
2D BC applicator. Mirrors MATLAB addScalarBC2D.
Signature keeps the discretization params (`k,m,dx,n,dy`) separate from `bc`.
source

Examples

The MOLE library contains examples demonstrating how to use the operators, in a broad range of partial differential equations (PDEs). More information on the mathematical content can be found in the main MOLE documentation.

Currently, the following examples are available in the MOLE Julia package.

  • Elliptic Problems
    • 1D Examples
      • elliptic1D: A script that solves the 1D Poisson's equation with Robin boundary conditions using mimetic operators.
    • 2D Examples
      • elliptic2DXDirichletYDirichlet: A script that solves the 2D Laplace equation, $\nabla^2 u = 0$, with Dirichlet boundary conditions in $x$ and $y$ using mimetic operators.
      • elliptic2DXPerYDirichlet: A script that solves the 2D Laplace equation, $\nabla^2 u = 0$, with periodic bonudary conditions in $x$ and Dirichlet boundary conditions in $y$ using mimetic operators.
  • Hyperbolic Problems
    • 1D Examples
      • burgers1D: A script that solves the 1D conservative form of inviscid Burgers equation using mimetic operators.
      • hyperbolic1D: A script that solves the 1D Hyperbolic Equation with Periodic boundary conditions using mimetic operators.
  • Parabolic Problems
    • 2D Examples
      • parabolic2D: A script that solves the 2D heat equation, $u_t = \nu \nabla^2 u$, with Dirichlet boundary conditions in $x$ and $y$ using mimetic operators.