xref: /libCEED/include/ceed/ceed.h (revision 07d5dec1642b3d8b5aca8f12f47bcc29bb156592)
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
1094b7b29bSJeremy L Thompson #ifndef CEED_H
1194b7b29bSJeremy L Thompson #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);
1025ae360d4SJeremy L Thompson CEED_EXTERN int CeedSetStream(Ceed ceed, void *handle);
1039560d06aSjeremylt CEED_EXTERN int CeedReferenceCopy(Ceed ceed, Ceed *ceed_copy);
104ec3da8bcSJed Brown CEED_EXTERN int CeedGetResource(Ceed ceed, const char **resource);
105d1d35e2fSjeremylt CEED_EXTERN int CeedIsDeterministic(Ceed ceed, bool *is_deterministic);
106ee5a26f2SJeremy L Thompson CEED_EXTERN int CeedAddJitSourceRoot(Ceed ceed, const char *jit_source_root);
107ec3da8bcSJed Brown CEED_EXTERN int CeedView(Ceed ceed, FILE *stream);
108ec3da8bcSJed Brown CEED_EXTERN int CeedDestroy(Ceed *ceed);
109ec3da8bcSJed Brown 
1102b730f8bSJeremy L Thompson CEED_EXTERN int CeedErrorImpl(Ceed, const char *, int, const char *, int, const char *, ...);
111ec3da8bcSJed Brown /// Raise an error on ceed object
112ec3da8bcSJed Brown ///
113ec3da8bcSJed Brown /// @param ceed Ceed library context or NULL
114ec3da8bcSJed Brown /// @param ecode Error code (int)
115ec3da8bcSJed Brown /// @param ... printf-style format string followed by arguments as needed
116ec3da8bcSJed Brown ///
117ec3da8bcSJed Brown /// @ingroup Ceed
118ec3da8bcSJed Brown /// @sa CeedSetErrorHandler()
1192b730f8bSJeremy L Thompson #define CeedError(ceed, ecode, ...) (CeedErrorImpl((ceed), __FILE__, __LINE__, __func__, (ecode), __VA_ARGS__), (ecode))
120ec3da8bcSJed Brown 
121ec3da8bcSJed Brown /// Ceed error handlers
1222b730f8bSJeremy L Thompson CEED_EXTERN int CeedErrorReturn(Ceed, const char *, int, const char *, int, const char *, va_list *);
1232b730f8bSJeremy L Thompson CEED_EXTERN int CeedErrorStore(Ceed, const char *, int, const char *, int, const char *, va_list *);
1242b730f8bSJeremy L Thompson CEED_EXTERN int CeedErrorAbort(Ceed, const char *, int, const char *, int, const char *, va_list *);
1252b730f8bSJeremy L Thompson CEED_EXTERN int CeedErrorExit(Ceed, const char *, int, const char *, int, const char *, va_list *);
1262b730f8bSJeremy L Thompson typedef int (*CeedErrorHandler)(Ceed, const char *, int, const char *, int, const char *, va_list *);
127ec3da8bcSJed Brown CEED_EXTERN int CeedSetErrorHandler(Ceed ceed, CeedErrorHandler eh);
128d1d35e2fSjeremylt CEED_EXTERN int CeedGetErrorMessage(Ceed, const char **err_msg);
129d1d35e2fSjeremylt CEED_EXTERN int CeedResetErrorMessage(Ceed, const char **err_msg);
130ec3da8bcSJed Brown 
131ec3da8bcSJed Brown /// libCEED library version numbering
132ec3da8bcSJed Brown /// @ingroup Ceed
133ec3da8bcSJed Brown #define CEED_VERSION_MAJOR 0
1348ec64e9aSJed Brown #define CEED_VERSION_MINOR 11
1358ec64e9aSJed Brown #define CEED_VERSION_PATCH 0
136d5780308SJeremy L Thompson #define CEED_VERSION_RELEASE false
137ec3da8bcSJed Brown 
138ea61e9acSJeremy L Thompson /// Compile-time check that the the current library version is at least as recent as the specified version.
139ea61e9acSJeremy L Thompson /// This macro is typically used in
140ec3da8bcSJed Brown /// @code
141ec3da8bcSJed Brown /// #if CEED_VERSION_GE(0, 8, 0)
142ec3da8bcSJed Brown ///   code path that needs at least 0.8.0
143ec3da8bcSJed Brown /// #else
144ec3da8bcSJed Brown ///   fallback code for older versions
145ec3da8bcSJed Brown /// #endif
146ec3da8bcSJed Brown /// @endcode
147ec3da8bcSJed Brown ///
148ec3da8bcSJed Brown /// A non-release version always compares as positive infinity.
149ec3da8bcSJed Brown ///
150ec3da8bcSJed Brown /// @param major   Major version
151ec3da8bcSJed Brown /// @param minor   Minor version
152ec3da8bcSJed Brown /// @param patch   Patch (subminor) version
153ec3da8bcSJed Brown ///
154ec3da8bcSJed Brown /// @ingroup Ceed
155ec3da8bcSJed Brown /// @sa CeedGetVersion()
156ec3da8bcSJed Brown #define CEED_VERSION_GE(major, minor, patch) \
157ec3da8bcSJed Brown   (!CEED_VERSION_RELEASE ||                  \
158ec3da8bcSJed Brown    (CEED_VERSION_MAJOR > major ||            \
1592b730f8bSJeremy L Thompson     (CEED_VERSION_MAJOR == major && (CEED_VERSION_MINOR > minor || (CEED_VERSION_MINOR == minor && CEED_VERSION_PATCH >= patch)))))
160ec3da8bcSJed Brown 
1612b730f8bSJeremy L Thompson CEED_EXTERN int CeedGetVersion(int *major, int *minor, int *patch, bool *release);
162ec3da8bcSJed Brown 
16380a9ef05SNatalie Beams CEED_EXTERN int CeedGetScalarType(CeedScalarType *scalar_type);
16480a9ef05SNatalie Beams 
1659bd0a4deSJeremy L Thompson /// String names for enum pretty printing
166ec3da8bcSJed Brown CEED_EXTERN const char *const *CeedErrorTypes;
167ec3da8bcSJed Brown CEED_EXTERN const char *const  CeedMemTypes[];
1689bd0a4deSJeremy L Thompson CEED_EXTERN const char *const  CeedCopyModes[];
1699bd0a4deSJeremy L Thompson CEED_EXTERN const char *const  CeedTransposeModes[];
1709bd0a4deSJeremy L Thompson CEED_EXTERN const char *const  CeedEvalModes[];
1719bd0a4deSJeremy L Thompson CEED_EXTERN const char *const  CeedQuadModes[];
1729bd0a4deSJeremy L Thompson CEED_EXTERN const char *const  CeedElemTopologies[];
1739bd0a4deSJeremy L Thompson CEED_EXTERN const char *const  CeedContextFieldTypes[];
174ec3da8bcSJed Brown 
175ec3da8bcSJed Brown CEED_EXTERN int CeedGetPreferredMemType(Ceed ceed, CeedMemType *type);
176ec3da8bcSJed Brown 
1771f9221feSJeremy L Thompson CEED_EXTERN int CeedVectorCreate(Ceed ceed, CeedSize len, CeedVector *vec);
1789560d06aSjeremylt CEED_EXTERN int CeedVectorReferenceCopy(CeedVector vec, CeedVector *vec_copy);
1795fb68f37SKaren (Ren) Stengel CEED_EXTERN int CeedVectorCopy(CeedVector vec, CeedVector vec_copy);
1802b730f8bSJeremy L Thompson CEED_EXTERN int CeedVectorSetArray(CeedVector vec, CeedMemType mem_type, CeedCopyMode copy_mode, CeedScalar *array);
181ec3da8bcSJed Brown CEED_EXTERN int CeedVectorSetValue(CeedVector vec, CeedScalar value);
182d1d35e2fSjeremylt CEED_EXTERN int CeedVectorSyncArray(CeedVector vec, CeedMemType mem_type);
1832b730f8bSJeremy L Thompson CEED_EXTERN int CeedVectorTakeArray(CeedVector vec, CeedMemType mem_type, CeedScalar **array);
1842b730f8bSJeremy L Thompson CEED_EXTERN int CeedVectorGetArray(CeedVector vec, CeedMemType mem_type, CeedScalar **array);
1852b730f8bSJeremy L Thompson CEED_EXTERN int CeedVectorGetArrayRead(CeedVector vec, CeedMemType mem_type, const CeedScalar **array);
1862b730f8bSJeremy L Thompson CEED_EXTERN int CeedVectorGetArrayWrite(CeedVector vec, CeedMemType mem_type, CeedScalar **array);
187ec3da8bcSJed Brown CEED_EXTERN int CeedVectorRestoreArray(CeedVector vec, CeedScalar **array);
1882b730f8bSJeremy L Thompson CEED_EXTERN int CeedVectorRestoreArrayRead(CeedVector vec, const CeedScalar **array);
1892b730f8bSJeremy L Thompson CEED_EXTERN int CeedVectorNorm(CeedVector vec, CeedNormType type, CeedScalar *norm);
190e0dd3b27Sjeremylt CEED_EXTERN int CeedVectorScale(CeedVector x, CeedScalar alpha);
1910f7fd0f8Sjeremylt CEED_EXTERN int CeedVectorAXPY(CeedVector y, CeedScalar alpha, CeedVector x);
1925fb68f37SKaren (Ren) Stengel CEED_EXTERN int CeedVectorAXPBY(CeedVector y, CeedScalar alpha, CeedScalar beta, CeedVector x);
1930f7fd0f8Sjeremylt CEED_EXTERN int CeedVectorPointwiseMult(CeedVector w, CeedVector x, CeedVector y);
194ec3da8bcSJed Brown CEED_EXTERN int CeedVectorReciprocal(CeedVector vec);
195acb2c48cSJeremy L Thompson CEED_EXTERN int CeedVectorViewRange(CeedVector vec, CeedSize start, CeedSize stop, CeedInt step, const char *fp_fmt, FILE *stream);
196d1d35e2fSjeremylt CEED_EXTERN int CeedVectorView(CeedVector vec, const char *fp_fmt, FILE *stream);
197b7c9bbdaSJeremy L Thompson CEED_EXTERN int CeedVectorGetCeed(CeedVector vec, Ceed *ceed);
1981f9221feSJeremy L Thompson CEED_EXTERN int CeedVectorGetLength(CeedVector vec, CeedSize *length);
199ec3da8bcSJed Brown CEED_EXTERN int CeedVectorDestroy(CeedVector *vec);
200ec3da8bcSJed Brown 
201ec3da8bcSJed Brown CEED_EXTERN CeedRequest *const CEED_REQUEST_IMMEDIATE;
202ec3da8bcSJed Brown CEED_EXTERN CeedRequest *const CEED_REQUEST_ORDERED;
203ec3da8bcSJed Brown CEED_EXTERN int                CeedRequestWait(CeedRequest *req);
204ec3da8bcSJed Brown 
205356036faSJeremy L Thompson /// Argument for CeedOperatorSetField to use active input or output.
206ec3da8bcSJed Brown /// @ingroup CeedVector
207ec3da8bcSJed Brown CEED_EXTERN const CeedVector CEED_VECTOR_ACTIVE;
208ec3da8bcSJed Brown 
209356036faSJeremy L Thompson /// Argument for CeedOperatorSetField to use no vector.
210356036faSJeremy L Thompson /// Only use this option with CeedEvalMode CEED_EVAL_WEIGHT.
211ec3da8bcSJed Brown /// @ingroup CeedVector
212ec3da8bcSJed Brown CEED_EXTERN const CeedVector CEED_VECTOR_NONE;
213ec3da8bcSJed Brown 
214356036faSJeremy L Thompson /// Argument for CeedOperatorSetField that no basis operation is needed to translate between the E-vector and the Q-vector.
215356036faSJeremy L Thompson /// Only use this option with CeedEvalMode CEED_EVAL_NONE.
216356036faSJeremy L Thompson /// @ingroup CeedBasis
217356036faSJeremy L Thompson CEED_EXTERN const CeedBasis CEED_BASIS_NONE;
218356036faSJeremy L Thompson 
219056ec191SJames Wright CEED_EXTERN const CeedBasis CEED_BASIS_COLLOCATED;
220056ec191SJames Wright 
221356036faSJeremy L Thompson /// Argument for CeedOperatorSetField to use no ElemRestriction.
222356036faSJeremy L Thompson /// Only use this option with CeedEvalMode CEED_EVAL_WEIGHT.
223ec3da8bcSJed Brown /// @ingroup CeedElemRestriction
224ec3da8bcSJed Brown CEED_EXTERN const CeedElemRestriction CEED_ELEMRESTRICTION_NONE;
225ec3da8bcSJed Brown 
226ec3da8bcSJed Brown /// Argument for CeedOperatorCreate that QFunction is not created by user.
227ea61e9acSJeremy L Thompson /// Only used for QFunctions dqf and dqfT.
228ea61e9acSJeremy L Thompson /// If implemented, a backend may attempt to provide the action of these QFunctions.
229ec3da8bcSJed Brown /// @ingroup CeedQFunction
230ec3da8bcSJed Brown CEED_EXTERN const CeedQFunction CEED_QFUNCTION_NONE;
231ec3da8bcSJed Brown 
232ea61e9acSJeremy L Thompson /// Argument for CeedElemRestrictionCreateStrided that L-vector is in the Ceed backend's preferred layout.
233ea61e9acSJeremy L Thompson /// This argument should only be used with vectors created by a Ceed backend.
234ec3da8bcSJed Brown /// @ingroup CeedElemRestriction
235ec3da8bcSJed Brown CEED_EXTERN const CeedInt CEED_STRIDES_BACKEND[3];
236ec3da8bcSJed Brown 
2372b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionCreate(Ceed ceed, CeedInt num_elem, CeedInt elem_size, CeedInt num_comp, CeedInt comp_stride, CeedSize l_size,
2382b730f8bSJeremy L Thompson                                           CeedMemType mem_type, CeedCopyMode copy_mode, const CeedInt *offsets, CeedElemRestriction *rstr);
2392b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionCreateOriented(Ceed ceed, CeedInt num_elem, CeedInt elem_size, CeedInt num_comp, CeedInt comp_stride,
2402b730f8bSJeremy L Thompson                                                   CeedSize l_size, CeedMemType mem_type, CeedCopyMode copy_mode, const CeedInt *offsets,
24177d1c127SSebastian Grimberg                                                   const bool *orients, CeedElemRestriction *rstr);
24277d1c127SSebastian Grimberg CEED_EXTERN int CeedElemRestrictionCreateCurlOriented(Ceed ceed, CeedInt num_elem, CeedInt elem_size, CeedInt num_comp, CeedInt comp_stride,
24377d1c127SSebastian Grimberg                                                       CeedSize l_size, CeedMemType mem_type, CeedCopyMode copy_mode, const CeedInt *offsets,
2440c73c039SSebastian Grimberg                                                       const CeedInt8 *curl_orients, CeedElemRestriction *rstr);
2452b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionCreateStrided(Ceed ceed, CeedInt num_elem, CeedInt elem_size, CeedInt num_comp, CeedSize l_size,
246ec3da8bcSJed Brown                                                  const CeedInt strides[3], CeedElemRestriction *rstr);
2473ac8f562SJeremy L Thompson CEED_EXTERN int CeedElemRestrictionCreateAtPoints(Ceed ceed, CeedInt num_elem, CeedInt num_points, CeedInt num_comp, CeedSize l_size,
2483ac8f562SJeremy L Thompson                                                   CeedMemType mem_type, CeedCopyMode copy_mode, const CeedInt *offsets, CeedElemRestriction *rstr);
249e7f679fcSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionCreateBlocked(Ceed ceed, CeedInt num_elem, CeedInt elem_size, CeedInt block_size, CeedInt num_comp,
2502b730f8bSJeremy L Thompson                                                  CeedInt comp_stride, CeedSize l_size, CeedMemType mem_type, CeedCopyMode copy_mode,
251ec3da8bcSJed Brown                                                  const CeedInt *offsets, CeedElemRestriction *rstr);
252e7f679fcSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionCreateBlockedOriented(Ceed ceed, CeedInt num_elem, CeedInt elem_size, CeedInt block_size, CeedInt num_comp,
25377d1c127SSebastian Grimberg                                                          CeedInt comp_stride, CeedSize l_size, CeedMemType mem_type, CeedCopyMode copy_mode,
25477d1c127SSebastian Grimberg                                                          const CeedInt *offsets, const bool *orients, CeedElemRestriction *rstr);
255e7f679fcSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionCreateBlockedCurlOriented(Ceed ceed, CeedInt num_elem, CeedInt elem_size, CeedInt block_size, CeedInt num_comp,
25677d1c127SSebastian Grimberg                                                              CeedInt comp_stride, CeedSize l_size, CeedMemType mem_type, CeedCopyMode copy_mode,
2570c73c039SSebastian Grimberg                                                              const CeedInt *offsets, const CeedInt8 *curl_orients, CeedElemRestriction *rstr);
258e7f679fcSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionCreateBlockedStrided(Ceed ceed, CeedInt num_elem, CeedInt elem_size, CeedInt block_size, CeedInt num_comp,
259e79b91d9SJeremy L Thompson                                                         CeedSize l_size, const CeedInt strides[3], CeedElemRestriction *rstr);
260c17ec2beSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionCreateUnsignedCopy(CeedElemRestriction rstr, CeedElemRestriction *rstr_unsigned);
2617c1dbaffSSebastian Grimberg CEED_EXTERN int CeedElemRestrictionCreateUnorientedCopy(CeedElemRestriction rstr, CeedElemRestriction *rstr_unoriented);
2622b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionReferenceCopy(CeedElemRestriction rstr, CeedElemRestriction *rstr_copy);
2632b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionCreateVector(CeedElemRestriction rstr, CeedVector *lvec, CeedVector *evec);
2642b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionApply(CeedElemRestriction rstr, CeedTransposeMode t_mode, CeedVector u, CeedVector ru, CeedRequest *request);
26505fa913cSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionApplyAtPointsInElement(CeedElemRestriction rstr, CeedInt elem, CeedTransposeMode t_mode, CeedVector u,
26605fa913cSJeremy L Thompson                                                           CeedVector ru, CeedRequest *request);
2672b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionApplyBlock(CeedElemRestriction rstr, CeedInt block, CeedTransposeMode t_mode, CeedVector u, CeedVector ru,
268ec3da8bcSJed Brown                                               CeedRequest *request);
2692b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetCeed(CeedElemRestriction rstr, Ceed *ceed);
2702b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetCompStride(CeedElemRestriction rstr, CeedInt *comp_stride);
2712b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetNumElements(CeedElemRestriction rstr, CeedInt *num_elem);
2722b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetElementSize(CeedElemRestriction rstr, CeedInt *elem_size);
273*07d5dec1SJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetNumPoints(CeedElemRestriction rstr, CeedInt *num_points);
274*07d5dec1SJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetNumPointsInElement(CeedElemRestriction rstr, CeedInt elem, CeedInt *num_points);
2753ac8f562SJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetMaxPointsInElement(CeedElemRestriction rstr, CeedInt *max_points);
2762b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetLVectorSize(CeedElemRestriction rstr, CeedSize *l_size);
2772b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetNumComponents(CeedElemRestriction rstr, CeedInt *num_comp);
278e7f679fcSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetNumBlocks(CeedElemRestriction rstr, CeedInt *num_block);
279e7f679fcSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetBlockSize(CeedElemRestriction rstr, CeedInt *block_size);
2802b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetMultiplicity(CeedElemRestriction rstr, CeedVector mult);
281ec3da8bcSJed Brown CEED_EXTERN int CeedElemRestrictionView(CeedElemRestriction rstr, FILE *stream);
282ec3da8bcSJed Brown CEED_EXTERN int CeedElemRestrictionDestroy(CeedElemRestriction *rstr);
283ec3da8bcSJed Brown 
284ec3da8bcSJed Brown // The formalism here is that we have the structure
285ec3da8bcSJed Brown //  \int_\Omega v^T f_0(u, \nabla u, qdata) + (\nabla v)^T f_1(u, \nabla u, qdata)
286ec3da8bcSJed Brown // where gradients are with respect to the reference element.
287ec3da8bcSJed Brown 
2882b730f8bSJeremy L Thompson CEED_EXTERN int CeedBasisCreateTensorH1Lagrange(Ceed ceed, CeedInt dim, CeedInt num_comp, CeedInt P, CeedInt Q, CeedQuadMode quad_mode,
289ec3da8bcSJed Brown                                                 CeedBasis *basis);
2902b730f8bSJeremy L Thompson CEED_EXTERN int CeedBasisCreateTensorH1(Ceed ceed, CeedInt dim, CeedInt num_comp, CeedInt P_1d, CeedInt Q_1d, const CeedScalar *interp_1d,
2912b730f8bSJeremy L Thompson                                         const CeedScalar *grad_1d, const CeedScalar *q_ref_1d, const CeedScalar *q_weight_1d, CeedBasis *basis);
2922b730f8bSJeremy L Thompson CEED_EXTERN int CeedBasisCreateH1(Ceed ceed, CeedElemTopology topo, CeedInt num_comp, CeedInt num_nodes, CeedInt nqpts, const CeedScalar *interp,
2932b730f8bSJeremy L Thompson                                   const CeedScalar *grad, const CeedScalar *q_ref, const CeedScalar *q_weights, CeedBasis *basis);
2942b730f8bSJeremy L Thompson CEED_EXTERN int CeedBasisCreateHdiv(Ceed ceed, CeedElemTopology topo, CeedInt num_comp, CeedInt num_nodes, CeedInt nqpts, const CeedScalar *interp,
2952b730f8bSJeremy L Thompson                                     const CeedScalar *div, const CeedScalar *q_ref, const CeedScalar *q_weights, CeedBasis *basis);
296c4e3f59bSSebastian Grimberg CEED_EXTERN int CeedBasisCreateHcurl(Ceed ceed, CeedElemTopology topo, CeedInt num_comp, CeedInt num_nodes, CeedInt nqpts, const CeedScalar *interp,
297c4e3f59bSSebastian Grimberg                                      const CeedScalar *curl, const CeedScalar *q_ref, const CeedScalar *q_weights, CeedBasis *basis);
298446e7af4SJeremy L Thompson CEED_EXTERN int CeedBasisCreateProjection(CeedBasis basis_from, CeedBasis basis_to, CeedBasis *basis_project);
2999560d06aSjeremylt CEED_EXTERN int CeedBasisReferenceCopy(CeedBasis basis, CeedBasis *basis_copy);
300ec3da8bcSJed Brown CEED_EXTERN int CeedBasisView(CeedBasis basis, FILE *stream);
3012b730f8bSJeremy L Thompson CEED_EXTERN int CeedBasisApply(CeedBasis basis, CeedInt num_elem, CeedTransposeMode t_mode, CeedEvalMode eval_mode, CeedVector u, CeedVector v);
302c8c3fa7dSJeremy L Thompson CEED_EXTERN int CeedBasisApplyAtPoints(CeedBasis basis, CeedInt num_points, CeedTransposeMode t_mode, CeedEvalMode eval_mode, CeedVector x_ref,
303c8c3fa7dSJeremy L Thompson                                        CeedVector u, CeedVector v);
304b7c9bbdaSJeremy L Thompson CEED_EXTERN int CeedBasisGetCeed(CeedBasis basis, Ceed *ceed);
305ec3da8bcSJed Brown CEED_EXTERN int CeedBasisGetDimension(CeedBasis basis, CeedInt *dim);
306ec3da8bcSJed Brown CEED_EXTERN int CeedBasisGetTopology(CeedBasis basis, CeedElemTopology *topo);
307d1d35e2fSjeremylt CEED_EXTERN int CeedBasisGetNumComponents(CeedBasis basis, CeedInt *num_comp);
308ec3da8bcSJed Brown CEED_EXTERN int CeedBasisGetNumNodes(CeedBasis basis, CeedInt *P);
309d1d35e2fSjeremylt CEED_EXTERN int CeedBasisGetNumNodes1D(CeedBasis basis, CeedInt *P_1d);
310ec3da8bcSJed Brown CEED_EXTERN int CeedBasisGetNumQuadraturePoints(CeedBasis basis, CeedInt *Q);
3112b730f8bSJeremy L Thompson CEED_EXTERN int CeedBasisGetNumQuadraturePoints1D(CeedBasis basis, CeedInt *Q_1d);
312d1d35e2fSjeremylt CEED_EXTERN int CeedBasisGetQRef(CeedBasis basis, const CeedScalar **q_ref);
3132b730f8bSJeremy L Thompson CEED_EXTERN int CeedBasisGetQWeights(CeedBasis basis, const CeedScalar **q_weights);
314ec3da8bcSJed Brown CEED_EXTERN int CeedBasisGetInterp(CeedBasis basis, const CeedScalar **interp);
3152b730f8bSJeremy L Thompson CEED_EXTERN int CeedBasisGetInterp1D(CeedBasis basis, const CeedScalar **interp_1d);
316ec3da8bcSJed Brown CEED_EXTERN int CeedBasisGetGrad(CeedBasis basis, const CeedScalar **grad);
317d1d35e2fSjeremylt CEED_EXTERN int CeedBasisGetGrad1D(CeedBasis basis, const CeedScalar **grad_1d);
31850c301a5SRezgar Shakeri CEED_EXTERN int CeedBasisGetDiv(CeedBasis basis, const CeedScalar **div);
319c4e3f59bSSebastian Grimberg CEED_EXTERN int CeedBasisGetCurl(CeedBasis basis, const CeedScalar **curl);
320ec3da8bcSJed Brown CEED_EXTERN int CeedBasisDestroy(CeedBasis *basis);
321ec3da8bcSJed Brown 
3222b730f8bSJeremy L Thompson CEED_EXTERN int CeedGaussQuadrature(CeedInt Q, CeedScalar *q_ref_1d, CeedScalar *q_weight_1d);
3232b730f8bSJeremy L Thompson CEED_EXTERN int CeedLobattoQuadrature(CeedInt Q, CeedScalar *q_ref_1d, CeedScalar *q_weight_1d);
324ec3da8bcSJed Brown 
325cdf32b93SJeremy L Thompson /** Handle for the user provided CeedQFunction callback function
326ec3da8bcSJed Brown 
327cdf32b93SJeremy L Thompson  @param[in,out] ctx  User-defined context set using CeedQFunctionSetContext() or NULL
328cdf32b93SJeremy L Thompson  @param[in] Q        Number of quadrature points at which to evaluate
329ea61e9acSJeremy L Thompson  @param[in] in       Array of pointers to each input argument in the order provided by the user in CeedQFunctionAddInput().
330ea61e9acSJeremy 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
331ea61e9acSJeremy 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
332d1d35e2fSjeremylt quadrature point `j` as `in[i][(d*num_comp + c)*Q + j]`.
333ea61e9acSJeremy L Thompson  @param[out]   out   Array of pointers to each output array in the order provided using CeedQFunctionAddOutput().
334ea61e9acSJeremy L Thompson                        The shapes are as above for \a in.
335ec3da8bcSJed Brown 
336ec3da8bcSJed Brown  @return An error code: 0 - success, otherwise - failure
337ec3da8bcSJed Brown 
338ec3da8bcSJed Brown  @ingroup CeedQFunction
339ec3da8bcSJed Brown **/
3402b730f8bSJeremy L Thompson typedef int (*CeedQFunctionUser)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out);
341ec3da8bcSJed Brown 
3422b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionCreateInterior(Ceed ceed, CeedInt vec_length, CeedQFunctionUser f, const char *source, CeedQFunction *qf);
3432b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionCreateInteriorByName(Ceed ceed, const char *name, CeedQFunction *qf);
3442b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionCreateIdentity(Ceed ceed, CeedInt size, CeedEvalMode in_mode, CeedEvalMode out_mode, CeedQFunction *qf);
3459560d06aSjeremylt CEED_EXTERN int CeedQFunctionReferenceCopy(CeedQFunction qf, CeedQFunction *qf_copy);
3462b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionAddInput(CeedQFunction qf, const char *field_name, CeedInt size, CeedEvalMode eval_mode);
3472b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionAddOutput(CeedQFunction qf, const char *field_name, CeedInt size, CeedEvalMode eval_mode);
3482b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionGetFields(CeedQFunction qf, CeedInt *num_input_fields, CeedQFunctionField **input_fields, CeedInt *num_output_fields,
34943bbe138SJeremy L Thompson                                        CeedQFunctionField **output_fields);
3502b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionSetContext(CeedQFunction qf, CeedQFunctionContext ctx);
351441428dfSJeremy L Thompson CEED_EXTERN int CeedQFunctionSetContextWritable(CeedQFunction qf, bool is_writable);
3529d36ca50SJeremy L Thompson CEED_EXTERN int CeedQFunctionSetUserFlopsEstimate(CeedQFunction qf, CeedSize flops);
353ec3da8bcSJed Brown CEED_EXTERN int CeedQFunctionView(CeedQFunction qf, FILE *stream);
354b7c9bbdaSJeremy L Thompson CEED_EXTERN int CeedQFunctionGetCeed(CeedQFunction qf, Ceed *ceed);
3552b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionApply(CeedQFunction qf, CeedInt Q, CeedVector *u, CeedVector *v);
356ec3da8bcSJed Brown CEED_EXTERN int CeedQFunctionDestroy(CeedQFunction *qf);
357ec3da8bcSJed Brown 
3582b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionFieldGetName(CeedQFunctionField qf_field, char **field_name);
3592b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionFieldGetSize(CeedQFunctionField qf_field, CeedInt *size);
3602b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionFieldGetEvalMode(CeedQFunctionField qf_field, CeedEvalMode *eval_mode);
36143bbe138SJeremy L Thompson 
3622790b72bSJeremy L Thompson /** Handle for the user provided CeedQFunctionContextDataDestroy callback function
3632790b72bSJeremy L Thompson 
3642790b72bSJeremy L Thompson  @param[in,out] data  User-CeedQFunctionContext data
3652790b72bSJeremy L Thompson 
3662790b72bSJeremy L Thompson  @return An error code: 0 - success, otherwise - failure
3672790b72bSJeremy L Thompson 
3682790b72bSJeremy L Thompson  @ingroup CeedQFunction
3692790b72bSJeremy L Thompson **/
3702790b72bSJeremy L Thompson typedef int (*CeedQFunctionContextDataDestroyUser)(void *data);
3712790b72bSJeremy L Thompson 
3722b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextCreate(Ceed ceed, CeedQFunctionContext *ctx);
3732b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextReferenceCopy(CeedQFunctionContext ctx, CeedQFunctionContext *ctx_copy);
3742b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextSetData(CeedQFunctionContext ctx, CeedMemType mem_type, CeedCopyMode copy_mode, size_t size, void *data);
3752b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextTakeData(CeedQFunctionContext ctx, CeedMemType mem_type, void *data);
3762b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextGetData(CeedQFunctionContext ctx, CeedMemType mem_type, void *data);
3772b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextGetDataRead(CeedQFunctionContext ctx, CeedMemType mem_type, void *data);
3782b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextRestoreData(CeedQFunctionContext ctx, void *data);
3792b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextRestoreDataRead(CeedQFunctionContext ctx, void *data);
3802b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextRegisterDouble(CeedQFunctionContext ctx, const char *field_name, size_t field_offset, size_t num_values,
3817bfe0f0eSJeremy L Thompson                                                    const char *field_description);
3822b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextRegisterInt32(CeedQFunctionContext ctx, const char *field_name, size_t field_offset, size_t num_values,
3837bfe0f0eSJeremy L Thompson                                                   const char *field_description);
3842b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextGetAllFieldLabels(CeedQFunctionContext ctx, const CeedContextFieldLabel **field_labels, CeedInt *num_fields);
3852b730f8bSJeremy L Thompson CEED_EXTERN int CeedContextFieldLabelGetDescription(CeedContextFieldLabel label, const char **field_name, const char **field_description,
3862b730f8bSJeremy L Thompson                                                     size_t *num_values, CeedContextFieldType *field_type);
3872b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextGetContextSize(CeedQFunctionContext ctx, size_t *ctx_size);
3882b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextView(CeedQFunctionContext ctx, FILE *stream);
3892b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextSetDataDestroy(CeedQFunctionContext ctx, CeedMemType f_mem_type, CeedQFunctionContextDataDestroyUser f);
390ec3da8bcSJed Brown CEED_EXTERN int CeedQFunctionContextDestroy(CeedQFunctionContext *ctx);
391ec3da8bcSJed Brown 
3922b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorCreate(Ceed ceed, CeedQFunction qf, CeedQFunction dqf, CeedQFunction dqfT, CeedOperator *op);
393ec3da8bcSJed Brown CEED_EXTERN int CeedCompositeOperatorCreate(Ceed ceed, CeedOperator *op);
3949560d06aSjeremylt CEED_EXTERN int CeedOperatorReferenceCopy(CeedOperator op, CeedOperator *op_copy);
3952b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorSetField(CeedOperator op, const char *field_name, CeedElemRestriction r, CeedBasis b, CeedVector v);
3962b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorGetFields(CeedOperator op, CeedInt *num_input_fields, CeedOperatorField **input_fields, CeedInt *num_output_fields,
39743bbe138SJeremy L Thompson                                       CeedOperatorField **output_fields);
3982b730f8bSJeremy L Thompson CEED_EXTERN int CeedCompositeOperatorAddSub(CeedOperator composite_op, CeedOperator sub_op);
399c6ebc35dSJeremy L Thompson CEED_EXTERN int CeedCompositeOperatorGetNumSub(CeedOperator op, CeedInt *num_suboperators);
400c6ebc35dSJeremy L Thompson CEED_EXTERN int CeedCompositeOperatorGetSubList(CeedOperator op, CeedOperator **sub_operators);
4014db537f9SJeremy L Thompson CEED_EXTERN int CeedOperatorCheckReady(CeedOperator op);
402c9366a6bSJeremy L Thompson CEED_EXTERN int CeedOperatorGetActiveVectorLengths(CeedOperator op, CeedSize *input_size, CeedSize *output_size);
403beecbf24SJeremy L Thompson CEED_EXTERN int CeedOperatorSetQFunctionAssemblyReuse(CeedOperator op, bool reuse_assembly_data);
404beecbf24SJeremy L Thompson CEED_EXTERN int CeedOperatorSetQFunctionAssemblyDataUpdateNeeded(CeedOperator op, bool needs_data_update);
4052b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorLinearAssembleQFunction(CeedOperator op, CeedVector *assembled, CeedElemRestriction *rstr, CeedRequest *request);
4062b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorLinearAssembleQFunctionBuildOrUpdate(CeedOperator op, CeedVector *assembled, CeedElemRestriction *rstr,
4072b730f8bSJeremy L Thompson                                                                  CeedRequest *request);
4082b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorLinearAssembleDiagonal(CeedOperator op, CeedVector assembled, CeedRequest *request);
4092b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorLinearAssembleAddDiagonal(CeedOperator op, CeedVector assembled, CeedRequest *request);
4102b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorLinearAssemblePointBlockDiagonal(CeedOperator op, CeedVector assembled, CeedRequest *request);
4112b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorLinearAssembleAddPointBlockDiagonal(CeedOperator op, CeedVector assembled, CeedRequest *request);
41201f0e615SJames Wright CEED_EXTERN int CeedOperatorLinearAssemblePointBlockDiagonalSymbolic(CeedOperator op, CeedSize *num_entries, CeedInt **rows, CeedInt **cols);
4132b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorLinearAssembleSymbolic(CeedOperator op, CeedSize *num_entries, CeedInt **rows, CeedInt **cols);
414ec3da8bcSJed Brown CEED_EXTERN int CeedOperatorLinearAssemble(CeedOperator op, CeedVector values);
41575f0d5a4SJeremy L Thompson CEED_EXTERN int CeedCompositeOperatorGetMultiplicity(CeedOperator op, CeedInt num_skip_indices, CeedInt *skip_indices, CeedVector mult);
4162b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorMultigridLevelCreate(CeedOperator op_fine, CeedVector p_mult_fine, CeedElemRestriction rstr_coarse,
4172b730f8bSJeremy L Thompson                                                  CeedBasis basis_coarse, CeedOperator *op_coarse, CeedOperator *op_prolong,
4182b730f8bSJeremy L Thompson                                                  CeedOperator *op_restrict);
4192b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorMultigridLevelCreateTensorH1(CeedOperator op_fine, CeedVector p_mult_fine, CeedElemRestriction rstr_coarse,
420d1d35e2fSjeremylt                                                          CeedBasis basis_coarse, const CeedScalar *interp_c_to_f, CeedOperator *op_coarse,
421d1d35e2fSjeremylt                                                          CeedOperator *op_prolong, CeedOperator *op_restrict);
4222b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorMultigridLevelCreateH1(CeedOperator op_fine, CeedVector p_mult_fine, CeedElemRestriction rstr_coarse,
4232b730f8bSJeremy L Thompson                                                    CeedBasis basis_coarse, const CeedScalar *interp_c_to_f, CeedOperator *op_coarse,
424d1d35e2fSjeremylt                                                    CeedOperator *op_prolong, CeedOperator *op_restrict);
4252b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorCreateFDMElementInverse(CeedOperator op, CeedOperator *fdm_inv, CeedRequest *request);
426cd4dfc48Sjeremylt CEED_EXTERN int CeedOperatorSetNumQuadraturePoints(CeedOperator op, CeedInt num_qpts);
427ea6b5821SJeremy L Thompson CEED_EXTERN int CeedOperatorSetName(CeedOperator op, const char *name);
428ec3da8bcSJed Brown CEED_EXTERN int CeedOperatorView(CeedOperator op, FILE *stream);
429b7c9bbdaSJeremy L Thompson CEED_EXTERN int CeedOperatorGetCeed(CeedOperator op, Ceed *ceed);
430b7c9bbdaSJeremy L Thompson CEED_EXTERN int CeedOperatorGetNumElements(CeedOperator op, CeedInt *num_elem);
4312b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorGetNumQuadraturePoints(CeedOperator op, CeedInt *num_qpts);
4329d36ca50SJeremy L Thompson CEED_EXTERN int CeedOperatorGetFlopsEstimate(CeedOperator op, CeedSize *flops);
4330126412dSJeremy L Thompson CEED_EXTERN int CeedOperatorGetContext(CeedOperator op, CeedQFunctionContext *ctx);
43417b0d5c6SJeremy L Thompson CEED_EXTERN int CeedOperatorGetContextFieldLabel(CeedOperator op, const char *field_name, CeedContextFieldLabel *field_label);
43517b0d5c6SJeremy L Thompson CEED_EXTERN int CeedOperatorSetContextDouble(CeedOperator op, CeedContextFieldLabel field_label, double *values);
43617b0d5c6SJeremy L Thompson CEED_EXTERN int CeedOperatorGetContextDoubleRead(CeedOperator op, CeedContextFieldLabel field_label, size_t *num_values, const double **values);
43717b0d5c6SJeremy L Thompson CEED_EXTERN int CeedOperatorRestoreContextDoubleRead(CeedOperator op, CeedContextFieldLabel field_label, const double **values);
43817b0d5c6SJeremy L Thompson CEED_EXTERN int CeedOperatorSetContextInt32(CeedOperator op, CeedContextFieldLabel field_label, int *values);
43917b0d5c6SJeremy L Thompson CEED_EXTERN int CeedOperatorGetContextInt32Read(CeedOperator op, CeedContextFieldLabel field_label, size_t *num_values, const int **values);
44017b0d5c6SJeremy L Thompson CEED_EXTERN int CeedOperatorRestoreContextInt32Read(CeedOperator op, CeedContextFieldLabel field_label, const int **values);
4412b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorApply(CeedOperator op, CeedVector in, CeedVector out, CeedRequest *request);
4422b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorApplyAdd(CeedOperator op, CeedVector in, CeedVector out, CeedRequest *request);
443ec3da8bcSJed Brown CEED_EXTERN int CeedOperatorDestroy(CeedOperator *op);
444ec3da8bcSJed Brown 
445de5900adSJames Wright CEED_EXTERN int CeedOperatorGetFieldByName(CeedOperator op, const char *field_name, CeedOperatorField *op_field);
4462b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorFieldGetName(CeedOperatorField op_field, char **field_name);
4472b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorFieldGetElemRestriction(CeedOperatorField op_field, CeedElemRestriction *rstr);
4482b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorFieldGetBasis(CeedOperatorField op_field, CeedBasis *basis);
4492b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorFieldGetVector(CeedOperatorField op_field, CeedVector *vec);
45043bbe138SJeremy L Thompson 
451ec3da8bcSJed Brown /**
452ec3da8bcSJed Brown   @brief Return integer power
453ec3da8bcSJed Brown 
454ec3da8bcSJed Brown   @param[in] base  The base to exponentiate
455ec3da8bcSJed Brown   @param[in] power The power to raise the base to
456ec3da8bcSJed Brown 
457ec3da8bcSJed Brown   @return base^power
458ec3da8bcSJed Brown 
459ec3da8bcSJed Brown   @ref Utility
460ec3da8bcSJed Brown **/
461ec3da8bcSJed Brown static inline CeedInt CeedIntPow(CeedInt base, CeedInt power) {
462ec3da8bcSJed Brown   CeedInt result = 1;
463ec3da8bcSJed Brown   while (power) {
464ec3da8bcSJed Brown     if (power & 1) result *= base;
465ec3da8bcSJed Brown     power >>= 1;
466ec3da8bcSJed Brown     base *= base;
467ec3da8bcSJed Brown   }
468ec3da8bcSJed Brown   return result;
469ec3da8bcSJed Brown }
470ec3da8bcSJed Brown 
471ec3da8bcSJed Brown /**
472ec3da8bcSJed Brown   @brief Return minimum of two integers
473ec3da8bcSJed Brown 
474ec3da8bcSJed Brown   @param[in] a The first integer to compare
475ec3da8bcSJed Brown   @param[in] b The second integer to compare
476ec3da8bcSJed Brown 
477ec3da8bcSJed Brown   @return The minimum of the two integers
478ec3da8bcSJed Brown 
479ec3da8bcSJed Brown   @ref Utility
480ec3da8bcSJed Brown **/
481ec3da8bcSJed Brown static inline CeedInt CeedIntMin(CeedInt a, CeedInt b) { return a < b ? a : b; }
482ec3da8bcSJed Brown 
483ec3da8bcSJed Brown /**
484ec3da8bcSJed Brown   @brief Return maximum of two integers
485ec3da8bcSJed Brown 
486ec3da8bcSJed Brown   @param[in] a The first integer to compare
487ec3da8bcSJed Brown   @param[in] b The second integer to compare
488ec3da8bcSJed Brown 
489ec3da8bcSJed Brown   @return The maximum of the two integers
490ec3da8bcSJed Brown 
491ec3da8bcSJed Brown   @ref Utility
492ec3da8bcSJed Brown **/
493ec3da8bcSJed Brown static inline CeedInt CeedIntMax(CeedInt a, CeedInt b) { return a > b ? a : b; }
494ec3da8bcSJed Brown 
495ec3da8bcSJed Brown // Used to ensure initialization before CeedInit()
496ec3da8bcSJed Brown CEED_EXTERN int CeedRegisterAll(void);
497ec3da8bcSJed Brown // Used to ensure initialization before CeedQFunctionCreate*()
498ec3da8bcSJed Brown CEED_EXTERN int CeedQFunctionRegisterAll(void);
499ec3da8bcSJed Brown 
50094b7b29bSJeremy L Thompson #endif  // CEED_H
501