Elements and cells
Type definitions
Elements or cells are subtypes of AbstractCell{<:AbstractRefShape}
. As shown, they are parametrized by the associated reference element.
Required methods to implement for all subtypes of AbstractCell
to define a new element
Ferrite.get_node_ids
— FunctionFerrite.get_node_ids(c::AbstractCell)
Return the node id's for cell c
in the order determined by the cell's reference cell.
Default implementation: c.nodes
.
Common utilities and definitions when working with grids internally.
First we have some topological queries on the element
Ferrite.vertices
— MethodFerrite.vertices(::AbstractCell)
Returns a tuple with the node indices (of the nodes in a grid) for each vertex in a given cell. This function induces the VertexIndex
, where the second index corresponds to the local index into this tuple.
Ferrite.edges
— MethodFerrite.edges(::AbstractCell)
Returns a tuple of 2-tuples containing the ordered node indices (of the nodes in a grid) corresponding to the vertices that define an oriented edge. This function induces the EdgeIndex
, where the second index corresponds to the local index into this tuple.
Note that the vertices are sufficient to define an edge uniquely.
Ferrite.faces
— MethodFerrite.faces(::AbstractCell)
Returns a tuple of n-tuples containing the ordered node indices (of the nodes in a grid) corresponding to the vertices that define an oriented face. This function induces the FaceIndex
, where the second index corresponds to the local index into this tuple.
An oriented face is a face with the first node having the local index and the other nodes spanning such that the normal to the face is pointing outwards.
Note that the vertices are sufficient to define a face uniquely.
Ferrite.facets
— MethodFerrite.facets(::AbstractCell)
Returns a tuple of n-tuples containing the ordered node indices (of the nodes in a grid) corresponding to the vertices that define an oriented facet. This function induces the FacetIndex
, where the second index corresponds to the local index into this tuple.
Ferrite.boundaryfunction
— Methodboundaryfunction(::Type{<:BoundaryIndex})
Helper function to dispatch on the correct entity from a given boundary index.
Ferrite.reference_vertices
— Methodreference_vertices(::Type{<:AbstractRefShape})
reference_vertices(::AbstractCell)
Returns a tuple of integers containing the local node indices corresponding to the vertices (i.e. corners or endpoints) of the cell.
Ferrite.reference_edges
— Methodreference_edges(::Type{<:AbstractRefShape})
reference_edges(::AbstractCell)
Returns a tuple of 2-tuples containing the ordered local node indices (corresponding to the vertices) that define an edge.
Ferrite.reference_faces
— Methodreference_faces(::Type{<:AbstractRefShape})
reference_faces(::AbstractCell)
Returns a tuple of n-tuples containing the ordered local node indices (corresponding to the vertices) that define a face.
and some generic utils which are commonly found in finite element codes
Ferrite.BoundaryIndex
— TypeAbstract type which is used as identifier for faces, edges and verices
Ferrite.get_coordinate_eltype
— MethodReturn the number type of the nodal coordinates.
Ferrite.get_coordinate_eltype
— Methodget_coordinate_eltype(::Node)
Get the data type of the components of the nodes coordinate.
Ferrite.toglobal
— Functiontoglobal(grid::AbstractGrid, vertexidx::VertexIndex) -> Int
toglobal(grid::AbstractGrid, vertexidx::Vector{VertexIndex}) -> Vector{Int}
This function takes the local vertex representation (a VertexIndex
) and looks up the unique global id (an Int
).
Ferrite.sortface
— Functionsortface(face::Tuple{Int})
sortface(face::Tuple{Int,Int})
sortface(face::Tuple{Int,Int,Int})
sortface(face::Tuple{Int,Int,Int,Int})
Returns the unique representation of a face. Here the unique representation is the sorted node index tuple. Note that in 3D we only need indices to uniquely identify a face, so the unique representation is always a tuple length 3.
Ferrite.sortface_fast
— Functionsortface_fast(face::Tuple{Int})
sortface_fast(face::Tuple{Int,Int})
sortface_fast(face::Tuple{Int,Int,Int})
sortface_fast(face::Tuple{Int,Int,Int,Int})
Returns the unique representation of a face. Here the unique representation is the sorted node index tuple. Note that in 3D we only need indices to uniquely identify a face, so the unique representation is always a tuple length 3.
Ferrite.sortedge
— Functionsortedge(edge::Tuple{Int,Int})
Returns the unique representation of an edge and its orientation. Here the unique representation is the sorted node index tuple. The orientation is true
if the edge is not flipped, where it is false
if the edge is flipped.
Ferrite.sortedge_fast
— Functionsortedge_fast(edge::Tuple{Int,Int})
Returns the unique representation of an edge. Here the unique representation is the sorted node index tuple.
Ferrite.element_to_facet_transformation
— Functionelement_to_facet_transformation(point::AbstractVector, ::Type{<:AbstractRefShape}, facet::Int)
Transform quadrature point from the cell's coordinates to the facet's reference coordinates, decreasing the number of dimensions by one. This is the inverse of facet_to_element_transformation
.
Ferrite.facet_to_element_transformation
— Functionfacet_to_element_transformation(point::Vec, ::Type{<:AbstractRefShape}, facet::Int)
Transform quadrature point from the facet's reference coordinates to coordinates on the cell's facet, increasing the number of dimensions by one.
Ferrite.InterfaceOrientationInfo
— TypeInterfaceOrientationInfo
Relative orientation information for 1D and 2D interfaces in 2D and 3D elements respectively. This information is used to construct the transformation matrix to transform the quadrature points from faceta to facetb achieving synced spatial coordinates. Face B's orientation relative to Face A's can possibly be flipped (i.e. the vertices indices order is reversed) and the vertices can be rotated against each other. The reference orientation of face B is such that the first node has the lowest vertex index. Thus, this structure also stores the shift of the lowest vertex index which is used to reorient the face in case of flipping transform_interface_points!
.
Ferrite.transform_interface_points!
— Functiontransform_interface_points!(dst::AbstractVector{Vec{3, Float64}}, points::AbstractVector{Vec{3, Float64}}, interface_transformation::InterfaceOrientationInfo)
Transform the points from face A to face B using the orientation information of the interface and store it in the vector dst. For 3D, the faces are transformed into regular polygons such that the rotation angle is the shift in reference node index × 2π ÷ number of edges in face. If the face is flipped then the flipping is about the axis that preserves the position of the first node (which is the reference node after being rotated to be in the first position, it's rotated back in the opposite direction after flipping). Take for example the interface
2 3
| \ | \
| \ | \
y | A \ | B \
↑ | \ | \
→ x 1-----3 1-----2
Transforming A to an equilateral triangle and translating it such that {0,0} is equidistant to all nodes
3
+
/ \
/ \
/ x \
/ ↑ \
/ ← \
/ y \
2+-------------+1
Rotating it -270° (or 120°) such that the reference node (the node with the smallest index) is at index 1
1
+
/ \
/ \
/ x \
/ ↑ \
/ ← \
/ y \
3+-------------+2
Flipping about the x axis (such that the position of the reference node doesn't change) and rotating 270° (or -120°)
2
+
/ \
/ \
/ x \
/ ↑ \
/ ← \
/ y \
3+-------------+1
Transforming back to triangle B
3
| \
| \
y | \
↑ | \
→ x 1-----2
Ferrite.get_transformation_matrix
— Functionget_transformation_matrix(interface_transformation::InterfaceOrientationInfo)
Returns the transformation matrix corresponding to the interface orientation information stored in InterfaceOrientationInfo
. The transformation matrix is constructed using a combination of affine transformations defined for each interface reference shape. The transformation for a flipped face is a function of both relative orientation and the orientation of the second face. If the face is not flipped then the transformation is a function of relative orientation only.