xref: /libCEED/rust/libceed-sys/c-src/include/ceed/ceed.h (revision 2b730f8b5a9c809740a0b3b302db43a719c636b1)
1ec3da8bcSJed Brown /// Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at
2ec3da8bcSJed Brown /// the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights
3ec3da8bcSJed Brown /// reserved. See files LICENSE and NOTICE for details.
4ec3da8bcSJed Brown ///
5ec3da8bcSJed Brown /// This file is part of CEED, a collection of benchmarks, miniapps, software
6ec3da8bcSJed Brown /// libraries and APIs for efficient high-order finite element and spectral
7ec3da8bcSJed Brown /// element discretizations for exascale applications. For more information and
83d8e8822SJeremy L Thompson /// source code availability see http://github.com/ceed
9ec3da8bcSJed Brown ///
10ec3da8bcSJed Brown /// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC,
11ec3da8bcSJed Brown /// a collaborative effort of two U.S. Department of Energy organizations (Office
12ec3da8bcSJed Brown /// of Science and the National Nuclear Security Administration) responsible for
13ec3da8bcSJed Brown /// the planning and preparation of a capable exascale ecosystem, including
14ec3da8bcSJed Brown /// software, applications, hardware, advanced system engineering and early
15ec3da8bcSJed Brown /// testbed platforms, in support of the nation's exascale computing imperative.
16ec3da8bcSJed Brown 
17ec3da8bcSJed Brown /// @file
18ec3da8bcSJed Brown /// Public header for user and utility components of libCEED
19ec3da8bcSJed Brown #ifndef _ceed_h
20ec3da8bcSJed Brown #define _ceed_h
21ec3da8bcSJed Brown 
22ec3da8bcSJed Brown /// @defgroup Ceed Ceed: core components
23ec3da8bcSJed Brown /// @defgroup CeedVector CeedVector: storing and manipulating vectors
24ec3da8bcSJed Brown /// @defgroup CeedElemRestriction CeedElemRestriction: restriction from local vectors to elements
25ec3da8bcSJed Brown /// @defgroup CeedBasis CeedBasis: fully discrete finite element-like objects
26ec3da8bcSJed Brown /// @defgroup CeedQFunction CeedQFunction: independent operations at quadrature points
27ec3da8bcSJed Brown /// @defgroup CeedOperator CeedOperator: composed FE-type operations on vectors
28ec3da8bcSJed Brown ///
29ec3da8bcSJed Brown /// @page FunctionCategories libCEED: Types of Functions
30ec3da8bcSJed Brown ///    libCEED provides three different header files depending upon the type of
31ec3da8bcSJed Brown ///    functions a user requires.
32ec3da8bcSJed Brown /// @section Utility Utility Functions
33ec3da8bcSJed Brown ///    These functions are intended general utilities that may be useful to
34ec3da8bcSJed Brown ///    libCEED developers and users. These functions can generally be found in
35ec3da8bcSJed Brown ///    "ceed.h".
36ec3da8bcSJed Brown /// @section User User Functions
37ec3da8bcSJed Brown ///    These functions are intended to be used by general users of libCEED
38ec3da8bcSJed Brown ///    and can generally be found in "ceed.h".
39e9b533fbSJeremy L Thompson /// @section Advanced Advanced Functions
40e9b533fbSJeremy L Thompson ///    These functions are intended to be used by advanced users of libCEED
41e9b533fbSJeremy L Thompson ///    and can generally be found in "ceed.h".
42ec3da8bcSJed Brown /// @section Backend Backend Developer Functions
43ec3da8bcSJed Brown ///    These functions are intended to be used by backend developers of
44ec3da8bcSJed Brown ///    libCEED and can generally be found in "ceed-backend.h".
45ec3da8bcSJed Brown /// @section Developer Library Developer Functions
46ec3da8bcSJed Brown ///    These functions are intended to be used by library developers of
47ec3da8bcSJed Brown ///    libCEED and can generally be found in "ceed-impl.h".
48ec3da8bcSJed Brown 
493b271f31SJed Brown #if !defined(CEED_SKIP_VISIBILITY)
503b271f31SJed Brown #define CEED_VISIBILITY(mode) __attribute__((visibility(#mode)))
513b271f31SJed Brown #else
523b271f31SJed Brown #define CEED_VISIBILITY(mode)
533b271f31SJed Brown #endif
543b271f31SJed Brown 
55ec3da8bcSJed Brown /**
56ec3da8bcSJed Brown   CEED_EXTERN is used in this header to denote all publicly visible symbols.
57ec3da8bcSJed Brown 
58ec3da8bcSJed Brown   No other file should declare publicly visible symbols, thus it should never be
59ec3da8bcSJed Brown   used outside ceed.h.
60ec3da8bcSJed Brown  */
61*2b730f8bSJeremy L Thompson #if defined(__clang_analyzer__)
62*2b730f8bSJeremy L Thompson #define CEED_EXTERN extern
63*2b730f8bSJeremy L Thompson #elif defined(__cplusplus)
643b271f31SJed Brown #define CEED_EXTERN extern "C" CEED_VISIBILITY(default)
65ec3da8bcSJed Brown #else
663b271f31SJed Brown #define CEED_EXTERN extern CEED_VISIBILITY(default)
67ec3da8bcSJed Brown #endif
68ec3da8bcSJed Brown 
69ec3da8bcSJed Brown #include <stdarg.h>
70ec3da8bcSJed Brown #include <stdbool.h>
713047f789SJeremy L Thompson #include <stdio.h>
72ec3da8bcSJed Brown 
73c9c2c079SJeremy L Thompson /// Typedefs and macros used in public interfaces and user QFunction source
74c9c2c079SJeremy L Thompson #include "types.h"
75ec3da8bcSJed Brown 
76ec3da8bcSJed Brown /// Library context created by CeedInit()
77ec3da8bcSJed Brown /// @ingroup CeedUser
78ec3da8bcSJed Brown typedef struct Ceed_private *Ceed;
79ec3da8bcSJed Brown /// Non-blocking Ceed interfaces return a CeedRequest.
80ec3da8bcSJed Brown /// To perform an operation immediately, pass \ref CEED_REQUEST_IMMEDIATE instead.
81ec3da8bcSJed Brown /// @ingroup CeedUser
82ec3da8bcSJed Brown typedef struct CeedRequest_private *CeedRequest;
83ec3da8bcSJed Brown /// Handle for vectors over the field \ref CeedScalar
84ec3da8bcSJed Brown /// @ingroup CeedVectorUser
85ec3da8bcSJed Brown typedef struct CeedVector_private *CeedVector;
86ec3da8bcSJed Brown /// Handle for object describing restriction to elements
87ec3da8bcSJed Brown /// @ingroup CeedElemRestrictionUser
88ec3da8bcSJed Brown typedef struct CeedElemRestriction_private *CeedElemRestriction;
89ec3da8bcSJed Brown /// Handle for object describing discrete finite element evaluations
90ec3da8bcSJed Brown /// @ingroup CeedBasisUser
91ec3da8bcSJed Brown typedef struct CeedBasis_private *CeedBasis;
9243bbe138SJeremy L Thompson /// Handle for object describing CeedQFunction fields
9343bbe138SJeremy L Thompson /// @ingroup CeedQFunctionBackend
9443bbe138SJeremy L Thompson typedef struct CeedQFunctionField_private *CeedQFunctionField;
95ec3da8bcSJed Brown /// Handle for object describing functions evaluated independently at quadrature points
96ec3da8bcSJed Brown /// @ingroup CeedQFunctionUser
97ec3da8bcSJed Brown typedef struct CeedQFunction_private *CeedQFunction;
9843bbe138SJeremy L Thompson /// Handle for object describing CeedOperator fields
9943bbe138SJeremy L Thompson /// @ingroup CeedOperatorBackend
10043bbe138SJeremy L Thompson typedef struct CeedOperatorField_private *CeedOperatorField;
101ec3da8bcSJed Brown /// Handle for object describing context data for CeedQFunctions
102ec3da8bcSJed Brown /// @ingroup CeedQFunctionUser
103ec3da8bcSJed Brown typedef struct CeedQFunctionContext_private *CeedQFunctionContext;
1043668ca4bSJeremy L Thompson /// Handle for object describing registered fields for CeedQFunctionContext
1053668ca4bSJeremy L Thompson /// @ingroup CeedQFunctionUser
1063668ca4bSJeremy L Thompson typedef struct CeedContextFieldLabel_private *CeedContextFieldLabel;
107ec3da8bcSJed Brown /// Handle for object describing FE-type operators acting on vectors
108ec3da8bcSJed Brown ///
109ec3da8bcSJed Brown /// Given an element restriction \f$E\f$, basis evaluator \f$B\f$, and
110ec3da8bcSJed Brown ///   quadrature function\f$f\f$, a CeedOperator expresses operations of the form
111ec3da8bcSJed Brown ///   $$ E^T B^T f(B E u) $$
112ec3da8bcSJed Brown ///   acting on the vector \f$u\f$.
113ec3da8bcSJed Brown /// @ingroup CeedOperatorUser
114ec3da8bcSJed Brown typedef struct CeedOperator_private *CeedOperator;
115ec3da8bcSJed Brown 
11622e44211Sjeremylt CEED_EXTERN int CeedRegistryGetList(size_t *n, char ***const resources, CeedInt **array);
117ec3da8bcSJed Brown CEED_EXTERN int CeedInit(const char *resource, Ceed *ceed);
1189560d06aSjeremylt CEED_EXTERN int CeedReferenceCopy(Ceed ceed, Ceed *ceed_copy);
119ec3da8bcSJed Brown CEED_EXTERN int CeedGetResource(Ceed ceed, const char **resource);
120d1d35e2fSjeremylt CEED_EXTERN int CeedIsDeterministic(Ceed ceed, bool *is_deterministic);
121ee5a26f2SJeremy L Thompson CEED_EXTERN int CeedAddJitSourceRoot(Ceed ceed, const char *jit_source_root);
122ec3da8bcSJed Brown CEED_EXTERN int CeedView(Ceed ceed, FILE *stream);
123ec3da8bcSJed Brown CEED_EXTERN int CeedDestroy(Ceed *ceed);
124ec3da8bcSJed Brown 
125*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedErrorImpl(Ceed, const char *, int, const char *, int, const char *, ...);
126ec3da8bcSJed Brown /// Raise an error on ceed object
127ec3da8bcSJed Brown ///
128ec3da8bcSJed Brown /// @param ceed Ceed library context or NULL
129ec3da8bcSJed Brown /// @param ecode Error code (int)
130ec3da8bcSJed Brown /// @param ... printf-style format string followed by arguments as needed
131ec3da8bcSJed Brown ///
132ec3da8bcSJed Brown /// @ingroup Ceed
133ec3da8bcSJed Brown /// @sa CeedSetErrorHandler()
134ec3da8bcSJed Brown #if defined(__clang__)
135ec3da8bcSJed Brown /// Use nonstandard ternary to convince the compiler/clang-tidy that this
136ec3da8bcSJed Brown /// function never returns zero.
137*2b730f8bSJeremy L Thompson #define CeedError(ceed, ecode, ...) (CeedErrorImpl((ceed), __FILE__, __LINE__, __func__, (ecode), __VA_ARGS__), (ecode))
138ec3da8bcSJed Brown #else
139*2b730f8bSJeremy L Thompson #define CeedError(ceed, ecode, ...) CeedErrorImpl((ceed), __FILE__, __LINE__, __func__, (ecode), __VA_ARGS__) ?: (ecode)
140ec3da8bcSJed Brown #endif
141ec3da8bcSJed Brown 
142ec3da8bcSJed Brown /// Ceed error handlers
143*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedErrorReturn(Ceed, const char *, int, const char *, int, const char *, va_list *);
144*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedErrorStore(Ceed, const char *, int, const char *, int, const char *, va_list *);
145*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedErrorAbort(Ceed, const char *, int, const char *, int, const char *, va_list *);
146*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedErrorExit(Ceed, const char *, int, const char *, int, const char *, va_list *);
147*2b730f8bSJeremy L Thompson typedef int (*CeedErrorHandler)(Ceed, const char *, int, const char *, int, const char *, va_list *);
148ec3da8bcSJed Brown CEED_EXTERN int CeedSetErrorHandler(Ceed ceed, CeedErrorHandler eh);
149d1d35e2fSjeremylt CEED_EXTERN int CeedGetErrorMessage(Ceed, const char **err_msg);
150d1d35e2fSjeremylt CEED_EXTERN int CeedResetErrorMessage(Ceed, const char **err_msg);
151ec3da8bcSJed Brown 
152ec3da8bcSJed Brown /// libCEED library version numbering
153ec3da8bcSJed Brown /// @ingroup Ceed
154ec3da8bcSJed Brown #define CEED_VERSION_MAJOR 0
155667e613fSJeremy L Thompson #define CEED_VERSION_MINOR 10
156f374d6a3SJeremy L Thompson #define CEED_VERSION_PATCH 1
15738faa2d6SJeremy L Thompson #define CEED_VERSION_RELEASE false
158ec3da8bcSJed Brown 
159ec3da8bcSJed Brown /// Compile-time check that the the current library version is at least as
160ec3da8bcSJed Brown /// recent as the specified version. This macro is typically used in
161ec3da8bcSJed Brown /// @code
162ec3da8bcSJed Brown /// #if CEED_VERSION_GE(0, 8, 0)
163ec3da8bcSJed Brown ///   code path that needs at least 0.8.0
164ec3da8bcSJed Brown /// #else
165ec3da8bcSJed Brown ///   fallback code for older versions
166ec3da8bcSJed Brown /// #endif
167ec3da8bcSJed Brown /// @endcode
168ec3da8bcSJed Brown ///
169ec3da8bcSJed Brown /// A non-release version always compares as positive infinity.
170ec3da8bcSJed Brown ///
171ec3da8bcSJed Brown /// @param major   Major version
172ec3da8bcSJed Brown /// @param minor   Minor version
173ec3da8bcSJed Brown /// @param patch   Patch (subminor) version
174ec3da8bcSJed Brown ///
175ec3da8bcSJed Brown /// @ingroup Ceed
176ec3da8bcSJed Brown /// @sa CeedGetVersion()
177ec3da8bcSJed Brown #define CEED_VERSION_GE(major, minor, patch) \
178ec3da8bcSJed Brown   (!CEED_VERSION_RELEASE ||                  \
179ec3da8bcSJed Brown    (CEED_VERSION_MAJOR > major ||            \
180*2b730f8bSJeremy L Thompson     (CEED_VERSION_MAJOR == major && (CEED_VERSION_MINOR > minor || (CEED_VERSION_MINOR == minor && CEED_VERSION_PATCH >= patch)))))
181ec3da8bcSJed Brown 
182*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedGetVersion(int *major, int *minor, int *patch, bool *release);
183ec3da8bcSJed Brown 
18480a9ef05SNatalie Beams CEED_EXTERN int CeedGetScalarType(CeedScalarType *scalar_type);
18580a9ef05SNatalie Beams 
186ec3da8bcSJed Brown CEED_EXTERN const char *const *CeedErrorTypes;
187ec3da8bcSJed Brown 
188ec3da8bcSJed Brown /// Specify memory type
189ec3da8bcSJed Brown ///
190ec3da8bcSJed Brown /// Many Ceed interfaces take or return pointers to memory.  This enum is used to
191ec3da8bcSJed Brown /// specify where the memory being provided or requested must reside.
192ec3da8bcSJed Brown /// @ingroup Ceed
193ec3da8bcSJed Brown typedef enum {
194ec3da8bcSJed Brown   /// Memory resides on the host
195ec3da8bcSJed Brown   CEED_MEM_HOST,
196ec3da8bcSJed Brown   /// Memory resides on a device (corresponding to \ref Ceed resource)
197ec3da8bcSJed Brown   CEED_MEM_DEVICE,
198ec3da8bcSJed Brown } CeedMemType;
199ec3da8bcSJed Brown CEED_EXTERN const char *const CeedMemTypes[];
200ec3da8bcSJed Brown 
201ec3da8bcSJed Brown CEED_EXTERN int CeedGetPreferredMemType(Ceed ceed, CeedMemType *type);
202ec3da8bcSJed Brown 
203ec3da8bcSJed Brown /// Conveys ownership status of arrays passed to Ceed interfaces.
204ec3da8bcSJed Brown /// @ingroup Ceed
205ec3da8bcSJed Brown typedef enum {
206ec3da8bcSJed Brown   /// Implementation will copy the values and not store the passed pointer.
207ec3da8bcSJed Brown   CEED_COPY_VALUES,
208ec3da8bcSJed Brown   /// Implementation can use and modify the data provided by the user, but does
209ec3da8bcSJed Brown   /// not take ownership.
210ec3da8bcSJed Brown   CEED_USE_POINTER,
211ec3da8bcSJed Brown   /// Implementation takes ownership of the pointer and will free using
212ec3da8bcSJed Brown   /// CeedFree() when done using it.  The user should not assume that the
213ec3da8bcSJed Brown   /// pointer remains valid after ownership has been transferred.  Note that
214ec3da8bcSJed Brown   /// arrays allocated using C++ operator new or other allocators cannot
215ec3da8bcSJed Brown   /// generally be freed using CeedFree().  CeedFree() is capable of freeing any
216ec3da8bcSJed Brown   /// memory that can be freed using free(3).
217ec3da8bcSJed Brown   CEED_OWN_POINTER,
218ec3da8bcSJed Brown } CeedCopyMode;
219cdf32b93SJeremy L Thompson CEED_EXTERN const char *const CeedCopyModes[];
220ec3da8bcSJed Brown 
221ec3da8bcSJed Brown /// Denotes type of vector norm to be computed
222ec3da8bcSJed Brown /// @ingroup CeedVector
223ec3da8bcSJed Brown typedef enum {
224ec3da8bcSJed Brown   /// L_1 norm: sum_i |x_i|
225ec3da8bcSJed Brown   CEED_NORM_1,
226ec3da8bcSJed Brown   /// L_2 norm: sqrt(sum_i |x_i|^2)
227ec3da8bcSJed Brown   CEED_NORM_2,
228ec3da8bcSJed Brown   /// L_Infinity norm: max_i |x_i|
229ec3da8bcSJed Brown   CEED_NORM_MAX,
230ec3da8bcSJed Brown } CeedNormType;
231ec3da8bcSJed Brown 
2321f9221feSJeremy L Thompson CEED_EXTERN int CeedVectorCreate(Ceed ceed, CeedSize len, CeedVector *vec);
2339560d06aSjeremylt CEED_EXTERN int CeedVectorReferenceCopy(CeedVector vec, CeedVector *vec_copy);
234*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedVectorSetArray(CeedVector vec, CeedMemType mem_type, CeedCopyMode copy_mode, CeedScalar *array);
235ec3da8bcSJed Brown CEED_EXTERN int CeedVectorSetValue(CeedVector vec, CeedScalar value);
236d1d35e2fSjeremylt CEED_EXTERN int CeedVectorSyncArray(CeedVector vec, CeedMemType mem_type);
237*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedVectorTakeArray(CeedVector vec, CeedMemType mem_type, CeedScalar **array);
238*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedVectorGetArray(CeedVector vec, CeedMemType mem_type, CeedScalar **array);
239*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedVectorGetArrayRead(CeedVector vec, CeedMemType mem_type, const CeedScalar **array);
240*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedVectorGetArrayWrite(CeedVector vec, CeedMemType mem_type, CeedScalar **array);
241ec3da8bcSJed Brown CEED_EXTERN int CeedVectorRestoreArray(CeedVector vec, CeedScalar **array);
242*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedVectorRestoreArrayRead(CeedVector vec, const CeedScalar **array);
243*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedVectorNorm(CeedVector vec, CeedNormType type, CeedScalar *norm);
244e0dd3b27Sjeremylt CEED_EXTERN int CeedVectorScale(CeedVector x, CeedScalar alpha);
2450f7fd0f8Sjeremylt CEED_EXTERN int CeedVectorAXPY(CeedVector y, CeedScalar alpha, CeedVector x);
2460f7fd0f8Sjeremylt CEED_EXTERN int CeedVectorPointwiseMult(CeedVector w, CeedVector x, CeedVector y);
247ec3da8bcSJed Brown CEED_EXTERN int CeedVectorReciprocal(CeedVector vec);
248d1d35e2fSjeremylt CEED_EXTERN int CeedVectorView(CeedVector vec, const char *fp_fmt, FILE *stream);
249b7c9bbdaSJeremy L Thompson CEED_EXTERN int CeedVectorGetCeed(CeedVector vec, Ceed *ceed);
2501f9221feSJeremy L Thompson CEED_EXTERN int CeedVectorGetLength(CeedVector vec, CeedSize *length);
251ec3da8bcSJed Brown CEED_EXTERN int CeedVectorDestroy(CeedVector *vec);
252ec3da8bcSJed Brown 
253ec3da8bcSJed Brown CEED_EXTERN CeedRequest *const CEED_REQUEST_IMMEDIATE;
254ec3da8bcSJed Brown CEED_EXTERN CeedRequest *const CEED_REQUEST_ORDERED;
255ec3da8bcSJed Brown CEED_EXTERN int                CeedRequestWait(CeedRequest *req);
256ec3da8bcSJed Brown 
257ec3da8bcSJed Brown /// Argument for CeedOperatorSetField that vector is collocated with
258151157abSJeremy L Thompson /// quadrature points, only used with CeedEvalMode CEED_EVAL_NONE
259ec3da8bcSJed Brown /// @ingroup CeedBasis
260ec3da8bcSJed Brown CEED_EXTERN const CeedBasis CEED_BASIS_COLLOCATED;
261ec3da8bcSJed Brown 
262ec3da8bcSJed Brown /// Argument for CeedOperatorSetField to use active input or output
263ec3da8bcSJed Brown /// @ingroup CeedVector
264ec3da8bcSJed Brown CEED_EXTERN const CeedVector CEED_VECTOR_ACTIVE;
265ec3da8bcSJed Brown 
266ec3da8bcSJed Brown /// Argument for CeedOperatorSetField to use no vector, used with
267ec3da8bcSJed Brown /// qfunction input with eval mode CEED_EVAL_WEIGHT
268ec3da8bcSJed Brown /// @ingroup CeedVector
269ec3da8bcSJed Brown CEED_EXTERN const CeedVector CEED_VECTOR_NONE;
270ec3da8bcSJed Brown 
271ec3da8bcSJed Brown /// Argument for CeedOperatorSetField to use no ElemRestriction, only used with
272ec3da8bcSJed Brown /// eval mode CEED_EVAL_WEIGHT.
273ec3da8bcSJed Brown /// @ingroup CeedElemRestriction
274ec3da8bcSJed Brown CEED_EXTERN const CeedElemRestriction CEED_ELEMRESTRICTION_NONE;
275ec3da8bcSJed Brown 
276ec3da8bcSJed Brown /// Argument for CeedOperatorCreate that QFunction is not created by user.
277ec3da8bcSJed Brown /// Only used for QFunctions dqf and dqfT. If implemented, a backend may
278ec3da8bcSJed Brown /// attempt to provide the action of these QFunctions.
279ec3da8bcSJed Brown /// @ingroup CeedQFunction
280ec3da8bcSJed Brown CEED_EXTERN const CeedQFunction CEED_QFUNCTION_NONE;
281ec3da8bcSJed Brown 
282ec3da8bcSJed Brown /// Denotes whether a linear transformation or its transpose should be applied
283ec3da8bcSJed Brown /// @ingroup CeedBasis
284ec3da8bcSJed Brown typedef enum {
285ec3da8bcSJed Brown   /// Apply the linear transformation
286ec3da8bcSJed Brown   CEED_NOTRANSPOSE,
287ec3da8bcSJed Brown   /// Apply the transpose
288ec3da8bcSJed Brown   CEED_TRANSPOSE
289ec3da8bcSJed Brown } CeedTransposeMode;
290ec3da8bcSJed Brown CEED_EXTERN const char *const CeedTransposeModes[];
291ec3da8bcSJed Brown 
292ec3da8bcSJed Brown /// Argument for CeedElemRestrictionCreateStrided that L-vector is in
293ec3da8bcSJed Brown /// the Ceed backend's preferred layout. This argument should only be used
294ec3da8bcSJed Brown /// with vectors created by a Ceed backend.
295ec3da8bcSJed Brown /// @ingroup CeedElemRestriction
296ec3da8bcSJed Brown CEED_EXTERN const CeedInt CEED_STRIDES_BACKEND[3];
297ec3da8bcSJed Brown 
298*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionCreate(Ceed ceed, CeedInt num_elem, CeedInt elem_size, CeedInt num_comp, CeedInt comp_stride, CeedSize l_size,
299*2b730f8bSJeremy L Thompson                                           CeedMemType mem_type, CeedCopyMode copy_mode, const CeedInt *offsets, CeedElemRestriction *rstr);
300*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionCreateOriented(Ceed ceed, CeedInt num_elem, CeedInt elem_size, CeedInt num_comp, CeedInt comp_stride,
301*2b730f8bSJeremy L Thompson                                                   CeedSize l_size, CeedMemType mem_type, CeedCopyMode copy_mode, const CeedInt *offsets,
302fc0567d9Srezgarshakeri                                                   const bool *orient, CeedElemRestriction *rstr);
303*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionCreateStrided(Ceed ceed, CeedInt num_elem, CeedInt elem_size, CeedInt num_comp, CeedSize l_size,
304ec3da8bcSJed Brown                                                  const CeedInt strides[3], CeedElemRestriction *rstr);
305*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionCreateBlocked(Ceed ceed, CeedInt num_elem, CeedInt elem_size, CeedInt blk_size, CeedInt num_comp,
306*2b730f8bSJeremy L Thompson                                                  CeedInt comp_stride, CeedSize l_size, CeedMemType mem_type, CeedCopyMode copy_mode,
307ec3da8bcSJed Brown                                                  const CeedInt *offsets, CeedElemRestriction *rstr);
308*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionCreateBlockedStrided(Ceed ceed, CeedInt num_elem, CeedInt elem_size, CeedInt blk_size, CeedInt num_comp,
309e79b91d9SJeremy L Thompson                                                         CeedSize l_size, const CeedInt strides[3], CeedElemRestriction *rstr);
310*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionReferenceCopy(CeedElemRestriction rstr, CeedElemRestriction *rstr_copy);
311*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionCreateVector(CeedElemRestriction rstr, CeedVector *lvec, CeedVector *evec);
312*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionApply(CeedElemRestriction rstr, CeedTransposeMode t_mode, CeedVector u, CeedVector ru, CeedRequest *request);
313*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionApplyBlock(CeedElemRestriction rstr, CeedInt block, CeedTransposeMode t_mode, CeedVector u, CeedVector ru,
314ec3da8bcSJed Brown                                               CeedRequest *request);
315*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetCeed(CeedElemRestriction rstr, Ceed *ceed);
316*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetCompStride(CeedElemRestriction rstr, CeedInt *comp_stride);
317*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetNumElements(CeedElemRestriction rstr, CeedInt *num_elem);
318*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetElementSize(CeedElemRestriction rstr, CeedInt *elem_size);
319*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetLVectorSize(CeedElemRestriction rstr, CeedSize *l_size);
320*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetNumComponents(CeedElemRestriction rstr, CeedInt *num_comp);
321*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetNumBlocks(CeedElemRestriction rstr, CeedInt *num_blk);
322*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetBlockSize(CeedElemRestriction rstr, CeedInt *blk_size);
323*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedElemRestrictionGetMultiplicity(CeedElemRestriction rstr, CeedVector mult);
324ec3da8bcSJed Brown CEED_EXTERN int CeedElemRestrictionView(CeedElemRestriction rstr, FILE *stream);
325ec3da8bcSJed Brown CEED_EXTERN int CeedElemRestrictionDestroy(CeedElemRestriction *rstr);
326ec3da8bcSJed Brown 
327ec3da8bcSJed Brown // The formalism here is that we have the structure
328ec3da8bcSJed Brown //  \int_\Omega v^T f_0(u, \nabla u, qdata) + (\nabla v)^T f_1(u, \nabla u, qdata)
329ec3da8bcSJed Brown // where gradients are with respect to the reference element.
330ec3da8bcSJed Brown 
331ec3da8bcSJed Brown /// Basis evaluation mode
332ec3da8bcSJed Brown ///
333ec3da8bcSJed Brown /// Modes can be bitwise ORed when passing to most functions.
334ec3da8bcSJed Brown /// @ingroup CeedBasis
335ec3da8bcSJed Brown typedef enum {
336ec3da8bcSJed Brown   /// Perform no evaluation (either because there is no data or it is already at
337ec3da8bcSJed Brown   /// quadrature points)
338ec3da8bcSJed Brown   CEED_EVAL_NONE = 0,
339ec3da8bcSJed Brown   /// Interpolate from nodes to quadrature points
340ec3da8bcSJed Brown   CEED_EVAL_INTERP = 1,
341ec3da8bcSJed Brown   /// Evaluate gradients at quadrature points from input in a nodal basis
342ec3da8bcSJed Brown   CEED_EVAL_GRAD = 2,
343ec3da8bcSJed Brown   /// Evaluate divergence at quadrature points from input in a nodal basis
344ec3da8bcSJed Brown   CEED_EVAL_DIV = 4,
345ec3da8bcSJed Brown   /// Evaluate curl at quadrature points from input in a nodal basis
346ec3da8bcSJed Brown   CEED_EVAL_CURL = 8,
347ec3da8bcSJed Brown   /// Using no input, evaluate quadrature weights on the reference element
348ec3da8bcSJed Brown   CEED_EVAL_WEIGHT = 16,
349ec3da8bcSJed Brown } CeedEvalMode;
350ec3da8bcSJed Brown CEED_EXTERN const char *const CeedEvalModes[];
351ec3da8bcSJed Brown 
352ec3da8bcSJed Brown /// Type of quadrature; also used for location of nodes
353ec3da8bcSJed Brown /// @ingroup CeedBasis
354ec3da8bcSJed Brown typedef enum {
355ec3da8bcSJed Brown   /// Gauss-Legendre quadrature
356ec3da8bcSJed Brown   CEED_GAUSS = 0,
357ec3da8bcSJed Brown   /// Gauss-Legendre-Lobatto quadrature
358ec3da8bcSJed Brown   CEED_GAUSS_LOBATTO = 1,
359ec3da8bcSJed Brown } CeedQuadMode;
360ec3da8bcSJed Brown CEED_EXTERN const char *const CeedQuadModes[];
361ec3da8bcSJed Brown 
362ec3da8bcSJed Brown /// Type of basis shape to create non-tensor H1 element basis
363ec3da8bcSJed Brown ///
364ec3da8bcSJed Brown /// Dimension can be extracted with bitwise AND
365ec3da8bcSJed Brown /// (CeedElemTopology & 2**(dim + 2)) == TRUE
366ec3da8bcSJed Brown /// @ingroup CeedBasis
367ec3da8bcSJed Brown typedef enum {
368ec3da8bcSJed Brown   /// Line
36950c301a5SRezgar Shakeri   CEED_TOPOLOGY_LINE = 1 << 16 | 0,
370ec3da8bcSJed Brown   /// Triangle - 2D shape
37150c301a5SRezgar Shakeri   CEED_TOPOLOGY_TRIANGLE = 2 << 16 | 1,
372ec3da8bcSJed Brown   /// Quadralateral - 2D shape
37350c301a5SRezgar Shakeri   CEED_TOPOLOGY_QUAD = 2 << 16 | 2,
374ec3da8bcSJed Brown   /// Tetrahedron - 3D shape
37550c301a5SRezgar Shakeri   CEED_TOPOLOGY_TET = 3 << 16 | 3,
376ec3da8bcSJed Brown   /// Pyramid - 3D shape
37750c301a5SRezgar Shakeri   CEED_TOPOLOGY_PYRAMID = 3 << 16 | 4,
378ec3da8bcSJed Brown   /// Prism - 3D shape
37950c301a5SRezgar Shakeri   CEED_TOPOLOGY_PRISM = 3 << 16 | 5,
380ec3da8bcSJed Brown   /// Hexehedron - 3D shape
38150c301a5SRezgar Shakeri   CEED_TOPOLOGY_HEX = 3 << 16 | 6,
382ec3da8bcSJed Brown } CeedElemTopology;
383ec3da8bcSJed Brown CEED_EXTERN const char *const CeedElemTopologies[];
384ec3da8bcSJed Brown 
385*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedBasisCreateTensorH1Lagrange(Ceed ceed, CeedInt dim, CeedInt num_comp, CeedInt P, CeedInt Q, CeedQuadMode quad_mode,
386ec3da8bcSJed Brown                                                 CeedBasis *basis);
387*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedBasisCreateTensorH1(Ceed ceed, CeedInt dim, CeedInt num_comp, CeedInt P_1d, CeedInt Q_1d, const CeedScalar *interp_1d,
388*2b730f8bSJeremy L Thompson                                         const CeedScalar *grad_1d, const CeedScalar *q_ref_1d, const CeedScalar *q_weight_1d, CeedBasis *basis);
389*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedBasisCreateH1(Ceed ceed, CeedElemTopology topo, CeedInt num_comp, CeedInt num_nodes, CeedInt nqpts, const CeedScalar *interp,
390*2b730f8bSJeremy L Thompson                                   const CeedScalar *grad, const CeedScalar *q_ref, const CeedScalar *q_weights, CeedBasis *basis);
391*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedBasisCreateHdiv(Ceed ceed, CeedElemTopology topo, CeedInt num_comp, CeedInt num_nodes, CeedInt nqpts, const CeedScalar *interp,
392*2b730f8bSJeremy L Thompson                                     const CeedScalar *div, const CeedScalar *q_ref, const CeedScalar *q_weights, CeedBasis *basis);
393446e7af4SJeremy L Thompson CEED_EXTERN int CeedBasisCreateProjection(CeedBasis basis_from, CeedBasis basis_to, CeedBasis *basis_project);
3949560d06aSjeremylt CEED_EXTERN int CeedBasisReferenceCopy(CeedBasis basis, CeedBasis *basis_copy);
395ec3da8bcSJed Brown CEED_EXTERN int CeedBasisView(CeedBasis basis, FILE *stream);
396*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedBasisApply(CeedBasis basis, CeedInt num_elem, CeedTransposeMode t_mode, CeedEvalMode eval_mode, CeedVector u, CeedVector v);
397b7c9bbdaSJeremy L Thompson CEED_EXTERN int CeedBasisGetCeed(CeedBasis basis, Ceed *ceed);
398ec3da8bcSJed Brown CEED_EXTERN int CeedBasisGetDimension(CeedBasis basis, CeedInt *dim);
399ec3da8bcSJed Brown CEED_EXTERN int CeedBasisGetTopology(CeedBasis basis, CeedElemTopology *topo);
40050c301a5SRezgar Shakeri CEED_EXTERN int CeedBasisGetNumQuadratureComponents(CeedBasis basis, CeedInt *Q_comp);
401d1d35e2fSjeremylt CEED_EXTERN int CeedBasisGetNumComponents(CeedBasis basis, CeedInt *num_comp);
402ec3da8bcSJed Brown CEED_EXTERN int CeedBasisGetNumNodes(CeedBasis basis, CeedInt *P);
403d1d35e2fSjeremylt CEED_EXTERN int CeedBasisGetNumNodes1D(CeedBasis basis, CeedInt *P_1d);
404ec3da8bcSJed Brown CEED_EXTERN int CeedBasisGetNumQuadraturePoints(CeedBasis basis, CeedInt *Q);
405*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedBasisGetNumQuadraturePoints1D(CeedBasis basis, CeedInt *Q_1d);
406d1d35e2fSjeremylt CEED_EXTERN int CeedBasisGetQRef(CeedBasis basis, const CeedScalar **q_ref);
407*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedBasisGetQWeights(CeedBasis basis, const CeedScalar **q_weights);
408ec3da8bcSJed Brown CEED_EXTERN int CeedBasisGetInterp(CeedBasis basis, const CeedScalar **interp);
409*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedBasisGetInterp1D(CeedBasis basis, const CeedScalar **interp_1d);
410ec3da8bcSJed Brown CEED_EXTERN int CeedBasisGetGrad(CeedBasis basis, const CeedScalar **grad);
411d1d35e2fSjeremylt CEED_EXTERN int CeedBasisGetGrad1D(CeedBasis basis, const CeedScalar **grad_1d);
41250c301a5SRezgar Shakeri CEED_EXTERN int CeedBasisGetDiv(CeedBasis basis, const CeedScalar **div);
413ec3da8bcSJed Brown CEED_EXTERN int CeedBasisDestroy(CeedBasis *basis);
414ec3da8bcSJed Brown 
415*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedGaussQuadrature(CeedInt Q, CeedScalar *q_ref_1d, CeedScalar *q_weight_1d);
416*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedLobattoQuadrature(CeedInt Q, CeedScalar *q_ref_1d, CeedScalar *q_weight_1d);
417*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedQRFactorization(Ceed ceed, CeedScalar *mat, CeedScalar *tau, CeedInt m, CeedInt n);
418*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedSymmetricSchurDecomposition(Ceed ceed, CeedScalar *mat, CeedScalar *lambda, CeedInt n);
419*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedSimultaneousDiagonalization(Ceed ceed, CeedScalar *mat_A, CeedScalar *mat_B, CeedScalar *x, CeedScalar *lambda, CeedInt n);
420ec3da8bcSJed Brown 
421cdf32b93SJeremy L Thompson /** Handle for the user provided CeedQFunction callback function
422ec3da8bcSJed Brown 
423cdf32b93SJeremy L Thompson  @param[in,out] ctx  User-defined context set using CeedQFunctionSetContext() or NULL
424cdf32b93SJeremy L Thompson  @param[in] Q        Number of quadrature points at which to evaluate
425cdf32b93SJeremy L Thompson  @param[in] in       Array of pointers to each input argument in the order provided
426ec3da8bcSJed Brown                        by the user in CeedQFunctionAddInput().  Each array has shape
427d1d35e2fSjeremylt                        `[dim, num_comp, Q]` where `dim` is the geometric dimension for
428ec3da8bcSJed Brown                        \ref CEED_EVAL_GRAD (`dim=1` for \ref CEED_EVAL_INTERP) and
429d1d35e2fSjeremylt                        `num_comp` is the number of field components (`num_comp=1` for
430ec3da8bcSJed Brown                        scalar fields).  This results in indexing the `i`th input at
431d1d35e2fSjeremylt                        quadrature point `j` as `in[i][(d*num_comp + c)*Q + j]`.
432cdf32b93SJeremy L Thompson  @param[out]   out   Array of pointers to each output array in the order provided
433ec3da8bcSJed Brown                        using CeedQFunctionAddOutput().  The shapes are as above for
434ec3da8bcSJed Brown                        \a in.
435ec3da8bcSJed Brown 
436ec3da8bcSJed Brown  @return An error code: 0 - success, otherwise - failure
437ec3da8bcSJed Brown 
438ec3da8bcSJed Brown  @ingroup CeedQFunction
439ec3da8bcSJed Brown **/
440*2b730f8bSJeremy L Thompson typedef int (*CeedQFunctionUser)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out);
441ec3da8bcSJed Brown 
442*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionCreateInterior(Ceed ceed, CeedInt vec_length, CeedQFunctionUser f, const char *source, CeedQFunction *qf);
443*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionCreateInteriorByName(Ceed ceed, const char *name, CeedQFunction *qf);
444*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionCreateIdentity(Ceed ceed, CeedInt size, CeedEvalMode in_mode, CeedEvalMode out_mode, CeedQFunction *qf);
4459560d06aSjeremylt CEED_EXTERN int CeedQFunctionReferenceCopy(CeedQFunction qf, CeedQFunction *qf_copy);
446*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionAddInput(CeedQFunction qf, const char *field_name, CeedInt size, CeedEvalMode eval_mode);
447*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionAddOutput(CeedQFunction qf, const char *field_name, CeedInt size, CeedEvalMode eval_mode);
448*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionGetFields(CeedQFunction qf, CeedInt *num_input_fields, CeedQFunctionField **input_fields, CeedInt *num_output_fields,
44943bbe138SJeremy L Thompson                                        CeedQFunctionField **output_fields);
450*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionSetContext(CeedQFunction qf, CeedQFunctionContext ctx);
451441428dfSJeremy L Thompson CEED_EXTERN int CeedQFunctionSetContextWritable(CeedQFunction qf, bool is_writable);
4529d36ca50SJeremy L Thompson CEED_EXTERN int CeedQFunctionSetUserFlopsEstimate(CeedQFunction qf, CeedSize flops);
453ec3da8bcSJed Brown CEED_EXTERN int CeedQFunctionView(CeedQFunction qf, FILE *stream);
454b7c9bbdaSJeremy L Thompson CEED_EXTERN int CeedQFunctionGetCeed(CeedQFunction qf, Ceed *ceed);
455*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionApply(CeedQFunction qf, CeedInt Q, CeedVector *u, CeedVector *v);
456ec3da8bcSJed Brown CEED_EXTERN int CeedQFunctionDestroy(CeedQFunction *qf);
457ec3da8bcSJed Brown 
458*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionFieldGetName(CeedQFunctionField qf_field, char **field_name);
459*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionFieldGetSize(CeedQFunctionField qf_field, CeedInt *size);
460*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionFieldGetEvalMode(CeedQFunctionField qf_field, CeedEvalMode *eval_mode);
46143bbe138SJeremy L Thompson 
462cdf32b93SJeremy L Thompson /// Denotes type of data stored in a CeedQFunctionContext field
463cdf32b93SJeremy L Thompson /// @ingroup CeedQFunction
464cdf32b93SJeremy L Thompson typedef enum {
465cdf32b93SJeremy L Thompson   /// Double precision value
4667bfe0f0eSJeremy L Thompson   CEED_CONTEXT_FIELD_DOUBLE = 1,
467cdf32b93SJeremy L Thompson   /// 32 bit integer value
4687bfe0f0eSJeremy L Thompson   CEED_CONTEXT_FIELD_INT32 = 2,
469cdf32b93SJeremy L Thompson } CeedContextFieldType;
470cdf32b93SJeremy L Thompson CEED_EXTERN const char *const CeedContextFieldTypes[];
471cdf32b93SJeremy L Thompson 
4722790b72bSJeremy L Thompson /** Handle for the user provided CeedQFunctionContextDataDestroy callback function
4732790b72bSJeremy L Thompson 
4742790b72bSJeremy L Thompson  @param[in,out] data  User-CeedQFunctionContext data
4752790b72bSJeremy L Thompson 
4762790b72bSJeremy L Thompson  @return An error code: 0 - success, otherwise - failure
4772790b72bSJeremy L Thompson 
4782790b72bSJeremy L Thompson  @ingroup CeedQFunction
4792790b72bSJeremy L Thompson **/
4802790b72bSJeremy L Thompson typedef int (*CeedQFunctionContextDataDestroyUser)(void *data);
4812790b72bSJeremy L Thompson 
482*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextCreate(Ceed ceed, CeedQFunctionContext *ctx);
483*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextReferenceCopy(CeedQFunctionContext ctx, CeedQFunctionContext *ctx_copy);
484*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextSetData(CeedQFunctionContext ctx, CeedMemType mem_type, CeedCopyMode copy_mode, size_t size, void *data);
485*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextTakeData(CeedQFunctionContext ctx, CeedMemType mem_type, void *data);
486*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextGetData(CeedQFunctionContext ctx, CeedMemType mem_type, void *data);
487*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextGetDataRead(CeedQFunctionContext ctx, CeedMemType mem_type, void *data);
488*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextRestoreData(CeedQFunctionContext ctx, void *data);
489*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextRestoreDataRead(CeedQFunctionContext ctx, void *data);
490*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextRegisterDouble(CeedQFunctionContext ctx, const char *field_name, size_t field_offset, size_t num_values,
4917bfe0f0eSJeremy L Thompson                                                    const char *field_description);
492*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextRegisterInt32(CeedQFunctionContext ctx, const char *field_name, size_t field_offset, size_t num_values,
4937bfe0f0eSJeremy L Thompson                                                   const char *field_description);
494*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextGetAllFieldLabels(CeedQFunctionContext ctx, const CeedContextFieldLabel **field_labels, CeedInt *num_fields);
495*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedContextFieldLabelGetDescription(CeedContextFieldLabel label, const char **field_name, const char **field_description,
496*2b730f8bSJeremy L Thompson                                                     size_t *num_values, CeedContextFieldType *field_type);
497*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextGetContextSize(CeedQFunctionContext ctx, size_t *ctx_size);
498*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextView(CeedQFunctionContext ctx, FILE *stream);
499*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedQFunctionContextSetDataDestroy(CeedQFunctionContext ctx, CeedMemType f_mem_type, CeedQFunctionContextDataDestroyUser f);
500ec3da8bcSJed Brown CEED_EXTERN int CeedQFunctionContextDestroy(CeedQFunctionContext *ctx);
501ec3da8bcSJed Brown 
502*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorCreate(Ceed ceed, CeedQFunction qf, CeedQFunction dqf, CeedQFunction dqfT, CeedOperator *op);
503ec3da8bcSJed Brown CEED_EXTERN int CeedCompositeOperatorCreate(Ceed ceed, CeedOperator *op);
5049560d06aSjeremylt CEED_EXTERN int CeedOperatorReferenceCopy(CeedOperator op, CeedOperator *op_copy);
505*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorSetField(CeedOperator op, const char *field_name, CeedElemRestriction r, CeedBasis b, CeedVector v);
506*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorGetFields(CeedOperator op, CeedInt *num_input_fields, CeedOperatorField **input_fields, CeedInt *num_output_fields,
50743bbe138SJeremy L Thompson                                       CeedOperatorField **output_fields);
508*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedCompositeOperatorAddSub(CeedOperator composite_op, CeedOperator sub_op);
5094db537f9SJeremy L Thompson CEED_EXTERN int CeedOperatorCheckReady(CeedOperator op);
510c9366a6bSJeremy L Thompson CEED_EXTERN int CeedOperatorGetActiveVectorLengths(CeedOperator op, CeedSize *input_size, CeedSize *output_size);
511beecbf24SJeremy L Thompson CEED_EXTERN int CeedOperatorSetQFunctionAssemblyReuse(CeedOperator op, bool reuse_assembly_data);
512beecbf24SJeremy L Thompson CEED_EXTERN int CeedOperatorSetQFunctionAssemblyDataUpdateNeeded(CeedOperator op, bool needs_data_update);
513*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorLinearAssembleQFunction(CeedOperator op, CeedVector *assembled, CeedElemRestriction *rstr, CeedRequest *request);
514*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorLinearAssembleQFunctionBuildOrUpdate(CeedOperator op, CeedVector *assembled, CeedElemRestriction *rstr,
515*2b730f8bSJeremy L Thompson                                                                  CeedRequest *request);
516*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorLinearAssembleDiagonal(CeedOperator op, CeedVector assembled, CeedRequest *request);
517*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorLinearAssembleAddDiagonal(CeedOperator op, CeedVector assembled, CeedRequest *request);
518*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorLinearAssemblePointBlockDiagonal(CeedOperator op, CeedVector assembled, CeedRequest *request);
519*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorLinearAssembleAddPointBlockDiagonal(CeedOperator op, CeedVector assembled, CeedRequest *request);
520*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorLinearAssembleSymbolic(CeedOperator op, CeedSize *num_entries, CeedInt **rows, CeedInt **cols);
521ec3da8bcSJed Brown CEED_EXTERN int CeedOperatorLinearAssemble(CeedOperator op, CeedVector values);
522*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorMultigridLevelCreate(CeedOperator op_fine, CeedVector p_mult_fine, CeedElemRestriction rstr_coarse,
523*2b730f8bSJeremy L Thompson                                                  CeedBasis basis_coarse, CeedOperator *op_coarse, CeedOperator *op_prolong,
524*2b730f8bSJeremy L Thompson                                                  CeedOperator *op_restrict);
525*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorMultigridLevelCreateTensorH1(CeedOperator op_fine, CeedVector p_mult_fine, CeedElemRestriction rstr_coarse,
526d1d35e2fSjeremylt                                                          CeedBasis basis_coarse, const CeedScalar *interp_c_to_f, CeedOperator *op_coarse,
527d1d35e2fSjeremylt                                                          CeedOperator *op_prolong, CeedOperator *op_restrict);
528*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorMultigridLevelCreateH1(CeedOperator op_fine, CeedVector p_mult_fine, CeedElemRestriction rstr_coarse,
529*2b730f8bSJeremy L Thompson                                                    CeedBasis basis_coarse, const CeedScalar *interp_c_to_f, CeedOperator *op_coarse,
530d1d35e2fSjeremylt                                                    CeedOperator *op_prolong, CeedOperator *op_restrict);
531*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorCreateFDMElementInverse(CeedOperator op, CeedOperator *fdm_inv, CeedRequest *request);
532cd4dfc48Sjeremylt CEED_EXTERN int CeedOperatorSetNumQuadraturePoints(CeedOperator op, CeedInt num_qpts);
533ea6b5821SJeremy L Thompson CEED_EXTERN int CeedOperatorSetName(CeedOperator op, const char *name);
534ec3da8bcSJed Brown CEED_EXTERN int CeedOperatorView(CeedOperator op, FILE *stream);
535b7c9bbdaSJeremy L Thompson CEED_EXTERN int CeedOperatorGetCeed(CeedOperator op, Ceed *ceed);
536b7c9bbdaSJeremy L Thompson CEED_EXTERN int CeedOperatorGetNumElements(CeedOperator op, CeedInt *num_elem);
537*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorGetNumQuadraturePoints(CeedOperator op, CeedInt *num_qpts);
5389d36ca50SJeremy L Thompson CEED_EXTERN int CeedOperatorGetFlopsEstimate(CeedOperator op, CeedSize *flops);
539*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorContextGetFieldLabel(CeedOperator op, const char *field_name, CeedContextFieldLabel *field_label);
540*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorContextSetDouble(CeedOperator op, CeedContextFieldLabel field_label, double *values);
541*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorContextSetInt32(CeedOperator op, CeedContextFieldLabel field_label, int *values);
542*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorApply(CeedOperator op, CeedVector in, CeedVector out, CeedRequest *request);
543*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorApplyAdd(CeedOperator op, CeedVector in, CeedVector out, CeedRequest *request);
544ec3da8bcSJed Brown CEED_EXTERN int CeedOperatorDestroy(CeedOperator *op);
545ec3da8bcSJed Brown 
546*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorFieldGetName(CeedOperatorField op_field, char **field_name);
547*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorFieldGetElemRestriction(CeedOperatorField op_field, CeedElemRestriction *rstr);
548*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorFieldGetBasis(CeedOperatorField op_field, CeedBasis *basis);
549*2b730f8bSJeremy L Thompson CEED_EXTERN int CeedOperatorFieldGetVector(CeedOperatorField op_field, CeedVector *vec);
55043bbe138SJeremy L Thompson 
551ec3da8bcSJed Brown /**
552ec3da8bcSJed Brown   @brief Return integer power
553ec3da8bcSJed Brown 
554ec3da8bcSJed Brown   @param[in] base   The base to exponentiate
555ec3da8bcSJed Brown   @param[in] power  The power to raise the base to
556ec3da8bcSJed Brown 
557ec3da8bcSJed Brown   @return base^power
558ec3da8bcSJed Brown 
559ec3da8bcSJed Brown   @ref Utility
560ec3da8bcSJed Brown **/
561ec3da8bcSJed Brown static inline CeedInt CeedIntPow(CeedInt base, CeedInt power) {
562ec3da8bcSJed Brown   CeedInt result = 1;
563ec3da8bcSJed Brown   while (power) {
564ec3da8bcSJed Brown     if (power & 1) result *= base;
565ec3da8bcSJed Brown     power >>= 1;
566ec3da8bcSJed Brown     base *= base;
567ec3da8bcSJed Brown   }
568ec3da8bcSJed Brown   return result;
569ec3da8bcSJed Brown }
570ec3da8bcSJed Brown 
571ec3da8bcSJed Brown /**
572ec3da8bcSJed Brown   @brief Return minimum of two integers
573ec3da8bcSJed Brown 
574ec3da8bcSJed Brown   @param[in] a  The first integer to compare
575ec3da8bcSJed Brown   @param[in] b  The second integer to compare
576ec3da8bcSJed Brown 
577ec3da8bcSJed Brown   @return The minimum of the two integers
578ec3da8bcSJed Brown 
579ec3da8bcSJed Brown   @ref Utility
580ec3da8bcSJed Brown **/
581ec3da8bcSJed Brown static inline CeedInt CeedIntMin(CeedInt a, CeedInt b) { return a < b ? a : b; }
582ec3da8bcSJed Brown 
583ec3da8bcSJed Brown /**
584ec3da8bcSJed Brown   @brief Return maximum of two integers
585ec3da8bcSJed Brown 
586ec3da8bcSJed Brown   @param[in] a  The first integer to compare
587ec3da8bcSJed Brown   @param[in] b  The second integer to compare
588ec3da8bcSJed Brown 
589ec3da8bcSJed Brown   @return The maximum of the two integers
590ec3da8bcSJed Brown 
591ec3da8bcSJed Brown   @ref Utility
592ec3da8bcSJed Brown **/
593ec3da8bcSJed Brown static inline CeedInt CeedIntMax(CeedInt a, CeedInt b) { return a > b ? a : b; }
594ec3da8bcSJed Brown 
595ec3da8bcSJed Brown // Used to ensure initialization before CeedInit()
596ec3da8bcSJed Brown CEED_EXTERN int CeedRegisterAll(void);
597ec3da8bcSJed Brown // Used to ensure initialization before CeedQFunctionCreate*()
598ec3da8bcSJed Brown CEED_EXTERN int CeedQFunctionRegisterAll(void);
599ec3da8bcSJed Brown 
600ec3da8bcSJed Brown #endif
601