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 one of nofunc ot nofunc2

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 one of nofunc ot nofunc2

source
VoronoiFVM.ResJacEvaluatorMethod
ResJacEvaluator(physics, 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

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.
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.
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

Abstract geometry data

VoronoiFVM.AbstractNodeType
abstract type AbstractNode{Tc<:Number, Tp<:Number, Ti<:Integer} <: VoronoiFVM.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} <: VoronoiFVM.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.eval_and_assembleFunction
eval_and_assemble(
    system,
    U,
    UOld,
    F,
    time,
    tstep,
    λ,
    params;
    edge_cutoff
)

Main assembly method.

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

source
VoronoiFVM._addFunction
_add(U::Array{Tv, 2}, idof, val) -> Any

Add residual value into global degree of freedom

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

Add residual value into global degree of freedom

source

Interface methods for VoronoiFVMDiffEq.jl

VoronoiFVM._eval_res_jac!Function
_eval_res_jac!(sys, 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.mass_matrixFunction
mass_matrix(system)

Calculate the mass matrix for use with ODEFunction. Return a Diagonal matrix if it occurs to be diagonal, otherwise return a SparseMatrixCSC.

source
VoronoiFVM.prepare_diffeq!Function
prepare_diffeq!(sys, 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