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 — Function
Ferrite.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 — Method
Ferrite.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 — Method
Ferrite.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 — Method
Ferrite.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 — Method
Ferrite.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 — Method
boundaryfunction(::Type{<:BoundaryIndex})Helper function to dispatch on the correct entity from a given boundary index.
Ferrite.reference_vertices — Method
reference_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 — Method
reference_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 — Method
reference_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 — Type
Abstract type which is used as identifier for faces, edges and vertices
Ferrite.get_coordinate_eltype — Method
Return the number type of the nodal coordinates.
Ferrite.get_coordinate_eltype — Method
get_coordinate_eltype(::Node)Get the data type of the components of the nodes coordinate.
Ferrite.toglobal — Function
toglobal(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 — Function
sortface(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 — Function
sortface_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 — Function
sortedge(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 — Function
sortedge_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 — Function
element_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 — Function
facet_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 — Type
InterfaceOrientationInfoRelative 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. Facet B's orientation relative to Facet 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 facet 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 facet in case of flipping transform_interface_points!.
Ferrite.transform_interface_points! — Function
transform_interface_points!(dst::AbstractVector{Vec{3, Float64}}, points::AbstractVector{Vec{3, Float64}}, interface_transformation::InterfaceOrientationInfo)Transform the points from facet A to facet B using the orientation information of the interface and store it in the vector dst. For 3D, the facets are transformed into regular polygons such that the rotation angle is the shift in reference node index × 2π ÷ number of edges in facet. If the facet 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 is rotated back in the opposite direction after flipping). Take for example the interface
2 3
| \ | \
| \ | \
y | A \ | B \
↑ | \ | \
→ x 1-----3 1-----2Transforming A to an equilateral triangle and translating it such that {0,0} is equidistant to all nodes
3
+
/ \
/ \
/ x \
/ ↑ \
/ ← \
/ y \
2+-------------+1Rotating it -270° (or 120°) such that the reference node (the node with the smallest index) is at index 1
1
+
/ \
/ \
/ x \
/ ↑ \
/ ← \
/ y \
3+-------------+2Flipping about the x axis (such that the position of the reference node doesn't change) and rotating 270° (or -120°)
2
+
/ \
/ \
/ x \
/ ↑ \
/ ← \
/ y \
3+-------------+1Transforming back to triangle B
3
| \
| \
y | \
↑ | \
→ x 1-----2Ferrite.get_transformation_matrix — Function
get_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 facet is a function of both relative orientation and the orientation of the second facet. If the facet is not flipped then the transformation is a function of relative orientation only.