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.258962 0.326227 0.878041 0.194412 … 0.0368448 0.319856 0.363384 0.602603 0.701687 0.857523 0.485972 0.69309 0.680801 0.507814

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

julia> field.data20-element Vector{Float64}:
 0.258962464151799
 0.6026030451522111
 0.3262266137033085
 0.7016873449787011
 0.8780408319973169
 0.857522913078377
 0.1944117891631959
 0.4859721846212982
 0.21387278194262438
 0.5881574745907664
 0.13764960840127693
 0.8972598975581803
 0.30336367204920933
 0.7770503373746674
 0.03684482729706284
 0.6930897227113059
 0.3198561243579384
 0.6808011720605588
 0.36338351447528605
 0.5078140471139648

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

julia> field[1, 1]0.258962464151799
julia> field[1, :]10-element Vector{Float64}:
 0.258962464151799
 0.3262266137033085
 0.8780408319973169
 0.1944117891631959
 0.21387278194262438
 0.13764960840127693
 0.30336367204920933
 0.03684482729706284
 0.3198561243579384
 0.36338351447528605

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