Internal API

Besides of the interface methods for VoronoiFVMDiffEq, these are not exported and therefore should not be used outside of the package

Wrapping evaluators for physics callbacks

VoronoiFVM.ResEvaluatorType
struct ResEvaluator{Tv<:Number, Func<:Function, G} <: VoronoiFVM.AbstractEvaluator

Evaluator for functions from physics. Allows to call different types of physic functions (flux, reaction, source) an provides a common interface to different function formats (with data, without data etc.)

  • fwrap::Function: wrapper function in Format ready for Diffetential equations

  • y::Vector{Tv} where Tv<:Number: pre-allocated result

  • geom::Any: Geometry object # geometry (node, edge...)

  • nspec::Int64: number of species

  • isnontrivial::Bool: Is the function not nofunc

source
VoronoiFVM.ResEvaluatorMethod
 ResEvaluator(physics,symb,uproto,geom,nspec)

Constructor for ResEvaluator

  • physics Physics object
  • symb: symbol naming one of the functions in physics to be wrapped.
  • uproto: solution vector prototype,
  • geom: node, edge...
  • nspec: number of species
source
VoronoiFVM.evaluate!Method
evaluate!(e::VoronoiFVM.ResEvaluator)

Call function in evaluator, store result in predefined memory.

source
VoronoiFVM.evaluate!Method
evaluate!(e::VoronoiFVM.ResEvaluator, u)

Call function in evaluator, store result in predefined memory.

source
VoronoiFVM.resMethod
res(
    e::VoronoiFVM.ResEvaluator
) -> Vector{Tv} where Tv<:Number

Retrieve evaluation result

source
VoronoiFVM.ResJacEvaluatorType
struct ResJacEvaluator{Tv<:Number, Func<:Function, Cfg, Res, G} <: VoronoiFVM.AbstractEvaluator

Evaluator for functions from physics and their Jacobians. Allows to call different types of physic functions (flux, reaction, source) an provides a common interface to different function formats (with data, without data etc.)

  • fwrap::Function: wrapper function in Format ready for Differential equations

  • config::Any: ForwardDiff.JacobianConfig

  • result::Any: DiffResults.JacobianResult

  • y::Vector{Tv} where Tv<:Number: pre-allocated result

  • geom::Any: Geometry object # geometry (node, edge...)

  • nspec::Int64: number of species

  • isnontrivial::Bool: Is the function not nofunc

source
VoronoiFVM.ResJacEvaluatorMethod
ResJacEvaluator(physics, data, symb, uproto, geom, nspec)

Constructor for ResJEvaluator

  • physics Physics object
  • symb: symbol naming one of the functions in physics to be wrapped.
  • uproto: solution vector prototype,
  • geom: node, edge...
  • nspec: number of species
source
VoronoiFVM.evaluate!Method
evaluate!(e::VoronoiFVM.ResJacEvaluator, u)

Call function in evaluator, store result and jacobian in predefined memory.

source
VoronoiFVM.isnontrivialFunction
isnontrivial(e::VoronoiFVM.AbstractEvaluator) -> Any

Does calling the evaluator giva nontrivial (nonzero) result?

source

Manipulating systems

VoronoiFVM._complete!Function
_complete!(system)

Update grid and compile species information for system. Uses a lock to ensure parallel access.

source

Global node and edge assembly loops

VoronoiFVM.CellwiseAssemblyDataType
struct CellwiseAssemblyData{Tv, Ti} <: VoronoiFVM.AbstractAssemblyData{Tv, Ti}

Data for cellwise assembly.

  • nodefactors::Matrix: Precomputed geometry factors for cell nodes. This is a ncells x nnodes_per_cell full matrix.
  • edgefactors::Matrix: Precomputed geometry factors for cell edges This is a ncells x nedge_per_cell full matrix.
  • pcolor_partitions::Vector

  • partition_cells::Vector

source
VoronoiFVM.EdgewiseAssemblyDataType
struct EdgewiseAssemblyData{Tv, Ti} <: VoronoiFVM.AbstractAssemblyData{Tv, Ti}
  • nodefactors::SparseArrays.SparseMatrixCSC{Tv, Ti} where {Tv, Ti}: Precomputed geometry factors for nodes. This is a nnodes x nregions sparse matrix.
  • edgefactors::SparseArrays.SparseMatrixCSC{Tv, Ti} where {Tv, Ti}: Precomputed geometry factors for edges This is a nedges x nregions sparse matrix.
  • pcolor_partitions::Vector

  • partition_nodes::Vector

  • partition_edges::Vector

