CeedBasis
A CeedBasis defines the discrete finite element basis and associated quadrature rule.
Discrete element bases and quadrature
-
typedef struct CeedBasis_private *CeedBasis
Handle for object describing discrete finite element evaluations.
-
const CeedBasis CEED_BASIS_NONE = &ceed_basis_none
Argument for CeedOperatorSetField() indicating that the field does not require a
CeedBasis
-
int CeedBasisCreateTensorH1(Ceed ceed, CeedInt dim, CeedInt num_comp, CeedInt P_1d, CeedInt Q_1d, const CeedScalar *interp_1d, const CeedScalar *grad_1d, const CeedScalar *q_ref_1d, const CeedScalar *q_weight_1d, CeedBasis *basis)
Create a tensor-product basis for \(H^1\) discretizations.
User Functions
- Parameters:
ceed – [in]
Ceedobject used to create theCeedBasisdim – [in] Topological dimension
num_comp – [in] Number of field components (1 for scalar fields)
P_1d – [in] Number of nodes in one dimension
Q_1d – [in] Number of quadrature points in one dimension
interp_1d – [in] Row-major (
Q_1d * P_1d) matrix expressing the values of nodal basis functions at quadrature pointsgrad_1d – [in] Row-major (
Q_1d * P_1d) matrix expressing derivatives of nodal basis functions at quadrature pointsq_ref_1d – [in] Array of length
Q_1dholding the locations of quadrature points on the 1D reference element[-1, 1]q_weight_1d – [in] Array of length
Q_1dholding the quadrature weights on the reference elementbasis – [out] Address of the variable where the newly created
CeedBasiswill be stored
- Returns:
An error code: 0 - success, otherwise - failure
-
int CeedBasisCreateTensorH1Lagrange(Ceed ceed, CeedInt dim, CeedInt num_comp, CeedInt P, CeedInt Q, CeedQuadMode quad_mode, CeedBasis *basis)
Create a tensor-product \(H^1\) Lagrange basis.
User Functions
- Parameters:
ceed – [in]
Ceedobject used to create theCeedBasisdim – [in] Topological dimension of element
num_comp – [in] Number of field components (1 for scalar fields)
P – [in] Number of Gauss-Lobatto nodes in one dimension. The polynomial degree of the resulting
Q_kelement isk = P - 1.Q – [in] Number of quadrature points in one dimension.
quad_mode – [in] Distribution of the
Qquadrature points (affects order of accuracy for the quadrature)basis – [out] Address of the variable where the newly created
CeedBasiswill be stored
- Returns:
An error code: 0 - success, otherwise - failure
-
int CeedBasisCreateH1(Ceed ceed, CeedElemTopology topo, CeedInt num_comp, CeedInt num_nodes, CeedInt num_qpts, const CeedScalar *interp, const CeedScalar *grad, const CeedScalar *q_ref, const CeedScalar *q_weight, CeedBasis *basis)
Create a non tensor-product basis for \(H^1\) discretizations.
User Functions
- Parameters:
ceed – [in]
Ceedobject used to create theCeedBasistopo – [in] Topology of element, e.g. hypercube, simplex, etc
num_comp – [in] Number of field components (1 for scalar fields)
num_nodes – [in] Total number of nodes
num_qpts – [in] Total number of quadrature points
interp – [in] Row-major (
num_qpts * num_nodes) matrix expressing the values of nodal basis functions at quadrature pointsgrad – [in] Row-major (
dim * num_qpts * num_nodes) matrix expressing derivatives of nodal basis functions at quadrature pointsq_ref – [in] Array of length
num_qpts * dimholding the locations of quadrature points on the reference elementq_weight – [in] Array of length
num_qptsholding the quadrature weights on the reference elementbasis – [out] Address of the variable where the newly created
CeedBasiswill be stored
- Returns:
An error code: 0 - success, otherwise - failure
-
int CeedBasisCreateHdiv(Ceed ceed, CeedElemTopology topo, CeedInt num_comp, CeedInt num_nodes, CeedInt num_qpts, const CeedScalar *interp, const CeedScalar *div, const CeedScalar *q_ref, const CeedScalar *q_weight, CeedBasis *basis)
Create a non tensor-product basis for \(H(\mathrm{div})\) discretizations.
User Functions
- Parameters:
ceed – [in]
Ceedobject used to create theCeedBasistopo – [in] Topology of element (
CEED_TOPOLOGY_QUAD,CEED_TOPOLOGY_PRISM, etc.), dimension of which is used in some array sizes belownum_comp – [in] Number of components (usually 1 for vectors in H(div) bases)
num_nodes – [in] Total number of nodes (DoFs per element)
num_qpts – [in] Total number of quadrature points
interp – [in] Row-major (
dim * num_qpts * num_nodes) matrix expressing the values of basis functions at quadrature pointsdiv – [in] Row-major (
num_qpts * num_nodes) matrix expressing divergence of basis functions at quadrature pointsq_ref – [in] Array of length
num_qpts* dim holding the locations of quadrature points on the reference elementq_weight – [in] Array of length
num_qptsholding the quadrature weights on the reference elementbasis – [out] Address of the variable where the newly created
CeedBasiswill be stored
- Returns:
An error code: 0 - success, otherwise - failure
-
int CeedBasisCreateHcurl(Ceed ceed, CeedElemTopology topo, CeedInt num_comp, CeedInt num_nodes, CeedInt num_qpts, const CeedScalar *interp, const CeedScalar *curl, const CeedScalar *q_ref, const CeedScalar *q_weight, CeedBasis *basis)
Create a non tensor-product basis for \(H(\mathrm{curl})\) discretizations.
User Functions
- Parameters:
ceed – [in]
Ceedobject used to create theCeedBasistopo – [in] Topology of element (
CEED_TOPOLOGY_QUAD,CEED_TOPOLOGY_PRISM, etc.), dimension of which is used in some array sizes belownum_comp – [in] Number of components (usually 1 for vectors in \(H(\mathrm{curl})\) bases)
num_nodes – [in] Total number of nodes (DoFs per element)
num_qpts – [in] Total number of quadrature points
interp – [in] Row-major (
dim * num_qpts * num_nodes) matrix expressing the values of basis functions at quadrature pointscurl – [in] Row-major (
curl_comp * num_qpts * num_nodes,curl_comp = 1ifdim < 3otherwisecurl_comp = dim) matrix expressing curl of basis functions at quadrature pointsq_ref – [in] Array of length
num_qpts * dimholding the locations of quadrature points on the reference elementq_weight – [in] Array of length
num_qptsholding the quadrature weights on the reference elementbasis – [out] Address of the variable where the newly created
CeedBasiswill be stored
- Returns:
An error code: 0 - success, otherwise - failure
-
int CeedBasisCreateProjection(CeedBasis basis_from, CeedBasis basis_to, CeedBasis *basis_project)
Create a
CeedBasisfor projection from the nodes ofbasis_fromto the nodes ofbasis_to.Only CEED_EVAL_INTERP will be valid for the new basis,
basis_project. For \(H^1\) spaces, CEED_EVAL_GRAD will also be valid. The interpolation is given byinterp_project = interp_to^+ * interp_from, where the pseudoinverseinterp_to^+is given by QR factorization. The gradient (for the \(H^1\) case) is given bygrad_project = interp_to^+ * grad_from.Note:
basis_fromandbasis_tomust have compatible quadrature spaces.Note:
basis_projectwill have the same number of components asbasis_from, regardless of the number of components thatbasis_tohas. Ifbasis_fromhas 3 components andbasis_tohas 5 components, thenbasis_projectwill have 3 components.Note: If either
basis_fromorbasis_toare non-tensor, thenbasis_projectwill also be non-tensorUser Functions
- Parameters:
basis_from – [in]
CeedBasisto prolong frombasis_to – [in]
CeedBasisto prolong tobasis_project – [out] Address of the variable where the newly created
CeedBasiswill be stored
- Returns:
An error code: 0 - success, otherwise - failure
-
int CeedBasisReferenceCopy(CeedBasis basis, CeedBasis *basis_copy)
Copy the pointer to a
CeedBasis.Note: If the value of
*basis_copypassed into this function is non-NULL, then it is assumed that*basis_copyis a pointer to aCeedBasis. ThisCeedBasiswill be destroyed if*basis_copyis the only reference to thisCeedBasis.User Functions
- Parameters:
basis – [in]
CeedBasisto copy reference tobasis_copy – [inout] Variable to store copied reference
- Returns:
An error code: 0 - success, otherwise - failure
-
int CeedBasisSetNumViewTabs(CeedBasis basis, CeedInt num_tabs)
Set the number of tabs to indent for CeedBasisView() output.
User Functions
- Parameters:
basis – [in]
CeedBasisto set the number of view tabsnum_tabs – [in] Number of view tabs to set
- Returns:
Error code: 0 - success, otherwise - failure
-
int CeedBasisGetNumViewTabs(CeedBasis basis, CeedInt *num_tabs)
Get the number of tabs to indent for CeedBasisView() output.
User Functions
- Parameters:
basis – [in]
CeedBasisto get the number of view tabsnum_tabs – [out] Number of view tabs
- Returns:
Error code: 0 - success, otherwise - failure
-
int CeedBasisView(CeedBasis basis, FILE *stream)
View a
CeedBasisUser Functions
- Parameters:
basis – [in]
CeedBasisto viewstream – [in] Stream to view to, e.g.,
stdout
- Returns:
An error code: 0 - success, otherwise - failure
-
int CeedBasisApply(CeedBasis basis, CeedInt num_elem, CeedTransposeMode t_mode, CeedEvalMode eval_mode, CeedVector u, CeedVector v)
Apply basis evaluation from nodes to quadrature points or vice versa.
User Functions
- Parameters:
basis – [in]
CeedBasisto evaluatenum_elem – [in] The number of elements to apply the basis evaluation to; the backend will specify the ordering in CeedElemRestrictionCreate()
t_mode – [in] CEED_NOTRANSPOSE to evaluate from nodes to quadrature points; CEED_TRANSPOSE to apply the transpose, mapping from quadrature points to nodes
eval_mode – [in] CEED_EVAL_NONE to use values directly, CEED_EVAL_INTERP to use interpolated values, CEED_EVAL_GRAD to use gradients, CEED_EVAL_DIV to use divergence, CEED_EVAL_CURL to use curl, CEED_EVAL_WEIGHT to use quadrature weights
u – [in] Input
CeedVectorv – [out] Output
CeedVector
- Returns:
An error code: 0 - success, otherwise - failure
-
int CeedBasisApplyAdd(CeedBasis basis, CeedInt num_elem, CeedTransposeMode t_mode, CeedEvalMode eval_mode, CeedVector u, CeedVector v)
Apply basis evaluation from quadrature points to nodes and sum into target vector.
User Functions
- Parameters:
basis – [in]
CeedBasisto evaluatenum_elem – [in] The number of elements to apply the basis evaluation to; the backend will specify the ordering in CeedElemRestrictionCreate()
t_mode – [in] CEED_TRANSPOSE to apply the transpose, mapping from quadrature points to nodes; CEED_NOTRANSPOSE is not valid for
CeedBasisApplyAdd()eval_mode – [in] CEED_EVAL_NONE to use values directly, CEED_EVAL_INTERP to use interpolated values, CEED_EVAL_GRAD to use gradients, CEED_EVAL_DIV to use divergence, CEED_EVAL_CURL to use curl, CEED_EVAL_WEIGHT to use quadrature weights
u – [in] Input
CeedVectorv – [out] Output
CeedVectorto sum into
- Returns:
An error code: 0 - success, otherwise - failure
-
int CeedBasisApplyAtPoints(CeedBasis basis, CeedInt num_elem, const CeedInt *num_points, CeedTransposeMode t_mode, CeedEvalMode eval_mode, CeedVector x_ref, CeedVector u, CeedVector v)
Apply basis evaluation from nodes to arbitrary points.
User Functions
- Parameters:
basis – [in]
CeedBasisto evaluatenum_elem – [in] The number of elements to apply the basis evaluation to; the backend will specify the ordering in CeedElemRestrictionCreate()
num_points – [in] Array of the number of points to apply the basis evaluation to in each element, size
num_elemt_mode – [in] CEED_NOTRANSPOSE to evaluate from nodes to points; CEED_TRANSPOSE to apply the transpose, mapping from points to nodes
eval_mode – [in] CEED_EVAL_INTERP to use interpolated values, CEED_EVAL_GRAD to use gradients, CEED_EVAL_WEIGHT to use quadrature weights
x_ref – [in]
CeedVectorholding reference coordinates of each pointu – [in] Input
CeedVector, of lengthnum_nodes * num_compfor CEED_NOTRANSPOSEv – [out] Output
CeedVector, of lengthnum_points * num_q_compfor CEED_NOTRANSPOSE with CEED_EVAL_INTERP
- Returns:
An error code: 0 - success, otherwise - failure
-
int CeedBasisApplyAddAtPoints(CeedBasis basis, CeedInt num_elem, const CeedInt *num_points, CeedTransposeMode t_mode, CeedEvalMode eval_mode, CeedVector x_ref, CeedVector u, CeedVector v)
Apply basis evaluation from nodes to arbitrary points and sum into target vector.
User Functions
- Parameters:
basis – [in]
CeedBasisto evaluatenum_elem – [in] The number of elements to apply the basis evaluation to; the backend will specify the ordering in CeedElemRestrictionCreate()
num_points – [in] Array of the number of points to apply the basis evaluation to in each element, size
num_elemt_mode – [in] CEED_NOTRANSPOSE to evaluate from nodes to points; CEED_NOTRANSPOSE is not valid for
CeedBasisApplyAddAtPoints()eval_mode – [in] CEED_EVAL_INTERP to use interpolated values, CEED_EVAL_GRAD to use gradients, CEED_EVAL_WEIGHT to use quadrature weights
x_ref – [in]
CeedVectorholding reference coordinates of each pointu – [in] Input
CeedVector, of lengthnum_nodes * num_compfor CEED_NOTRANSPOSEv – [out] Output
CeedVector, of lengthnum_points * num_q_compfor CEED_NOTRANSPOSE with CEED_EVAL_INTERP
- Returns:
An error code: 0 - success, otherwise - failure
-
int CeedBasisGetCeed(CeedBasis basis, Ceed *ceed)
Get the
Ceedassociated with aCeedBasisAdvanced Functions
- Parameters:
basis – [in]
CeedBasisceed – [out] Variable to store
Ceed
- Returns:
An error code: 0 - success, otherwise - failure
-
Ceed CeedBasisReturnCeed(CeedBasis basis)
Return the
Ceedassociated with aCeedBasisAdvanced Functions
- Parameters:
basis – [in]
CeedBasis
- Returns:
Ceedassociated with thebasis
-
int CeedBasisGetDimension(CeedBasis basis, CeedInt *dim)
Get dimension for given
CeedBasisAdvanced Functions
- Parameters:
basis – [in]
CeedBasisdim – [out] Variable to store dimension of basis
- Returns:
An error code: 0 - success, otherwise - failure
-
int CeedBasisGetTopology(CeedBasis basis, CeedElemTopology *topo)
Get topology for given
CeedBasisAdvanced Functions
- Parameters:
basis – [in]
CeedBasistopo – [out] Variable to store topology of basis
- Returns:
An error code: 0 - success, otherwise - failure
-
int CeedBasisGetNumComponents(CeedBasis basis, CeedInt *num_comp)
Get number of components for given
CeedBasisAdvanced Functions
- Parameters:
basis – [in]
CeedBasisnum_comp – [out] Variable to store number of components
- Returns:
An error code: 0 - success, otherwise - failure
-
int CeedBasisGetNumNodes(CeedBasis basis, CeedInt *P)
Get total number of nodes (in
dimdimensions) of aCeedBasisUtility Functions
- Parameters:
basis – [in]
CeedBasisP – [out] Variable to store number of nodes
- Returns:
An error code: 0 - success, otherwise - failure
-
int CeedBasisGetNumNodes1D(CeedBasis basis, CeedInt *P_1d)
Get total number of nodes (in 1 dimension) of a
CeedBasisAdvanced Functions
- Parameters:
basis – [in]
CeedBasisP_1d – [out] Variable to store number of nodes
- Returns:
An error code: 0 - success, otherwise - failure
-
int CeedBasisGetNumQuadraturePoints(CeedBasis basis, CeedInt *Q)
Get total number of quadrature points (in
dimdimensions) of aCeedBasisUtility Functions
- Parameters:
basis – [in]
CeedBasisQ – [out] Variable to store number of quadrature points
- Returns:
An error code: 0 - success, otherwise - failure
-
int CeedBasisGetNumQuadraturePoints1D(CeedBasis basis, CeedInt *Q_1d)
Get total number of quadrature points (in 1 dimension) of a
CeedBasisAdvanced Functions
- Parameters:
basis – [in]
CeedBasisQ_1d – [out] Variable to store number of quadrature points
- Returns:
An error code: 0 - success, otherwise - failure
-
int CeedBasisGetQRef(CeedBasis basis, const CeedScalar **q_ref)
Get reference coordinates of quadrature points (in
dimdimensions) of aCeedBasisAdvanced Functions
- Parameters:
basis – [in]
CeedBasisq_ref – [out] Variable to store reference coordinates of quadrature points
- Returns:
An error code: 0 - success, otherwise - failure
-
int CeedBasisGetQWeights(CeedBasis basis, const CeedScalar **q_weight)
Get quadrature weights of quadrature points (in
dimdimensions) of aCeedBasisAdvanced Functions
- Parameters:
basis – [in]
CeedBasisq_weight – [out] Variable to store quadrature weights
- Returns:
An error code: 0 - success, otherwise - failure
-
int CeedBasisGetInterp(CeedBasis basis, const CeedScalar **interp)
Get interpolation matrix of a
CeedBasisAdvanced Functions
- Parameters:
basis – [in]
CeedBasisinterp – [out] Variable to store interpolation matrix
- Returns:
An error code: 0 - success, otherwise - failure
-
int CeedBasisGetInterp1D(CeedBasis basis, const CeedScalar **interp_1d)
Get 1D interpolation matrix of a tensor product
CeedBasisBackend Developer Functions
- Parameters:
basis – [in]
CeedBasisinterp_1d – [out] Variable to store interpolation matrix
- Returns:
An error code: 0 - success, otherwise - failure
-
int CeedBasisGetGrad(CeedBasis basis, const CeedScalar **grad)
Get gradient matrix of a
CeedBasisAdvanced Functions
- Parameters:
basis – [in]
CeedBasisgrad – [out] Variable to store gradient matrix
- Returns:
An error code: 0 - success, otherwise - failure
-
int CeedBasisGetGrad1D(CeedBasis basis, const CeedScalar **grad_1d)
Get 1D gradient matrix of a tensor product
CeedBasisAdvanced Functions
- Parameters:
basis – [in]
CeedBasisgrad_1d – [out] Variable to store gradient matrix
- Returns:
An error code: 0 - success, otherwise - failure
-
int CeedBasisGetDiv(CeedBasis basis, const CeedScalar **div)
Get divergence matrix of a
CeedBasisAdvanced Functions
- Parameters:
basis – [in]
CeedBasisdiv – [out] Variable to store divergence matrix
- Returns:
An error code: 0 - success, otherwise - failure
-
int CeedBasisGetCurl(CeedBasis basis, const CeedScalar **curl)
Get curl matrix of a
CeedBasisAdvanced Functions
- Parameters:
basis – [in]
CeedBasiscurl – [out] Variable to store curl matrix
- Returns:
An error code: 0 - success, otherwise - failure
-
int CeedBasisDestroy(CeedBasis *basis)
Destroy a CeedBasis: fully discrete finite element-like objects.
User Functions
- Parameters:
basis – [inout]
CeedBasisto destroy
- Returns:
An error code: 0 - success, otherwise - failure
-
int CeedGaussQuadrature(CeedInt Q, CeedScalar *q_ref_1d, CeedScalar *q_weight_1d)
Construct a Gauss-Legendre quadrature.
Utility Functions
- Parameters:
Q – [in] Number of quadrature points (integrates polynomials of degree
2*Q-1exactly)q_ref_1d – [out] Array of length
Qto hold the abscissa on[-1, 1]q_weight_1d – [out] Array of length
Qto hold the weights
- Returns:
An error code: 0 - success, otherwise - failure
-
int CeedLobattoQuadrature(CeedInt Q, CeedScalar *q_ref_1d, CeedScalar *q_weight_1d)
Construct a Gauss-Legendre-Lobatto quadrature.
Utility Functions
- Parameters:
Q – [in] Number of quadrature points (integrates polynomials of degree
2*Q-3exactly)q_ref_1d – [out] Array of length
Qto hold the abscissa on[-1, 1]q_weight_1d – [out] Array of length
Qto hold the weights
- Returns:
An error code: 0 - success, otherwise - failure
Typedefs and Enumerations
-
enum CeedTransposeMode
Denotes whether a linear transformation or its transpose should be applied.
Values:
-
enumerator CEED_NOTRANSPOSE
Apply the linear transformation.
-
enumerator CEED_TRANSPOSE
Apply the transpose.
-
enumerator CEED_NOTRANSPOSE
-
enum CeedEvalMode
Basis evaluation mode.
Values:
-
enumerator CEED_EVAL_NONE
Perform no evaluation (either because there is no data or it is already at quadrature points)
-
enumerator CEED_EVAL_INTERP
Interpolate from nodes to quadrature points.
-
enumerator CEED_EVAL_GRAD
Evaluate gradients at quadrature points from input in the basis.
-
enumerator CEED_EVAL_DIV
Evaluate divergence at quadrature points from input in the basis.
-
enumerator CEED_EVAL_CURL
Evaluate curl at quadrature points from input in the basis.
-
enumerator CEED_EVAL_WEIGHT
Using no input, evaluate quadrature weights on the reference element.
-
enumerator CEED_EVAL_NONE
-
enum CeedQuadMode
Type of quadrature; also used for location of nodes.
Values:
-
enumerator CEED_GAUSS
Gauss-Legendre quadrature.
-
enumerator CEED_GAUSS_LOBATTO
Gauss-Legendre-Lobatto quadrature.
-
enumerator CEED_GAUSS
-
enum CeedElemTopology
Type of basis shape to create non-tensor element basis.
Dimension can be extracted with bitwise AND (CeedElemTopology & 2**(dim + 2)) == TRUE
Values:
-
enumerator CEED_TOPOLOGY_LINE
Line.
-
enumerator CEED_TOPOLOGY_TRIANGLE
Triangle - 2D shape.
-
enumerator CEED_TOPOLOGY_QUAD
Quadralateral - 2D shape.
-
enumerator CEED_TOPOLOGY_TET
Tetrahedron - 3D shape.
-
enumerator CEED_TOPOLOGY_PYRAMID
Pyramid - 3D shape.
-
enumerator CEED_TOPOLOGY_PRISM
Prism - 3D shape.
-
enumerator CEED_TOPOLOGY_HEX
Hexehedron - 3D shape.
-
enumerator CEED_TOPOLOGY_LINE