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.250213 0.175501 0.184282 0.18371 … 0.856352 0.601913 0.0834221 0.240481 0.799655 0.421249 0.597754 0.93649 0.883094 0.329884

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

julia> field.data20-element Vector{Float64}:
 0.25021302299770554
 0.24048071010055194
 0.17550073592080517
 0.7996548019030506
 0.184282219384017
 0.421249354181226
 0.18371025752680958
 0.5977537018752379
 0.631888016471821
 0.4214457339754325
 0.340186037333874
 0.038685575763522606
 0.2421164792911472
 0.2749180482238661
 0.8563516755765289
 0.9364902109969993
 0.6019129948117486
 0.883093518526227
 0.08342212661783921
 0.3298839216882635

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

julia> field[1, 1]0.25021302299770554
julia> field[1, :]10-element Vector{Float64}:
 0.25021302299770554
 0.17550073592080517
 0.184282219384017
 0.18371025752680958
 0.631888016471821
 0.340186037333874
 0.2421164792911472
 0.8563516755765289
 0.6019129948117486
 0.08342212661783921

etc.

Fields

The base type for fields is the AbstractField abstract type.

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