CeedOperator

A CeedOperator defines the finite/spectral element operator associated to a CeedQFunction. A CeedOperator connects objects of the type CeedElemRestriction, CeedBasis, and CeedQFunction.

Discrete operators on user vectors

typedef struct CeedOperator_private *CeedOperator

Handle for object describing FE-type operators acting on vectors.

Given an element restriction \(E\), basis evaluator \(B\), and quadrature function \(f\), a CeedOperator expresses operations of the form $$ E^T B^T f(B E u) $$ acting on the vector \(u\).

int CeedOperatorCreate(Ceed ceed, CeedQFunction qf, CeedQFunction dqf, CeedQFunction dqfT, CeedOperator *op)

Create a CeedOperator and associate a CeedQFunction.

A CeedBasis and CeedElemRestriction can be associated with CeedQFunction fields with CeedOperatorSetField.

User Functions

Parameters
  • ceed – A Ceed object where the CeedOperator will be created

  • qf – QFunction defining the action of the operator at quadrature points

  • dqf – QFunction defining the action of the Jacobian of qf (or CEED_QFUNCTION_NONE)

  • dqfT – QFunction defining the action of the transpose of the Jacobian of qf (or CEED_QFUNCTION_NONE)

  • op[out] Address of the variable where the newly created CeedOperator will be stored

Returns

An error code: 0 - success, otherwise - failure

int CeedCompositeOperatorCreate(Ceed ceed, CeedOperator *op)

Create an operator that composes the action of several operators.

User Functions

Parameters
  • ceed – A Ceed object where the CeedOperator will be created

  • op[out] Address of the variable where the newly created Composite CeedOperator will be stored

Returns

An error code: 0 - success, otherwise - failure

int CeedOperatorReferenceCopy(CeedOperator op, CeedOperator *op_copy)

Copy the pointer to a CeedOperator.

Both pointers should be destroyed with CeedOperatorDestroy(); Note: If *op_copy is non-NULL, then it is assumed that *op_copy is a pointer to a CeedOperator. This CeedOperator will be destroyed if *op_copy is the only reference to this CeedOperator.

User Functions

Parameters
  • op – CeedOperator to copy reference to

  • op_copy[out] Variable to store copied reference

Returns

An error code: 0 - success, otherwise - failure

int CeedOperatorSetField(CeedOperator op, const char *field_name, CeedElemRestriction r, CeedBasis b, CeedVector v)

Provide a field to a CeedOperator for use by its CeedQFunction.

This function is used to specify both active and passive fields to a CeedOperator. For passive fields, a vector

  • v must be provided. Passive fields can inputs or outputs (updated in-place when operator is applied).

Active fields must be specified using this function, but their data (in a CeedVector) is passed in CeedOperatorApply(). There can be at most one active input and at most one active output.

User Functions

Parameters
  • op – CeedOperator on which to provide the field

  • field_name – Name of the field (to be matched with the name used by CeedQFunction)

  • r – CeedElemRestriction

  • b – CeedBasis in which the field resides or CEED_BASIS_COLLOCATED if collocated with quadrature points

  • v – CeedVector to be used by CeedOperator or CEED_VECTOR_ACTIVE if field is active or CEED_VECTOR_NONE if using CEED_EVAL_WEIGHT in the QFunction

Returns

An error code: 0 - success, otherwise - failure

int CeedOperatorGetFields(CeedOperator op, CeedInt *num_input_fields, CeedOperatorField **input_fields, CeedInt *num_output_fields, CeedOperatorField **output_fields)

Get the CeedOperatorFields of a CeedOperator.

Note: Calling this function asserts that setup is complete and sets the CeedOperator as immutable.

Advanced Functions

Parameters
  • op – CeedOperator

  • input_fields[out] Variable to store input_fields

  • output_fields[out] Variable to store output_fields

Returns

An error code: 0 - success, otherwise - failure

