System
Types and Constants
VoronoiFVM.AbstractSystem
— Typeabstract type AbstractSystem
Abstract type for finite volume system structure
VoronoiFVM.DenseSystem
— Typemutable struct DenseSystem{Tv, Ti} <: VoronoiFVM.AbstractSystem{Tv,Ti}
Structure holding data for finite volume system solution. Information on species distribution is kept in dense matrices, and the solution array is of type Array{2}.
Unlike in the SparseSystem, the system matrix handles exactly those degrees of freedom which correspond to unknowns, and dummy degrees of freedom where unknowns are not defined. Handling of the sparse matrix structures for the bookeeping of the unknowns has less overhead, but additional dummy equations are added to the system matrix.
grid::VoronoiFVM.Grid
Grid{Tv,Ti}
physics::VoronoiFVM.Physics
Physics data
boundary_values::Array{Tv,2} where Tv
Array of boundary values
boundary_factors::Array{Tv,2} where Tv
Array of boundary factors
region_species::Array{Int8,2}
Full matrix containing species numbers for inner regions
bregion_species::Array{Int8,2}
Full matrix containing species numbers for boundary regions
node_dof::Array{Int8,2}
Full matrix containing degree of freedom numbers for each node
matrix::ExtendableSparse.ExtendableSparseMatrix{Tv,Ti} where Ti where Tv
Jacobi matrix for nonlinear problem
species_homogeneous::Bool
Flag which says if the number of unknowns per node is constant
update::Array{Tv,2} where Tv
Solution vector holding Newton update
residual::Array{Tv,2} where Tv
Solution vector holding Newton residual
VoronoiFVM.DenseSystem
— MethodDenseSystem(grid::VoronoiFVM.Grid, physics::VoronoiFVM.Physics) -> VoronoiFVM.DenseSystem{_1,_2} where _2 where _1
Constructor for DenseSystem.
VoronoiFVM.SparseSolutionArray
— Typestruct SparseSolutionArray{Tv, Ti} <: AbstractArray{Tv,2}
Struct holding solution information for SparseSystem. Solution is stored in a sparse matrix structure.
This class plays well with the abstract array interface.
node_dof::SparseArrays.SparseMatrixCSC{Tv,Ti} where Ti where Tv
Sparse matrix holding actual data.
VoronoiFVM.SparseSystem
— Typemutable struct SparseSystem{Tv, Ti} <: VoronoiFVM.AbstractSystem{Tv,Ti}
Structure holding data for finite volume system solution. Information on species distribution is kept in sparse matrices, and the solution array is of type SparseSolutionArray, i.e. effectively it is a sparse matrix.
Unlike in the DenseSystem, the system matrix handles exactly those degrees of freedom which correspond to unknowns. However, handling of the sparse matrix structures for the bookkeeping of the unknowns creates overhead.
grid::VoronoiFVM.Grid{Tv,Ti} where Ti where Tv
Grid
physics::VoronoiFVM.Physics
Physics data
boundary_values::Array{Tv,2} where Tv
Array of boundary values
boundary_factors::Array{Tv,2} where Tv
Array of boundary factors
region_species::SparseArrays.SparseMatrixCSC{Int8,Ti} where Ti
Sparse matrix containing species numbers for inner regions
bregion_species::SparseArrays.SparseMatrixCSC{Int8,Ti} where Ti
Sparse matrix containing species numbers for boundary regions
node_dof::SparseArrays.SparseMatrixCSC{Int8,Ti} where Ti
Sparse matrix containing degree of freedom numbers for each node
matrix::ExtendableSparse.ExtendableSparseMatrix{Tv,Ti} where Ti where Tv
Jacobi matrix for nonlinear problem
species_homogeneous::Bool
Flag which says if the number of unknowns per node is constant
update::VoronoiFVM.SparseSolutionArray
Solution vector holding Newton update
residual::VoronoiFVM.SparseSolutionArray
Solution vector holding Newton residual
VoronoiFVM.SubgridArrayView
— Typestruct SubgridArrayView{Tv, Ta} <: AbstractArray{Tv,2}
Struct holding information for solution array view on subgrid
sysarray::Any
Original array
subgrid::VoronoiFVM.SubGrid
Subgrid for view
VoronoiFVM.BNode
— Typemutable struct BNode{Tv, Ti} <: VoronoiFVM.AbstractGeometryItem{Tv,Ti}
Structure holding local boundary node information.
index::Any
Index in grid
region::Any
Boundary region number
nspec::Any
Number of species defined in node
grid::VoronoiFVM.Grid{Tv,Ti} where Ti where Tv
Grid
VoronoiFVM.Edge
— Typemutable struct Edge{Tv, Ti} <: VoronoiFVM.AbstractGeometryItem{Tv,Ti}
Structure holding local edge information.
index::Any
Index in grid
node::Array{Ti,1} where Ti
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
grid::VoronoiFVM.Grid{Tv,Ti} where Ti where Tv
Grid
VoronoiFVM.Node
— Typemutable struct Node{Tv, Ti} <: VoronoiFVM.AbstractGeometryItem{Tv,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
grid::VoronoiFVM.Grid{Tv,Ti} where Ti where Tv
Grid
VoronoiFVM.AssemblyError
— Typestruct AssemblyError <: Exception
Exception thrown if error occured during assembly (e.g. domain error)
VoronoiFVM.ConvergenceError
— Typestruct ConvergenceError <: Exception
Exception thrown if Newton's method convergence fails.
VoronoiFVM.EmbeddingError
— Typestruct EmbeddingError <: Exception
Exception thrown if embedding fails
VoronoiFVM.FactorizationError
— Typestruct FactorizationError <: Exception
Exception thrown if error occured during factorization.
VoronoiFVM.NewtonControl
— Typemutable struct NewtonControl
Control parameter structure for Newton method.
tol_absolute::Float64
Tolerance (in terms of norm of Newton update)
tol_relative::Float64
Tolerance (relative to the first residual)
tol_round::Float64
Tolerance for roundoff error detection
damp_initial::Float64
Initial damping parameter
damp_growth::Float64
Damping parameter growth factor
max_iterations::Int32
Maximum number of iterations
max_lureuse::Int32
Maximum number of reuses of lu factorization
max_round::Int32
Maximum number of consecutive iterations within roundoff error tolerance
tol_linear::Float64
Tolerance of iterative linear solver
verbose::Bool
Verbosity flag
handle_exceptions::Bool
Handle exceptions
Δp::Float64
Parameter step for embedding
Δp_max::Float64
Maximal parameter step
Δp_min::Float64
Minimal parameter step
edge_cutoff::Float64
Edge cutoff for rectangular triangles
VoronoiFVM.NewtonControl
— MethodNewtonControl(this::Any) -> Any
Default constructor
VoronoiFVM.TestFunctionFactory
— Typemutable struct TestFunctionFactory{Tv}
Data structure containing DenseSystem used to calculate test functions for boundary flux calculations.
system::VoronoiFVM.AbstractSystem{Tv,Ti} where Ti<:Integer where Tv
Original system
tfsystem::VoronoiFVM.DenseSystem
Test function system
VoronoiFVM.TestFunctionFactory
— MethodConstructor for TestFunctionFactory from System
VoronoiFVM.Dirichlet
— ConstantConstant to be used as boundary condition factor to mark Dirichlet boundary conditons.
Methods
VoronoiFVM.boundary_dirichlet!
— Methodboundary_dirichlet!(this::VoronoiFVM.AbstractSystem, ispec::Integer, ibc::Integer, val::Any) -> Any
Set Dirichlet boundary conditon for species ispec at boundary ibc.
VoronoiFVM.boundary_neumann!
— Methodboundary_neumann!(this::VoronoiFVM.AbstractSystem, ispec::Integer, ibc::Integer, val::Any) -> Any
Set Neumann boundary conditon for species ispec at boundary ibc.
VoronoiFVM.boundary_robin!
— Methodboundary_robin!(this::VoronoiFVM.AbstractSystem, ispec::Integer, ibc::Integer, fac::Any, val::Any) -> Any
Set Robin boundary conditon for species ispec at boundary ibc.
VoronoiFVM.data
— Methoddata(this::VoronoiFVM.AbstractSystem) -> Any
Retrieve user data record.
VoronoiFVM.enable_boundary_species!
— Methodenable_boundary_species!(this::VoronoiFVM.AbstractSystem, ispec::Integer, bregions::AbstractArray{T,1} where T)
Add species to a list of boundary regions. Species numbers for bulk and boundary species have to be distinct.
VoronoiFVM.enable_species!
— Methodenable_species!(this::VoronoiFVM.AbstractSystem, ispec::Integer, regions::AbstractArray{T,1} where T)
Add species to a list of bulk regions. Species numbers for bulk and boundary species have to be distinct.
VoronoiFVM.num_nodes
— Methodnum_nodes(a::AbstractArray) -> Any
Number of nodes (size of second dimension) of solution array.
VoronoiFVM.dof
— Methoddof(a::Tv, ispec::Tv, K::Tv)
Get number of degree of freedom.
VoronoiFVM.num_dof
— Methodnum_dof(this::VoronoiFVM.DenseSystem) -> Int64
Number of degrees of freedom for system.
VoronoiFVM.unknowns
— MethodCreate a solution vector for dense system. If inival is not specified, the entries of the returned vector are undefined.
VoronoiFVM.unknowns
— Methodunknowns(Tu::Tv, sys::Tv; inival) -> Any
Create a solution vector for dense system. If inival is not specified, the entries of the returned vector are undefined.
VoronoiFVM.dof
— Methoddof(a, i, j)
Get number of degree of freedom. Return 0 if species is not defined in node.
VoronoiFVM.getdof
— Methodgetdof(a::VoronoiFVM.SparseSolutionArray, i::Integer) -> Any
Return value for degree of freedom.
VoronoiFVM.num_dof
— Methodnum_dof(this::VoronoiFVM.SparseSystem) -> Any
Number of degrees of freedom for system.
VoronoiFVM.setdof!
— Methodsetdof!(a::VoronoiFVM.SparseSolutionArray, v::Any, i::Integer) -> Any
Set value for degree of freedom.
VoronoiFVM.unknowns
— MethodCreate a solution vector for sparse system. The entries of the returned vector are undefined.
VoronoiFVM.unknowns
— Methodunknowns(Tu, sys; inival)
Create a solution vector for sparse system with given type. If inival is not specified, the entries of the returned vector are undefined.
VoronoiFVM.meas
— Methodmeas(edge::VoronoiFVM.Edge) -> Any
Calculate the length of an edge.
VoronoiFVM.viewK
— MethodviewK(nspec::Any, u::AbstractArray) -> Any
Solution view on first edge node
VoronoiFVM.viewK
— MethodviewK(edge::VoronoiFVM.Edge, u::AbstractArray) -> Any
Solution view on first edge node
VoronoiFVM.viewL
— MethodviewL(nspec::Any, u::AbstractArray) -> Any
Solution view on second edge node
VoronoiFVM.viewL
— MethodviewL(edge::VoronoiFVM.Edge, u::AbstractArray) -> Any
Solution view on second edge node
VoronoiFVM.embed!
— Methodembed!(solution::Tv, xinival::Tv, this::Tv; control, pre, post)
Solution method for instance of abstract system.
Perform solution via parameter embedding, calling solve! for each value of the parameter p from interval (0,1). The user is responsible for the interpretation of the parameter. The optional pre()
callback can be used to communicate its value to the system. The optionalpost()
callback method can be used to perform various postprocessing steps.
If control.handle_error
is true, solve!
throws an error, and stepsize control.Δp
is lowered, and solve!
is called again with a smaller parameter value. If control.Δp<control.Δp_min
, embed!
is aborted with error.
VoronoiFVM.integrate
— Methodintegrate(this, F, U)
Integrate function F
of solution vector over domain. The result contains the integral for each species separately.
VoronoiFVM.solve!
— MethodSolution method for instance of abstract system.
Perform solution of stationary system (if tstep==Inf
) or one tine step of implicit Euler time step system using Newton's method with damping. Initial damping is chosen according control.damp_initial
.
VoronoiFVM.value
— FunctionExtract value from dual number. Use to debug physics callbacks. Re-exported from ForwardDiff.jl
VoronoiFVM.integrate
— Methodintegrate(this, tf, U, Uold, tstep)
Calculate test function integral for transient solution.
VoronoiFVM.integrate
— Methodintegrate(this, tf, U)
Calculate test function integral for steady state solution.
VoronoiFVM.testfunction
— Methodtestfunction(factory::Tv, bc0::Tv, bc1::Tv)
Create testfunction which has Dirichlet zero boundary conditions for boundary regions in bc0 and Dirichlet one boundary conditions for boundary regions in bc1.
VoronoiFVM.System
— MethodSystem(grid::VoronoiFVM.Grid, physics::VoronoiFVM.Physics; unknown_storage) -> Union{DenseSystem{_1,_2} where _2 where _1, SparseSystem{_1,_2} where _2 where _1}
Create Finite Volume System.
grid
: 1D/2D/3D discretization gridphysics
: Physics struct containing node and edge callbacksunknown_storage
: string or symbol::dense
: solution vector is annspecies
xnnodes
dense matrix:sparse
: solution vector is annspecies
xnnodes
sparse matrix
VoronoiFVM.is_boundary_species
— Methodis_boundary_species(this::VoronoiFVM.AbstractSystem, ispec::Integer) -> Bool
Check if species number corresponds to boundary species.
VoronoiFVM.is_bulk_species
— Methodis_bulk_species(this::VoronoiFVM.AbstractSystem, ispec::Integer) -> Bool
Check if species number corresponds bulk species.
VoronoiFVM.isdof
— Methodisdof(this::VoronoiFVM.AbstractSystem, ispec::Any, inode::Any) -> Bool
Check if degree of freedom is defined.
VoronoiFVM.num_species
— Methodnum_species(a::AbstractArray) -> Any
Number of species (size of first dimension) of solution array.
VoronoiFVM.num_species
— Methodnum_species(this::VoronoiFVM.AbstractSystem) -> Any
Number of species in system
Base.reshape
— Methodreshape(v, sys)
Reshape vector to fit as solution to system.
VoronoiFVM.values
— Methodvalues(a::Array) -> Array{T,1} where T
Array of values in solution array.
Base.copy
— MethodCreate a copy of solution array
Base.getindex
— Methodgetindex(a::VoronoiFVM.SparseSolutionArray, ispec::Integer, inode::Integer) -> Any
Accessor for solution array.
Base.reshape
— Methodreshape(v, sys)
Reshape vector to fit as solution to system.
Base.setindex!
— Methodsetindex!(a::VoronoiFVM.SparseSolutionArray, v::Any, ispec::Integer, inode::Integer) -> Union{Nothing, SparseSolutionArray}
Accessor for solution array.
Base.size
— Methodsize(a::VoronoiFVM.SparseSolutionArray) -> Tuple{Int64,Int64}
Return size of solution array.
VoronoiFVM.values
— Methodvalues(a::VoronoiFVM.SparseSolutionArray) -> Array{Tv,1} where Tv
Array of values in solution array.
Base.getindex
— Methodgetindex(aview::VoronoiFVM.SubgridArrayView, ispec::Integer, inode::Integer) -> Any
Accessor method for subgrid array view.
Base.setindex!
— Methodsetindex!(aview::VoronoiFVM.SubgridArrayView, v::Any, ispec::Integer, inode::Integer) -> VoronoiFVM.SubgridArrayView
Accessor method for subgrid array view.
Base.size
— Methodsize(a::VoronoiFVM.SubgridArrayView) -> Tuple{Any,Int64}
Return size of solution array view.
Base.view
— Methodview(a::Tv, sg::Tv) -> SubArray
Create a view of the solution array on a subgrid.
VoronoiFVM.num_species
— Methodnum_species(edge::VoronoiFVM.Edge) -> Any
Return number of species for edge
VoronoiFVM.eval_and_assemble
— Methodeval_and_assemble(system, U, UOld, F, tstep; edge_cutoff)
Main assembly method.
Evaluate solution with result in right hand side F and assemble matrix into system.matrix.
VoronoiFVM.integrate_stdy
— MethodSteady state part of test function integral.
VoronoiFVM.integrate_tran
— Methodintegrate_tran(this, tf, U)
Calculate transient part of test function integral.