Fields
Fields serve as loose wrappers around AbstractArray subtypes such that the size of array slices are known at compile time. Although this introduces a type-instability, the idea is to do this at the top most level (mainly at setup time of a FEM simulation). By introducing this type instability, we can gain information about the field type that is used in methods downstream to construct StaticArrays of views of field types.
All fields are subtypes of the abstract type AbstractField
julia> using FiniteElementContainersjulia> AbstractFieldERROR: UndefVarError: `AbstractField` not defined
Example - H1Field a.k.a. NodalField
We can set up a H1Field in one of two ways. The simplest constructor form can be used as follows
julia> using FiniteElementContainersjulia> field = H1Field(rand(2, 10), (:field_1, :field_2))ERROR: MethodError: no method matching H1Field(::Matrix{Float64}, ::Tuple{Symbol, Symbol}) Closest candidates are: H1Field(::M) where M<:(AbstractMatrix) @ FiniteElementContainers ~/work/FiniteElementContainers.jl/FiniteElementContainers.jl/src/fields/H1Field.jl:13
This is stored in a vectorized way as can be seen above
julia> field.valsERROR: UndefVarError: `field` not defined
Fields can be indexed like regular arrays, e.g.
julia> field[1, 1]ERROR: UndefVarError: `field` not defined
julia> field[1, :]ERROR: UndefVarError: `field` not defined
etc.
But they can also be indexed by the symbols provided during construction
julia> field[:field_1]ERROR: UndefVarError: `field` not defined
Abstract type
The base type for fields is the AbstractField abstract type.
FiniteElementContainers.AbstractField — Typeabstract type AbstractField{T, N, D<:AbstractArray{T, 1}, NF} <: AbstractArray{T, N}Thin wrapper that subtypes AbstractArray and serves as the base Field type
Any new field added to FiniteElementContainers should be a subtype of this type.
Methods for AbstractField
Base.fill! — Methodfill!(
field::FiniteElementContainers.AbstractField{T, N, D, NF},
v
) -> Any
FiniteElementContainers.num_fields — Methodnum_fields(
_::FiniteElementContainers.AbstractField{T, N, D, NF}
) -> Any
KernelAbstractions.get_backend — Methodget_backend(
field::FiniteElementContainers.AbstractField
) -> Any
Implementations
The existing direct subtypes of AbstractField are the following
Connectivity
The connectivity type is a simple alias for L2ElementField defined below
FiniteElementContainers.Connectivity — Typestruct L2ElementField{T, D, NF} <: FiniteElementContainers.AbstractField{T, 2, D, NF}FiniteElementContainers.connectivity — Methodconnectivity(
conn::L2ElementField,
e::Int64
) -> SubArray{T, 1} where T
FiniteElementContainers.connectivity — Methodconnectivity(conn::L2ElementField) -> Any
H1 field
FiniteElementContainers.H1Field — Typestruct H1Field{T, D, NF} <: FiniteElementContainers.AbstractField{T, 2, D, NF}Implementation of fields that live on nodes.
FiniteElementContainers.H1Field — MethodH1Field(data::AbstractMatrix) -> H1Field
FiniteElementContainers.num_nodes — Methodnum_nodes(field::H1Field{T, D, NF}) -> Any
L2Element field
FiniteElementContainers.L2ElementField — Typestruct L2ElementField{T, D, NF} <: FiniteElementContainers.AbstractField{T, 2, D, NF}Implementation of fields that live on elements.
FiniteElementContainers.L2ElementField — MethodL2ElementField(data::AbstractMatrix) -> L2ElementField
FiniteElementContainers.num_elements — Methodnum_elements(field::L2ElementField{T, D, NF}) -> Any
FiniteElementContainers.num_nodes_per_element — Methodnum_nodes_per_element(field::L2ElementField) -> Any
L2Quadrature field
FiniteElementContainers.L2QuadratureField — Typestruct L2QuadratureField{T, D, NF, NQ} <: FiniteElementContainers.AbstractField{T, 3, D, NF}Implementation of fields that live on elements.
There are plans to add HcurlField and HdivField types as well