int CeedOperatorFieldGetName(CeedOperatorField op_field, char **field_name)

Get the name of a CeedOperatorField.

Advanced Functions

Parameters
  • op_field – CeedOperatorField

  • field_name[out] Variable to store the field name

Returns

An error code: 0 - success, otherwise - failure

int CeedOperatorFieldGetElemRestriction(CeedOperatorField op_field, CeedElemRestriction *rstr)

Get the CeedElemRestriction of a CeedOperatorField.

Advanced Functions

Parameters
  • op_field – CeedOperatorField

  • rstr[out] Variable to store CeedElemRestriction

Returns

An error code: 0 - success, otherwise - failure

int CeedOperatorFieldGetBasis(CeedOperatorField op_field, CeedBasis *basis)

Get the CeedBasis of a CeedOperatorField.

Advanced Functions

Parameters
  • op_field – CeedOperatorField

  • basis[out] Variable to store CeedBasis

Returns

An error code: 0 - success, otherwise - failure

int CeedOperatorFieldGetVector(CeedOperatorField op_field, CeedVector *vec)

Get the CeedVector of a CeedOperatorField.

Advanced Functions

Parameters
  • op_field – CeedOperatorField

  • vec[out] Variable to store CeedVector

Returns

An error code: 0 - success, otherwise - failure

int CeedCompositeOperatorAddSub(CeedOperator composite_op, CeedOperator sub_op)

Add a sub-operator to a composite CeedOperator.

User Functions

Parameters
  • composite_op[out] Composite CeedOperator

  • sub_op – Sub-operator CeedOperator

Returns

An error code: 0 - success, otherwise - failure

int CeedOperatorSetNumQuadraturePoints(CeedOperator op, CeedInt num_qpts)

Set the number of quadrature points associated with a CeedOperator.

This should be used when creating a CeedOperator where every field has a collocated basis. This function cannot be used for composite CeedOperators.

Advanced Functions

Parameters
  • op – CeedOperator

  • num_qpts – Number of quadrature points to set

Returns

An error code: 0 - success, otherwise - failure

int CeedOperatorView(CeedOperator op, FILE *stream)

View a CeedOperator.

User Functions

Parameters
  • op[in] CeedOperator to view

  • stream[in] Stream to write; typically stdout/stderr or a file

Returns

Error code: 0 - success, otherwise - failure

int CeedOperatorGetCeed(CeedOperator op, Ceed *ceed)

Get the Ceed associated with a CeedOperator.

Advanced Functions

Parameters
  • op – CeedOperator

  • ceed[out] Variable to store Ceed

Returns

An error code: 0 - success, otherwise - failure

int CeedOperatorGetNumElements(CeedOperator op, CeedInt *num_elem)

Get the number of elements associated with a CeedOperator.

Advanced Functions

Parameters
  • op – CeedOperator

  • num_elem[out] Variable to store number of elements

Returns

An error code: 0 - success, otherwise - failure

int CeedOperatorGetNumQuadraturePoints(CeedOperator op, CeedInt *num_qpts)

Get the number of quadrature points associated with a CeedOperator.

Advanced Functions

Parameters
  • op – CeedOperator

  • num_qpts[out] Variable to store vector number of quadrature points

Returns

An error code: 0 - success, otherwise - failure

int CeedOperatorApply(CeedOperator op, CeedVector in, CeedVector out, CeedRequest *request)

Apply CeedOperator to a vector.

This computes the action of the operator on the specified (active) input, yielding its (active) output. All inputs and outputs must be specified using CeedOperatorSetField().

Note: Calling this function asserts that setup is complete and sets the CeedOperator as immutable.

User Functions

Parameters
  • op – CeedOperator to apply

  • in[in] CeedVector containing input state or CEED_VECTOR_NONE if there are no active inputs

  • out[out] CeedVector to store result of applying operator (must be distinct from in) or CEED_VECTOR_NONE if there are no active outputs

  • request – Address of CeedRequest for non-blocking completion, else CEED_REQUEST_IMMEDIATE

