xref: /libCEED/rust/libceed-sys/c-src/include/ceed/ceed.h (revision c17ec2be5925899f8dbadb36e34e9a5bd9f00203)
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()
1182b730f8bSJeremy L Thompson #define CeedError(ceed, ecode, ...) (CeedErrorImpl((ceed), __FILE__, __LINE__, __func__, (ecode), __VA_ARGS__), (ecode))
119ec3da8bcSJed Brown 
120ec3da8bcSJed Brown /// Ceed error handlers
1212b730f8bSJeremy L Thompson CEED_EXTERN int CeedErrorReturn(Ceed, const char *, int, const char *, int, const char *, va_list *);
1222b730f8bSJeremy L Thompson CEED_EXTERN int CeedErrorStore(Ceed, const char *, int, const char *, int, const char *, va_list *);
1232b730f8bSJeremy L Thompson CEED_EXTERN int CeedErrorAbort(Ceed, const char *, int, const char *, int, const char *, va_list *);
1242b730f8bSJeremy L Thompson CEED_EXTERN int CeedErrorExit(Ceed, const char *, int, const char *, int, const char *, va_list *);
1252b730f8bSJeremy L Thompson typedef int (*CeedErrorHandler)(Ceed, const char *, int, const char *, int, const char *, va_list *);
126ec3da8bcSJed Brown CEED_EXTERN int CeedSetErrorHandler(Ceed ceed, CeedErrorHandler eh);
127d1d35e2fSjeremylt CEED_EXTERN int CeedGetErrorMessage(Ceed, const char **err_msg);
128d1d35e2fSjeremylt CEED_EXTERN int CeedResetErrorMessage(Ceed, const char **err_msg);
129ec3da8bcSJed Brown 
130ec3da8bcSJed Brown /// libCEED library version numbering
131ec3da8bcSJed Brown /// @ingroup Ceed
132ec3da8bcSJed Brown #define CEED_VERSION_MAJOR 0
1338ec64e9aSJed Brown #define CEED_VERSION_MINOR 11
1348ec64e9aSJed Brown #define CEED_VERSION_PATCH 0
135d5780308SJeremy L Thompson #define CEED_VERSION_RELEASE false
136ec3da8bcSJed Brown 
137ea61e9acSJeremy L Thompson /// Compile-time check that the the current library version is at least as recent as the specified version.
138ea61e9acSJeremy L Thompson /// This macro is typically used in
139ec3da8bcSJed Brown /// @code
140ec3da8bcSJed Brown /// #if CEED_VERSION_GE(0, 8, 0)
141ec3da8bcSJed Brown ///   code path that needs at least 0.8.0
142ec3da8bcSJed Brown /// #else
143ec3da8bcSJed Brown ///   fallback code for older versions
144ec3da8bcSJed Brown /// #endif
145ec3da8bcSJed Brown /// @endcode
146ec3da8bcSJed Brown ///
147ec3da8bcSJed Brown /// A non-release version always compares as positive infinity.
148ec3da8bcSJed Brown ///
149ec3da8bcSJed Brown /// @param major   Major version
150ec3da8bcSJed Brown /// @param minor   Minor version
151ec3da8bcSJed Brown /// @param patch   Patch (subminor) version
152ec3da8bcSJed Brown ///
153ec3da8bcSJed Brown /// @ingroup Ceed
154ec3da8bcSJed Brown /// @sa CeedGetVersion()
155ec3da8bcSJed Brown #define CEED_VERSION_GE(major, minor, patch) \
156ec3da8bcSJed Brown   (!CEED_VERSION_RELEASE ||                  \
157ec3da8bcSJed Brown    (CEED_VERSION_MAJOR > major ||            \
1582b730f8bSJeremy L Thompson     (CEED_VERSION_MAJOR == major && (CEED_VERSION_MINOR > minor || (CEED_VERSION_MINOR == minor && CEED_VERSION_PATCH >= patch)))))
159ec3da8bcSJed Brown 
1602b730f8bSJeremy L Thompson CEED_EXTERN int CeedGetVersion(int *major, int *minor, int *patch, bool *release);
161ec3da8bcSJed Brown 
16280a9ef05SNatalie Beams CEED_EXTERN int CeedGetScalarType(CeedScalarType *scalar_type);
16380a9ef05SNatalie Beams 
1649bd0a4deSJeremy L Thompson /// String names for enum pretty printing
165ec3da8bcSJed Brown CEED_EXTERN const char *const *CeedErrorTypes;
166ec3da8bcSJed Brown CEED_EXTERN const char *const  CeedMemTypes[];
1679bd0a4deSJeremy L Thompson CEED_EXTERN const char *const  CeedCopyModes[];
1689bd0a4deSJeremy L Thompson CEED_EXTERN const char *const  CeedTransposeModes[];
1699bd0a4deSJeremy L Thompson CEED_EXTERN const char *const  CeedEvalModes[];
1709bd0a4deSJeremy L Thompson CEED_EXTERN const char *const  CeedQuadModes[];
1719bd0a4deSJeremy L Thompson CEED_EXTERN const char *const  CeedElemTopologies[];
1729bd0a4deSJeremy L Thompson CEED_EXTERN const char *const  CeedContextFieldTypes[];
173ec3da8bcSJed Brown 
174ec3da8bcSJed Brown CEED_EXTERN int CeedGetPreferredMemType(Ceed ceed, CeedMemType *type);
175ec3da8bcSJed Brown 
1761f9221feSJeremy L Thompson CEED_EXTERN int CeedVectorCreate(Ceed ceed, CeedSize len, CeedVector *vec);
1779560d06aSjeremylt CEED_EXTERN int CeedVectorReferenceCopy(CeedVector vec, CeedVector *vec_copy);
1785fb68f37SKaren (Ren) Stengel CEED_EXTERN int CeedVectorCopy(CeedVector vec, CeedVector vec_copy);
1792b730f8bSJeremy L Thompson CEED_EXTERN int CeedVectorSetArray(CeedVector vec, CeedMemType mem_type, CeedCopyMode copy_mode, CeedScalar *array);
180ec3da8bcSJed Brown CEED_EXTERN int CeedVectorSetValue(CeedVector vec, CeedScalar value);
181d1d35e2fSjeremylt CEED_EXTERN int CeedVectorSyncArray(CeedVector vec, CeedMemType mem_type);
1822b730f8bSJeremy L Thompson CEED_EXTERN int CeedVectorTakeArray(CeedVector vec, CeedMemType mem_type, CeedScalar **array);
1832b730f8bSJeremy L Thompson CEED_EXTERN int CeedVectorGetArray(CeedVector vec, CeedMemType mem_type, CeedScalar **array);
1842b730f8bSJeremy L Thompson CEED_EXTERN int CeedVectorGetArrayRead(CeedVector vec, CeedMemType mem_type, const CeedScalar **array);
1852b730f8bSJeremy L Thompson CEED_EXTERN int CeedVectorGetArrayWrite(CeedVector vec, CeedMemType mem_type, CeedScalar **array);
186ec3da8bcSJed Brown CEED_EXTERN int CeedVectorRestoreArray(CeedVector vec, CeedScalar **array);
1872b730f8bSJeremy L Thompson CEED_EXTERN int CeedVectorRestoreArrayRead(CeedVector vec, const CeedScalar **array);
1882b730f8bSJeremy L Thompson CEED_EXTERN int CeedVectorNorm(CeedVector vec, CeedNormType type, CeedScalar *norm);
189e0dd3b27Sjeremylt CEED_EXTERN int CeedVectorScale(CeedVector x, CeedScalar alpha);
1900f7fd0f8Sjeremylt CEED_EXTERN int CeedVectorAXPY(CeedVector y, CeedScalar alpha, CeedVector x);
1915fb68f37SKaren (Ren) Stengel CEED_EXTERN int CeedVectorAXPBY(CeedVector y, CeedScalar alpha, CeedScalar beta, CeedVector x);
1920f7fd0f8Sjeremylt CEED_EXTERN int CeedVectorPointwiseMult(CeedVector w, CeedVector x, CeedVector y);
193ec3da8bcSJed Brown CEED_EXTERN int CeedVectorReciprocal(CeedVector vec);
194acb2c48cSJeremy L Thompson CEED_EXTERN int CeedVectorViewRange(CeedVector vec, CeedSize start, CeedSize stop, CeedInt step, const char *fp_fmt, FILE *stream);
195d1d35e2fSjeremylt CEED_EXTERN int CeedVectorView(CeedVector vec, const char *fp_fmt, FILE *stream);
196b7c9bbdaSJeremy L Thompson CEED_EXTERN int CeedVectorGetCeed(CeedVector vec, Ceed *ceed);
1971f9221feSJeremy L Thompson CEED_EXTERN int CeedVectorGetLength(CeedVector vec, CeedSize *length);
198ec3da8bcSJed Brown CEED_EXTERN int CeedVectorDestroy(CeedVector *vec);
199ec3da8bcSJed Brown 
200ec3da8bcSJed Brown CEED_EXTERN CeedRequest *const CEED_REQUEST_IMMEDIATE;
201ec3da8bcSJed Brown CEED_EXTERN CeedRequest *const CEED_REQUEST_ORDERED;
202ec3da8bcSJed Brown CEED_EXTERN int                CeedRequestWait(CeedRequest *req);
203ec3da8bcSJed Brown 
204ea61e9acSJeremy L Thompson /// Argument for CeedOperatorSetField that vector is collocated with quadrature points, only used with CeedEvalMode CEED_EVAL_NONE
205ec3da8bcSJed Brown /// @ingroup CeedBasis
206ec3da8bcSJed Brown CEED_EXTERN const CeedBasis CEED_BASIS_COLLOCATED;
207ec3da8bcSJed Brown 
208ec3da8bcSJed Brown /// Argument for CeedOperatorSetField to use active input or output
209ec3da8bcSJed Brown /// @ingroup CeedVector
210ec3da8bcSJed Brown CEED_EXTERN const CeedVector CEED_VECTOR_ACTIVE;
211ec3da8bcSJed Brown 
212ea61e9acSJeremy L Thompson /// Argument for CeedOperatorSetField to use no vector, used with QFunction input with eval mode CEED_EVAL_WEIGHT
213ec3da8bcSJed Brown /// @ingroup CeedVector
214ec3da8bcSJed Brown CEED_EXTERN const CeedVector CEED_VECTOR_NONE;
215ec3da8bcSJed Brown 
216ea61e9acSJeremy L Thompson /// Argument for CeedOperatorSetField to use no ElemRestriction, only used with eval mode CEED_EVAL_WEIGHT.
217ec3da8bcSJed Brown /// @ingroup CeedElemRestriction
218ec3da8bcSJed Brown CEED_EXTERN const CeedElemRestriction CEED_ELEMRESTRICTION_NONE;
219ec3da8bcSJed Brown 
220ec3da8bcSJed Brown /// Argument for CeedOperatorCreate that QFunction is not created by user.
221ea61e9acSJeremy L Thompson /// Only used for QFunctions dqf and dqfT.
222ea61e9acSJeremy L Thompson /// If implemented, a backend may attempt to provide the action of these QFunctions.
223ec3da8bcSJed Brown /// @ingroup CeedQFunction
224ec3da8bcSJed Brown CEED_EXTERN const CeedQFunction CEED_QFUNCTION_NONE;
225ec3da8bcSJed Brown 
226ea61e9acSJeremy L Thompson /// Argument for CeedElemRestrictionCreateStrided that L-vector is in the Ceed backend's preferred layout.
227ea61e9acSJeremy L Thompson /// This argument should only be used with vectors created by a Ceed backend.
228ec3da8bcSJed Brown /// @ingroup CeedElemRestriction
229ec3da8bcSJed Brown CEED_EXTERN const CeedInt CEED_STRIDES_BACKEND[3];
230ec3da8bcSJed Brown 
2312b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionCreate(Ceed ceed, CeedInt num_elem, CeedInt elem_size, CeedInt num_comp, CeedInt comp_stride, CeedSize l_size,
2322b730f8bSJeremy L Thompson                                           CeedMemType mem_type, CeedCopyMode copy_mode, const CeedInt *offsets, CeedElemRestriction *rstr);
2332b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionCreateOriented(Ceed ceed, CeedInt num_elem, CeedInt elem_size, CeedInt num_comp, CeedInt comp_stride,
2342b730f8bSJeremy L Thompson                                                   CeedSize l_size, CeedMemType mem_type, CeedCopyMode copy_mode, const CeedInt *offsets,
235fc0567d9Srezgarshakeri                                                   const bool *orient, CeedElemRestriction *rstr);
2362b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionCreateStrided(Ceed ceed, CeedInt num_elem, CeedInt elem_size, CeedInt num_comp, CeedSize l_size,
237ec3da8bcSJed Brown                                                  const CeedInt strides[3], CeedElemRestriction *rstr);
2382b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionCreateBlocked(Ceed ceed, CeedInt num_elem, CeedInt elem_size, CeedInt blk_size, CeedInt num_comp,
2392b730f8bSJeremy L Thompson                                                  CeedInt comp_stride, CeedSize l_size, CeedMemType mem_type, CeedCopyMode copy_mode,
240ec3da8bcSJed Brown                                                  const CeedInt *offsets, CeedElemRestriction *rstr);
2412b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionCreateBlockedStrided(Ceed ceed, CeedInt num_elem, CeedInt elem_size, CeedInt blk_size, CeedInt num_comp,
242e79b91d9SJeremy L Thompson                                                         CeedSize l_size, const CeedInt strides[3], CeedElemRestriction *rstr);
243*c17ec2beSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionCreateUnsignedCopy(CeedElemRestriction rstr, CeedElemRestriction *rstr_unsigned);
2442b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionReferenceCopy(CeedElemRestriction rstr, CeedElemRestriction *rstr_copy);
2452b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionCreateVector(CeedElemRestriction rstr, CeedVector *lvec, CeedVector *evec);
2462b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionApply(CeedElemRestriction rstr, CeedTransposeMode t_mode, CeedVector u, CeedVector ru, CeedRequest *request);
247f30b1135SSebastian Grimberg CEED_EXTERN int CeedElemRestrictionApplyUnsigned(CeedElemRestriction rstr, CeedTransposeMode t_mode, CeedVector u, CeedVector ru,
248f30b1135SSebastian Grimberg                                                  CeedRequest *request);
2492b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionApplyBlock(CeedElemRestriction rstr, CeedInt block, CeedTransposeMode t_mode, CeedVector u, CeedVector ru,
250ec3da8bcSJed Brown                                               CeedRequest *request);
2512b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetCeed(CeedElemRestriction rstr, Ceed *ceed);
2522b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetCompStride(CeedElemRestriction rstr, CeedInt *comp_stride);
2532b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetNumElements(CeedElemRestriction rstr, CeedInt *num_elem);
2542b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetElementSize(CeedElemRestriction rstr, CeedInt *elem_size);
2552b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetLVectorSize(CeedElemRestriction rstr, CeedSize *l_size);
2562b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetNumComponents(CeedElemRestriction rstr, CeedInt *num_comp);
2572b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetNumBlocks(CeedElemRestriction rstr, CeedInt *num_blk);
2582b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetBlockSize(CeedElemRestriction rstr, CeedInt *blk_size);
2592b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetMultiplicity(CeedElemRestriction rstr, CeedVector mult);
260ec3da8bcSJed Brown CEED_EXTERN int CeedElemRestrictionView(CeedElemRestriction rstr, FILE *stream);
261ec3da8bcSJed Brown CEED_EXTERN int CeedElemRestrictionDestroy(CeedElemRestriction *rstr);
262ec3da8bcSJed Brown 
263ec3da8bcSJed Brown // The formalism here is that we have the structure
264ec3da8bcSJed Brown //  \int_\Omega v^T f_0(u, \nabla u, qdata) + (\nabla v)^T f_1(u, \nabla u, qdata)
265ec3da8bcSJed Brown // where gradients are with respect to the reference element.
266ec3da8bcSJed Brown 
2672b730f8bSJeremy L Thompson CEED_EXTERN int CeedBasisCreateTensorH1Lagrange(Ceed ceed, CeedInt dim, CeedInt num_comp, CeedInt P, CeedInt Q, CeedQuadMode quad_mode,
268ec3da8bcSJed Brown                                                 CeedBasis *basis);
2692b730f8bSJeremy L Thompson CEED_EXTERN int CeedBasisCreateTensorH1(Ceed ceed, CeedInt dim, CeedInt num_comp, CeedInt P_1d, CeedInt Q_1d, const CeedScalar *interp_1d,
2702b730f8bSJeremy L Thompson                                         const CeedScalar *grad_1d, const CeedScalar *q_ref_1d, const CeedScalar *q_weight_1d, CeedBasis *basis);
2712b730f8bSJeremy L Thompson CEED_EXTERN int CeedBasisCreateH1(Ceed ceed, CeedElemTopology topo, CeedInt num_comp, CeedInt num_nodes, CeedInt nqpts, const CeedScalar *interp,
2722b730f8bSJeremy L Thompson                                   const CeedScalar *grad, const CeedScalar *q_ref, const CeedScalar *q_weights, CeedBasis *basis);
2732b730f8bSJeremy L Thompson CEED_EXTERN int CeedBasisCreateHdiv(Ceed ceed, CeedElemTopology topo, CeedInt num_comp, CeedInt num_nodes, CeedInt nqpts, const CeedScalar *interp,
2742b730f8bSJeremy L Thompson                                     const CeedScalar *div, const CeedScalar *q_ref, const CeedScalar *q_weights, CeedBasis *basis);
275c4e3f59bSSebastian Grimberg CEED_EXTERN int CeedBasisCreateHcurl(Ceed ceed, CeedElemTopology topo, CeedInt num_comp, CeedInt num_nodes, CeedInt nqpts, const CeedScalar *interp,
276c4e3f59bSSebastian Grimberg                                      const CeedScalar *curl, const CeedScalar *q_ref, const CeedScalar *q_weights, CeedBasis *basis);
277446e7af4SJeremy L Thompson CEED_EXTERN int CeedBasisCreateProjection(CeedBasis basis_from, CeedBasis basis_to, CeedBasis *basis_project);
2789560d06aSjeremylt CEED_EXTERN int CeedBasisReferenceCopy(CeedBasis basis, CeedBasis *basis_copy);
279ec3da8bcSJed Brown CEED_EXTERN int CeedBasisView(CeedBasis basis, FILE *stream);
2802b730f8bSJeremy L Thompson CEED_EXTERN int CeedBasisApply(CeedBasis basis, CeedInt num_elem, CeedTransposeMode t_mode, CeedEvalMode eval_mode, CeedVector u, CeedVector v);
281b7c9bbdaSJeremy L Thompson CEED_EXTERN int CeedBasisGetCeed(CeedBasis basis, Ceed *ceed);
282ec3da8bcSJed Brown CEED_EXTERN int CeedBasisGetDimension(CeedBasis basis, CeedInt *dim);
283ec3da8bcSJed Brown CEED_EXTERN int CeedBasisGetTopology(CeedBasis basis, CeedElemTopology *topo);
284d1d35e2fSjeremylt CEED_EXTERN int CeedBasisGetNumComponents(CeedBasis basis, CeedInt *num_comp);
285ec3da8bcSJed Brown CEED_EXTERN int CeedBasisGetNumNodes(CeedBasis basis, CeedInt *P);
286d1d35e2fSjeremylt CEED_EXTERN int CeedBasisGetNumNodes1D(CeedBasis basis, CeedInt *P_1d);
287ec3da8bcSJed Brown CEED_EXTERN int CeedBasisGetNumQuadraturePoints(CeedBasis basis, CeedInt *Q);
2882b730f8bSJeremy L Thompson CEED_EXTERN int CeedBasisGetNumQuadraturePoints1D(CeedBasis basis, CeedInt *Q_1d);
289d1d35e2fSjeremylt CEED_EXTERN int CeedBasisGetQRef(CeedBasis basis, const CeedScalar **q_ref);
2902b730f8bSJeremy L Thompson CEED_EXTERN int CeedBasisGetQWeights(CeedBasis basis, const CeedScalar **q_weights);
291ec3da8bcSJed Brown CEED_EXTERN int CeedBasisGetInterp(CeedBasis basis, const CeedScalar **interp);
2922b730f8bSJeremy L Thompson CEED_EXTERN int CeedBasisGetInterp1D(CeedBasis basis, const CeedScalar **interp_1d);
293ec3da8bcSJed Brown CEED_EXTERN int CeedBasisGetGrad(CeedBasis basis, const CeedScalar **grad);
294d1d35e2fSjeremylt CEED_EXTERN int CeedBasisGetGrad1D(CeedBasis basis, const CeedScalar **grad_1d);
29550c301a5SRezgar Shakeri CEED_EXTERN int CeedBasisGetDiv(CeedBasis basis, const CeedScalar **div);
296c4e3f59bSSebastian Grimberg CEED_EXTERN int CeedBasisGetCurl(CeedBasis basis, const CeedScalar **curl);
297ec3da8bcSJed Brown CEED_EXTERN int CeedBasisDestroy(CeedBasis *basis);
298ec3da8bcSJed Brown 
2992b730f8bSJeremy L Thompson CEED_EXTERN int CeedGaussQuadrature(CeedInt Q, CeedScalar *q_ref_1d, CeedScalar *q_weight_1d);
3002b730f8bSJeremy L Thompson CEED_EXTERN int CeedLobattoQuadrature(CeedInt Q, CeedScalar *q_ref_1d, CeedScalar *q_weight_1d);
301ec3da8bcSJed Brown 
302cdf32b93SJeremy L Thompson /** Handle for the user provided CeedQFunction callback function
303ec3da8bcSJed Brown 
304cdf32b93SJeremy L Thompson  @param[in,out] ctx  User-defined context set using CeedQFunctionSetContext() or NULL
305cdf32b93SJeremy L Thompson  @param[in] Q        Number of quadrature points at which to evaluate
306ea61e9acSJeremy L Thompson  @param[in] in       Array of pointers to each input argument in the order provided by the user in CeedQFunctionAddInput().
307ea61e9acSJeremy 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
308ea61e9acSJeremy 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
309d1d35e2fSjeremylt quadrature point `j` as `in[i][(d*num_comp + c)*Q + j]`.
310ea61e9acSJeremy L Thompson  @param[out]   out   Array of pointers to each output array in the order provided using CeedQFunctionAddOutput().
311ea61e9acSJeremy L Thompson                        The shapes are as above for \a in.
312ec3da8bcSJed Brown 
313ec3da8bcSJed Brown  @return An error code: 0 - success, otherwise - failure
314ec3da8bcSJed Brown 
315ec3da8bcSJed Brown  @ingroup CeedQFunction
316ec3da8bcSJed Brown **/
3172b730f8bSJeremy L Thompson typedef int (*CeedQFunctionUser)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out);
318ec3da8bcSJed Brown 
3192b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionCreateInterior(Ceed ceed, CeedInt vec_length, CeedQFunctionUser f, const char *source, CeedQFunction *qf);
3202b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionCreateInteriorByName(Ceed ceed, const char *name, CeedQFunction *qf);
3212b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionCreateIdentity(Ceed ceed, CeedInt size, CeedEvalMode in_mode, CeedEvalMode out_mode, CeedQFunction *qf);
3229560d06aSjeremylt CEED_EXTERN int CeedQFunctionReferenceCopy(CeedQFunction qf, CeedQFunction *qf_copy);
3232b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionAddInput(CeedQFunction qf, const char *field_name, CeedInt size, CeedEvalMode eval_mode);
3242b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionAddOutput(CeedQFunction qf, const char *field_name, CeedInt size, CeedEvalMode eval_mode);
3252b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionGetFields(CeedQFunction qf, CeedInt *num_input_fields, CeedQFunctionField **input_fields, CeedInt *num_output_fields,
32643bbe138SJeremy L Thompson                                        CeedQFunctionField **output_fields);
3272b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionSetContext(CeedQFunction qf, CeedQFunctionContext ctx);
328441428dfSJeremy L Thompson CEED_EXTERN int CeedQFunctionSetContextWritable(CeedQFunction qf, bool is_writable);
3299d36ca50SJeremy L Thompson CEED_EXTERN int CeedQFunctionSetUserFlopsEstimate(CeedQFunction qf, CeedSize flops);
330ec3da8bcSJed Brown CEED_EXTERN int CeedQFunctionView(CeedQFunction qf, FILE *stream);
331b7c9bbdaSJeremy L Thompson CEED_EXTERN int CeedQFunctionGetCeed(CeedQFunction qf, Ceed *ceed);
3322b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionApply(CeedQFunction qf, CeedInt Q, CeedVector *u, CeedVector *v);
333ec3da8bcSJed Brown CEED_EXTERN int CeedQFunctionDestroy(CeedQFunction *qf);
334ec3da8bcSJed Brown 
3352b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionFieldGetName(CeedQFunctionField qf_field, char **field_name);
3362b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionFieldGetSize(CeedQFunctionField qf_field, CeedInt *size);
3372b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionFieldGetEvalMode(CeedQFunctionField qf_field, CeedEvalMode *eval_mode);
33843bbe138SJeremy L Thompson 
3392790b72bSJeremy L Thompson /** Handle for the user provided CeedQFunctionContextDataDestroy callback function
3402790b72bSJeremy L Thompson 
3412790b72bSJeremy L Thompson  @param[in,out] data  User-CeedQFunctionContext data
3422790b72bSJeremy L Thompson 
3432790b72bSJeremy L Thompson  @return An error code: 0 - success, otherwise - failure
3442790b72bSJeremy L Thompson 
3452790b72bSJeremy L Thompson  @ingroup CeedQFunction
3462790b72bSJeremy L Thompson **/
3472790b72bSJeremy L Thompson typedef int (*CeedQFunctionContextDataDestroyUser)(void *data);
3482790b72bSJeremy L Thompson 
3492b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextCreate(Ceed ceed, CeedQFunctionContext *ctx);
3502b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextReferenceCopy(CeedQFunctionContext ctx, CeedQFunctionContext *ctx_copy);
3512b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextSetData(CeedQFunctionContext ctx, CeedMemType mem_type, CeedCopyMode copy_mode, size_t size, void *data);
3522b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextTakeData(CeedQFunctionContext ctx, CeedMemType mem_type, void *data);
3532b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextGetData(CeedQFunctionContext ctx, CeedMemType mem_type, void *data);
3542b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextGetDataRead(CeedQFunctionContext ctx, CeedMemType mem_type, void *data);
3552b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextRestoreData(CeedQFunctionContext ctx, void *data);
3562b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextRestoreDataRead(CeedQFunctionContext ctx, void *data);
3572b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextRegisterDouble(CeedQFunctionContext ctx, const char *field_name, size_t field_offset, size_t num_values,
3587bfe0f0eSJeremy L Thompson                                                    const char *field_description);
3592b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextRegisterInt32(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 CeedQFunctionContextGetAllFieldLabels(CeedQFunctionContext ctx, const CeedContextFieldLabel **field_labels, CeedInt *num_fields);
3622b730f8bSJeremy L Thompson CEED_EXTERN int CeedContextFieldLabelGetDescription(CeedContextFieldLabel label, const char **field_name, const char **field_description,
3632b730f8bSJeremy L Thompson                                                     size_t *num_values, CeedContextFieldType *field_type);
3642b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextGetContextSize(CeedQFunctionContext ctx, size_t *ctx_size);
3652b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextView(CeedQFunctionContext ctx, FILE *stream);
3662b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextSetDataDestroy(CeedQFunctionContext ctx, CeedMemType f_mem_type, CeedQFunctionContextDataDestroyUser f);
367ec3da8bcSJed Brown CEED_EXTERN int CeedQFunctionContextDestroy(CeedQFunctionContext *ctx);
368ec3da8bcSJed Brown 
3692b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorCreate(Ceed ceed, CeedQFunction qf, CeedQFunction dqf, CeedQFunction dqfT, CeedOperator *op);
370ec3da8bcSJed Brown CEED_EXTERN int CeedCompositeOperatorCreate(Ceed ceed, CeedOperator *op);
3719560d06aSjeremylt CEED_EXTERN int CeedOperatorReferenceCopy(CeedOperator op, CeedOperator *op_copy);
3722b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorSetField(CeedOperator op, const char *field_name, CeedElemRestriction r, CeedBasis b, CeedVector v);
3732b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorGetFields(CeedOperator op, CeedInt *num_input_fields, CeedOperatorField **input_fields, CeedInt *num_output_fields,
37443bbe138SJeremy L Thompson                                       CeedOperatorField **output_fields);
3752b730f8bSJeremy L Thompson CEED_EXTERN int CeedCompositeOperatorAddSub(CeedOperator composite_op, CeedOperator sub_op);
376c6ebc35dSJeremy L Thompson CEED_EXTERN int CeedCompositeOperatorGetNumSub(CeedOperator op, CeedInt *num_suboperators);
377c6ebc35dSJeremy L Thompson CEED_EXTERN int CeedCompositeOperatorGetSubList(CeedOperator op, CeedOperator **sub_operators);
3784db537f9SJeremy L Thompson CEED_EXTERN int CeedOperatorCheckReady(CeedOperator op);
379c9366a6bSJeremy L Thompson CEED_EXTERN int CeedOperatorGetActiveVectorLengths(CeedOperator op, CeedSize *input_size, CeedSize *output_size);
380beecbf24SJeremy L Thompson CEED_EXTERN int CeedOperatorSetQFunctionAssemblyReuse(CeedOperator op, bool reuse_assembly_data);
381beecbf24SJeremy L Thompson CEED_EXTERN int CeedOperatorSetQFunctionAssemblyDataUpdateNeeded(CeedOperator op, bool needs_data_update);
3822b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorLinearAssembleQFunction(CeedOperator op, CeedVector *assembled, CeedElemRestriction *rstr, CeedRequest *request);
3832b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorLinearAssembleQFunctionBuildOrUpdate(CeedOperator op, CeedVector *assembled, CeedElemRestriction *rstr,
3842b730f8bSJeremy L Thompson                                                                  CeedRequest *request);
3852b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorLinearAssembleDiagonal(CeedOperator op, CeedVector assembled, CeedRequest *request);
3862b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorLinearAssembleAddDiagonal(CeedOperator op, CeedVector assembled, CeedRequest *request);
3872b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorLinearAssemblePointBlockDiagonal(CeedOperator op, CeedVector assembled, CeedRequest *request);
3882b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorLinearAssembleAddPointBlockDiagonal(CeedOperator op, CeedVector assembled, CeedRequest *request);
3892b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorLinearAssembleSymbolic(CeedOperator op, CeedSize *num_entries, CeedInt **rows, CeedInt **cols);
390ec3da8bcSJed Brown CEED_EXTERN int CeedOperatorLinearAssemble(CeedOperator op, CeedVector values);
39175f0d5a4SJeremy L Thompson CEED_EXTERN int CeedCompositeOperatorGetMultiplicity(CeedOperator op, CeedInt num_skip_indices, CeedInt *skip_indices, CeedVector mult);
3922b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorMultigridLevelCreate(CeedOperator op_fine, CeedVector p_mult_fine, CeedElemRestriction rstr_coarse,
3932b730f8bSJeremy L Thompson                                                  CeedBasis basis_coarse, CeedOperator *op_coarse, CeedOperator *op_prolong,
3942b730f8bSJeremy L Thompson                                                  CeedOperator *op_restrict);
3952b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorMultigridLevelCreateTensorH1(CeedOperator op_fine, CeedVector p_mult_fine, CeedElemRestriction rstr_coarse,
396d1d35e2fSjeremylt                                                          CeedBasis basis_coarse, const CeedScalar *interp_c_to_f, CeedOperator *op_coarse,
397d1d35e2fSjeremylt                                                          CeedOperator *op_prolong, CeedOperator *op_restrict);
3982b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorMultigridLevelCreateH1(CeedOperator op_fine, CeedVector p_mult_fine, CeedElemRestriction rstr_coarse,
3992b730f8bSJeremy L Thompson                                                    CeedBasis basis_coarse, const CeedScalar *interp_c_to_f, CeedOperator *op_coarse,
400d1d35e2fSjeremylt                                                    CeedOperator *op_prolong, CeedOperator *op_restrict);
4012b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorCreateFDMElementInverse(CeedOperator op, CeedOperator *fdm_inv, CeedRequest *request);
402cd4dfc48Sjeremylt CEED_EXTERN int CeedOperatorSetNumQuadraturePoints(CeedOperator op, CeedInt num_qpts);
403ea6b5821SJeremy L Thompson CEED_EXTERN int CeedOperatorSetName(CeedOperator op, const char *name);
404ec3da8bcSJed Brown CEED_EXTERN int CeedOperatorView(CeedOperator op, FILE *stream);
405b7c9bbdaSJeremy L Thompson CEED_EXTERN int CeedOperatorGetCeed(CeedOperator op, Ceed *ceed);
406b7c9bbdaSJeremy L Thompson CEED_EXTERN int CeedOperatorGetNumElements(CeedOperator op, CeedInt *num_elem);
4072b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorGetNumQuadraturePoints(CeedOperator op, CeedInt *num_qpts);
4089d36ca50SJeremy L Thompson CEED_EXTERN int CeedOperatorGetFlopsEstimate(CeedOperator op, CeedSize *flops);
4090126412dSJeremy L Thompson CEED_EXTERN int CeedOperatorGetContext(CeedOperator op, CeedQFunctionContext *ctx);
41017b0d5c6SJeremy L Thompson CEED_EXTERN int CeedOperatorGetContextFieldLabel(CeedOperator op, const char *field_name, CeedContextFieldLabel *field_label);
41117b0d5c6SJeremy L Thompson CEED_EXTERN int CeedOperatorSetContextDouble(CeedOperator op, CeedContextFieldLabel field_label, double *values);
41217b0d5c6SJeremy L Thompson CEED_EXTERN int CeedOperatorGetContextDoubleRead(CeedOperator op, CeedContextFieldLabel field_label, size_t *num_values, const double **values);
41317b0d5c6SJeremy L Thompson CEED_EXTERN int CeedOperatorRestoreContextDoubleRead(CeedOperator op, CeedContextFieldLabel field_label, const double **values);
41417b0d5c6SJeremy L Thompson CEED_EXTERN int CeedOperatorSetContextInt32(CeedOperator op, CeedContextFieldLabel field_label, int *values);
41517b0d5c6SJeremy L Thompson CEED_EXTERN int CeedOperatorGetContextInt32Read(CeedOperator op, CeedContextFieldLabel field_label, size_t *num_values, const int **values);
41617b0d5c6SJeremy L Thompson CEED_EXTERN int CeedOperatorRestoreContextInt32Read(CeedOperator op, CeedContextFieldLabel field_label, const int **values);
4172b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorApply(CeedOperator op, CeedVector in, CeedVector out, CeedRequest *request);
4182b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorApplyAdd(CeedOperator op, CeedVector in, CeedVector out, CeedRequest *request);
419ec3da8bcSJed Brown CEED_EXTERN int CeedOperatorDestroy(CeedOperator *op);
420ec3da8bcSJed Brown 
421de5900adSJames Wright CEED_EXTERN int CeedOperatorGetFieldByName(CeedOperator op, const char *field_name, CeedOperatorField *op_field);
4222b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorFieldGetName(CeedOperatorField op_field, char **field_name);
4232b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorFieldGetElemRestriction(CeedOperatorField op_field, CeedElemRestriction *rstr);
4242b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorFieldGetBasis(CeedOperatorField op_field, CeedBasis *basis);
4252b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorFieldGetVector(CeedOperatorField op_field, CeedVector *vec);
42643bbe138SJeremy L Thompson 
427ec3da8bcSJed Brown /**
428ec3da8bcSJed Brown   @brief Return integer power
429ec3da8bcSJed Brown 
430ec3da8bcSJed Brown   @param[in] base  The base to exponentiate
431ec3da8bcSJed Brown   @param[in] power The power to raise the base to
432ec3da8bcSJed Brown 
433ec3da8bcSJed Brown   @return base^power
434ec3da8bcSJed Brown 
435ec3da8bcSJed Brown   @ref Utility
436ec3da8bcSJed Brown **/
437ec3da8bcSJed Brown static inline CeedInt CeedIntPow(CeedInt base, CeedInt power) {
438ec3da8bcSJed Brown   CeedInt result = 1;
439ec3da8bcSJed Brown   while (power) {
440ec3da8bcSJed Brown     if (power & 1) result *= base;
441ec3da8bcSJed Brown     power >>= 1;
442ec3da8bcSJed Brown     base *= base;
443ec3da8bcSJed Brown   }
444ec3da8bcSJed Brown   return result;
445ec3da8bcSJed Brown }
446ec3da8bcSJed Brown 
447ec3da8bcSJed Brown /**
448ec3da8bcSJed Brown   @brief Return minimum of two integers
449ec3da8bcSJed Brown 
450ec3da8bcSJed Brown   @param[in] a The first integer to compare
451ec3da8bcSJed Brown   @param[in] b The second integer to compare
452ec3da8bcSJed Brown 
453ec3da8bcSJed Brown   @return The minimum of the two integers
454ec3da8bcSJed Brown 
455ec3da8bcSJed Brown   @ref Utility
456ec3da8bcSJed Brown **/
457ec3da8bcSJed Brown static inline CeedInt CeedIntMin(CeedInt a, CeedInt b) { return a < b ? a : b; }
458ec3da8bcSJed Brown 
459ec3da8bcSJed Brown /**
460ec3da8bcSJed Brown   @brief Return maximum of two integers
461ec3da8bcSJed Brown 
462ec3da8bcSJed Brown   @param[in] a The first integer to compare
463ec3da8bcSJed Brown   @param[in] b The second integer to compare
464ec3da8bcSJed Brown 
465ec3da8bcSJed Brown   @return The maximum of the two integers
466ec3da8bcSJed Brown 
467ec3da8bcSJed Brown   @ref Utility
468ec3da8bcSJed Brown **/
469ec3da8bcSJed Brown static inline CeedInt CeedIntMax(CeedInt a, CeedInt b) { return a > b ? a : b; }
470ec3da8bcSJed Brown 
471ec3da8bcSJed Brown // Used to ensure initialization before CeedInit()
472ec3da8bcSJed Brown CEED_EXTERN int CeedRegisterAll(void);
473ec3da8bcSJed Brown // Used to ensure initialization before CeedQFunctionCreate*()
474ec3da8bcSJed Brown CEED_EXTERN int CeedQFunctionRegisterAll(void);
475ec3da8bcSJed Brown 
476ec3da8bcSJed Brown #endif
477