Physics & special functions
Physics
VoronoiFVM.AbstractPhysics
— Typeabstract type AbstractPhysics
Abstract type for physics.
VoronoiFVM.Physics
— Typestruct Physics
Physics data record with the following fields:
flux::Function
: Flux between neighboring control volumes:flux(f,u,edge)
orflux(f,u,edge,data)
should return inf[i]
the flux of species i along the edge joining circumcenters of neighboring control volumes. u is a 2D array such that for species i,u[i,1]
andu[i,2]
contain the unknown values at the corresponding ends of the edge.
storage::Function
: Storage term (term under time derivative):storage(f,u,node)
orstorage(f,u,node,data)
It should return in
f[i]
the storage term for the i-th equation.u[i]
contains the value of the i-th unknown.
reaction::Function
: Reaction term:reaction(f,u,node)
orreaction(f,u,node,data)
It should return in
f[i]
the reaction term for the i-th equation.u[i]
contains the value of the i-th unknown.
edgereaction::Function
: Edge reaction term:edgereaction(f,u,edge)
oredgereaction(f,u,edge,data)
It should return in
f[i]
the reaction term for the i-th equation.u[i]
contains the value of the i-th unknown. u is a 2D array such that for species i,u[i,1]
andu[i,2]
contain the unknown values at the corresponding ends of the edge.
source::Function
: Source term:source(f,node)
orsource(f,node,data)
.It should return the in
f[i]
the value of the source term for the i-th equation.
bflux::Function
: Flux between neighboring control volumes on the boundary. Called on edges fully adjacent to the boundary:bflux(f,u,bedge)
or `bflux(f,u,bedge,data)
breaction::Function
: Boundary reaction term:breaction(f,u,node)
orbreaction(f,u,node,data)
Similar to reaction, but restricted to the inner or outer boundaries.
bsource::Function
: Boundary source term:bsource(f,node)
orbsource(f,node,data)
.It should return in
f[i]
the value of the source term for the i-th equation.
bstorage::Function
: Boundary storage term:bstorage(f,u,node)
orbstorage(f,u,node,data)
Similar to storage, but restricted to the inner or outer boundaries.
boutflow::Function
: Outflow boundary termboutflow(f,u,edge)
orboutflow(f,u,edge,data)
This function is called for edges (including interior ones) which have at least one ode on one of the outflow boundaries. Within this function,outflownode
andisoutflownode
can be used to identify that node. There is some ambiguity in the case that both nodes are outflow nodes, in that case it is assumed that the contribution is zero.
outflowboundaries::Vector{Int64}
: List (Vector) of boundary regions which carry outflow bondary conditions. Influences whenboutflow
is called.
generic_operator::Function
: Generic operatorgeneric_operator(f,u,sys)
. This operator acts on the full solutionu
of a system. Sparsity is detected automatically unlessgeneric_operator_sparsity
is given.
generic_operator_sparsity::Function
: Function defining the sparsity structure of the generic operator. This should return the sparsity pattern of thegeneric_operator
.
data::Any
: User data (parameters). This allows to pass various parameters to the callback functions.
num_species::Int8
: Number of species including boundary species.
VoronoiFVM.Physics
— MethodPhysics(;num_species=0,
data=nothing,
flux,
reaction,
edgereaction,
storage,
source,
breaction,
bstorage,
boutflow,
outflowboundaries,
generic,
generic_sparsity
)
Constructor for physics data. For the meaning of the optional keyword arguments, see VoronoiFVM.System(grid::ExtendableGrid; kwargs...)
.
Base.show
— Methodshow(io, physics)
Show physics object
Edge and node data
VoronoiFVM.Node
— Typemutable struct Node{Tc, Tp, Ti} <: VoronoiFVM.AbstractNode{Tc, Tp, Ti}
Structure holding local node information.
index::Any
: Index in grid
region::Any
: Inner region number
nspec::Any
: Number of species defined in node
icell::Any
: Number of discretization cell the node is invoked from
coord::Matrix
: Grid coordinates
cellnodes::Matrix
: Grid cell nodes
cellregions::Vector
: Grid cell regions
time::Float64
: System time
embedparam::Float64
: Current value of embedding parameter
params::Vector
: parameters
fac::Float64
: Form factor
_idx::Any
: Local loop index
VoronoiFVM.BNode
— Typemutable struct BNode{Tv, Tc, Tp, Ti} <: VoronoiFVM.AbstractNode{Tc, Tp, Ti}
Structure holding local boundary node information.
index::Any
: Index in grid
ibface::Any
: BFace number it is called from
ibnode::Any
: local node number
region::Any
: Boundary region number
cellregions::Vector
nspec::Any
: Number of species defined in node
coord::Matrix
: Grid coordinates
bfacenodes::Matrix
bfaceregions::Vector
allcellregions::Vector
bfacecells::Adjacency
Dirichlet::Any
time::Float64
: System time
embedparam::Float64
: Current value of embedding parameter
params::Vector
dirichlet_value::Vector
fac::Float64
VoronoiFVM.Edge
— Typemutable struct Edge{Tc, Tp, Ti} <: VoronoiFVM.AbstractEdge{Tc, Tp, Ti}
Structure holding local edge information.
index::Any
: Index in grid
node::Vector
: Index
region::Any
: Inner region number corresponding to edge
nspec::Any
: Number of species defined in edge
icell::Any
: Number of discretization cell the edge is invoked from
coord::Matrix
: Grid coordinates
cellx::Matrix
edgenodes::Matrix
cellregions::Vector
has_celledges::Bool
time::Float64
: System time
embedparam::Float64
: Current value of embedding parameter
params::Vector
fac::Float64
: Form factor
_idx::Any
: Local loop index
outflownoderegions::Union{Nothing, SparseArrays.SparseMatrixCSC{Bool, Int64}}
outflownode::Int64
: Outflow node
VoronoiFVM.BEdge
— Typemutable struct BEdge{Tc, Tp, Ti} <: VoronoiFVM.AbstractEdge{Tc, Tp, Ti}
Structure holding local edge information.
index::Any
: Index in grid
node::Vector
: Index
region::Any
: Inner region number corresponding to edge
nspec::Any
: Number of species defined in edge
icell::Any
: Number of discretization cell the edge is invoked from
coord::Matrix
: Grid coordinates
bedgenodes::Matrix
bfaceedges::Matrix
bfaceregions::Vector
time::Float64
: System time
embedparam::Float64
: Current value of embedding parameter
params::Vector
fac::Float64
Special functions
VoronoiFVM.fbernoulli
— Functionfbernoulli(x)
Bernoulli function $B(x)=\frac{x}{e^x-1}$ for exponentially fitted upwinding.
The name fbernoulli
has been chosen to avoid confusion with Bernoulli from JuliaStats/Distributions.jl
Returns a real number containing the result.
VoronoiFVM.fbernoulli_pm
— Functionfbernoulli_pm(x)
Bernoulli function $B(x)=\frac{x}{e^x-1}$ for exponentially fitted upwind, joint evaluation for positive and negative argument
Usually, we need $B(x), B(-x)$ together, and it is cheaper to calculate them together.
Returns two real numbers containing the result for argument x
and argument -x
.
The error in comparison with the evaluation of the original expression with BigFloat is less than 1.0e-15
VoronoiFVM.inplace_linsolve!
— Methodinplace_linsolve!(A, b)
Non-allocating, non-pivoting inplace solution of square linear system of equations A*x=b
using Doolittle's method.
After solution, A
will contain the LU factorization, and b
the result.
A pivoting version is available with Julia v1.9.
VoronoiFVM.inplace_linsolve!
— Methodinplace_linsolve!(A, b, ipiv)
Non-allocating, pivoting, inplace solution of square linear system of equations A*x=b
using LU factorization from RecursiveFactorizations.jl.
After solution, A
will contain the LU factorization, and b
the result. ipiv
must be an Int64 vector of the same length as b
.
Needs Julia v1.9 or later