Returns

An error code: 0 - success, otherwise - failure

int CeedOperatorApplyAdd(CeedOperator op, CeedVector in, CeedVector out, CeedRequest *request)

Apply CeedOperator to a vector and add result to output vector.

This computes the action of the operator on the specified (active) input, yielding its (active) output. All inputs and outputs must be specified using CeedOperatorSetField().

User Functions

Parameters
  • op – CeedOperator to apply

  • in[in] CeedVector containing input state or NULL if there are no active inputs

  • out[out] CeedVector to sum in result of applying operator (must be distinct from in) or NULL if there are no active outputs

  • request – Address of CeedRequest for non-blocking completion, else CEED_REQUEST_IMMEDIATE

Returns

An error code: 0 - success, otherwise - failure

int CeedOperatorDestroy(CeedOperator *op)

Destroy a CeedOperator.

User Functions

Parameters
  • op – CeedOperator to destroy

Returns

An error code: 0 - success, otherwise - failure

int CeedOperatorLinearAssembleQFunction(CeedOperator op, CeedVector *assembled, CeedElemRestriction *rstr, CeedRequest *request)

Assemble a linear CeedQFunction associated with a CeedOperator.

This returns a CeedVector containing a matrix at each quadrature point providing the action of the CeedQFunction associated with the CeedOperator. The vector ‘assembled’ is of shape [num_elements, num_input_fields, num_output_fields, num_quad_points] and contains column-major matrices representing the action of the CeedQFunction for a corresponding quadrature point on an element. Inputs and outputs are in the order provided by the user when adding CeedOperator fields. For example, a CeedQFunction with inputs ‘u’ and ‘gradu’ and outputs ‘gradv’ and ‘v’, provided in that order, would result in an assembled QFunction that consists of (1 + dim) x (dim + 1) matrices at each quadrature point acting on the input [u, du_0, du_1] and producing the output [dv_0, dv_1, v].

Note: Calling this function asserts that setup is complete and sets the CeedOperator as immutable.

User Functions

Parameters
  • op – CeedOperator to assemble CeedQFunction

  • assembled[out] CeedVector to store assembled CeedQFunction at quadrature points

  • rstr[out] CeedElemRestriction for CeedVector containing assembled CeedQFunction

  • request – Address of CeedRequest for non-blocking completion, else CEED_REQUEST_IMMEDIATE

Returns

An error code: 0 - success, otherwise - failure

int CeedOperatorLinearAssembleDiagonal(CeedOperator op, CeedVector assembled, CeedRequest *request)

Assemble the diagonal of a square linear CeedOperator.

This overwrites a CeedVector with the diagonal of a linear CeedOperator.

Note: Currently only non-composite CeedOperators with a single field and composite CeedOperators with single field sub-operators are supported.

Note: Calling this function asserts that setup is complete and sets the CeedOperator as immutable.

User Functions

Parameters
  • op – CeedOperator to assemble CeedQFunction

  • assembled[out] CeedVector to store assembled CeedOperator diagonal

  • request – Address of CeedRequest for non-blocking completion, else CEED_REQUEST_IMMEDIATE

Returns

An error code: 0 - success, otherwise - failure

int CeedOperatorLinearAssembleAddDiagonal(CeedOperator op, CeedVector assembled, CeedRequest *request)

Assemble the diagonal of a square linear CeedOperator.

This sums into a CeedVector the diagonal of a linear CeedOperator.

Note: Currently only non-composite CeedOperators with a single field and composite CeedOperators with single field sub-operators are supported.

Note: Calling this function asserts that setup is complete and sets the CeedOperator as immutable.

User Functions

Parameters
  • op – CeedOperator to assemble CeedQFunction

  • assembled[out] CeedVector to store assembled CeedOperator diagonal

  • request – Address of CeedRequest for non-blocking completion, else CEED_REQUEST_IMMEDIATE

