Given a struct defining an element, e.g.,
using StaticArrays
const Point2D = SVector{2,Float64};
# struct to hold a single mesh element
struct Element
p1::Point2D # coordinates first node
p2::Point2D # coordinates second node
p3::Point2D # coordinates third node
e1::Int64 # global index first node
e2::Int64 # global index second node
e3::Int64 # global index third node
Emat::MMatrix{3,3,Float64, 9} # matrix of basis function coefficients
area::Float64 # area of the element
end
and given a mesh as an array of such elements, e.g.,
# struct to hold entire mesh
struct Mesh
nnodes::Int64 # number of nodes
nelems::Int64 # number of elements
Elements::Array{Element,1} # list of Elements
bndNodeIds::Vector{Int64} # indices of nodes where Dirichlet bc are applied
dofPerElem::Int64 # number of dofs per element
end
I wish to implement the method
stiffmat(mesh)
Q1: I am considering using dispatch on the length of the static array, see e.g. API · StaticArrays.jl . More examples of this method would be wonderful to see.
Q2: how to implement dispatch on length of the static array Point2D such that the same signature works for elements in line segments 1D, 2D and 3D.
A partial answer is given for linear elements only is given in MinFEM.jl/src/fem.jl at master · MinFEM/MinFEM.jl · GitHub .
Is it common practice to inquire the length on mesh.Element[1].p1 in the signature of the function stiffmat() for instance?
Q3: how to implement dispatch on the type of element such that the same signature works for linear and quadratic elements in 1D for instance.