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 FiniteElementContainers
julia> FiniteElementContainers.AbstractFieldFiniteElementContainers.AbstractField

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 FiniteElementContainers
julia> field = H1Field(rand(2, 10))2×10 H1Field{Float64, Vector{Float64}, 2}: 0.2625 0.696863 0.276498 0.161868 … 0.204328 0.0565398 0.631138 0.672887 0.273929 0.16284 0.10129 0.687316 0.639741 0.314222

This is stored in a vectorized way as can be seen above

julia> field.data20-element Vector{Float64}:
 0.26250048724258657
 0.6728870366672512
 0.6968627370479328
 0.27392894646528143
 0.27649836663486393
 0.16283984608204738
 0.1618676335505721
 0.10128958708397673
 0.08805389459819679
 0.4566398390063837
 0.5479227390251085
 0.7015440566108491
 0.9297215697528822
 0.7354521814918624
 0.2043282984653768
 0.6873161696034323
 0.05653981684108089
 0.6397409992248637
 0.6311379444668546
 0.31422237717748713

Fields can be indexed like regular arrays, e.g.

julia> field[1, 1]0.26250048724258657
julia> field[1, :]10-element Vector{Float64}:
 0.26250048724258657
 0.6968627370479328
 0.27649836663486393
 0.1618676335505721
 0.08805389459819679
 0.5479227390251085
 0.9297215697528822
 0.2043282984653768
 0.05653981684108089
 0.6311379444668546

etc.

Fields

The base type for fields is the AbstractField abstract type.

Base.IndexStyleMethod
IndexStyle(
    _::Type{<:FiniteElementContainers.AbstractField}
) -> IndexLinear
source
Base.eltypeMethod
eltype(
    _::FiniteElementContainers.AbstractField{T, N, D}
) -> Any
source
Base.fill!Method
fill!(
    field::FiniteElementContainers.AbstractField{T, N, D},
    v
) -> Any
source
Base.getindexMethod
getindex(
    field::FiniteElementContainers.AbstractField,
    n::Int64
) -> Any
source
Base.setindex!Method
setindex!(
    field::FiniteElementContainers.AbstractField{T, N, D},
    v,
    n::Int64
)
source
Base.uniqueMethod
unique(field::FiniteElementContainers.AbstractField) -> Any
source