Returns

An error code: 0 - success, otherwise - failure

int CeedOperatorLinearAssemblePointBlockDiagonal(CeedOperator op, CeedVector assembled, CeedRequest *request)

Assemble the point block diagonal of a square linear CeedOperator.

This overwrites a CeedVector with the point block diagonal of a linear CeedOperator.

Note: Currently only non-composite CeedOperators with a single field and composite CeedOperators with single field sub-operators are supported.

Note: Calling this function asserts that setup is complete and sets the CeedOperator as immutable.

User Functions

Parameters
  • op – CeedOperator to assemble CeedQFunction

  • assembled[out] CeedVector to store assembled CeedOperator point block diagonal, provided in row-major form with an num_comp * num_comp block at each node. The dimensions of this vector are derived from the active vector for the CeedOperator. The array has shape [nodes, component out, component in].

  • request – Address of CeedRequest for non-blocking completion, else CEED_REQUEST_IMMEDIATE

Returns

An error code: 0 - success, otherwise - failure

int CeedOperatorLinearAssembleAddPointBlockDiagonal(CeedOperator op, CeedVector assembled, CeedRequest *request)

Assemble the point block diagonal of a square linear CeedOperator.

This sums into a CeedVector with the point block diagonal of a linear CeedOperator.

Note: Currently only non-composite CeedOperators with a single field and composite CeedOperators with single field sub-operators are supported.

Note: Calling this function asserts that setup is complete and sets the CeedOperator as immutable.

User Functions

Parameters
  • op – CeedOperator to assemble CeedQFunction

  • assembled[out] CeedVector to store assembled CeedOperator point block diagonal, provided in row-major form with an num_comp * num_comp block at each node. The dimensions of this vector are derived from the active vector for the CeedOperator. The array has shape [nodes, component out, component in].

  • request – Address of CeedRequest for non-blocking completion, else CEED_REQUEST_IMMEDIATE

Returns

An error code: 0 - success, otherwise - failure

int CeedOperatorLinearAssembleSymbolic(CeedOperator op, CeedInt *num_entries, CeedInt **rows, CeedInt **cols)

Fully assemble the nonzero pattern of a linear operator.

Expected to be used in conjunction with CeedOperatorLinearAssemble()

The assembly routines use coordinate format, with num_entries tuples of the form (i, j, value) which indicate that value should be added to the matrix in entry (i, j). Note that the (i, j) pairs are not unique and may repeat. This function returns the number of entries and their (i, j) locations, while CeedOperatorLinearAssemble() provides the values in the same ordering.

This will generally be slow unless your operator is low-order.

Note: Calling this function asserts that setup is complete and sets the CeedOperator as immutable.

User Functions

Parameters
  • op[in] CeedOperator to assemble

  • num_entries[out] Number of entries in coordinate nonzero pattern

  • rows[out] Row number for each entry

  • cols[out] Column number for each entry

int CeedOperatorLinearAssemble(CeedOperator op, CeedVector values)

Fully assemble the nonzero entries of a linear operator.

Expected to be used in conjunction with CeedOperatorLinearAssembleSymbolic()

The assembly routines use coordinate format, with num_entries tuples of the form (i, j, value) which indicate that value should be added to the matrix in entry (i, j). Note that the (i, j) pairs are not unique and may repeat. This function returns the values of the nonzero entries to be added, their (i, j) locations are provided by CeedOperatorLinearAssembleSymbolic()

This will generally be slow unless your operator is low-order.

Note: Calling this function asserts that setup is complete and sets the CeedOperator as immutable.

User Functions

Parameters
  • op[in] CeedOperator to assemble

  • values[out] Values to assemble into matrix

int CeedOperatorMultigridLevelCreate(CeedOperator op_fine, CeedVector p_mult_fine, CeedElemRestriction rstr_coarse, CeedBasis basis_coarse, CeedOperator *op_coarse, CeedOperator *op_prolong, CeedOperator *op_restrict)

