Gridap.ReferenceFEs
Gridap.ReferenceFEs — ModuleThe exported names are
BDMBDMRefFEBezierBezierRefFEBubbleBubbleRefFECDConformityCONTConformityContraVariantPiolaMapCurlConformityDISCDivConformingDivConformityDofExtrusionPolytopeGeneralPolytopeGenericLagrangianRefFEGenericQuadratureGenericRefFEGradConformityH1ConformityHEXHEX8HEX_AXISINVALID_PERML2ConformityLagrangianLagrangianDofBasisLagrangianRefFEModalC0ModalC0RefFEMomentBasedDofBasisNedelecNedelecRefFEPYRAMIDPolygonPolyhedronPolytopeQUADQUAD4QuadratureQuadratureNameRaviartThomasRaviartThomasRefFEReferenceFEReferenceFENameSEG2SEGMENTSerendipityRefFETETTET4TET_AXISTRITRI3VERTEXVERTEX1WEDGEbdmbezierbubblecompress_cell_datacompute_cell_to_modalC0_reffecompute_face_orderscompute_lagrangian_reffacescompute_monomial_basiscompute_nodescompute_own_nodescompute_own_nodes_permutationscompute_shapefunsduffyevaluate!expand_cell_dataget_bounding_boxget_coordinatesget_dimrangeget_dimrangesget_dof_basisget_dof_to_compget_dof_to_nodeget_edge_tangentget_extrusionget_face_coordinatesget_face_dimrangesget_face_dofsget_face_momentsget_face_nodesget_face_nodes_dofsget_face_own_dofsget_face_own_dofs_permutationsget_face_own_nodesget_face_own_nodes_permutationsget_face_typeget_face_vertex_permutationsget_face_verticesget_facedimsget_facesget_facet_normalget_facet_orientationsget_nameget_node_and_comp_to_dofget_node_coordinatesget_nodesget_offsetget_offsetsget_orderget_ordersget_own_dofs_permutationsget_own_nodes_permutationsget_polytopeget_prebasisget_reffacesget_shapefunsget_vertex_coordinatesget_vertex_nodeget_vertex_permutationsget_weightsis_Pis_Qis_Sis_first_orderis_n_cubeis_simplexlagrangianlinear_combinationmodalC0nedelecnum_cell_dimsnum_dimsnum_dofsnum_edgesnum_facesnum_facetsnum_nodesnum_point_dimsnum_pointsnum_verticesraviart_thomasreturn_cachereturn_typesimplexifystrangtensor_producttest_doftest_dof_arraytest_lagrangian_reference_fetest_polytopetest_quadraturetest_reference_fexiao_gimbutas
Gridap.ReferenceFEs.HEX — Constantconst HEX = Polytope(HEX_AXIS,HEX_AXIS,HEX_AXIS)Gridap.ReferenceFEs.HEX8 — Constantconst HEX8 = LagrangianRefFE(Float64,HEX,1)Gridap.ReferenceFEs.HEX_AXIS — ConstantConstant to be used in order to indicate a hex-like extrusion axis.
Gridap.ReferenceFEs.INVALID_PERM — ConstantConstant of type Int used to signal that a permutation is not valid.
Gridap.ReferenceFEs.PYRAMID — Constantconst PYRAMID = Polytope(HEX_AXIS,HEX_AXIS,TET_AXIS)Gridap.ReferenceFEs.QUAD — Constantconst QUAD = Polytope(HEX_AXIS,HEX_AXIS)Gridap.ReferenceFEs.QUAD4 — Constantconst QUAD4 = LagrangianRefFE(Float64,QUAD,1)Gridap.ReferenceFEs.SEG2 — Constantconst SEG2 = LagrangianRefFE(Float64,SEGMENT,1)Gridap.ReferenceFEs.SEGMENT — Constantconst SEGMENT = Polytope(HEX_AXIS)Gridap.ReferenceFEs.TET — Constantconst TET = Polytope(TET_AXIS,TET_AXIS,TET_AXIS)Gridap.ReferenceFEs.TET4 — Constantconst TET4 = LagrangianRefFE(Float64,TET,1)Gridap.ReferenceFEs.TET_AXIS — ConstantConstant to be used in order to indicate a tet-like extrusion axis.
Gridap.ReferenceFEs.TRI — Constantconst TRI = Polytope(TET_AXIS,TET_AXIS)Gridap.ReferenceFEs.TRI3 — Constantconst TRI3 = LagrangianRefFE(Float64,TRI,1)Gridap.ReferenceFEs.VERTEX — Constantconst VERTEX = Polytope()Gridap.ReferenceFEs.VERTEX1 — Constantconst VERTEX1 = LagrangianRefFE(Float64,VERTEX,1)Gridap.ReferenceFEs.WEDGE — Constantconst WEDGE = Polytope(TET_AXIS,TET_AXIS,HEX_AXIS)Gridap.ReferenceFEs.Conformity — MethodConformity(reffe::ReferenceFE) -> ConformityGridap.ReferenceFEs.ExtrusionPolytope — Typestruct ExtrusionPolytope{D} <: Polytope{D}
extrusion::Point{D,Int}
# + private fields
endConcrete type for polytopes that can be represented with an "extrusion" tuple. The underlying extrusion is available in the field extrusion. Instances of this type can be obtained with the constructors
Gridap.ReferenceFEs.ExtrusionPolytope — MethodExtrusionPolytope(extrusion::Int...)Generates an ExtrusionPolytope from the tuple extrusion. The values in extrusion are either equal to the constant HEX_AXIS or the constant TET_AXIS.
Examples
Creating a quadrilateral, a triangle, and a wedge
using Gridap.ReferenceFEs
quad = ExtrusionPolytope(HEX_AXIS,HEX_AXIS)
tri = ExtrusionPolytope(TET_AXIS,TET_AXIS)
wedge = ExtrusionPolytope(TET_AXIS,TET_AXIS,HEX_AXIS)
println(quad == QUAD)
println(tri == TRI)
println(wedge == WEDGE)
# output
true
true
true
Gridap.ReferenceFEs.GeneralPolytope — Typestruct GeneralPolytope{D,Dp,Tp} <: Polytope{D}The GeneralPolytope is definded defined by a set of vertices and a rototation system (a planar oriented graph). This polytopal representation can represent any polytope in 2 and 3 dimensions.
In 2 dimensions (Polygon), the representation of the polygon is a closed polyline.
In 3 dimensions (Polyhedron), the rotation system generates the connectivities, each facet is a closed cycle of the graph. This construction allows complex geometrical operations, e.g., intersecting polytopes by halfspaces. See also,
K. Sugihara, "A robust and consistent algorithm for intersecting convex polyhedra", Comput. Graph. Forum 13 (3) (1994) 45–54, doi: 10.1111/1467-8659.1330045
D. Powell, T. Abel, "An exact general remeshing scheme applied to physically conservative voxelization", J. Comput. Phys. 297 (Sept. 2015) 340–356, doi: [10.1016/j.jcp.2015.05.022](https://doi.org/10.1016/j.jcp.2015.05.022.
S. Badia, P. A. Martorell, F. Verdugo. "Geometrical discretisations for unfitted finite elements on explicit boundary representations", J.Comput. Phys. 460 (2022): 111162. doi: 10.1016/j.jcp.2022.111162
Gridap.ReferenceFEs.GeneralPolytope — MethodGeneralPolytope{D}(vertices,graph;kwargs...)Constructor of a GeneralPolytope that generates a polytope of D dimensions with the given vertices and graph of connectivities.
Gridap.ReferenceFEs.GenericLagrangianRefFE — Typestruct GenericLagrangianRefFE{C,D} <: LagrangianRefFE{D} reffe::GenericRefFE{C,D} face_nodes::Vector{Vector{Int}} end
Gridap.ReferenceFEs.GenericQuadrature — Typestruct GenericQuadrature{D,T,C <: AbstractVector{Point{D,T}},W <: AbstractVector{T}} <: Quadrature{D,T}
coordinates::Vector{Point{D,T}}
weights::Vector{T}
name::String
endGridap.ReferenceFEs.GenericRefFE — Typestruct GenericRefFE{T,D} <: ReferenceFE{D}
# + private fields
endThis type is a materialization of the ReferenceFE interface. That is, it is a struct that stores the values of all abstract methods in the ReferenceFE interface. This type is useful to build reference FEs from the underlying ingredients without the need to create a new type.
Note that some fields in this struct are type unstable deliberately in order to simplify the type signature. Don't access them in computationally expensive functions, instead extract the required fields before and pass them to the computationally expensive function.
Gridap.ReferenceFEs.GenericRefFE — Method GenericRefFE{T}(
ndofs::Int,
polytope::Polytope{D},
prebasis::AbstractVector{<:Field},
dofs::AbstractVector{<:Dof},
conformity::Conformity,
metadata,
face_dofs::Vector{Vector{Int}},
shapefuns::AbstractVector{<:Field}=compute_shapefuns(dofs,prebasis)) where {T,D}Constructs a GenericRefFE object with the provided data.
Gridap.ReferenceFEs.GenericRefFE — Method GenericRefFE{T}(
ndofs::Int,
polytope::Polytope{D},
prebasis::AbstractVector{<:Field},
predofs::AbstractVector{<:Dof},
conformity::Conformity,
metadata,
face_dofs::Vector{Vector{Int}},
shapefuns::AbstractVector{<:Field},
dofs::AbstractVector{<:Dof}=compute_dofs(predofs,shapefuns)) where {T,D}Constructs a GenericRefFE object with the provided data.
Gridap.ReferenceFEs.LagrangianDofBasis — Typestruct LagrangianDofBasis{P,V} <: AbstractArray{<:Dof}
nodes::Vector{P}
dof_to_node::Vector{Int}
dof_to_comp::Vector{Int}
node_and_comp_to_dof::Vector{V}
endType that implements a Lagrangian dof basis.
Fields:
nodes::Vector{P}vector of points (P<:Point) storing the nodal coordinatesnode_and_comp_to_dof::Vector{V}vector such thatnode_and_comp_to_dof[node][comp]returns the dof associated with nodenodeand the componentcompin the typeV.dof_to_node::Vector{Int}vector of integers such thatdof_to_node[dof]returns the node id associated with dof iddof.dof_to_comp::Vector{Int}vector of integers such thatdof_to_comp[dof]returns the component id associated with dof iddof.
Gridap.ReferenceFEs.LagrangianDofBasis — MethodLagrangianDofBasis(::Type{T},nodes::Vector{<:Point}) where TCreates a LagrangianDofBasis for fields of value type T associated with the vector of nodal coordinates nodes.
Gridap.ReferenceFEs.LagrangianRefFE — Typeabstract type LagrangianRefFE{D} <: ReferenceFE{D}Abstract type representing a Lagrangian reference FE. Lagrangian in the sense that get_dof_basis returns an instance of LagrangianDofBasis. The interface for this type is defined with the methods of ReferenceFE plus the following ones
Gridap.ReferenceFEs.LagrangianRefFE — MethodLagrangianRefFE(::Type{T},p::Polytope,orders) where T
LagrangianRefFE(::Type{T},p::Polytope,order::Int) where TBuilds a LagrangianRefFE object on top of the given polytope. T is the type of the value of the approximation space (e.g., T=Float64 for scalar-valued problems, T=VectorValue{N,Float64} for vector-valued problems with N components). The arguments order or orders are for the polynomial order of the resulting space, which allows isotropic or anisotropic orders respectively (provided that the cell topology allows the given anisotropic order). The argument orders should be an indexable collection of D integers (e.g., a tuple or a vector), being D the number of space dimensions.
In order to be able to use this function, the type of the provided polytope p has to implement the following additional methods. They have been implemented for ExtrusionPolytope in the library. They need to be implemented for new polytope types in order to build Lagangian reference elements on top of them.
compute_monomial_basis(::Type{T},p::Polytope,orders) where Tcompute_own_nodes(p::Polytope,orders)compute_face_orders(p::Polytope,face::Polytope,iface::Int,orders)
The following methods are also used in the construction of the LagrangianRefFE object. A default implementation of them is available in terms of the three previous methods. However, the user can also implement them for new polytope types increasing customization possibilities.
Gridap.ReferenceFEs.LinearCombinationDofVector — Typestruct LinearCombinationDofVector{T} <: AbstractVector{Dof}
change_of_basis::Matrix{T}
dof_basis::AbstractVector{<:Dof}
endType that implements a dof basis (a) as the linear combination of a dof basis (b). The dofs are first evaluated at dof basis (b) (field dof_basis) and the dof values are next mapped to dof basis (a) applying a change of basis (field change_of_basis).
Fields:
change_of_basis::Matrix{T}the matrix of the change from dof basis (b) to (a)dof_basis::AbstractVector{<:Dof}A type representing dof basis (b)
Gridap.ReferenceFEs.Polygon — TypePolygon = GeneralPolytope{2}A polygon is a GeneralPolytope in 2 dimensions.
Gridap.ReferenceFEs.Polyhedron — TypePolyhedron = GeneralPolytope{3}A polyhedron is a GeneralPolytope in 3 dimensions.
Gridap.ReferenceFEs.Polytope — Typeabstract type Polytope{D} <: GridapTypeAbstract type representing a polytope (i.e., a polyhedron in arbitrary dimensions). D is the environment dimension (typically, 0, 1, 2, or 3). This type parameter is needed since there are functions in the Polytope interface that return containers with Point{D} objects. We adopt the usual nomenclature for polytope-related objects. All objects in a polytope (from vertices to the polytope itself) are called n-faces or simply faces. The notation n-faces is used only when it is needed to refer to the object dimension n. Otherwise we simply use face. In addition, we say
- vertex (pl. vertices): for 0-faces
- edge: for 1-faces
- facet: for (
D-1)-faces
The Polytope interface is defined by overloading the following functions
get_faces(p::Polytope)get_dimranges(p::Polytope)Polytope{N}(p::Polytope,faceid::Integer) where Nget_vertex_coordinates(p::Polytope)(==)(a::Polytope{D},b::Polytope{D}) where D
And optionally these ones:
get_edge_tangent(p::Polytope)get_facet_normal(p::Polytope)get_facet_orientations(p::Polytope)get_vertex_permutations(p::Polytope)is_n_cube(p::Polytope)is_simplex(p::Polytope)simplexify(p::Polytope)
The interface can be tested with the function
Gridap.ReferenceFEs.Polytope — MethodPolytope(extrusion::Int...)Equivalent to ExtrusionPolytope(extrusion...)
Gridap.ReferenceFEs.Polytope — MethodPolytope{N}(p::Polytope,faceid::Integer) where NReturns a Polytope{N} object representing the "reference" polytope of the N-face with id faceid. The value faceid refers to the numeration restricted to the dimension N (it starts with 1 for the first N-face).
Gridap.ReferenceFEs.Quadrature — Typeabstract type Quadrature{D,T} <: GridapType end-get_coordinates(q::Quadrature) -get_weights(q::Quadrature) -test_quadrature
Gridap.ReferenceFEs.Quadrature — MethodQuadrature(polytope::Polytope{D},degree) where DGridap.ReferenceFEs.ReferenceFE — Typeabstract type ReferenceFE{D} <: GridapTypeAbstract type representing a Reference finite element. D is the underlying coordinate space dimension. We follow the Ciarlet definition. A reference finite element is defined by a polytope (cell topology), a basis of an interpolation space of top of this polytope (denoted here as the prebasis), and a basis of the dual of this space (i.e. the degrees of freedom). From this information one can compute the shape functions (i.e, the canonical basis of w.r.t. the degrees of freedom) with a simple change of basis. In addition, we also encode in this type information about how the interpolation space in a reference finite element is "glued" with neighbors in order to build conforming cell-wise spaces.
The ReferenceFE interface is defined by overloading these methods:
num_dofs(reffe::ReferenceFE)get_polytope(reffe::ReferenceFE)get_prebasis(reffe::ReferenceFE)get_dof_basis(reffe::ReferenceFE)Conformity(reffe::ReferenceFE)get_face_own_dofs(reffe::ReferenceFE,conf::Conformity)get_face_own_dofs_permutations(reffe::ReferenceFE,conf::Conformity)get_face_dofs(reffe::ReferenceFE)
The interface is tested with
Gridap.ReferenceFEs.ReferenceFE — MethodReferenceFE{N}(reffe::GenericLagrangianRefFE{GradConformity},iface::Integer) where NBase.:== — Method(==)(a::LagrangianRefFE{D}, b::LagrangianRefFE{D}) where DBase.:== — Method(==)(a::Polytope{D},b::Polytope{D}) where DReturns true if the polytopes a and b are equivalent. Otherwise, it returns false. Note that the operator == returns false by default for polytopes of different dimensions. Thus, this function has to be overloaded only for the case of polytopes a and b of same dimension.
Base.isopen — Methodisopen(p::GeneralPolytope) -> BoolIn return whether the polytope is watter tight or not.
Gridap.Polynomials.get_order — Methodget_order(reffe::LagrangianRefFE)Gridap.Polynomials.get_orders — Methodget_orders(reffe::LagrangianRefFE)Gridap.ReferenceFEs.BDMRefFE — MethodBDMRefFE(::Type{et},p::Polytope,order::Integer) where et
The order argument has the following meaning: the divergence of the functions in this basis is in the P space of degree order-1.
Gridap.ReferenceFEs.ModalC0RefFE — MethodModalC0RefFE(::Type{T},p::Polytope{D},orders) where {T,D}
Returns an instance of GenericRefFE{ModalC0} representing a ReferenceFE with Modal C0-continuous shape functions (multivariate scalar-valued, vector-valued, or tensor-valued, iso- or aniso-tropic).
For more details about the shape functions, see Section 1.1.5 in
Ern, A., & Guermond, J. L. (2013). Theory and practice of finite elements (Vol. 159). Springer Science & Business Media.
and references therein.
The constructor is only implemented for for n-cubes and the minimum order in any dimension must be greater than one. The DoFs are numbered by n-faces in the same way as with CLagrangianRefFEs.
Gridap.ReferenceFEs.NedelecRefFE — MethodNedelecRefFE(::Type{et},p::Polytope,order::Integer) where etThe order argument has the following meaning: the curl of the functions in this basis is in the Q space of degree order.
Gridap.ReferenceFEs.RaviartThomasRefFE — MethodRaviartThomasRefFE(::Type{et},p::Polytope,order::Integer) where etThe order argument has the following meaning: the divergence of the functions in this basis is in the Q space of degree order.
Gridap.ReferenceFEs.SerendipityRefFE — MethodSerendipityRefFE(::Type{T},p::Polytope,order::Int) where T
SerendipityRefFE(::Type{T},p::Polytope,orders::Tuple) where TReturns an instance of LagrangianRefFE, whose underlying approximation space is the serendipity space of order order. Implemented for order from 1 to 4. The type of the polytope p has to implement all the queries detailed in the constructor LagrangianRefFE(::Type{T},p::Polytope{D},orders) where {T,D}.
Examples
using Gridap.ReferenceFEs
order = 2
reffe = SerendipityRefFE(Float64,QUAD,order)
println( num_dofs(reffe) )
# output
8
Gridap.ReferenceFEs.check_polytope_graph — Methodcheck_polytope_graph(p::GeneralPolytope) -> BoolIt checks whether the graph is well-constructed. The graph must be oriented and planar.
Gridap.ReferenceFEs.compute_dofs — Methodcompute_dofs(predofs,shapefuns)Helper function used to compute the dof basis associated with the dof basis predofs and the basis shapefuns.
It is equivalent to
change = inv(evaluate(predofs,shapefuns))
linear_combination(change,predofs) # i.e. transpose(change)*predofsGridap.ReferenceFEs.compute_face_orders — Methodcompute_face_orders(p::Polytope,face::Polytope,iface::Int,orders)Returns a vector or a tuple with the order per direction at the face face of the polytope p when restricting the order per direction orders to this face. iface is the face id of face in the numeration restricted to the face dimension.
Gridap.ReferenceFEs.compute_lagrangian_reffaces — Methodcompute_lagrangian_reffaces(::Type{T},p::Polytope,orders) where TReturns a tuple of length D being the number of space dimensions. The entry d+1 of this tuple contains a vector of LagrangianRefFE one for each face of dimension d on the boundary of the polytope.
Gridap.ReferenceFEs.compute_monomial_basis — Methodcompute_monomial_basis(::Type{T},p::Polytope,orders) where T -> MonomialBasisReturns the monomial basis of value type T and order per direction described by orders on top of the polytope p.
Gridap.ReferenceFEs.compute_nodes — Methodcompute_nodes(p::Polytope,orders)When called
node_coords, face_own_nodes = compute_nodes(p,orders)Returns node_coords, the nodal coordinates of all the Lagrangian nodes associated with the order per direction orders, and face_own_nodes, being a vector of vectors indicating which nodes are owned by each of the faces of the polytope p.
Gridap.ReferenceFEs.compute_own_nodes — Methodcompute_own_nodes(p::Polytope{D},orders) where D -> Vector{Point{D,Float64}}Returns the coordinates of the nodes owned by the interior of the polytope associated with a Lagrangian space with the order per direction described by orders.
Gridap.ReferenceFEs.compute_own_nodes_permutations — Methodcompute_own_nodes_permutations(
p::Polytope, own_nodes_coordinates) -> Vector{Vector{Int}}Returns a vector of vectors with the permutations of the nodes owned by the interior of the polytope.
Gridap.ReferenceFEs.compute_shapefuns — Methodcompute_shapefuns(dofs,prebasis)Helper function used to compute the shape function basis associated with the dof basis dofs and the basis prebasis.
It is equivalent to
change = inv(evaluate(dofs,prebasis))
linear_combination(change,prebasis) # i.e. transpose(change)*prebasisGridap.ReferenceFEs.expand_cell_data — MethodGridap.ReferenceFEs.get_bounding_box — Methodget_bounding_box(p::Polytope)Gridap.ReferenceFEs.get_coordinates — Methodget_coordinates(q::Quadrature)Gridap.ReferenceFEs.get_dimrange — Methodget_dimrange(p::Polytope,d::Integer)Equivalent to
get_dimranges(p)[d+1]Gridap.ReferenceFEs.get_dimranges — Methodget_dimranges(p::Polytope) -> Vector{UnitRange{Int}}Given a polytope p it returns a vector of ranges. The entry d+1 in this vector contains the range of face ids for the faces of dimension d.
Examples
using Gridap.ReferenceFEs
ranges = get_dimranges(SEGMENT)
println(ranges)
# output
UnitRange{Int}[1:2, 3:3]Face ids for the vertices in the segment range from 1 to 2 (2 vertices), the face ids for edges in the segment range from 3 to 3 (only one edge with id 3).
Gridap.ReferenceFEs.get_dof_basis — Methodget_dof_basis(reffe::ReferenceFE) -> DofReturns the underlying dof basis encoded in a Dof object.
Gridap.ReferenceFEs.get_dof_to_comp — Methodget_dof_to_comp(reffe::LagrangianRefFE)Gridap.ReferenceFEs.get_dof_to_node — Methodget_dof_to_node(reffe::LagrangianRefFE)Gridap.ReferenceFEs.get_edge_tangent — Methodget_edge_tangent(p::Polytope) -> Vector{VectorValue{D,Float64}}Given a polytope p, returns a vector of VectorValue objects representing the unit tangent vectors to the polytope edges.
Gridap.ReferenceFEs.get_extrusion — Methodget_extrusion(p::ExtrusionPolytope)Equivalent to p.extrusion.
Gridap.ReferenceFEs.get_face_coordinates — Methodget_face_coordinates(p::Polytope)
get_face_coordinates(p::Polytope,d::Integer)Gridap.ReferenceFEs.get_face_dimranges — Methodget_face_dimranges(p::Polytope,d::Integer)Gridap.ReferenceFEs.get_face_dofs — Methodget_face_dofs(reffe::ReferenceFE,d::Integer)Gridap.ReferenceFEs.get_face_dofs — Methodget_face_dofs(reffe::ReferenceFE) -> Vector{Vector{Int}}Returns a vector of vector that, for each face, stores the dofids in the closure of the face.
Gridap.ReferenceFEs.get_face_nodes — Methodget_face_nodes(reffe::LagrangianRefFE,d::Integer)Gridap.ReferenceFEs.get_face_nodes — Methodget_face_nodes(reffe::LagrangianRefFE)Gridap.ReferenceFEs.get_face_own_dofs — Methodget_face_own_dofs(reffe::ReferenceFE,conf::Conformity,d::Integer)Gridap.ReferenceFEs.get_face_own_dofs — Methodget_face_own_dofs(reffe::ReferenceFE,conf::Conformity) -> Vector{Vector{Int}}Gridap.ReferenceFEs.get_face_own_dofs — Methodget_face_own_dofs(reffe::ReferenceFE,d::Integer)Gridap.ReferenceFEs.get_face_own_dofs — Methodget_face_own_dofs(reffe::ReferenceFE) -> Vector{Vector{Int}}Gridap.ReferenceFEs.get_face_own_dofs_permutations — Methodget_face_own_dofs_permutations(reffe::ReferenceFE,conf::Conformity,d::Integer)Gridap.ReferenceFEs.get_face_own_dofs_permutations — Methodget_face_own_dofs_permutations(reffe::ReferenceFE,conf::Conformity) -> Vector{Vector{Vector{Int}}}Gridap.ReferenceFEs.get_face_own_dofs_permutations — Methodget_face_own_dofs_permutations(reffe::ReferenceFE,d::Integer)Gridap.ReferenceFEs.get_face_own_dofs_permutations — Methodget_face_own_dofs_permutations(reffe::ReferenceFE) -> Vector{Vector{Vector{Int}}}Gridap.ReferenceFEs.get_face_own_nodes — Methodget_face_own_nodes(reffe::LagrangianRefFE,conf::Conformity,d::Integer)Gridap.ReferenceFEs.get_face_own_nodes — Methodget_face_own_nodes(reffe::LagrangianRefFE,conf::Conformity)Gridap.ReferenceFEs.get_face_own_nodes — Methodget_face_own_nodes(reffe::LagrangianRefFE,d::Integer)Gridap.ReferenceFEs.get_face_own_nodes — Methodget_face_own_nodes(reffe::LagrangianRefFE)Gridap.ReferenceFEs.get_face_own_nodes_permutations — Methodget_face_own_nodes_permutations(reffe::LagrangianRefFE,conf::Conformity,d::Integer)Gridap.ReferenceFEs.get_face_own_nodes_permutations — Methodget_face_own_nodes_permutations(reffe::LagrangianRefFE,conf::Conformity)Gridap.ReferenceFEs.get_face_own_nodes_permutations — Methodget_face_own_nodes_permutations(reffe::LagrangianRefFE,d::Integer)Gridap.ReferenceFEs.get_face_own_nodes_permutations — Methodget_face_own_nodes_permutations(reffe::LagrangianRefFE)Gridap.ReferenceFEs.get_face_type — Methodget_face_type(reffe::GenericLagrangianRefFE{GradConformity}, d::Integer) -> Vector{Int}Gridap.ReferenceFEs.get_face_type — Methodget_face_type(p::Polytope,d::Integer) -> Vector{Int}Return a vector of integers denoting, for each face of dimension d, an index to the vector get_reffaces(Polytope{d},p)
Examples
Get the unique polytopes for the facets of a wedge and identify of which type each face is.
using Gridap.ReferenceFEs
reffaces = get_reffaces(Polytope{2},WEDGE)
face_types = get_face_type(WEDGE,2)
println(reffaces)
println(face_types)
# output
Gridap.ReferenceFEs.ExtrusionPolytope{2}[TRI, QUAD]
[1, 1, 2, 2, 2]
The three first facets are of type 1, i.e, QUAD, and the last ones of type 2, i.e., TRI.
Gridap.ReferenceFEs.get_face_vertex_permutations — Methodget_face_vertex_permutations(p::Polytope)
get_face_vertex_permutations(p::Polytope,d::Integer)Gridap.ReferenceFEs.get_face_vertices — Methodget_face_vertices(p::Polytope) -> Vector{Vector{Int}}
get_face_vertices(p::Polytope,dim::Integer) -> Vector{Vector{Int}}Gridap.ReferenceFEs.get_facedims — Methodget_facedims(p::Polytope) -> Vector{Int}Given a polytope p, returns a vector indicating the dimension of each face in the polytope
Examples
using Gridap.ReferenceFEs
dims = get_facedims(SEGMENT)
println(dims)
# output
[0, 0, 1]
The first two faces in the segment (the two vertices) have dimension 0 and the third face (the segment itself) has dimension 1
Gridap.ReferenceFEs.get_faces — Methodget_faces(p::Polytope,dimfrom::Integer,dimto::Integer) -> Vector{Vector{Int}}For dimfrom >= dimto returns a vector that for each face of dimension dimfrom stores a vector of the ids of faces of dimension dimto on its boundary.
For dimfrom < dimto returns a vector that for each face of dimfrom stores a vector of the face ids of faces of dimension dimto that touch it.
The numerations used in this function are the ones restricted to each dimension.
using Gridap.ReferenceFEs
edge_to_vertices = get_faces(QUAD,1,0)
println(edge_to_vertices)
vertex_to_edges_around = get_faces(QUAD,0,1)
println(vertex_to_edges_around)
# output
Array{Int,1}[[1, 2], [3, 4], [1, 3], [2, 4]]
Array{Int,1}[[1, 3], [1, 4], [2, 3], [2, 4]]Gridap.ReferenceFEs.get_faces — Methodget_faces(p::Polytope) -> Vector{Vector{Int}}Given a polytope p the function returns a vector of vectors defining the incidence relation of the faces in the polytope.
Each face in the polytope receives a unique integer id. The id 1 is assigned to the first 0-face. Consecutive increasing ids are assigned to the other 0-faces, then to 1-faces, and so on. The polytope itself receives the largest id which coincides with num_faces(p). For a face id iface, get_faces(p)[iface] is a vector of face ids, corresponding to the faces that are incident with the face labeled with iface. That is, faces that are either on its boundary or the face itself. In this vector of incident face ids, faces are ordered by dimension, starting with 0-faces. Within each dimension, the labels are ordered in a consistent way with the polyope object for the face iface itself.
Examples
using Gridap.ReferenceFEs
faces = get_faces(SEGMENT)
println(faces)
# output
Array{Int,1}[[1], [2], [1, 2, 3]]The constant SEGMENT is bound to a predefined instance of polytope that represents a segment. The face labels associated with a segment are [1,2,3], being 1 and 2 for the vertices and 3 for the segment itself. In this case, this function returns the vector of vectors [[1],[2],[1,2,3]] meaning that vertex 1 is incident with vertex 1 (idem for vertex 2), and that the segment (id 3) is incident with the vertices 1 and 2 and the segment itself.
Gridap.ReferenceFEs.get_facet_normal — Methodget_facet_normal(p::Polytope) -> Vector{VectorValue{D,Float64}}Given a polytope p, returns a vector of VectorValue objects representing the unit outward normal vectors to the polytope facets.
Gridap.ReferenceFEs.get_facet_orientations — Methodget_facet_orientations(p::Polytope) -> Vector{Int}Given a polytope p returns a vector of integers of length num_facets(p). Facets, whose vertices are ordered consistently with the outwards normal vector, receive value 1 in this vector. Otherwise, facets receive value -1.
Gridap.ReferenceFEs.get_graph — Methodget_graph(p::GeneralPolytope) -> Vector{Vector{Int32}}It returns the edge-vertex graph of the polytope p.
Gridap.ReferenceFEs.get_metadata — Methodget_metadata(p::GeneralPolytope)It return the metadata stored in the polytope p.
Gridap.ReferenceFEs.get_name — Methodget_name(q::Quadrature)Gridap.ReferenceFEs.get_node_and_comp_to_dof — Methodget_node_and_comp_to_dof(reffe::LagrangianRefFE)Gridap.ReferenceFEs.get_node_coordinates — Methodget_node_coordinates(reffe::LagrangianRefFE)Gridap.ReferenceFEs.get_offset — Methodget_offset(p::Polytope,d::Integer)Equivalent to get_offsets(p)[d+1].
Gridap.ReferenceFEs.get_offsets — Methodget_offsets(p::Polytope) -> Vector{Int}Given a polytope p, it returns a vector of integers. The position in the d+1 entry in this vector is the offset that transforms a face id in the global numeration in the polytope to the numeration restricted to faces to dimension d.
Examples
using Gridap.ReferenceFEs
offsets = get_offsets(SEGMENT)
println(offsets)
# output
[0, 2]
Gridap.ReferenceFEs.get_own_dofs_permutations — Methodget_own_dofs_permutations(reffe::ReferenceFE,conf::Conformity)Gridap.ReferenceFEs.get_own_dofs_permutations — Methodget_own_dofs_permutations(reffe::ReferenceFE)Gridap.ReferenceFEs.get_own_nodes_permutations — Methodget_own_nodes_permutations(reffe::LagrangianRefFE,conf::Conformity)Gridap.ReferenceFEs.get_own_nodes_permutations — Methodget_own_nodes_permutations(reffe::LagrangianRefFE)Gridap.ReferenceFEs.get_polytope — Methodget_polytope(reffe::ReferenceFE) -> PolytopeReturns the underlying polytope object.
Gridap.ReferenceFEs.get_prebasis — Methodget_prebasis(reffe::ReferenceFE) -> FieldReturns the underlying prebasis encoded as a Field object.
Gridap.ReferenceFEs.get_reffaces — Methodget_reffaces(::Type{Polytope{d}},p::Polytope) where d -> Vector{Polytope{d}}Get a vector of the unique polytopes for the faces of dimension d.
Examples
Get the unique polytopes for the facets of a wedge.
using Gridap.ReferenceFEs
reffaces = get_reffaces(Polytope{2},WEDGE)
println(reffaces)
# output
Gridap.ReferenceFEs.ExtrusionPolytope{2}[TRI, QUAD]
Gridap.ReferenceFEs.get_reffaces — Methodget_reffaces(
::Type{ReferenceFE{d}},
reffe::GenericLagrangianRefFE{GradConformity}) where d -> Vector{GenericLagrangianRefFE{GradConformity,M,d}}Gridap.ReferenceFEs.get_shapefuns — Methodget_shapefuns(reffe::ReferenceFE) -> FieldReturns the basis of shape functions (i.e. the canonical basis) associated with the reference FE. The result is encoded as a Field object.
Gridap.ReferenceFEs.get_vertex_coordinates — Methodget_vertex_coordinates(p::Polytope) -> Vector{Point{D,Float64}}Given a polytope p return a vector of points representing containing the coordinates of the vertices.
Gridap.ReferenceFEs.get_vertex_node — Methodget_vertex_node(reffe::LagrangianRefFE,conf::Conformity) -> Vector{Int}Gridap.ReferenceFEs.get_vertex_node — Methodget_vertex_node(reffe::LagrangianRefFE) -> Vector{Int}Gridap.ReferenceFEs.get_vertex_permutations — Methodget_vertex_permutations(p::Polytope) -> Vector{Vector{Int}}Given a polytope p, returns a vector of vectors containing all admissible permutations of the polytope vertices. An admissible permutation is one such that, if the vertices of the polytope are re-labeled according to this permutation, the resulting polytope preserves the shape of the original one.
Examples
using Gridap.ReferenceFEs
perms = get_vertex_permutations(SEGMENT)
println(perms)
# output
Array{Int,1}[[1, 2], [2, 1]]
The first admissible permutation for a segment is [1,2],i.e., the identity. The second one is [2,1], i.e., the first vertex is relabeled as 2 and the second vertex is relabeled as 1.
Gridap.ReferenceFEs.get_weights — Methodget_weights(q::Quadrature)Gridap.ReferenceFEs.is_P — Methodis_P(reffe::GenericLagrangianRefFE{GradConformity})Gridap.ReferenceFEs.is_Q — Methodis_Q(reffe::GenericLagrangianRefFE{GradConformity})
Gridap.ReferenceFEs.is_S — Methodis_S(reffe::GenericLagrangianRefFE{GradConformity})
Gridap.ReferenceFEs.is_first_order — Methodis_first_order(reffe::GenericLagrangianRefFE{GradConformity}) -> BoolGridap.ReferenceFEs.is_n_cube — Methodis_n_cube(p::Polytope) -> BoolGridap.ReferenceFEs.is_simplex — Methodis_simplex(p::Polytope) -> BoolGridap.ReferenceFEs.isactive — Methodisactive(p::GeneralPolytope,vertex::Integer) -> BoolIt returns whether a vertex is connected to any other vertex.
Gridap.ReferenceFEs.merge_nodes! — Methodmerge_nodes!(graph::Vector{Vector{Int32}},i::Int,j::Int)Given a polyhedron graph, i.e a planar graph with oriented closed paths representing the faces, merge the nodes i and j by collapsing the edge i-j into i. The algorithm preserves the orientation of the neighboring faces, maintaining a consistent graph.
Gridap.ReferenceFEs.merge_nodes — Methodmerge_nodes(p::GeneralPolytope{D};atol=1e-6)Given a polytope, merge all the nodes that are closer than atol to each other.
Gridap.ReferenceFEs.merge_polytopes — Methodmerge_polytopes(p1::GeneralPolytope{D},p2::GeneralPolytope{D},f1,f2)Merge polytopes p1 and p2 by gluing the faces f1 and f2 together. The faces f1 and f2 need to be given as list of nodes in the same order. I.e we assume that get_vertex_coordinates(p1)[f1[k]] == get_vertex_coordinates(p2)[f2[k]] for all k.
Algorithm:
Polyhedrons have planar graphs, with each face represented by an oriented closed path.
Visually, this means we can glue boths polytopes
p1andp2by drawing the graphG2inside the
closed path of the face f1 of G1. We can them add edges between the vertices of the closed paths of f1 and f2, then collapse the edges to create the final graph.
- To create the edge
(i1,i2):- Around each node, its neighbors are oriented in a consistent way. This means that for a selected face (closed path), there will always be two consecutive neighbors that belong to the selected face.
- To create the new edge, we insert the new neighbor between the two consecutive neighbors of the selected face. This will consistently embed
G2intof1.
Gridap.ReferenceFEs.next_corner! — MethodSweep through the dim-dimensional hypercube recursively, collecting all simplices.
We represent vertices as bit patterns. In dim dimensions, the lowermost dim bits are either zero or one. Interpreted as integer, this labels the vertices of the hypercube from the origin ("bottom") 0 to the diagonally opposite vertex ("top") 2^dim-1.
Each simplex contains both the bottom vertex 0 as well as the top vertex 2^dim-1. Its other vertices trace a path from the bottom to the top. The algorithm below finds all possible paths.
simplicesis the accumulator where the simplices are collected.verticesis the current set of vertices as we sweep from the origin to the diagonally opposide vertex.corneris the current corner.
Gridap.ReferenceFEs.num_cell_dims — Methodnum_cell_dims(::Type{<:ReferenceFE{D}}) where D
num_cell_dims(reffe::ReferenceFE{D}) where DReturns D.
Gridap.ReferenceFEs.num_dims — Methodnum_dims(::Type{<:Polytope{D}}) where D
num_dims(p::Polytope{D}) where DReturns D.
Gridap.ReferenceFEs.num_dims — Methodnum_dims(::Type{<:ReferenceFE{D}}) where D
num_dims(reffe::ReferenceFE{D}) where DReturns D.
Gridap.ReferenceFEs.num_dims — Methodnum_dims(::Quadrature{D}) where D where D
num_dims(::Type{<:Quadrature{D}}) where DGridap.ReferenceFEs.num_dofs — Methodnum_dofs(reffe::ReferenceFE) -> IntReturns the number of DOFs.
Gridap.ReferenceFEs.num_edges — Methodnum_edges(p::Polytope)Returns the number of edges in the polytope p.
Gridap.ReferenceFEs.num_edges — Methodnum_edges(reffe::ReferenceFE)Gridap.ReferenceFEs.num_faces — Methodnum_faces(p::Polytope,dim::Integer)Returns the number of faces of dimension dim in polytope p.
Gridap.ReferenceFEs.num_faces — Methodnum_faces(p::Polytope)Returns the total number of faces in polytope p (from vertices to the polytope itself).
Gridap.ReferenceFEs.num_faces — Methodnum_faces(reffe::ReferenceFE)
num_faces(reffe::ReferenceFE,d::Integer)Gridap.ReferenceFEs.num_facets — Methodnum_facets(p::Polytope)Returns the number of facets in the polytope p.
Gridap.ReferenceFEs.num_facets — Methodnum_facets(reffe::ReferenceFE)Gridap.ReferenceFEs.num_nodes — Methodnum_nodes(reffe::LagrangianRefFE)Gridap.ReferenceFEs.num_point_dims — Methodnum_point_dims(::Type{<:ReferenceFE{D}}) where D
num_point_dims(reffe::ReferenceFE{D}) where DReturns D.
Gridap.ReferenceFEs.num_point_dims — Methodnum_point_dims(::Quadrature{D}) where D
num_point_dims(::Type{<:Quadrature{D}}) where DGridap.ReferenceFEs.num_points — Methodnum_points(q::Quadrature)Gridap.ReferenceFEs.num_vertices — Methodnum_vertices(p::Polytope)Returns the number of vertices in the polytope p.
Gridap.ReferenceFEs.num_vertices — Methodnum_vertices(reffe::ReferenceFE)Gridap.ReferenceFEs.polytope_from_faces — Methodpolytope_from_faces(D::Integer,vertices::AbstractVector{<:Point},face_to_vertex::AbstractVector{<:AbstractVector{<:Integer}})Returns a polygon/polyhedron given a list of vertex coordinates and the face-to-vertex connectivity. The polytope is assumed to be closed, i.e there are no open edges.
Gridap.ReferenceFEs.renumber! — Methodrenumber!(graph::Vector{Vector{Int32}},new_to_old::Vector{Int},n_old::Int)Given a polyhedron graph, renumber the nodes of the graph using the new_to_old mapping. Removes the empty nodes.
Gridap.ReferenceFEs.simplexify — Methodsimplexify(p::Polytope) -> Tuple{Vector{Vector{Int}},Polytope}Gridap.ReferenceFEs.simplexify_interior — Methodsimplexify_interior(p::Polyhedron)simplex_interior computes a simplex partition of the volume inside the Polyhedron p. It returns a vector of coordinates and an array of connectivitties.
Gridap.ReferenceFEs.simplexify_surface — Methodsimplexify_surface(p::Polyhedron)simplex_surface computes a simplex partition of the surface bounding the Polyhedron p. It returns a vector of coordinates and an array of connectivitties.
Gridap.ReferenceFEs.test_dof — Methodtest_dof(dof,field,v;cmp::Function=(==))Test that the Dof interface is properly implemented for object dof. It also checks if the object dof when evaluated at the field field returns the same value as v. Comparison is made with the comp function.
Gridap.ReferenceFEs.test_lagrangian_reference_fe — Methodtest_lagrangian_reference_fe(reffe::LagrangianRefFE)Gridap.ReferenceFEs.test_polytope — Methodtest_polytope(p::Polytope{D}; optional::Bool=false) where DFunction that stresses out the functions in the Polytope interface. It tests whether the function in the polytope interface are defined for the given object, and whether they return objects of the expected type. With optional=false (the default), only the mandatory functions are checked. With optional=true, the optional functions are also tested.
Gridap.ReferenceFEs.test_quadrature — Methodtest_quadrature(q::Quadrature{D,T}) where {D,T}Gridap.ReferenceFEs.test_reference_fe — Methodtest_reference_fe(reffe::ReferenceFE{D}) where DTest if the methods in the ReferenceFE interface are defined for the object reffe.