xref: /libCEED/rust/libceed-sys/c-src/include/ceed/ceed.h (revision c4e3f59b2ea5a0c95cc0118aa5026c447cce3092)
1ea61e9acSJeremy L Thompson /// Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors.
2ea61e9acSJeremy L Thompson /// All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
3ec3da8bcSJed Brown ///
4ea61e9acSJeremy L Thompson /// SPDX-License-Identifier: BSD-2-Clause
5ec3da8bcSJed Brown ///
6ea61e9acSJeremy L Thompson /// This file is part of CEED:  http://github.com/ceed
7ec3da8bcSJed Brown 
8ec3da8bcSJed Brown /// @file
9ec3da8bcSJed Brown /// Public header for user and utility components of libCEED
10ec3da8bcSJed Brown #ifndef _ceed_h
11ec3da8bcSJed Brown #define _ceed_h
12ec3da8bcSJed Brown 
13ec3da8bcSJed Brown /// @defgroup Ceed Ceed: core components
14ec3da8bcSJed Brown /// @defgroup CeedVector CeedVector: storing and manipulating vectors
15ec3da8bcSJed Brown /// @defgroup CeedElemRestriction CeedElemRestriction: restriction from local vectors to elements
16ec3da8bcSJed Brown /// @defgroup CeedBasis CeedBasis: fully discrete finite element-like objects
17ec3da8bcSJed Brown /// @defgroup CeedQFunction CeedQFunction: independent operations at quadrature points
18ec3da8bcSJed Brown /// @defgroup CeedOperator CeedOperator: composed FE-type operations on vectors
19ec3da8bcSJed Brown ///
20ea61e9acSJeremy L Thompson /// @page FunctionCategories libCEED: Types of Functions libCEED provides three different header files depending upon the type of functions a user
21ea61e9acSJeremy L Thompson /// requires.
22ec3da8bcSJed Brown /// @section Utility Utility Functions
23ea61e9acSJeremy L Thompson ///    These functions are intended general utilities that may be useful to libCEED developers and users.
24ea61e9acSJeremy L Thompson ///    These functions can generally be found in "ceed.h".
25ec3da8bcSJed Brown /// @section User User Functions
26ea61e9acSJeremy L Thompson ///    These functions are intended to be used by general users of libCEED and can generally be found in "ceed.h".
27e9b533fbSJeremy L Thompson /// @section Advanced Advanced Functions
28ea61e9acSJeremy L Thompson ///    These functions are intended to be used by advanced users of libCEED and can generally be found in "ceed.h".
29ec3da8bcSJed Brown /// @section Backend Backend Developer Functions
30ea61e9acSJeremy L Thompson ///    These functions are intended to be used by backend developers of libCEED and can generally be found in "ceed-backend.h".
31ec3da8bcSJed Brown /// @section Developer Library Developer Functions
32ea61e9acSJeremy L Thompson ///    These functions are intended to be used by library developers of libCEED and can generally be found in "ceed-impl.h".
33ec3da8bcSJed Brown 
343b271f31SJed Brown #if !defined(CEED_SKIP_VISIBILITY)
353b271f31SJed Brown #define CEED_VISIBILITY(mode) __attribute__((visibility(#mode)))
363b271f31SJed Brown #else
373b271f31SJed Brown #define CEED_VISIBILITY(mode)
383b271f31SJed Brown #endif
393b271f31SJed Brown 
40ec3da8bcSJed Brown /**
41ec3da8bcSJed Brown   CEED_EXTERN is used in this header to denote all publicly visible symbols.
42ec3da8bcSJed Brown 
43ea61e9acSJeremy L Thompson   No other file should declare publicly visible symbols, thus it should never be used outside ceed.h.
44ec3da8bcSJed Brown  */
452b730f8bSJeremy L Thompson #if defined(__clang_analyzer__)
462b730f8bSJeremy L Thompson #define CEED_EXTERN extern
472b730f8bSJeremy L Thompson #elif defined(__cplusplus)
483b271f31SJed Brown #define CEED_EXTERN extern "C" CEED_VISIBILITY(default)
49ec3da8bcSJed Brown #else
503b271f31SJed Brown #define CEED_EXTERN extern CEED_VISIBILITY(default)
51ec3da8bcSJed Brown #endif
52ec3da8bcSJed Brown 
53ec3da8bcSJed Brown #include <stdarg.h>
54ec3da8bcSJed Brown #include <stdbool.h>
553047f789SJeremy L Thompson #include <stdio.h>
56ec3da8bcSJed Brown 
57c9c2c079SJeremy L Thompson /// Typedefs and macros used in public interfaces and user QFunction source
5849aac155SJeremy L Thompson #include "types.h"  // IWYU pragma: export
5949aac155SJeremy L Thompson /// This line prevents IWYU from suggesting "ceed.h"
6049aac155SJeremy L Thompson // IWYU pragma: private, include <ceed.h>
61ec3da8bcSJed Brown 
62ec3da8bcSJed Brown /// Library context created by CeedInit()
63ec3da8bcSJed Brown /// @ingroup CeedUser
64ec3da8bcSJed Brown typedef struct Ceed_private *Ceed;
65ec3da8bcSJed Brown /// Non-blocking Ceed interfaces return a CeedRequest.
66ec3da8bcSJed Brown /// To perform an operation immediately, pass \ref CEED_REQUEST_IMMEDIATE instead.
67ec3da8bcSJed Brown /// @ingroup CeedUser
68ec3da8bcSJed Brown typedef struct CeedRequest_private *CeedRequest;
69ec3da8bcSJed Brown /// Handle for vectors over the field \ref CeedScalar
70ec3da8bcSJed Brown /// @ingroup CeedVectorUser
71ec3da8bcSJed Brown typedef struct CeedVector_private *CeedVector;
72ec3da8bcSJed Brown /// Handle for object describing restriction to elements
73ec3da8bcSJed Brown /// @ingroup CeedElemRestrictionUser
74ec3da8bcSJed Brown typedef struct CeedElemRestriction_private *CeedElemRestriction;
75ec3da8bcSJed Brown /// Handle for object describing discrete finite element evaluations
76ec3da8bcSJed Brown /// @ingroup CeedBasisUser
77ec3da8bcSJed Brown typedef struct CeedBasis_private *CeedBasis;
7843bbe138SJeremy L Thompson /// Handle for object describing CeedQFunction fields
7943bbe138SJeremy L Thompson /// @ingroup CeedQFunctionBackend
8043bbe138SJeremy L Thompson typedef struct CeedQFunctionField_private *CeedQFunctionField;
81ec3da8bcSJed Brown /// Handle for object describing functions evaluated independently at quadrature points
82ec3da8bcSJed Brown /// @ingroup CeedQFunctionUser
83ec3da8bcSJed Brown typedef struct CeedQFunction_private *CeedQFunction;
8443bbe138SJeremy L Thompson /// Handle for object describing CeedOperator fields
8543bbe138SJeremy L Thompson /// @ingroup CeedOperatorBackend
8643bbe138SJeremy L Thompson typedef struct CeedOperatorField_private *CeedOperatorField;
87ec3da8bcSJed Brown /// Handle for object describing context data for CeedQFunctions
88ec3da8bcSJed Brown /// @ingroup CeedQFunctionUser
89ec3da8bcSJed Brown typedef struct CeedQFunctionContext_private *CeedQFunctionContext;
903668ca4bSJeremy L Thompson /// Handle for object describing registered fields for CeedQFunctionContext
913668ca4bSJeremy L Thompson /// @ingroup CeedQFunctionUser
923668ca4bSJeremy L Thompson typedef struct CeedContextFieldLabel_private *CeedContextFieldLabel;
93ec3da8bcSJed Brown /// Handle for object describing FE-type operators acting on vectors
94ec3da8bcSJed Brown ///
95859c15bbSJames Wright /// Given an element restriction \f$E\f$, basis evaluator \f$B\f$, and quadrature function\f$f\f$, a CeedOperator expresses operations of the form
96859c15bbSJames Wright /// \f$E^T B^T f(B E u)\f$ acting on the vector \f$u\f$.
97ec3da8bcSJed Brown /// @ingroup CeedOperatorUser
98ec3da8bcSJed Brown typedef struct CeedOperator_private *CeedOperator;
99ec3da8bcSJed Brown 
10022e44211Sjeremylt CEED_EXTERN int CeedRegistryGetList(size_t *n, char ***const resources, CeedInt **array);
101ec3da8bcSJed Brown CEED_EXTERN int CeedInit(const char *resource, Ceed *ceed);
1029560d06aSjeremylt CEED_EXTERN int CeedReferenceCopy(Ceed ceed, Ceed *ceed_copy);
103ec3da8bcSJed Brown CEED_EXTERN int CeedGetResource(Ceed ceed, const char **resource);
104d1d35e2fSjeremylt CEED_EXTERN int CeedIsDeterministic(Ceed ceed, bool *is_deterministic);
105ee5a26f2SJeremy L Thompson CEED_EXTERN int CeedAddJitSourceRoot(Ceed ceed, const char *jit_source_root);
106ec3da8bcSJed Brown CEED_EXTERN int CeedView(Ceed ceed, FILE *stream);
107ec3da8bcSJed Brown CEED_EXTERN int CeedDestroy(Ceed *ceed);
108ec3da8bcSJed Brown 
1092b730f8bSJeremy L Thompson CEED_EXTERN int CeedErrorImpl(Ceed, const char *, int, const char *, int, const char *, ...);
110ec3da8bcSJed Brown /// Raise an error on ceed object
111ec3da8bcSJed Brown ///
112ec3da8bcSJed Brown /// @param ceed Ceed library context or NULL
113ec3da8bcSJed Brown /// @param ecode Error code (int)
114ec3da8bcSJed Brown /// @param ... printf-style format string followed by arguments as needed
115ec3da8bcSJed Brown ///
116ec3da8bcSJed Brown /// @ingroup Ceed
117ec3da8bcSJed Brown /// @sa CeedSetErrorHandler()
118ec3da8bcSJed Brown #if defined(__clang__)
119ea61e9acSJeremy L Thompson /// Use nonstandard ternary to convince the compiler/clang-tidy that this function never returns zero.
1202b730f8bSJeremy L Thompson #define CeedError(ceed, ecode, ...) (CeedErrorImpl((ceed), __FILE__, __LINE__, __func__, (ecode), __VA_ARGS__), (ecode))
121ec3da8bcSJed Brown #else
1222b730f8bSJeremy L Thompson #define CeedError(ceed, ecode, ...) CeedErrorImpl((ceed), __FILE__, __LINE__, __func__, (ecode), __VA_ARGS__) ?: (ecode)
123ec3da8bcSJed Brown #endif
124ec3da8bcSJed Brown 
125ec3da8bcSJed Brown /// Ceed error handlers
1262b730f8bSJeremy L Thompson CEED_EXTERN int CeedErrorReturn(Ceed, const char *, int, const char *, int, const char *, va_list *);
1272b730f8bSJeremy L Thompson CEED_EXTERN int CeedErrorStore(Ceed, const char *, int, const char *, int, const char *, va_list *);
1282b730f8bSJeremy L Thompson CEED_EXTERN int CeedErrorAbort(Ceed, const char *, int, const char *, int, const char *, va_list *);
1292b730f8bSJeremy L Thompson CEED_EXTERN int CeedErrorExit(Ceed, const char *, int, const char *, int, const char *, va_list *);
1302b730f8bSJeremy L Thompson typedef int (*CeedErrorHandler)(Ceed, const char *, int, const char *, int, const char *, va_list *);
131ec3da8bcSJed Brown CEED_EXTERN int CeedSetErrorHandler(Ceed ceed, CeedErrorHandler eh);
132d1d35e2fSjeremylt CEED_EXTERN int CeedGetErrorMessage(Ceed, const char **err_msg);
133d1d35e2fSjeremylt CEED_EXTERN int CeedResetErrorMessage(Ceed, const char **err_msg);
134ec3da8bcSJed Brown 
135ec3da8bcSJed Brown /// libCEED library version numbering
136ec3da8bcSJed Brown /// @ingroup Ceed
137ec3da8bcSJed Brown #define CEED_VERSION_MAJOR 0
1388ec64e9aSJed Brown #define CEED_VERSION_MINOR 11
1398ec64e9aSJed Brown #define CEED_VERSION_PATCH 0
140d5780308SJeremy L Thompson #define CEED_VERSION_RELEASE false
141ec3da8bcSJed Brown 
142ea61e9acSJeremy L Thompson /// Compile-time check that the the current library version is at least as recent as the specified version.
143ea61e9acSJeremy L Thompson /// This macro is typically used in
144ec3da8bcSJed Brown /// @code
145ec3da8bcSJed Brown /// #if CEED_VERSION_GE(0, 8, 0)
146ec3da8bcSJed Brown ///   code path that needs at least 0.8.0
147ec3da8bcSJed Brown /// #else
148ec3da8bcSJed Brown ///   fallback code for older versions
149ec3da8bcSJed Brown /// #endif
150ec3da8bcSJed Brown /// @endcode
151ec3da8bcSJed Brown ///
152ec3da8bcSJed Brown /// A non-release version always compares as positive infinity.
153ec3da8bcSJed Brown ///
154ec3da8bcSJed Brown /// @param major   Major version
155ec3da8bcSJed Brown /// @param minor   Minor version
156ec3da8bcSJed Brown /// @param patch   Patch (subminor) version
157ec3da8bcSJed Brown ///
158ec3da8bcSJed Brown /// @ingroup Ceed
159ec3da8bcSJed Brown /// @sa CeedGetVersion()
160ec3da8bcSJed Brown #define CEED_VERSION_GE(major, minor, patch) \
161ec3da8bcSJed Brown   (!CEED_VERSION_RELEASE ||                  \
162ec3da8bcSJed Brown    (CEED_VERSION_MAJOR > major ||            \
1632b730f8bSJeremy L Thompson     (CEED_VERSION_MAJOR == major && (CEED_VERSION_MINOR > minor || (CEED_VERSION_MINOR == minor && CEED_VERSION_PATCH >= patch)))))
164ec3da8bcSJed Brown 
1652b730f8bSJeremy L Thompson CEED_EXTERN int CeedGetVersion(int *major, int *minor, int *patch, bool *release);
166ec3da8bcSJed Brown 
16780a9ef05SNatalie Beams CEED_EXTERN int CeedGetScalarType(CeedScalarType *scalar_type);
16880a9ef05SNatalie Beams 
1699bd0a4deSJeremy L Thompson /// String names for enum pretty printing
170ec3da8bcSJed Brown CEED_EXTERN const char *const *CeedErrorTypes;
171ec3da8bcSJed Brown CEED_EXTERN const char *const  CeedMemTypes[];
1729bd0a4deSJeremy L Thompson CEED_EXTERN const char *const  CeedCopyModes[];
1739bd0a4deSJeremy L Thompson CEED_EXTERN const char *const  CeedTransposeModes[];
1749bd0a4deSJeremy L Thompson CEED_EXTERN const char *const  CeedEvalModes[];
1759bd0a4deSJeremy L Thompson CEED_EXTERN const char *const  CeedQuadModes[];
1769bd0a4deSJeremy L Thompson CEED_EXTERN const char *const  CeedElemTopologies[];
1779bd0a4deSJeremy L Thompson CEED_EXTERN const char *const  CeedContextFieldTypes[];
178ec3da8bcSJed Brown 
179ec3da8bcSJed Brown CEED_EXTERN int CeedGetPreferredMemType(Ceed ceed, CeedMemType *type);
180ec3da8bcSJed Brown 
1811f9221feSJeremy L Thompson CEED_EXTERN int CeedVectorCreate(Ceed ceed, CeedSize len, CeedVector *vec);
1829560d06aSjeremylt CEED_EXTERN int CeedVectorReferenceCopy(CeedVector vec, CeedVector *vec_copy);
1835fb68f37SKaren (Ren) Stengel CEED_EXTERN int CeedVectorCopy(CeedVector vec, CeedVector vec_copy);
1842b730f8bSJeremy L Thompson CEED_EXTERN int CeedVectorSetArray(CeedVector vec, CeedMemType mem_type, CeedCopyMode copy_mode, CeedScalar *array);
185ec3da8bcSJed Brown CEED_EXTERN int CeedVectorSetValue(CeedVector vec, CeedScalar value);
186d1d35e2fSjeremylt CEED_EXTERN int CeedVectorSyncArray(CeedVector vec, CeedMemType mem_type);
1872b730f8bSJeremy L Thompson CEED_EXTERN int CeedVectorTakeArray(CeedVector vec, CeedMemType mem_type, CeedScalar **array);
1882b730f8bSJeremy L Thompson CEED_EXTERN int CeedVectorGetArray(CeedVector vec, CeedMemType mem_type, CeedScalar **array);
1892b730f8bSJeremy L Thompson CEED_EXTERN int CeedVectorGetArrayRead(CeedVector vec, CeedMemType mem_type, const CeedScalar **array);
1902b730f8bSJeremy L Thompson CEED_EXTERN int CeedVectorGetArrayWrite(CeedVector vec, CeedMemType mem_type, CeedScalar **array);
191ec3da8bcSJed Brown CEED_EXTERN int CeedVectorRestoreArray(CeedVector vec, CeedScalar **array);
1922b730f8bSJeremy L Thompson CEED_EXTERN int CeedVectorRestoreArrayRead(CeedVector vec, const CeedScalar **array);
1932b730f8bSJeremy L Thompson CEED_EXTERN int CeedVectorNorm(CeedVector vec, CeedNormType type, CeedScalar *norm);
194e0dd3b27Sjeremylt CEED_EXTERN int CeedVectorScale(CeedVector x, CeedScalar alpha);
1950f7fd0f8Sjeremylt CEED_EXTERN int CeedVectorAXPY(CeedVector y, CeedScalar alpha, CeedVector x);
1965fb68f37SKaren (Ren) Stengel CEED_EXTERN int CeedVectorAXPBY(CeedVector y, CeedScalar alpha, CeedScalar beta, CeedVector x);
1970f7fd0f8Sjeremylt CEED_EXTERN int CeedVectorPointwiseMult(CeedVector w, CeedVector x, CeedVector y);
198ec3da8bcSJed Brown CEED_EXTERN int CeedVectorReciprocal(CeedVector vec);
199acb2c48cSJeremy L Thompson CEED_EXTERN int CeedVectorViewRange(CeedVector vec, CeedSize start, CeedSize stop, CeedInt step, const char *fp_fmt, FILE *stream);
200d1d35e2fSjeremylt CEED_EXTERN int CeedVectorView(CeedVector vec, const char *fp_fmt, FILE *stream);
201b7c9bbdaSJeremy L Thompson CEED_EXTERN int CeedVectorGetCeed(CeedVector vec, Ceed *ceed);
2021f9221feSJeremy L Thompson CEED_EXTERN int CeedVectorGetLength(CeedVector vec, CeedSize *length);
203ec3da8bcSJed Brown CEED_EXTERN int CeedVectorDestroy(CeedVector *vec);
204ec3da8bcSJed Brown 
205ec3da8bcSJed Brown CEED_EXTERN CeedRequest *const CEED_REQUEST_IMMEDIATE;
206ec3da8bcSJed Brown CEED_EXTERN CeedRequest *const CEED_REQUEST_ORDERED;
207ec3da8bcSJed Brown CEED_EXTERN int                CeedRequestWait(CeedRequest *req);
208ec3da8bcSJed Brown 
209ea61e9acSJeremy L Thompson /// Argument for CeedOperatorSetField that vector is collocated with quadrature points, only used with CeedEvalMode CEED_EVAL_NONE
210ec3da8bcSJed Brown /// @ingroup CeedBasis
211ec3da8bcSJed Brown CEED_EXTERN const CeedBasis CEED_BASIS_COLLOCATED;
212ec3da8bcSJed Brown 
213ec3da8bcSJed Brown /// Argument for CeedOperatorSetField to use active input or output
214ec3da8bcSJed Brown /// @ingroup CeedVector
215ec3da8bcSJed Brown CEED_EXTERN const CeedVector CEED_VECTOR_ACTIVE;
216ec3da8bcSJed Brown 
217ea61e9acSJeremy L Thompson /// Argument for CeedOperatorSetField to use no vector, used with QFunction input with eval mode CEED_EVAL_WEIGHT
218ec3da8bcSJed Brown /// @ingroup CeedVector
219ec3da8bcSJed Brown CEED_EXTERN const CeedVector CEED_VECTOR_NONE;
220ec3da8bcSJed Brown 
221ea61e9acSJeremy L Thompson /// Argument for CeedOperatorSetField to use no ElemRestriction, only used with eval mode CEED_EVAL_WEIGHT.
222ec3da8bcSJed Brown /// @ingroup CeedElemRestriction
223ec3da8bcSJed Brown CEED_EXTERN const CeedElemRestriction CEED_ELEMRESTRICTION_NONE;
224ec3da8bcSJed Brown 
225ec3da8bcSJed Brown /// Argument for CeedOperatorCreate that QFunction is not created by user.
226ea61e9acSJeremy L Thompson /// Only used for QFunctions dqf and dqfT.
227ea61e9acSJeremy L Thompson /// If implemented, a backend may attempt to provide the action of these QFunctions.
228ec3da8bcSJed Brown /// @ingroup CeedQFunction
229ec3da8bcSJed Brown CEED_EXTERN const CeedQFunction CEED_QFUNCTION_NONE;
230ec3da8bcSJed Brown 
231ea61e9acSJeremy L Thompson /// Argument for CeedElemRestrictionCreateStrided that L-vector is in the Ceed backend's preferred layout.
232ea61e9acSJeremy L Thompson /// This argument should only be used with vectors created by a Ceed backend.
233ec3da8bcSJed Brown /// @ingroup CeedElemRestriction
234ec3da8bcSJed Brown CEED_EXTERN const CeedInt CEED_STRIDES_BACKEND[3];
235ec3da8bcSJed Brown 
2362b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionCreate(Ceed ceed, CeedInt num_elem, CeedInt elem_size, CeedInt num_comp, CeedInt comp_stride, CeedSize l_size,
2372b730f8bSJeremy L Thompson                                           CeedMemType mem_type, CeedCopyMode copy_mode, const CeedInt *offsets, CeedElemRestriction *rstr);
2382b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionCreateOriented(Ceed ceed, CeedInt num_elem, CeedInt elem_size, CeedInt num_comp, CeedInt comp_stride,
2392b730f8bSJeremy L Thompson                                                   CeedSize l_size, CeedMemType mem_type, CeedCopyMode copy_mode, const CeedInt *offsets,
240fc0567d9Srezgarshakeri                                                   const bool *orient, CeedElemRestriction *rstr);
2412b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionCreateStrided(Ceed ceed, CeedInt num_elem, CeedInt elem_size, CeedInt num_comp, CeedSize l_size,
242ec3da8bcSJed Brown                                                  const CeedInt strides[3], CeedElemRestriction *rstr);
2432b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionCreateBlocked(Ceed ceed, CeedInt num_elem, CeedInt elem_size, CeedInt blk_size, CeedInt num_comp,
2442b730f8bSJeremy L Thompson                                                  CeedInt comp_stride, CeedSize l_size, CeedMemType mem_type, CeedCopyMode copy_mode,
245ec3da8bcSJed Brown                                                  const CeedInt *offsets, CeedElemRestriction *rstr);
2462b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionCreateBlockedStrided(Ceed ceed, CeedInt num_elem, CeedInt elem_size, CeedInt blk_size, CeedInt num_comp,
247e79b91d9SJeremy L Thompson                                                         CeedSize l_size, const CeedInt strides[3], CeedElemRestriction *rstr);
2482b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionReferenceCopy(CeedElemRestriction rstr, CeedElemRestriction *rstr_copy);
2492b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionCreateVector(CeedElemRestriction rstr, CeedVector *lvec, CeedVector *evec);
2502b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionApply(CeedElemRestriction rstr, CeedTransposeMode t_mode, CeedVector u, CeedVector ru, CeedRequest *request);
2512b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionApplyBlock(CeedElemRestriction rstr, CeedInt block, CeedTransposeMode t_mode, CeedVector u, CeedVector ru,
252ec3da8bcSJed Brown                                               CeedRequest *request);
2532b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetCeed(CeedElemRestriction rstr, Ceed *ceed);
2542b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetCompStride(CeedElemRestriction rstr, CeedInt *comp_stride);
2552b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetNumElements(CeedElemRestriction rstr, CeedInt *num_elem);
2562b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetElementSize(CeedElemRestriction rstr, CeedInt *elem_size);
2572b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetLVectorSize(CeedElemRestriction rstr, CeedSize *l_size);
2582b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetNumComponents(CeedElemRestriction rstr, CeedInt *num_comp);
2592b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetNumBlocks(CeedElemRestriction rstr, CeedInt *num_blk);
2602b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetBlockSize(CeedElemRestriction rstr, CeedInt *blk_size);
2612b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetMultiplicity(CeedElemRestriction rstr, CeedVector mult);
262ec3da8bcSJed Brown CEED_EXTERN int CeedElemRestrictionView(CeedElemRestriction rstr, FILE *stream);
263ec3da8bcSJed Brown CEED_EXTERN int CeedElemRestrictionDestroy(CeedElemRestriction *rstr);
264ec3da8bcSJed Brown 
265ec3da8bcSJed Brown // The formalism here is that we have the structure
266ec3da8bcSJed Brown //  \int_\Omega v^T f_0(u, \nabla u, qdata) + (\nabla v)^T f_1(u, \nabla u, qdata)
267ec3da8bcSJed Brown // where gradients are with respect to the reference element.
268ec3da8bcSJed Brown 
2692b730f8bSJeremy L Thompson CEED_EXTERN int CeedBasisCreateTensorH1Lagrange(Ceed ceed, CeedInt dim, CeedInt num_comp, CeedInt P, CeedInt Q, CeedQuadMode quad_mode,
270ec3da8bcSJed Brown                                                 CeedBasis *basis);
2712b730f8bSJeremy L Thompson CEED_EXTERN int CeedBasisCreateTensorH1(Ceed ceed, CeedInt dim, CeedInt num_comp, CeedInt P_1d, CeedInt Q_1d, const CeedScalar *interp_1d,
2722b730f8bSJeremy L Thompson                                         const CeedScalar *grad_1d, const CeedScalar *q_ref_1d, const CeedScalar *q_weight_1d, CeedBasis *basis);
2732b730f8bSJeremy L Thompson CEED_EXTERN int CeedBasisCreateH1(Ceed ceed, CeedElemTopology topo, CeedInt num_comp, CeedInt num_nodes, CeedInt nqpts, const CeedScalar *interp,
2742b730f8bSJeremy L Thompson                                   const CeedScalar *grad, const CeedScalar *q_ref, const CeedScalar *q_weights, CeedBasis *basis);
2752b730f8bSJeremy L Thompson CEED_EXTERN int CeedBasisCreateHdiv(Ceed ceed, CeedElemTopology topo, CeedInt num_comp, CeedInt num_nodes, CeedInt nqpts, const CeedScalar *interp,
2762b730f8bSJeremy L Thompson                                     const CeedScalar *div, const CeedScalar *q_ref, const CeedScalar *q_weights, CeedBasis *basis);
277*c4e3f59bSSebastian Grimberg CEED_EXTERN int CeedBasisCreateHcurl(Ceed ceed, CeedElemTopology topo, CeedInt num_comp, CeedInt num_nodes, CeedInt nqpts, const CeedScalar *interp,
278*c4e3f59bSSebastian Grimberg                                      const CeedScalar *curl, const CeedScalar *q_ref, const CeedScalar *q_weights, CeedBasis *basis);
279446e7af4SJeremy L Thompson CEED_EXTERN int CeedBasisCreateProjection(CeedBasis basis_from, CeedBasis basis_to, CeedBasis *basis_project);
2809560d06aSjeremylt CEED_EXTERN int CeedBasisReferenceCopy(CeedBasis basis, CeedBasis *basis_copy);
281ec3da8bcSJed Brown CEED_EXTERN int CeedBasisView(CeedBasis basis, FILE *stream);
2822b730f8bSJeremy L Thompson CEED_EXTERN int CeedBasisApply(CeedBasis basis, CeedInt num_elem, CeedTransposeMode t_mode, CeedEvalMode eval_mode, CeedVector u, CeedVector v);
283b7c9bbdaSJeremy L Thompson CEED_EXTERN int CeedBasisGetCeed(CeedBasis basis, Ceed *ceed);
284ec3da8bcSJed Brown CEED_EXTERN int CeedBasisGetDimension(CeedBasis basis, CeedInt *dim);
285ec3da8bcSJed Brown CEED_EXTERN int CeedBasisGetTopology(CeedBasis basis, CeedElemTopology *topo);
286d1d35e2fSjeremylt CEED_EXTERN int CeedBasisGetNumComponents(CeedBasis basis, CeedInt *num_comp);
287ec3da8bcSJed Brown CEED_EXTERN int CeedBasisGetNumNodes(CeedBasis basis, CeedInt *P);
288d1d35e2fSjeremylt CEED_EXTERN int CeedBasisGetNumNodes1D(CeedBasis basis, CeedInt *P_1d);
289ec3da8bcSJed Brown CEED_EXTERN int CeedBasisGetNumQuadraturePoints(CeedBasis basis, CeedInt *Q);
2902b730f8bSJeremy L Thompson CEED_EXTERN int CeedBasisGetNumQuadraturePoints1D(CeedBasis basis, CeedInt *Q_1d);
291d1d35e2fSjeremylt CEED_EXTERN int CeedBasisGetQRef(CeedBasis basis, const CeedScalar **q_ref);
2922b730f8bSJeremy L Thompson CEED_EXTERN int CeedBasisGetQWeights(CeedBasis basis, const CeedScalar **q_weights);
293ec3da8bcSJed Brown CEED_EXTERN int CeedBasisGetInterp(CeedBasis basis, const CeedScalar **interp);
2942b730f8bSJeremy L Thompson CEED_EXTERN int CeedBasisGetInterp1D(CeedBasis basis, const CeedScalar **interp_1d);
295ec3da8bcSJed Brown CEED_EXTERN int CeedBasisGetGrad(CeedBasis basis, const CeedScalar **grad);
296d1d35e2fSjeremylt CEED_EXTERN int CeedBasisGetGrad1D(CeedBasis basis, const CeedScalar **grad_1d);
29750c301a5SRezgar Shakeri CEED_EXTERN int CeedBasisGetDiv(CeedBasis basis, const CeedScalar **div);
298*c4e3f59bSSebastian Grimberg CEED_EXTERN int CeedBasisGetCurl(CeedBasis basis, const CeedScalar **curl);
299ec3da8bcSJed Brown CEED_EXTERN int CeedBasisDestroy(CeedBasis *basis);
300ec3da8bcSJed Brown 
3012b730f8bSJeremy L Thompson CEED_EXTERN int CeedGaussQuadrature(CeedInt Q, CeedScalar *q_ref_1d, CeedScalar *q_weight_1d);
3022b730f8bSJeremy L Thompson CEED_EXTERN int CeedLobattoQuadrature(CeedInt Q, CeedScalar *q_ref_1d, CeedScalar *q_weight_1d);
303ec3da8bcSJed Brown 
304cdf32b93SJeremy L Thompson /** Handle for the user provided CeedQFunction callback function
305ec3da8bcSJed Brown 
306cdf32b93SJeremy L Thompson  @param[in,out] ctx  User-defined context set using CeedQFunctionSetContext() or NULL
307cdf32b93SJeremy L Thompson  @param[in] Q        Number of quadrature points at which to evaluate
308ea61e9acSJeremy L Thompson  @param[in] in       Array of pointers to each input argument in the order provided by the user in CeedQFunctionAddInput().
309ea61e9acSJeremy L Thompson                        Each array has shape `[dim, num_comp, Q]` where `dim` is the geometric dimension for \ref CEED_EVAL_GRAD (`dim=1` for \ref
310ea61e9acSJeremy L Thompson CEED_EVAL_INTERP) and `num_comp` is the number of field components (`num_comp=1` for scalar fields). This results in indexing the `i`th input at
311d1d35e2fSjeremylt quadrature point `j` as `in[i][(d*num_comp + c)*Q + j]`.
312ea61e9acSJeremy L Thompson  @param[out]   out   Array of pointers to each output array in the order provided using CeedQFunctionAddOutput().
313ea61e9acSJeremy L Thompson                        The shapes are as above for \a in.
314ec3da8bcSJed Brown 
315ec3da8bcSJed Brown  @return An error code: 0 - success, otherwise - failure
316ec3da8bcSJed Brown 
317ec3da8bcSJed Brown  @ingroup CeedQFunction
318ec3da8bcSJed Brown **/
3192b730f8bSJeremy L Thompson typedef int (*CeedQFunctionUser)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out);
320ec3da8bcSJed Brown 
3212b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionCreateInterior(Ceed ceed, CeedInt vec_length, CeedQFunctionUser f, const char *source, CeedQFunction *qf);
3222b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionCreateInteriorByName(Ceed ceed, const char *name, CeedQFunction *qf);
3232b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionCreateIdentity(Ceed ceed, CeedInt size, CeedEvalMode in_mode, CeedEvalMode out_mode, CeedQFunction *qf);
3249560d06aSjeremylt CEED_EXTERN int CeedQFunctionReferenceCopy(CeedQFunction qf, CeedQFunction *qf_copy);
3252b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionAddInput(CeedQFunction qf, const char *field_name, CeedInt size, CeedEvalMode eval_mode);
3262b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionAddOutput(CeedQFunction qf, const char *field_name, CeedInt size, CeedEvalMode eval_mode);
3272b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionGetFields(CeedQFunction qf, CeedInt *num_input_fields, CeedQFunctionField **input_fields, CeedInt *num_output_fields,
32843bbe138SJeremy L Thompson                                        CeedQFunctionField **output_fields);
3292b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionSetContext(CeedQFunction qf, CeedQFunctionContext ctx);
330441428dfSJeremy L Thompson CEED_EXTERN int CeedQFunctionSetContextWritable(CeedQFunction qf, bool is_writable);
3319d36ca50SJeremy L Thompson CEED_EXTERN int CeedQFunctionSetUserFlopsEstimate(CeedQFunction qf, CeedSize flops);
332ec3da8bcSJed Brown CEED_EXTERN int CeedQFunctionView(CeedQFunction qf, FILE *stream);
333b7c9bbdaSJeremy L Thompson CEED_EXTERN int CeedQFunctionGetCeed(CeedQFunction qf, Ceed *ceed);
3342b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionApply(CeedQFunction qf, CeedInt Q, CeedVector *u, CeedVector *v);
335ec3da8bcSJed Brown CEED_EXTERN int CeedQFunctionDestroy(CeedQFunction *qf);
336ec3da8bcSJed Brown 
3372b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionFieldGetName(CeedQFunctionField qf_field, char **field_name);
3382b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionFieldGetSize(CeedQFunctionField qf_field, CeedInt *size);
3392b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionFieldGetEvalMode(CeedQFunctionField qf_field, CeedEvalMode *eval_mode);
34043bbe138SJeremy L Thompson 
3412790b72bSJeremy L Thompson /** Handle for the user provided CeedQFunctionContextDataDestroy callback function
3422790b72bSJeremy L Thompson 
3432790b72bSJeremy L Thompson  @param[in,out] data  User-CeedQFunctionContext data
3442790b72bSJeremy L Thompson 
3452790b72bSJeremy L Thompson  @return An error code: 0 - success, otherwise - failure
3462790b72bSJeremy L Thompson 
3472790b72bSJeremy L Thompson  @ingroup CeedQFunction
3482790b72bSJeremy L Thompson **/
3492790b72bSJeremy L Thompson typedef int (*CeedQFunctionContextDataDestroyUser)(void *data);
3502790b72bSJeremy L Thompson 
3512b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextCreate(Ceed ceed, CeedQFunctionContext *ctx);
3522b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextReferenceCopy(CeedQFunctionContext ctx, CeedQFunctionContext *ctx_copy);
3532b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextSetData(CeedQFunctionContext ctx, CeedMemType mem_type, CeedCopyMode copy_mode, size_t size, void *data);
3542b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextTakeData(CeedQFunctionContext ctx, CeedMemType mem_type, void *data);
3552b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextGetData(CeedQFunctionContext ctx, CeedMemType mem_type, void *data);
3562b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextGetDataRead(CeedQFunctionContext ctx, CeedMemType mem_type, void *data);
3572b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextRestoreData(CeedQFunctionContext ctx, void *data);
3582b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextRestoreDataRead(CeedQFunctionContext ctx, void *data);
3592b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextRegisterDouble(CeedQFunctionContext ctx, const char *field_name, size_t field_offset, size_t num_values,
3607bfe0f0eSJeremy L Thompson                                                    const char *field_description);
3612b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextRegisterInt32(CeedQFunctionContext ctx, const char *field_name, size_t field_offset, size_t num_values,
3627bfe0f0eSJeremy L Thompson                                                   const char *field_description);
3632b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextGetAllFieldLabels(CeedQFunctionContext ctx, const CeedContextFieldLabel **field_labels, CeedInt *num_fields);
3642b730f8bSJeremy L Thompson CEED_EXTERN int CeedContextFieldLabelGetDescription(CeedContextFieldLabel label, const char **field_name, const char **field_description,
3652b730f8bSJeremy L Thompson                                                     size_t *num_values, CeedContextFieldType *field_type);
3662b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextGetContextSize(CeedQFunctionContext ctx, size_t *ctx_size);
3672b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextView(CeedQFunctionContext ctx, FILE *stream);
3682b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextSetDataDestroy(CeedQFunctionContext ctx, CeedMemType f_mem_type, CeedQFunctionContextDataDestroyUser f);
369ec3da8bcSJed Brown CEED_EXTERN int CeedQFunctionContextDestroy(CeedQFunctionContext *ctx);
370ec3da8bcSJed Brown 
3712b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorCreate(Ceed ceed, CeedQFunction qf, CeedQFunction dqf, CeedQFunction dqfT, CeedOperator *op);
372ec3da8bcSJed Brown CEED_EXTERN int CeedCompositeOperatorCreate(Ceed ceed, CeedOperator *op);
3739560d06aSjeremylt CEED_EXTERN int CeedOperatorReferenceCopy(CeedOperator op, CeedOperator *op_copy);
3742b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorSetField(CeedOperator op, const char *field_name, CeedElemRestriction r, CeedBasis b, CeedVector v);
3752b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorGetFields(CeedOperator op, CeedInt *num_input_fields, CeedOperatorField **input_fields, CeedInt *num_output_fields,
37643bbe138SJeremy L Thompson                                       CeedOperatorField **output_fields);
3772b730f8bSJeremy L Thompson CEED_EXTERN int CeedCompositeOperatorAddSub(CeedOperator composite_op, CeedOperator sub_op);
378c6ebc35dSJeremy L Thompson CEED_EXTERN int CeedCompositeOperatorGetNumSub(CeedOperator op, CeedInt *num_suboperators);
379c6ebc35dSJeremy L Thompson CEED_EXTERN int CeedCompositeOperatorGetSubList(CeedOperator op, CeedOperator **sub_operators);
3804db537f9SJeremy L Thompson CEED_EXTERN int CeedOperatorCheckReady(CeedOperator op);
381c9366a6bSJeremy L Thompson CEED_EXTERN int CeedOperatorGetActiveVectorLengths(CeedOperator op, CeedSize *input_size, CeedSize *output_size);
382beecbf24SJeremy L Thompson CEED_EXTERN int CeedOperatorSetQFunctionAssemblyReuse(CeedOperator op, bool reuse_assembly_data);
383beecbf24SJeremy L Thompson CEED_EXTERN int CeedOperatorSetQFunctionAssemblyDataUpdateNeeded(CeedOperator op, bool needs_data_update);
3842b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorLinearAssembleQFunction(CeedOperator op, CeedVector *assembled, CeedElemRestriction *rstr, CeedRequest *request);
3852b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorLinearAssembleQFunctionBuildOrUpdate(CeedOperator op, CeedVector *assembled, CeedElemRestriction *rstr,
3862b730f8bSJeremy L Thompson                                                                  CeedRequest *request);
3872b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorLinearAssembleDiagonal(CeedOperator op, CeedVector assembled, CeedRequest *request);
3882b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorLinearAssembleAddDiagonal(CeedOperator op, CeedVector assembled, CeedRequest *request);
3892b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorLinearAssemblePointBlockDiagonal(CeedOperator op, CeedVector assembled, CeedRequest *request);
3902b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorLinearAssembleAddPointBlockDiagonal(CeedOperator op, CeedVector assembled, CeedRequest *request);
3912b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorLinearAssembleSymbolic(CeedOperator op, CeedSize *num_entries, CeedInt **rows, CeedInt **cols);
392ec3da8bcSJed Brown CEED_EXTERN int CeedOperatorLinearAssemble(CeedOperator op, CeedVector values);
39375f0d5a4SJeremy L Thompson CEED_EXTERN int CeedCompositeOperatorGetMultiplicity(CeedOperator op, CeedInt num_skip_indices, CeedInt *skip_indices, CeedVector mult);
3942b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorMultigridLevelCreate(CeedOperator op_fine, CeedVector p_mult_fine, CeedElemRestriction rstr_coarse,
3952b730f8bSJeremy L Thompson                                                  CeedBasis basis_coarse, CeedOperator *op_coarse, CeedOperator *op_prolong,
3962b730f8bSJeremy L Thompson                                                  CeedOperator *op_restrict);
3972b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorMultigridLevelCreateTensorH1(CeedOperator op_fine, CeedVector p_mult_fine, CeedElemRestriction rstr_coarse,
398d1d35e2fSjeremylt                                                          CeedBasis basis_coarse, const CeedScalar *interp_c_to_f, CeedOperator *op_coarse,
399d1d35e2fSjeremylt                                                          CeedOperator *op_prolong, CeedOperator *op_restrict);
4002b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorMultigridLevelCreateH1(CeedOperator op_fine, CeedVector p_mult_fine, CeedElemRestriction rstr_coarse,
4012b730f8bSJeremy L Thompson                                                    CeedBasis basis_coarse, const CeedScalar *interp_c_to_f, CeedOperator *op_coarse,
402d1d35e2fSjeremylt                                                    CeedOperator *op_prolong, CeedOperator *op_restrict);
4032b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorCreateFDMElementInverse(CeedOperator op, CeedOperator *fdm_inv, CeedRequest *request);
404cd4dfc48Sjeremylt CEED_EXTERN int CeedOperatorSetNumQuadraturePoints(CeedOperator op, CeedInt num_qpts);
405ea6b5821SJeremy L Thompson CEED_EXTERN int CeedOperatorSetName(CeedOperator op, const char *name);
406ec3da8bcSJed Brown CEED_EXTERN int CeedOperatorView(CeedOperator op, FILE *stream);
407b7c9bbdaSJeremy L Thompson CEED_EXTERN int CeedOperatorGetCeed(CeedOperator op, Ceed *ceed);
408b7c9bbdaSJeremy L Thompson CEED_EXTERN int CeedOperatorGetNumElements(CeedOperator op, CeedInt *num_elem);
4092b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorGetNumQuadraturePoints(CeedOperator op, CeedInt *num_qpts);
4109d36ca50SJeremy L Thompson CEED_EXTERN int CeedOperatorGetFlopsEstimate(CeedOperator op, CeedSize *flops);
4110126412dSJeremy L Thompson CEED_EXTERN int CeedOperatorGetContext(CeedOperator op, CeedQFunctionContext *ctx);
41217b0d5c6SJeremy L Thompson CEED_EXTERN int CeedOperatorGetContextFieldLabel(CeedOperator op, const char *field_name, CeedContextFieldLabel *field_label);
41317b0d5c6SJeremy L Thompson CEED_EXTERN int CeedOperatorSetContextDouble(CeedOperator op, CeedContextFieldLabel field_label, double *values);
41417b0d5c6SJeremy L Thompson CEED_EXTERN int CeedOperatorGetContextDoubleRead(CeedOperator op, CeedContextFieldLabel field_label, size_t *num_values, const double **values);
41517b0d5c6SJeremy L Thompson CEED_EXTERN int CeedOperatorRestoreContextDoubleRead(CeedOperator op, CeedContextFieldLabel field_label, const double **values);
41617b0d5c6SJeremy L Thompson CEED_EXTERN int CeedOperatorSetContextInt32(CeedOperator op, CeedContextFieldLabel field_label, int *values);
41717b0d5c6SJeremy L Thompson CEED_EXTERN int CeedOperatorGetContextInt32Read(CeedOperator op, CeedContextFieldLabel field_label, size_t *num_values, const int **values);
41817b0d5c6SJeremy L Thompson CEED_EXTERN int CeedOperatorRestoreContextInt32Read(CeedOperator op, CeedContextFieldLabel field_label, const int **values);
4192b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorApply(CeedOperator op, CeedVector in, CeedVector out, CeedRequest *request);
4202b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorApplyAdd(CeedOperator op, CeedVector in, CeedVector out, CeedRequest *request);
421ec3da8bcSJed Brown CEED_EXTERN int CeedOperatorDestroy(CeedOperator *op);
422ec3da8bcSJed Brown 
423de5900adSJames Wright CEED_EXTERN int CeedOperatorGetFieldByName(CeedOperator op, const char *field_name, CeedOperatorField *op_field);
4242b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorFieldGetName(CeedOperatorField op_field, char **field_name);
4252b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorFieldGetElemRestriction(CeedOperatorField op_field, CeedElemRestriction *rstr);
4262b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorFieldGetBasis(CeedOperatorField op_field, CeedBasis *basis);
4272b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorFieldGetVector(CeedOperatorField op_field, CeedVector *vec);
42843bbe138SJeremy L Thompson 
429ec3da8bcSJed Brown /**
430ec3da8bcSJed Brown   @brief Return integer power
431ec3da8bcSJed Brown 
432ec3da8bcSJed Brown   @param[in] base  The base to exponentiate
433ec3da8bcSJed Brown   @param[in] power The power to raise the base to
434ec3da8bcSJed Brown 
435ec3da8bcSJed Brown   @return base^power
436ec3da8bcSJed Brown 
437ec3da8bcSJed Brown   @ref Utility
438ec3da8bcSJed Brown **/
439ec3da8bcSJed Brown static inline CeedInt CeedIntPow(CeedInt base, CeedInt power) {
440ec3da8bcSJed Brown   CeedInt result = 1;
441ec3da8bcSJed Brown   while (power) {
442ec3da8bcSJed Brown     if (power & 1) result *= base;
443ec3da8bcSJed Brown     power >>= 1;
444ec3da8bcSJed Brown     base *= base;
445ec3da8bcSJed Brown   }
446ec3da8bcSJed Brown   return result;
447ec3da8bcSJed Brown }
448ec3da8bcSJed Brown 
449ec3da8bcSJed Brown /**
450ec3da8bcSJed Brown   @brief Return minimum of two integers
451ec3da8bcSJed Brown 
452ec3da8bcSJed Brown   @param[in] a The first integer to compare
453ec3da8bcSJed Brown   @param[in] b The second integer to compare
454ec3da8bcSJed Brown 
455ec3da8bcSJed Brown   @return The minimum of the two integers
456ec3da8bcSJed Brown 
457ec3da8bcSJed Brown   @ref Utility
458ec3da8bcSJed Brown **/
459ec3da8bcSJed Brown static inline CeedInt CeedIntMin(CeedInt a, CeedInt b) { return a < b ? a : b; }
460ec3da8bcSJed Brown 
461ec3da8bcSJed Brown /**
462ec3da8bcSJed Brown   @brief Return maximum of two integers
463ec3da8bcSJed Brown 
464ec3da8bcSJed Brown   @param[in] a The first integer to compare
465ec3da8bcSJed Brown   @param[in] b The second integer to compare
466ec3da8bcSJed Brown 
467ec3da8bcSJed Brown   @return The maximum of the two integers
468ec3da8bcSJed Brown 
469ec3da8bcSJed Brown   @ref Utility
470ec3da8bcSJed Brown **/
471ec3da8bcSJed Brown static inline CeedInt CeedIntMax(CeedInt a, CeedInt b) { return a > b ? a : b; }
472ec3da8bcSJed Brown 
473ec3da8bcSJed Brown // Used to ensure initialization before CeedInit()
474ec3da8bcSJed Brown CEED_EXTERN int CeedRegisterAll(void);
475ec3da8bcSJed Brown // Used to ensure initialization before CeedQFunctionCreate*()
476ec3da8bcSJed Brown CEED_EXTERN int CeedQFunctionRegisterAll(void);
477ec3da8bcSJed Brown 
478ec3da8bcSJed Brown #endif
479