Assemblers

This section describes the assemblers that are currently available and their abstract interface.

All assemblers must possess at minimum a DofManager.

The assemblers possess all the baggage to use the internal method sparse! in SparseArrays.jl. This method allows for a zero allocation instantiation of a SparseMatrixCSC type on the CPU. There are also methods available to ease in the conversion of CSC types and other sparse types such as CSR.

On the GPU, however, this type is first converted to an appropriate COO matrix type on the desired backend. There is unfortunately not a unified sparse matrix API in julia for GPUs, so we implement this functionality in package extensions. On CUDA, for example, the operational sequence to get a CuSparseMatrixCSC is to first sort the COO (row, col, val) triplets so they are ordered by row and then column. Then a CuSparseMatrixCOO type is created and converted to a CuSparseMatrixCSC type via CUDA.jl methods. An identical approach is taken for RocM types.

NOTE: This is one of the most actively developed areas of the package. Please use caution with any method beginning with a "_" as these are internal methods that will change without notice.

Matrices

Matrix Action

FiniteElementContainers._assemble_block_matrix_action!Method
_assemble_block_matrix_action!(
    backend::KernelAbstractions.Backend,
    field::FiniteElementContainers.AbstractField,
    conns::L2ElementField,
    b1,
    b2,
    func::Function,
    physics::AbstractPhysics,
    ref_fe::ReferenceFiniteElements.ReferenceFE,
    X::FiniteElementContainers.AbstractField,
    t::Number,
    Δt::Number,
    U::FiniteElementContainers.AbstractField,
    U_old::FiniteElementContainers.AbstractField,
    V::FiniteElementContainers.AbstractField,
    state_old,
    state_new,
    props::AbstractArray,
    return_type
)

Assembly method for a block labelled as block_id. This is a GPU agnostic implementation using KernelAbstractions and Atomix for eliminating race conditions

TODO add state variables and physics properties

source
FiniteElementContainers._assemble_block_matrix_action!Method
_assemble_block_matrix_action!(
    _::KernelAbstractions.CPU,
    field::FiniteElementContainers.AbstractField,
    conns::L2ElementField,
    b1,
    b2,
    func::Function,
    physics::AbstractPhysics,
    ref_fe::ReferenceFiniteElements.ReferenceFE,
    X::FiniteElementContainers.AbstractField,
    t::Number,
    Δt::Number,
    U::FiniteElementContainers.AbstractField,
    U_old::FiniteElementContainers.AbstractField,
    V::FiniteElementContainers.AbstractField,
    state_old,
    state_new,
    props::AbstractArray,
    return_type
)

Assembly method for a block labelled as block_id. This is a CPU implementation with no threading.

TODO improve typing of fields to ensure they mathc up in terms of function spaces

source

Matrix Action

FiniteElementContainers._assemble_block_vector_neumann_bc!Method
_assemble_block_vector_neumann_bc!(
    backend::KernelAbstractions.Backend,
    field::FiniteElementContainers.AbstractField,
    U::FiniteElementContainers.AbstractField,
    X::FiniteElementContainers.AbstractField,
    bc::FiniteElementContainers.NeumannBCContainer
)
source

Scalar

Vector

Abstract Interface

FiniteElementContainers._assemble_block!Method
_assemble_block!(
    _::KernelAbstractions.CPU,
    field,
    conns::L2ElementField,
    block_start_index::Int64,
    block_el_level_size::Int64,
    func::Function,
    physics::AbstractPhysics,
    ref_fe::ReferenceFiniteElements.ReferenceFE,
    X::FiniteElementContainers.AbstractField,
    t::Number,
    dt::Number,
    U::FiniteElementContainers.AbstractField,
    U_old::FiniteElementContainers.AbstractField,
    state_old,
    state_new,
    props::AbstractArray,
    return_type::FiniteElementContainers.AssembledReturnType
)

Assembly method for a block labelled as block_id. This is a CPU implementation with no threading.

TODO add state variables and physics properties

source
FiniteElementContainers._assemble_element!Method
_assemble_element!(
    storage,
    K_el::StaticArraysCore.SMatrix,
    conns,
    el_id::Int64,
    block_start_index::Int64,
    block_el_level_size::Int64
)

Specialization of of _assemble_element! for SparseMatrixAssembler.

source

SparseMatrixAssembler

FiniteElementContainers.SparseMatrixAssemblerType
struct SparseMatrixAssembler{Condensed, NumArrDims, NumFields, IV<:AbstractVector{Int64}, RV<:AbstractVector{Float64}, Var<:FiniteElementContainers.AbstractFunction, FieldStorage<:FiniteElementContainers.AbstractField{Float64, NumArrDims, RV<:AbstractVector{Float64}, NumFields}, QuadratureStorage<:NamedTuple} <: FiniteElementContainers.AbstractAssembler{DofManager{Condensed, Int64, IV<:AbstractVector{Int64}, Var<:FiniteElementContainers.AbstractFunction}}

General sparse matrix assembler that can handle first or second order problems in time.

source
FiniteElementContainers.SparseMatrixAssemblerMethod
SparseMatrixAssembler(
    dof::DofManager
) -> SparseMatrixAssembler{_A, _B, _C, Vector{Int64}, Vector{Float64}, Var, _D, QuadratureStorage} where {_A, _B, _C, Var<:FiniteElementContainers.AbstractFunction, _D<:FiniteElementContainers.AbstractField{Float64, _B, Vector{Float64}, _C}, QuadratureStorage<:(NamedTuple{_A, Tuple{Vararg{Matrix{Float64}, N}}} where {_A, N})}

Construct a SparseMatrixAssembler for a specific field type, e.g. H1Field. Can be used to create block arrays for mixed FEM problems.

source

SparsityPattern