source
VoronoiFVM._fill!Function
_fill!(node, asmdata, inode, icell)

Fill node with the help of assemblydata.

source
_fill!(node, asmdata, ibnode, ibface)

Fill boundary node with the help of assemblydata.

source
_fill!(edge, asmdata, iedge, icell)

Fill edge with the help of assemblydata.

source
_fill!(bedge, asmdata, ibedge, ibface)

Fill boundary edge with the help of assemblydata.

source
_fill!(node, asmdata, k, inode)

Fill node with the help of assemblydata.

source
_fill!(edge, asmdata, k, iedge)

Fill edge with the help of assemblydata.

source

Local node and edge assembly loops

Local assembly methods organize the assembly of data to those degrees of freedom (dofs) which are defined for a given node or edge. E.g. for an node residual for nspec defined species, only those entries need to be assembled into the global residual vector which correspond to actually defined degrees of freedom.

Similarly for nspec x nspec node Jacobian, an for the nparam x nspec parameter derivatives.

These local assembly methods organize the correct loops and call back to the concrete assembly methods passed to them. These receive global degrees of freedom and the local species numbers to be handled. The callbacks can be used as well for other purposes than assembly

VoronoiFVM.assemble_res_jacFunction
assemble_res_jac(node, system, asm_res, asm_jac, asm_param)

Assemble residual and jacobian for node functions. Parameters:

  • system: System to be worked with

  • node: node

  • asm_jac(idof,jdof,ispec,jspec): e.g. assemble entry ispec,jspec of local jacobian into entry idof,jdof of global matrix

  • asm_param(idof,ispec,iparam) shall assemble parameter derivatives

source
assemble_res_jac(bnode, system, asm_res, asm_jac, asm_param)

Assemble residual and jacobian for boundary node functions. See assemble_res_jac for more explanations.

source
assemble_res_jac(edge, system, asm_res, asm_jac, asm_param)

Assemble residual and jacobian for edge (flux) functions. Parameters:

  • system: System to be worked with
  • edge: edge
  • asm_res(idofK,idofL,ispec): e.g. assemble local ispec to global degrees of freedom in unknowns
  • asm_jac(idofK,jdofK,idofL,jdofL,ispec,jspec): e.g. assemble entry ispec,jspec of local jacobian into entry four entries defined by idofK and idofL of global matrix
  • asm_param(idofK,idofL,ispec,iparam) shall assemble parameter derivatives
source
assemble_res_jac(bedge, system, asm_res, asm_jac, asm_param)

Assemble residual and jacobian for boundary edge (flux) functions. See assemble_res_jac for more explanations.

source
VoronoiFVM.assemble_resFunction
assemble_res(node, system, asm_res)

Assemble residual for node functions. See assemble_res_jac for more explanations.

source
assemble_res(bnode, system, asm_res)

Assemble residual for boundary node functions. See assemble_res_jac for more explanations.

source
assemble_res(edge, system, asm_res)

Assemble residual for edge (flux) functions. See assemble_res_jac for more explanations.

source
assemble_res(bedge, system, asm_res)

Assemble residual for boundary edge (flux) functions. See assemble_res_jac for more explanations.

source

Degree of Freedom management

We distinguish

  • active degrees of freedom: these are the actual degrees of freedom
  • degrees of freedom (dof) potential degrees of freedom - the may be active dofs or dummy ones With sparse arrays there are no dummy ones, with dense arrays dummy are maske in the node_dof field
  • species: each degree of freedom has associated the species it represents and the node index where it is localized
VoronoiFVM.getnodedofFunction
getnodedof(system,ispec,inode)

Get active or dummy degree of freedom associated with node and species

source
VoronoiFVM.addzrowsFunction
addzrows(matrix,maxrow)

Return matrix with number of rows increased to maxrow, and set the new elements to zero.

source
VoronoiFVM.dofsFunction
dofs(a)

Vector of degrees of freedom in solution array.

source
dofs(a)

Vector of degrees of freedom in sparse solution array.

source

Geometry data

VoronoiFVM.AbstractNodeType
abstract type AbstractNode{Tc<:Number, Tp<:Number, Ti<:Integer} <: AbstractGeometryItem{Tc<:Number, Tp<:Number, Ti<:Integer}

