ReferenceFiniteElements.jl is meant to serve as an educational and lightweight package to define finite elements in the reference (quadrature space) configuration. The goal is to provide a very simple to utilize interface so researchers can play with new finite element formulations without having to learn an entire large code or package base.
To use ReferenceFiniteElements first install it via the package manager via the following command
pkg> add ReferenceFiniteElements
To setup a finite element you can do the following with a 8 node hexahedral element with a second order quadrature rule (8 integration points) used as an example below
using ReferenceFiniteElements
re = ReferenceFE(Hex8(2))
# output
ReferenceFE
Element type = Hex8{8}
Dimension = 3
Number of nodes = 8
Number of quadrature points = 8
Integer type = Int64
Float type = Float64
Nodal coordinates type = Matrix{Float64}
Face nodes type = Matrix{Int64}
Interior nodes type = Vector{Int64}
Interpolants type = StructArray{Interpolants}
To do something useful with our finite element we can look at the quadrature points. To get all the quadrature points, use the following method
ξs = quadrature_points(re)
# output
8-element Vector{StaticArraysCore.SVector{3, Float64}}:
[-0.5773502691896258, -0.5773502691896258, -0.5773502691896258]
[0.5773502691896258, -0.5773502691896258, -0.5773502691896258]
[-0.5773502691896258, 0.5773502691896258, -0.5773502691896258]
[0.5773502691896258, 0.5773502691896258, -0.5773502691896258]
[-0.5773502691896258, -0.5773502691896258, 0.5773502691896258]
[0.5773502691896258, -0.5773502691896258, 0.5773502691896258]
[-0.5773502691896258, 0.5773502691896258, 0.5773502691896258]
[0.5773502691896258, 0.5773502691896258, 0.5773502691896258]
To get a specific quadrature point, say the first point, we can use an analogous method as follows
ξ = quadrature_points(re, 1)
# output
3-element StaticArraysCore.SVector{3, Float64} with indices SOneTo(3):
-0.5773502691896258
-0.5773502691896258
-0.5773502691896258
There are similar methods for the quadrature weights. See below.
ws = quadrature_weights(re)
# output
8-element Vector{Float64}:
1.0
1.0
1.0
1.0
1.0
1.0
1.0
1.0
w = quadrature_weights(re, 1)
# output
1.0
For the shape function values we can access these via the following methods
Ns = shape_function_values(re)
# output
8-element Vector{StaticArraysCore.SVector{8, Float64}}:
[0.4905626121623441, 0.13144585576580212, 0.035220810900864506, 0.13144585576580212, 0.13144585576580212, 0.035220810900864506, 0.009437387837655926, 0.035220810900864506]
[0.13144585576580212, 0.4905626121623441, 0.13144585576580212, 0.035220810900864506, 0.035220810900864506, 0.13144585576580212, 0.035220810900864506, 0.009437387837655926]
[0.13144585576580212, 0.035220810900864506, 0.13144585576580212, 0.4905626121623441, 0.035220810900864506, 0.009437387837655926, 0.035220810900864506, 0.13144585576580212]
[0.035220810900864506, 0.13144585576580212, 0.4905626121623441, 0.13144585576580212, 0.009437387837655926, 0.035220810900864506, 0.13144585576580212, 0.035220810900864506]
[0.13144585576580212, 0.035220810900864506, 0.009437387837655926, 0.035220810900864506, 0.4905626121623441, 0.13144585576580212, 0.035220810900864506, 0.13144585576580212]
[0.035220810900864506, 0.13144585576580212, 0.035220810900864506, 0.009437387837655926, 0.13144585576580212, 0.4905626121623441, 0.13144585576580212, 0.035220810900864506]
[0.035220810900864506, 0.009437387837655926, 0.035220810900864506, 0.13144585576580212, 0.13144585576580212, 0.035220810900864506, 0.13144585576580212, 0.4905626121623441]
[0.009437387837655926, 0.035220810900864506, 0.13144585576580212, 0.035220810900864506, 0.035220810900864506, 0.13144585576580212, 0.4905626121623441, 0.13144585576580212]
N = shape_function_values(re, 1)
# output
8-element StaticArraysCore.SVector{8, Float64} with indices SOneTo(8):
0.4905626121623441
0.13144585576580212
0.035220810900864506
0.13144585576580212
0.13144585576580212
0.035220810900864506
0.009437387837655926
0.035220810900864506
For shape function gradients, the method calls are as follows
∇N_ξ = shape_function_gradients(re)
# output
8-element Vector{StaticArraysCore.SMatrix{8, 3, Float64, 24}}:
[-0.3110042339640731 -0.3110042339640731 -0.3110042339640731; 0.3110042339640731 -0.08333333333333331 -0.08333333333333331; … ; 0.022329099369260218 0.022329099369260218 0.022329099369260218; -0.022329099369260218 0.08333333333333331 0.08333333333333331]
[-0.3110042339640731 -0.08333333333333331 -0.08333333333333331; 0.3110042339640731 -0.3110042339640731 -0.3110042339640731; … ; 0.022329099369260218 0.08333333333333331 0.08333333333333331; -0.022329099369260218 0.022329099369260218 0.022329099369260218]
[-0.08333333333333331 -0.3110042339640731 -0.08333333333333331; 0.08333333333333331 -0.08333333333333331 -0.022329099369260218; … ; 0.08333333333333331 0.022329099369260218 0.08333333333333331; -0.08333333333333331 0.08333333333333331 0.3110042339640731]
[-0.08333333333333331 -0.08333333333333331 -0.022329099369260218; 0.08333333333333331 -0.3110042339640731 -0.08333333333333331; … ; 0.08333333333333331 0.08333333333333331 0.3110042339640731; -0.08333333333333331 0.022329099369260218 0.08333333333333331]
[-0.08333333333333331 -0.08333333333333331 -0.3110042339640731; 0.08333333333333331 -0.022329099369260218 -0.08333333333333331; … ; 0.08333333333333331 0.08333333333333331 0.022329099369260218; -0.08333333333333331 0.3110042339640731 0.08333333333333331]
[-0.08333333333333331 -0.022329099369260218 -0.08333333333333331; 0.08333333333333331 -0.08333333333333331 -0.3110042339640731; … ; 0.08333333333333331 0.3110042339640731 0.08333333333333331; -0.08333333333333331 0.08333333333333331 0.022329099369260218]
[-0.022329099369260218 -0.08333333333333331 -0.08333333333333331; 0.022329099369260218 -0.022329099369260218 -0.022329099369260218; … ; 0.3110042339640731 0.08333333333333331 0.08333333333333331; -0.3110042339640731 0.3110042339640731 0.3110042339640731]
[-0.022329099369260218 -0.022329099369260218 -0.022329099369260218; 0.022329099369260218 -0.08333333333333331 -0.08333333333333331; … ; 0.3110042339640731 0.3110042339640731 0.3110042339640731; -0.3110042339640731 0.08333333333333331 0.08333333333333331]
∇N_ξ = shape_function_gradients(re, 1)
# output
8×3 StaticArraysCore.SMatrix{8, 3, Float64, 24} with indices SOneTo(8)×SOneTo(3):
-0.311004 -0.311004 -0.311004
0.311004 -0.0833333 -0.0833333
0.0833333 0.0833333 -0.0223291
-0.0833333 0.311004 -0.0833333
-0.0833333 -0.0833333 0.311004
0.0833333 -0.0223291 0.0833333
0.0223291 0.0223291 0.0223291
-0.0223291 0.0833333 0.0833333
For shape function hessians, the method calls are as follows
∇∇N_ξ = shape_function_hessians(re)
# output
8-element Vector{StaticArraysCore.SArray{Tuple{8, 3, 3}, Float64, 3, 72}}:
[0.0 0.19716878364870322 0.19716878364870322; 0.0 -0.19716878364870322 -0.19716878364870322; … ; 0.0 0.05283121635129677 0.05283121635129677; 0.0 -0.05283121635129677 -0.05283121635129677;;; 0.19716878364870322 0.0 0.19716878364870322; -0.19716878364870322 0.0 0.05283121635129677; … ; 0.05283121635129677 0.0 0.05283121635129677; -0.05283121635129677 0.0 0.19716878364870322;;; 0.19716878364870322 0.19716878364870322 0.0; -0.19716878364870322 0.05283121635129677 0.0; … ; 0.05283121635129677 0.05283121635129677 0.0; -0.05283121635129677 0.19716878364870322 0.0]
[0.0 0.19716878364870322 0.19716878364870322; 0.0 -0.19716878364870322 -0.19716878364870322; … ; 0.0 0.05283121635129677 0.05283121635129677; 0.0 -0.05283121635129677 -0.05283121635129677;;; 0.19716878364870322 0.0 0.05283121635129677; -0.19716878364870322 0.0 0.19716878364870322; … ; 0.05283121635129677 0.0 0.19716878364870322; -0.05283121635129677 0.0 0.05283121635129677;;; 0.19716878364870322 0.05283121635129677 0.0; -0.19716878364870322 0.19716878364870322 0.0; … ; 0.05283121635129677 0.19716878364870322 0.0; -0.05283121635129677 0.05283121635129677 0.0]
[0.0 0.19716878364870322 0.05283121635129677; 0.0 -0.19716878364870322 -0.05283121635129677; … ; 0.0 0.05283121635129677 0.19716878364870322; 0.0 -0.05283121635129677 -0.19716878364870322;;; 0.19716878364870322 0.0 0.19716878364870322; -0.19716878364870322 0.0 0.05283121635129677; … ; 0.05283121635129677 0.0 0.05283121635129677; -0.05283121635129677 0.0 0.19716878364870322;;; 0.05283121635129677 0.19716878364870322 0.0; -0.05283121635129677 0.05283121635129677 0.0; … ; 0.19716878364870322 0.05283121635129677 0.0; -0.19716878364870322 0.19716878364870322 0.0]
[0.0 0.19716878364870322 0.05283121635129677; 0.0 -0.19716878364870322 -0.05283121635129677; … ; 0.0 0.05283121635129677 0.19716878364870322; 0.0 -0.05283121635129677 -0.19716878364870322;;; 0.19716878364870322 0.0 0.05283121635129677; -0.19716878364870322 0.0 0.19716878364870322; … ; 0.05283121635129677 0.0 0.19716878364870322; -0.05283121635129677 0.0 0.05283121635129677;;; 0.05283121635129677 0.05283121635129677 0.0; -0.05283121635129677 0.19716878364870322 0.0; … ; 0.19716878364870322 0.19716878364870322 0.0; -0.19716878364870322 0.05283121635129677 0.0]
[0.0 0.05283121635129677 0.19716878364870322; 0.0 -0.05283121635129677 -0.19716878364870322; … ; 0.0 0.19716878364870322 0.05283121635129677; 0.0 -0.19716878364870322 -0.05283121635129677;;; 0.05283121635129677 0.0 0.19716878364870322; -0.05283121635129677 0.0 0.05283121635129677; … ; 0.19716878364870322 0.0 0.05283121635129677; -0.19716878364870322 0.0 0.19716878364870322;;; 0.19716878364870322 0.19716878364870322 0.0; -0.19716878364870322 0.05283121635129677 0.0; … ; 0.05283121635129677 0.05283121635129677 0.0; -0.05283121635129677 0.19716878364870322 0.0]
[0.0 0.05283121635129677 0.19716878364870322; 0.0 -0.05283121635129677 -0.19716878364870322; … ; 0.0 0.19716878364870322 0.05283121635129677; 0.0 -0.19716878364870322 -0.05283121635129677;;; 0.05283121635129677 0.0 0.05283121635129677; -0.05283121635129677 0.0 0.19716878364870322; … ; 0.19716878364870322 0.0 0.19716878364870322; -0.19716878364870322 0.0 0.05283121635129677;;; 0.19716878364870322 0.05283121635129677 0.0; -0.19716878364870322 0.19716878364870322 0.0; … ; 0.05283121635129677 0.19716878364870322 0.0; -0.05283121635129677 0.05283121635129677 0.0]
[0.0 0.05283121635129677 0.05283121635129677; 0.0 -0.05283121635129677 -0.05283121635129677; … ; 0.0 0.19716878364870322 0.19716878364870322; 0.0 -0.19716878364870322 -0.19716878364870322;;; 0.05283121635129677 0.0 0.19716878364870322; -0.05283121635129677 0.0 0.05283121635129677; … ; 0.19716878364870322 0.0 0.05283121635129677; -0.19716878364870322 0.0 0.19716878364870322;;; 0.05283121635129677 0.19716878364870322 0.0; -0.05283121635129677 0.05283121635129677 0.0; … ; 0.19716878364870322 0.05283121635129677 0.0; -0.19716878364870322 0.19716878364870322 0.0]
[0.0 0.05283121635129677 0.05283121635129677; 0.0 -0.05283121635129677 -0.05283121635129677; … ; 0.0 0.19716878364870322 0.19716878364870322; 0.0 -0.19716878364870322 -0.19716878364870322;;; 0.05283121635129677 0.0 0.05283121635129677; -0.05283121635129677 0.0 0.19716878364870322; … ; 0.19716878364870322 0.0 0.19716878364870322; -0.19716878364870322 0.0 0.05283121635129677;;; 0.05283121635129677 0.05283121635129677 0.0; -0.05283121635129677 0.19716878364870322 0.0; … ; 0.19716878364870322 0.19716878364870322 0.0; -0.19716878364870322 0.05283121635129677 0.0]
∇∇N_ξ = shape_function_hessians(re, 1)
# output
8×3×3 StaticArraysCore.SArray{Tuple{8, 3, 3}, Float64, 3, 72} with indices SOneTo(8)×SOneTo(3)×SOneTo(3):
[:, :, 1] =
0.0 0.197169 0.197169
0.0 -0.197169 -0.197169
0.0 0.197169 -0.0528312
0.0 -0.197169 0.0528312
0.0 0.0528312 -0.197169
0.0 -0.0528312 0.197169
0.0 0.0528312 0.0528312
0.0 -0.0528312 -0.0528312
[:, :, 2] =
0.197169 0.0 0.197169
-0.197169 0.0 0.0528312
0.197169 0.0 -0.0528312
-0.197169 0.0 -0.197169
0.0528312 0.0 -0.197169
-0.0528312 0.0 -0.0528312
0.0528312 0.0 0.0528312
-0.0528312 0.0 0.197169
[:, :, 3] =
0.197169 0.197169 0.0
-0.197169 0.0528312 0.0
-0.0528312 -0.0528312 0.0
0.0528312 -0.197169 0.0
-0.197169 -0.197169 0.0
0.197169 -0.0528312 0.0
0.0528312 0.0528312 0.0
-0.0528312 0.197169 0.0