Create a multigrid coarse operator and level transfer operators for a CeedOperator, creating the prolongation basis from the fine and coarse grid interpolation.

Note: Calling this function asserts that setup is complete and sets the CeedOperator as immutable.

User Functions

Parameters
  • op_fine[in] Fine grid operator

  • p_mult_fine[in] L-vector multiplicity in parallel gather/scatter

  • rstr_coarse[in] Coarse grid restriction

  • basis_coarse[in] Coarse grid active vector basis

  • op_coarse[out] Coarse grid operator

  • op_prolong[out] Coarse to fine operator

  • op_restrict[out] Fine to coarse operator

Returns

An error code: 0 - success, otherwise - failure

int CeedOperatorMultigridLevelCreateTensorH1(CeedOperator op_fine, CeedVector p_mult_fine, CeedElemRestriction rstr_coarse, CeedBasis basis_coarse, const CeedScalar *interp_c_to_f, CeedOperator *op_coarse, CeedOperator *op_prolong, CeedOperator *op_restrict)

Create a multigrid coarse operator and level transfer operators for a CeedOperator with a tensor basis for the active basis.

Note: Calling this function asserts that setup is complete and sets the CeedOperator as immutable.

User Functions

Parameters
  • op_fine[in] Fine grid operator

  • p_mult_fine[in] L-vector multiplicity in parallel gather/scatter

  • rstr_coarse[in] Coarse grid restriction

  • basis_coarse[in] Coarse grid active vector basis

  • interp_c_to_f[in] Matrix for coarse to fine interpolation

  • op_coarse[out] Coarse grid operator

  • op_prolong[out] Coarse to fine operator

  • op_restrict[out] Fine to coarse operator

Returns

An error code: 0 - success, otherwise - failure

int CeedOperatorMultigridLevelCreateH1(CeedOperator op_fine, CeedVector p_mult_fine, CeedElemRestriction rstr_coarse, CeedBasis basis_coarse, const CeedScalar *interp_c_to_f, CeedOperator *op_coarse, CeedOperator *op_prolong, CeedOperator *op_restrict)

Create a multigrid coarse operator and level transfer operators for a CeedOperator with a non-tensor basis for the active vector.

Note: Calling this function asserts that setup is complete and sets the CeedOperator as immutable.

User Functions

Parameters
  • op_fine[in] Fine grid operator

  • p_mult_fine[in] L-vector multiplicity in parallel gather/scatter

  • rstr_coarse[in] Coarse grid restriction

  • basis_coarse[in] Coarse grid active vector basis

  • interp_c_to_f[in] Matrix for coarse to fine interpolation

  • op_coarse[out] Coarse grid operator

  • op_prolong[out] Coarse to fine operator

  • op_restrict[out] Fine to coarse operator

Returns

An error code: 0 - success, otherwise - failure

int CeedOperatorCreateFDMElementInverse(CeedOperator op, CeedOperator *fdm_inv, CeedRequest *request)

Build a FDM based approximate inverse for each element for a CeedOperator.

This returns a CeedOperator and CeedVector to apply a Fast Diagonalization Method based approximate inverse. This function obtains the simultaneous diagonalization for the 1D mass and Laplacian operators, M = V^T V, K = V^T S V. The assembled QFunction is used to modify the eigenvalues from simultaneous diagonalization and obtain an approximate inverse of the form V^T S^hat V. The CeedOperator must be linear and non-composite. The associated CeedQFunction must therefore also be linear.

Note: Calling this function asserts that setup is complete and sets the CeedOperator as immutable.

Backend Developer Functions

Parameters
  • op – CeedOperator to create element inverses

  • fdm_inv[out] CeedOperator to apply the action of a FDM based inverse for each element

  • request – Address of CeedRequest for non-blocking completion, else CEED_REQUEST_IMMEDIATE

Returns

An error code: 0 - success, otherwise - failure