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.0414053 0.924033 0.18637 0.437207 … 0.998834 0.881548 0.462089 0.377381 0.409938 0.442279 0.977602 0.217552 0.239444 0.376374

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

julia> field.data20-element Vector{Float64}:
 0.041405299223359004
 0.3773807001538755
 0.9240328347530314
 0.40993753394498955
 0.18636952562976938
 0.4422789033408554
 0.43720692573052944
 0.9776024265320052
 0.46897427403005376
 0.3391479617269254
 0.5024061363250425
 0.0956816533756859
 0.7056318399254996
 0.40517955322317867
 0.9988341013334446
 0.2175524799244013
 0.8815477099678324
 0.2394436363867507
 0.4620892696237008
 0.3763744618878242

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

julia> field[1, 1]0.041405299223359004
julia> field[1, :]10-element Vector{Float64}:
 0.041405299223359004
 0.9240328347530314
 0.18636952562976938
 0.43720692573052944
 0.46897427403005376
 0.5024061363250425
 0.7056318399254996
 0.9988341013334446
 0.8815477099678324
 0.4620892696237008

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