Fields
Fields serve as loose wrappers around AbstractArray
subtypes such that the size of the array is 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 StaticArray
s of view
s of field types.
Example - NodalField
We can set up a NodalField
in one of two ways. The simplest constructor form can be used as follows
julia> vals = rand(2, 10)
2×10 Matrix{Float64}:
0.671652 0.163963 0.538689 0.480536 0.833398 0.551275 0.790613 0.609717 0.383385 0.0387093
0.074336 0.963916 0.658381 0.902902 0.642238 0.617257 0.566368 0.71399 0.493144 0.153415
julia> field = NodalField{2, 10, Matrix}(vals)
2×10 FiniteElementContainers.SimpleNodalField{Float64, 2, 2, 10, Matrix{Float64}}:
0.671652 0.163963 0.538689 0.480536 0.833398 0.551275 0.790613 0.609717 0.383385 0.0387093
0.074336 0.963916 0.658381 0.902902 0.642238 0.617257 0.566368 0.71399 0.493144 0.153415
julia> field.vals
2×10 Matrix{Float64}:
0.671652 0.163963 0.538689 0.480536 0.833398 0.551275 0.790613 0.609717 0.383385 0.0387093
0.074336 0.963916 0.658381 0.902902 0.642238 0.617257 0.566368 0.71399 0.493144 0.153415
We could also store this in vectorized format as follows
julia> vals = rand(2, 10)
2×10 Matrix{Float64}:
0.80535 0.730575 0.712725 0.474454 0.0892281 0.156759 0.0425675 0.864044 0.538667 0.377565
0.348685 0.852966 0.531284 0.34784 0.133556 0.483717 0.280693 0.155209 0.827217 0.532938
julia> field = NodalField{2, 10, Vector}(vals)
2×10 FiniteElementContainers.VectorizedNodalField{Float64, 2, 2, 10, Vector{Float64}}:
0.80535 0.730575 0.712725 0.474454 0.0892281 0.156759 0.0425675 0.864044 0.538667 0.377565
0.348685 0.852966 0.531284 0.34784 0.133556 0.483717 0.280693 0.155209 0.827217 0.532938
julia> field.vals
20-element Vector{Float64}:
0.805349766666621
0.34868545083892455
0.7305749598014636
0.8529660539980414
0.7127252744440836
0.5312840325763362
0.47445360786490387
0.34784023927079855
0.08922808334086696
⋮
0.04256750367757933
0.28069295436131725
0.864043693939776
0.15520937344242647
0.5386666785752343
0.8272174353577112
0.3775645360156227
0.532938439960596
Implementation
The base type for fields is the AbstractField
abstract type.
FiniteElementContainers.AbstractField
— Typeabstract type AbstractField{T, N, NF, Vals} <: 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.
The existing direct subtypes of AbstractField
are the following
FiniteElementContainers.ElementField
— Typeabstract type ElementField{T, N, NN, NE, Vals} <: FiniteElementContainers.AbstractField{T, N, NN, Vals}
Abstract type for implementations of fields that live on elements.
Constructors
ElementField{NN, NE, Vector}(vals::M) where {NN, NE, M <: AbstractArray{<:Number, 2}}
ElementField{NN, NE, Matrix}(vals::M) where {NN, NE, M <: AbstractArray{<:Number, 2}}
ElementField{NN, NE, Vector}(vals::V) where {NN, NE, V <: AbstractArray{<:Number, 1}}
ElementField{NN, NE, Vector, T}(::UndefInitializer) where {NN, NE, T}
ElementField{NN, NE, Matrix, T}(::UndefInitializer) where {NN, NE, T <: Number}
ElementField{NN, NE, StructArray, T}(::UndefInitializer) where {NN, NE, T}
ElementField{Tup, A, T}(::UndefInitializer) where {Tup, A, T}
ElementField{Tup, A}(vals::M) where {Tup, A, M <: AbstractArray}
FiniteElementContainers.NodalField
— Typeabstract type NodalField{T, N, NF, NN, Vals} <: FiniteElementContainers.AbstractField{T, N, NF, Vals}
Abstract type for implementations of fields that live on nodes.
Constructors
NodalField{NF, NN, Vector}(vals::M) where {NF, NN, M <: AbstractArray{<:Number, 2}}
NodalField{NF, NN, Matrix}(vals::M) where {NF, NN, M <: AbstractArray{<:Number, 2}}
NodalField{NF, NN, Vector}(vals::V) where {NF, NN, V <: AbstractArray{<:Number, 1}}
NodalField{NF, NN, Vector}(vals::V) where {NF, NN, V <: AbstractArray{<:Number, 1}}
NodalField{NF, NN, Vector, T}(::UndefInitializer) where {NF, NN, T}
NodalField{NF, NN, Matrix, T}(::UndefInitializer) where {NF, NN, T <: Number}
NodalField{NF, NN, StructArray, T}(::UndefInitializer) where {NF, NN, T}
NodalField{Tup, A, T}(::UndefInitializer) where {Tup, A, T}
FiniteElementContainers.QuadratureField
— Typeabstract type QuadratureField{T, N, NF, NQ, NE, Vals} <: FiniteElementContainers.AbstractField{T, N, NF, Vals}
Abstract type for implementations of fields that live on quadrature points.
Constructors
QuadratureField{NF, NQ, NE, Matrix}(vals::Matrix{<:Number}) where {NF, NQ, NE}
QuadratureField{NF, NQ, NE, Vector}(vals::Matrix{<:Number}) where {NF, NQ, NE}
QuadratureField{NF, NQ, NE, Matrix, T}(::UndefInitializer) where {NF, NQ, NE, T}
QuadratureField{NF, NQ, NE, StructArray, T}(::UndefInitializer) where {NF, NQ, NE, T}
QuadratureField{NF, NQ, NE, StructVector, T}(::UndefInitializer) where {NF, NQ, NE, T}
QuadratureField{NF, NQ, NE, Vector, T}(::UndefInitializer) where {NF, NQ, NE, T}
QuadratureField{Tup, A, T}(::UndefInitializer) where {Tup, A, T}
QuadratureField{Tup, A}(vals::M) where {Tup, A, M <: AbstractArray}
Types
There's several different implementations currently for different field types.
Methods on AbstractField
Base.eltype
— Methodeltype(
_::Type{FiniteElementContainers.AbstractField{T, N, NF, Vals}}
) -> Any
FiniteElementContainers.num_elements
— Methodnum_elements(_::ElementField{T, N, NN, NE, Vals}) -> Any
FiniteElementContainers.num_elements
— Methodnum_elements(
_::QuadratureField{T, N, NF, NQ, NE, Vals}
) -> Any
FiniteElementContainers.num_fields
— Methodnum_fields(
_::FiniteElementContainers.AbstractField{T, N, NF, Vals}
) -> Any
FiniteElementContainers.num_nodes
— Methodnum_nodes(_::NodalField{T, N, NF, NN, Vals}) -> Any
FiniteElementContainers.num_nodes_per_element
— Methodnum_nodes_per_element(field::ElementField) -> Any
FiniteElementContainers.num_q_points
— Methodnum_q_points(
_::QuadratureField{T, N, NF, NQ, NE, Vals}
) -> Any
Internal constructors for ElementField
s
FiniteElementContainers.SimpleElementField
— Typestruct SimpleElementField{T, N, NN, NE, Vals} <: ElementField{T, N, NN, NE, Vals}
FiniteElementContainers.SimpleElementField
— MethodSimpleElementField{NN, NE}(vals::M) where {NN, NE, M <: AbstractArray{<:Number, 2}}
FiniteElementContainers.SimpleElementField
— MethodSimpleElementField{NN, NE, Matrix, T}(::UndefInitializer) where {NN, NE, T}
FiniteElementContainers.VectorizedElementField
— Typestruct VectorizedElementField{T, N, NN, NE, Vals<:AbstractArray{T, 1}} <: ElementField{T, N, NN, NE, Vals<:AbstractArray{T, 1}}
FiniteElementContainers.VectorizedElementField
— MethodVectorizedElementField{NN, NE}(vals::Matrix{<:Number}) where {NN, NE}
FiniteElementContainers.VectorizedElementField
— MethodVectorizedElementField{NN, NE, T}(::UndefInitializer) where {NN, NE, T <: AbstractArray}
FiniteElementContainers.VectorizedElementField
— MethodVectorizedElementField{NN, NE, T}(::UndefInitializer) where {NN, NE, T <: Number}
FiniteElementContainers.VectorizedElementField
— MethodVectorizedElementField{NN, NE, StructArray, T}(::UndefInitializer) where {NN, NE, T}
FiniteElementContainers.VectorizedElementField
— MethodVectorizedElementField{NN, NE}(vals::V) where {NN, NE, V <: AbstractArray{<:AbstractArray, 1}}
FiniteElementContainers.VectorizedElementField
— MethodVectorizedElementField{NN, NE}(vals::V) where {NN, NE, V <: AbstractArray{<:Number, 1}}
Internal constructors for NodalField
s
FiniteElementContainers.SimpleNodalField
— Typestruct SimpleNodalField{T, N, NF, NN, Vals<:AbstractArray{T, 2}} <: NodalField{T, N, NF, NN, Vals<:AbstractArray{T, 2}}
FiniteElementContainers.SimpleNodalField
— MethodSimpleNodalField{NF, NN, T}(::UndefInitializer) where {NF, NN, T}
FiniteElementContainers.SimpleNodalField
— MethodSimpleNodalField{NF, NN}(vals::V) where {NF, NN, V <: AbstractArray{<:Number, 2}}
FiniteElementContainers.VectorizedNodalField
— Typestruct VectorizedNodalField{T, N, NF, NN, Vals<:AbstractArray{T, 1}} <: NodalField{T, N, NF, NN, Vals<:AbstractArray{T, 1}}
FiniteElementContainers.VectorizedNodalField
— MethodVectorizedNodalField{NF, NN}(vals::M) where {NF, NN, M <: AbstractArray{<:Number, 2}}
FiniteElementContainers.VectorizedNodalField
— MethodVectorizedNodalField{NF, NN, T}(::UndefInitializer) where {NF, NN, T <: AbstractArray}
FiniteElementContainers.VectorizedNodalField
— MethodVectorizedNodalField{NF, NN, T}(::UndefInitializer) where {NF, NN, T <: Number}
FiniteElementContainers.VectorizedNodalField
— MethodVectorizedNodalField{NF, NN, StructArray, T}(::UndefInitializer) where {NF, NN, T}
FiniteElementContainers.VectorizedNodalField
— MethodVectorizedNodalField{NF, NN}(vals::V) where {NF, NN, V <: AbstractArray{<:AbstractArray, 1}}
FiniteElementContainers.VectorizedNodalField
— MethodVectorizedNodalField{NF, NN}(vals::V) where {NF, NN, V <: AbstractArray{<:Number, 1}}
Internal constructors for QuadratureField
s
FiniteElementContainers.SimpleQuadratureField
— Typestruct SimpleQuadratureField{T, N, NF, NQ, NE, Vals<:AbstractArray{T, 2}} <: QuadratureField{T, N, NF, NQ, NE, Vals<:AbstractArray{T, 2}}
FiniteElementContainers.SimpleQuadratureField
— MethodSimpleQuadratureField{1, NQ, NE}(vals::M) where {NQ, NE, M <: AbstractArray{<:Number, 2}}
FiniteElementContainers.SimpleQuadratureField
— MethodSimpleQuadratureField{NF, NQ, NE}(vals::S) where {NF, NQ, NE, S <: StructArray}
FiniteElementContainers.SimpleQuadratureField
— MethodSimpleQuadratureField{NF, NQ, NE, StructArray, T}(::UndefInitializer) where {NF, NQ, NE, T}
FiniteElementContainers.SimpleQuadratureField
— MethodSimpleQuadratureField{1, NQ, NE, Matrix, T}(::UndefInitializer) where {NQ, NE, T <: AbstractArray}
FiniteElementContainers.SimpleQuadratureField
— MethodSimpleQuadratureField{1, NQ, NE, Matrix, T}(::UndefInitializer) where {NQ, NE, T <: Number}
FiniteElementContainers.VectorizedQuadratureField
— Typestruct VectorizedQuadratureField{T, N, NF, NQ, NE, Vals<:AbstractArray{T, 1}} <: QuadratureField{T, N, NF, NQ, NE, Vals<:AbstractArray{T, 1}}
FiniteElementContainers.VectorizedQuadratureField
— MethodVectorizedQuadratureField{1, NQ, NE}(vals::M) where {NQ, NE, M <: AbstractArray{<:Number, 2}}
FiniteElementContainers.VectorizedQuadratureField
— MethodVectorizedQuadratureField{NF, NQ, NE}(vals::S) where {NF, NQ, NE, S <: StructVector}
FiniteElementContainers.VectorizedQuadratureField
— MethodVectorizedQuadratureField{NF, NQ, NE, Vector, T}(::UndefInitializer) where {NF, NQ, NE, T}
FiniteElementContainers.VectorizedQuadratureField
— MethodVectorizedQuadratureField{1, NQ, NE}(vals::V) where {NQ, NE, V <: AbstractArray{<:Number, 1}}