Elements and cells
Type definitions
Elements or cells are subtypes of AbstractCell{dim,N,M}
. They are parametrized by the dimension of their nodes via dim
, the number of nodes N
and the number of faces M
.
Required methods to implement for all subtypes of AbstractCell
to define a new 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.reference_faces
— Methodreference_faces(::AbstractRefShape)
Returns a tuple of n-tuples containing the ordered local node indices corresponding to the vertices that define an oriented face.
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.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.default_interpolation
— MethodFerrite.default_interpolation(::AbstractCell)::Interpolation
Returns the interpolation which defines the geometry of a given cell.
Common utilities and definitions when working with grids internally.
Ferrite.BoundaryIndex
— TypeAbstract type which is used as identifier for faces, edges and verices
Ferrite.boundaryfunction
— Methodboundaryfunction(::Type{<:BoundaryIndex})
Helper function to dispatch on the correct entity from a given boundary index.
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.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.getfaceedges
— Functiongetfaceedges(grid::AbstractGrid, face::FaceIndex)
getfaceedges(cell::AbstractCell, face::FaceIndex)
Returns the edges represented as Set{EdgeIndex}
in a given face represented as FaceIndex
.
julia> using Ferrite; using Ferrite: getfaceedges
julia> grid = generate_grid(Tetrahedron, (2,1,1));
julia> getfaceedges(grid, FaceIndex(4,2))
Set{EdgeIndex} with 3 elements:
EdgeIndex((4, 4))
EdgeIndex((4, 5))
EdgeIndex((4, 1))
Ferrite.getfacevertices
— Functiongetfacevertices(grid::AbstractGrid, face::FaceIndex)
getfacevertices(cell::AbstractCell, face::FaceIndex)
Returns the vertices represented as Set{VertexIndex}
in a given face represented as FaceIndex
.
julia> using Ferrite; using Ferrite: getfacevertices
julia> grid = generate_grid(Tetrahedron, (2,1,1));
julia> getfacevertices(grid, FaceIndex(4,2))
Set{VertexIndex} with 3 elements:
VertexIndex((4, 2))
VertexIndex((4, 4))
VertexIndex((4, 1))
Ferrite.getedgevertices
— Functiongetedgevertices(grid::AbstractGrid, edge::EdgeIndex)
getedgevertices(cell::AbstractCell, edge::EdgeIndex)
Returns the vertices represented as Set{VertexIndex}
in a given edge represented as EdgeIndex
.
julia> using Ferrite; using Ferrite: getedgevertices
julia> grid = generate_grid(Tetrahedron, (2,1,1));
julia> getedgevertices(grid, EdgeIndex(4,2))
Set{EdgeIndex} with 2 elements:
VertexIndex((4, 2))
VertexIndex((4, 3))
Ferrite.getfaceinstances
— Functiongetfaceinstances(grid::AbstractGrid, topology::ExclusiveTopology, face::FaceIndex)
Returns all the faces as Set{FaceIndex}
that share all their vertices with a given face represented as FaceIndex
. The returned set includes the input face.
julia> using Ferrite; using Ferrite: getfaceinstances
julia> grid = generate_grid(Tetrahedron, (2,1,1));
julia> topology = ExclusiveTopology(grid);
julia> getfaceinstances(grid, topology, FaceIndex(4,2))
Set{FaceIndex} with 2 elements:
FaceIndex((6, 4))
FaceIndex((4, 2))
Ferrite.getedgeinstances
— Functiongetedgeinstances(grid::AbstractGrid, topology::ExclusiveTopology, edge::EdgeIndex)
Returns all the edges as Set{EdgeIndex}
that share all their vertices with a given edge represented as EdgeIndex
. The returned set includes the input edge.
julia> using Ferrite; using Ferrite: getedgeinstances
julia> grid = generate_grid(Tetrahedron, (2,1,1));
julia> topology = ExclusiveTopology(grid);
julia> getedgeinstances(grid, topology, EdgeIndex(4,2))
Set{EdgeIndex} with 3 elements:
EdgeIndex((4, 2))
EdgeIndex((9, 6))
EdgeIndex((7, 6))
Ferrite.getvertexinstances
— Functiongetvertexinstances(grid::AbstractGrid, topology::ExclusiveTopology, vertex::EdgeIndex)
Returns all the vertices as Set{::VertexIndex}
that use a given vertex represented as VertexIndex
in all cells. The returned set includes the input vertex.
julia> using Ferrite; using Ferrite: getvertexinstances
julia> grid = generate_grid(Tetrahedron,(2,1,1));
julia> topology = ExclusiveTopology(grid);
julia> getvertexinstances(grid, topology, VertexIndex(4,2))
Set{VertexIndex} with 8 elements:
VertexIndex((7, 4))
VertexIndex((10, 4))
VertexIndex((12, 4))
VertexIndex((6, 3))
VertexIndex((4, 2))
VertexIndex((9, 4))
VertexIndex((11, 4))
VertexIndex((8, 4))
Ferrite.filterfaces
— Functionfilterfaces(grid::AbstractGrid, faces::Set{FaceIndex}, f::Function; all::Bool=true)
Returns the faces in faces
that satisfy f
as a Set{FaceIndex}
. all=true
implies that f(x)
must return true
for all nodal coordinates x
on the face if the face should be added to the set, otherwise it suffices that f(x)
returns true
for one node.
julia> using Ferrite; using Ferrite: filterfaces
julia> grid = generate_grid(Tetrahedron, (2,2,2));
julia> topology = ExclusiveTopology(grid);
julia> addboundaryfaceset!(grid, topology, "b", x -> true);
julia> filterfaces(grid, grid.facesets["b"], x -> x[3] ≈ -1)
Set{FaceIndex} with 8 elements:
FaceIndex((7, 1))
FaceIndex((3, 1))
FaceIndex((21, 1))
FaceIndex((13, 1))
FaceIndex((19, 1))
FaceIndex((15, 1))
FaceIndex((1, 1))
FaceIndex((9, 1))
Ferrite.filteredges
— Functionfilteredges(grid::AbstractGrid, edges::Set{EdgeIndex}, f::Function; all::Bool=true)
Returns the edges in edges
that satisfy f
as a Set{EdgeIndex}
. all=true
implies that f(x)
must return true
for all nodal coordinates x
on the face if the face should be added to the set, otherwise it suffices that f(x)
returns true
for one node.
julia> using Ferrite; using Ferrite: filteredges
julia> grid = generate_grid(Tetrahedron, (1,1,1));
julia> topology = ExclusiveTopology(grid);
julia> addboundaryedgeset!(grid, topology, "b", x -> true);
julia> filteredges(grid, grid.edgesets["b"], x -> x[3] ≈ -1)
Set{EdgeIndex} with 8 elements:
EdgeIndex((1, 2))
EdgeIndex((3, 2))
EdgeIndex((4, 3))
EdgeIndex((1, 3))
EdgeIndex((3, 3))
EdgeIndex((1, 1))
EdgeIndex((3, 1))
EdgeIndex((2, 3))
Ferrite.filtervertices
— Functionfiltervertices(grid::AbstractGrid, vertices::Set{VertexIndex}, f::Function; all::Bool=true)
Returns the vertices in vertices
that satisfy f
as a Set{VertexIndex}
. all=true
implies that f(x)
must return true
for all nodal coordinates x
on the face if the face should be added to the set, otherwise it suffices that f(x)
returns true
for one node.
julia> using Ferrite; using Ferrite: filtervertices
julia> grid = generate_grid(Tetrahedron,(1,1,1));
julia> topology = ExclusiveTopology(grid);
julia> addboundaryvertexset!(grid, topology, "b", x -> true);
julia> filtervertices(grid, grid.vertexsets["b"], x -> x[3] ≈ -1)
Set{VertexIndex} with 12 elements:
VertexIndex((2, 3))
VertexIndex((4, 3))
VertexIndex((4, 1))
VertexIndex((3, 3))
VertexIndex((3, 2))
VertexIndex((1, 1))
VertexIndex((2, 1))
VertexIndex((3, 1))
VertexIndex((1, 3))
VertexIndex((5, 1))
VertexIndex((1, 2))
VertexIndex((6, 1))
Ferrite.element_to_face_transformation
— Functionelement_to_face_transformation(point::AbstractVector, cell::AbstractCell{AbstractRefShape}, face::Int)
Transform quadrature point from cell's coordinates to the face's reference coordinates, decreasing the number of dimensions by one. This is the inverse of face_to_element_transformation
.
Ferrite.face_to_element_transformation
— Functionface_to_element_transformation(point::Vec, ::Type{<:AbstractRefShape}, face::Int)
Transform quadrature point from face's reference coordinates to coordinates on the cell's face, 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 facea to faceb 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::Vector{Vec{3, Float64}}, points::Vector{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