Abstract type for nodes.

node[idim] gives the the corresponding coordinate.

source
VoronoiFVM.AbstractNodeDataType
abstract type AbstractNodeData{Tv<:Number} <: AbstractArray{Tv<:Number, 1}

Abstract type for data on nodes. u[ispec] accesses value of species at this node.

source
VoronoiFVM.AbstractEdgeType
abstract type AbstractEdge{Tv<:Number, Tp<:Number, Ti<:Integer} <: AbstractGeometryItem{Tv<:Number, Tp<:Number, Ti<:Integer}

Abstract type for edges

edge[idim,inode] gives coordinate of node.

source
VoronoiFVM.AbstractEdgeDataType
abstract type AbstractEdgeData{Tv<:Number} <: AbstractArray{Tv<:Number, 2}

Abstract type for data on edges. u[ispec,inode] accesses value of species at corresponding node.

source

Global assembly & helpers

VoronoiFVM.solve_step!Function
solve_step!(
    state,
    solution,
    oldsol,
    control,
    time,
    tstep,
    embedparam,
    params
)

Solve time step problem. This is the core routine for implicit Euler and stationary solve.

source
VoronoiFVM.eval_and_assembleFunction
eval_and_assemble(
    system,
    U,
    UOld,
    F,
    matrix,
    dudp,
    time,
    tstep,
    λ,
    data,
    params;
    edge_cutoff
)

Main assembly method.

Evaluate solution with result in right hand side F and assemble Jacobi matrix into system.matrix.

source
VoronoiFVM._addnzFunction
_addnz(matrix, i, j, v, fac)
_addnz(matrix, i, j, v, fac, part)

Add value v*fac to matrix if v is nonzero

source
VoronoiFVM._addFunction
_add(U::VoronoiFVM.DenseSolutionArray, idof, val) -> Any

Add residual value into global degree of freedom

(Internal method)

source
_add(U::VoronoiFVM.SparseSolutionArray, idof, val) -> Any

Add residual value into global degree of freedom

(internal)

source

Interface methods for VoronoiFVMDiffEq.jl

VoronoiFVM._eval_res_jac!Function
_eval_res_jac!(state, u, t)

Evaluate functiaon and Jacobian at u if they have not been evaluated before at u. See https://github.com/SciML/DifferentialEquations.jl/issues/521 for discussion of another way to do this.

source
VoronoiFVM.prepare_diffeq!Function
prepare_diffeq!(state, jacval, tjac)

Prepare system for use with VoronoiFVMDiffEq.

  • jacval: value at which to evaluate jacobian to obtatin prototype
  • tjac: time moment for jacobian

Returns a prototype for the jacobian.

source

Misc tools

VoronoiFVM.integrateMethod
integrate(, coordl, coordr, hnormal, velofunc; kwargs...)

This is an internal function to integrate velofunc along the edge $\sigma=\overline{\mathtt{coordl}\,\mathtt{coordr}}$ between the $x_K$ and $x_L$ where $\mathtt{hnormal}=x_K-x_L$ using Simpson's Rule. To be precise, compute for a cartesian coordinate system: $\int_{\sigma} \mathbf{v} \cdot \mathbf{n} \,\mathrm{ds} \lvert x_K - x_L \rvert / \lvert\sigma\rvert$.

source
VoronoiFVM.integrateMethod
integrate(, coordl, coordr, hnormal, velofunc; kwargs...)

This is an internal function similar to integrate(::Type{<:Cartesian2D},...), but computes instead $\int_{\sigma} r \, \mathbf{v} \cdot \mathbf{n} \,\mathrm{ds} \lvert x_K - x_L \rvert / \left ( \lvert\sigma\rvert r(\mathrm{mid}(\sigma)) \right )$ where $r(\mathrm{mid}(\sigma))$ is the $r$-coordinate of the mid-point of $\sigma$.

source
VoronoiFVM.doolittle_ludecomp!Function
doolittle_ludecomp!(LU)

Non-pivoting inplace LU factorization using Doolittle's method. Adapted from https://en.wikipedia.org/wiki/LUdecomposition#MATLABcode_example.

source
VoronoiFVM.doolittle_lusolve!Function
doolittle_lusolve!(LU, b)

Non-pivoting inplace upper and lower triangular solve of matrix factorized with doolittle_ludecomp!. Adapted from https://en.wikipedia.org/wiki/LUdecomposition#MATLABcode_example.

source