xref: /libCEED/include/ceed.h (revision 8621c6c6de0ebe428b5b7a9c1ff9e4a60667b9cc)
1 /// Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at
2 /// the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights
3 /// reserved. See files LICENSE and NOTICE for details.
4 ///
5 /// This file is part of CEED, a collection of benchmarks, miniapps, software
6 /// libraries and APIs for efficient high-order finite element and spectral
7 /// element discretizations for exascale applications. For more information and
8 /// source code availability see http://github.com/ceed.
9 ///
10 /// The CEED research is supported by the Exascale Computing Project 17-SC-20-SC,
11 /// a collaborative effort of two U.S. Department of Energy organizations (Office
12 /// of Science and the National Nuclear Security Administration) responsible for
13 /// the planning and preparation of a capable exascale ecosystem, including
14 /// software, applications, hardware, advanced system engineering and early
15 /// testbed platforms, in support of the nation's exascale computing imperative.
16 
17 /// @file
18 /// Public header for user and utility components of libCEED
19 #ifndef _ceed_h
20 #define _ceed_h
21 
22 /// @defgroup Ceed Ceed: core components
23 /// @defgroup CeedVector CeedVector: storing and manipulating vectors
24 /// @defgroup CeedElemRestriction CeedElemRestriction: restriction from local vectors to elements
25 /// @defgroup CeedBasis CeedBasis: fully discrete finite element-like objects
26 /// @defgroup CeedQFunction CeedQFunction: independent operations at quadrature points
27 /// @defgroup CeedOperator CeedOperator: composed FE-type operations on vectors
28 ///
29 /// @page FunctionCategories libCEED: Types of Functions
30 ///    libCEED provides three different header files depending upon the type of
31 ///    functions a user requires.
32 /// @section Utility Utility Functions
33 ///    These functions are intended general utilities that may be useful to
34 ///    libCEED developers and users. These functions can generally be found in
35 ///    "ceed.h".
36 /// @section Basic User Functions
37 ///    These functions are intended to be used by general users of the libCEED
38 ///    interface. These functions can generally be found in "ceed.h".
39 /// @section Advanced Backend Developer Functions
40 ///    These functions are intended to be used by backend developers of the
41 ///    libCEED interface. These functions can generally be found in
42 ///    "ceed-backend.h".
43 /// @section Developer Frontend Developer Functions
44 ///    These functions are intended to be used by frontend developers of the
45 ///    libCEED interface. These functions can generally be found in "ceed-impl.h".
46 
47 /**
48   CEED_EXTERN is used in this header to denote all publicly visible symbols.
49 
50   No other file should declare publicly visible symbols, thus it should never be
51   used outside ceed.h.
52  */
53 #ifdef __cplusplus
54 #  define CEED_EXTERN extern "C"
55 #else
56 #  define CEED_EXTERN extern
57 #endif
58 
59 #ifndef CEED_QFUNCTION
60 #define CEED_QFUNCTION(name) \
61   static const char name ## _loc[] = __FILE__ ":" #name;        \
62   static int name
63 #endif
64 
65 #ifndef CeedPragmaSIMD
66 #  if defined(__INTEL_COMPILER) &&__INTEL_COMPILER >= 900
67 #    define CeedPragmaSIMD _Pragma("simd")
68 #  elif defined(__GNUC__) && __GNUC__ >= 5
69 #    define CeedPragmaSIMD _Pragma("GCC ivdep")
70 #  elif defined(_OPENMP) && _OPENMP >= 201307 // OpenMP-4.0 (July, 2013)
71 #    define CeedPragmaSIMD _Pragma("omp simd")
72 #  else
73 #    define CeedPragmaSIMD
74 #  endif
75 #endif
76 
77 #include <assert.h>
78 #include <stdint.h>
79 #include <stddef.h>
80 #include <stdarg.h>
81 #include <stdio.h>
82 #include <stdbool.h>
83 
84 /// We can discuss ways to avoid forcing these to be compile-time decisions,
85 ///   but let's leave that for later.
86 /// Integer type, used for indexing
87 /// @ingroup Ceed
88 typedef int32_t CeedInt;
89 /// Scalar (floating point) type
90 /// @ingroup Ceed
91 typedef double CeedScalar;
92 
93 /// Library context created by CeedInit()
94 /// @ingroup Ceed
95 typedef struct Ceed_private *Ceed;
96 /// Non-blocking Ceed interfaces return a CeedRequest.
97 /// To perform an operation immediately, pass \ref CEED_REQUEST_IMMEDIATE instead.
98 /// @ingroup Ceed
99 typedef struct CeedRequest_private *CeedRequest;
100 /// Handle for vectors over the field \ref CeedScalar
101 /// @ingroup CeedVector
102 typedef struct CeedVector_private *CeedVector;
103 /// Handle for object describing restriction to elements
104 /// @ingroup CeedElemRestriction
105 typedef struct CeedElemRestriction_private *CeedElemRestriction;
106 /// Handle for object describing discrete finite element evaluations
107 /// @ingroup CeedBasis
108 typedef struct CeedBasis_private *CeedBasis;
109 /// Handle for object describing functions evaluated independently at quadrature points
110 /// @ingroup CeedQFunction
111 typedef struct CeedQFunction_private *CeedQFunction;
112 /// Handle for object describing FE-type operators acting on vectors
113 ///
114 /// Given an element restriction \f$E\f$, basis evaluator \f$B\f$, and
115 ///   quadrature function\f$f\f$, a CeedOperator expresses operations of the form
116 ///   $$ E^T B^T f(B E u) $$
117 ///   acting on the vector \f$u\f$.
118 /// @ingroup CeedOperator
119 typedef struct CeedOperator_private *CeedOperator;
120 
121 CEED_EXTERN int CeedInit(const char *resource, Ceed *ceed);
122 CEED_EXTERN int CeedGetResource(Ceed ceed, const char **resource);
123 CEED_EXTERN int CeedDestroy(Ceed *ceed);
124 
125 CEED_EXTERN int CeedErrorImpl(Ceed, const char *, int, const char *, int,
126                               const char *, ...);
127 /// Raise an error on ceed object
128 ///
129 /// @param ceed Ceed library context or NULL
130 /// @param ecode Error code (int)
131 /// @param ... printf-style format string followed by arguments as needed
132 ///
133 /// @ingroup Ceed
134 /// @sa CeedSetErrorHandler()
135 #if defined(__clang__)
136 /// Use nonstandard ternary to convince the compiler/clang-tidy that this
137 /// function never returns zero.
138 #  define CeedError(ceed, ecode, ...)                                     \
139   (CeedErrorImpl((ceed), __FILE__, __LINE__, __func__, (ecode), __VA_ARGS__) ?: (ecode))
140 #else
141 #  define CeedError(ceed, ecode, ...)                                     \
142   CeedErrorImpl((ceed), __FILE__, __LINE__, __func__, (ecode), __VA_ARGS__) ?: (ecode)
143 #endif
144 /// Specify memory type
145 ///
146 /// Many Ceed interfaces take or return pointers to memory.  This enum is used to
147 /// specify where the memory being provided or requested must reside.
148 /// @ingroup Ceed
149 typedef enum {
150   /// Memory resides on the host
151   CEED_MEM_HOST,
152   /// Memory resides on a device (corresponding to \ref Ceed resource)
153   CEED_MEM_DEVICE,
154 } CeedMemType;
155 
156 CEED_EXTERN const char *const CeedMemTypes[];
157 
158 CEED_EXTERN int CeedGetPreferredMemType(Ceed ceed, CeedMemType *type);
159 
160 /// Conveys ownership status of arrays passed to Ceed interfaces.
161 /// @ingroup Ceed
162 typedef enum {
163   /// Implementation will copy the values and not store the passed pointer.
164   CEED_COPY_VALUES,
165   /// Implementation can use and modify the data provided by the user, but does
166   /// not take ownership.
167   CEED_USE_POINTER,
168   /// Implementation takes ownership of the pointer and will free using
169   /// CeedFree() when done using it.  The user should not assume that the
170   /// pointer remains valid after ownership has been transferred.  Note that
171   /// arrays allocated using C++ operator new or other allocators cannot
172   /// generally be freed using CeedFree().  CeedFree() is capable of freeing any
173   /// memory that can be freed using free(3).
174   CEED_OWN_POINTER,
175 } CeedCopyMode;
176 
177 /// Denotes type of vector norm to be computed
178 /// @ingroup CeedVector
179 typedef enum {
180   /// L_1 norm: sum_i |x_i|
181   CEED_NORM_1,
182   /// L_2 norm: sqrt(sum_i |x_i|^2)
183   CEED_NORM_2,
184   /// L_Infinity norm: max_i |x_i|
185   CEED_NORM_MAX,
186 } CeedNormType;
187 
188 CEED_EXTERN const char *const CeedCopyModes[];
189 
190 CEED_EXTERN int CeedVectorCreate(Ceed ceed, CeedInt len, CeedVector *vec);
191 CEED_EXTERN int CeedVectorSetArray(CeedVector vec, CeedMemType mtype,
192                                    CeedCopyMode cmode, CeedScalar *array);
193 CEED_EXTERN int CeedVectorSetValue(CeedVector vec, CeedScalar value);
194 CEED_EXTERN int CeedVectorSyncArray(CeedVector vec, CeedMemType mtype);
195 CEED_EXTERN int CeedVectorGetArray(CeedVector vec, CeedMemType mtype,
196                                    CeedScalar **array);
197 CEED_EXTERN int CeedVectorGetArrayRead(CeedVector vec, CeedMemType mtype,
198                                        const CeedScalar **array);
199 CEED_EXTERN int CeedVectorRestoreArray(CeedVector vec, CeedScalar **array);
200 CEED_EXTERN int CeedVectorRestoreArrayRead(CeedVector vec,
201     const CeedScalar **array);
202 CEED_EXTERN int CeedVectorNorm(CeedVector vec, CeedNormType type,
203                                CeedScalar *norm);
204 CEED_EXTERN int CeedVectorView(CeedVector vec, const char *fpfmt, FILE *stream);
205 CEED_EXTERN int CeedVectorGetLength(CeedVector vec, CeedInt *length);
206 CEED_EXTERN int CeedVectorDestroy(CeedVector *vec);
207 
208 CEED_EXTERN CeedRequest *const CEED_REQUEST_IMMEDIATE;
209 CEED_EXTERN CeedRequest *const CEED_REQUEST_ORDERED;
210 CEED_EXTERN int CeedRequestWait(CeedRequest *req);
211 
212 /// Argument for CeedOperatorSetField that vector is collocated with
213 /// quadrature points, used with QFunction eval mode CEED_EVAL_NONE
214 /// or CEED_EVAL_INTERP only, not with CEED_EVAL_GRAD, CEED_EVAL_DIV,
215 /// or CEED_EVAL_CURL
216 /// @ingroup CeedBasis
217 CEED_EXTERN CeedBasis CEED_BASIS_COLLOCATED;
218 
219 /// Argument for CeedOperatorSetField to use active input or output
220 /// @ingroup CeedVector
221 CEED_EXTERN CeedVector CEED_VECTOR_ACTIVE;
222 
223 /// Argument for CeedOperatorSetField to use no vector, used with
224 /// qfunction input with eval mode CEED_EVAL_WEIGHT
225 /// @ingroup CeedVector
226 CEED_EXTERN CeedVector CEED_VECTOR_NONE;
227 
228 /// Argument for CeedOperatorSetField to use no ElemRestriction, only used with
229 /// eval mode CEED_EVAL_WEIGHT.
230 /// @ingroup CeedElemRestriction
231 CEED_EXTERN CeedElemRestriction CEED_ELEMRESTRICTION_NONE;
232 
233 /// Argument for CeedOperatorCreate that QFunction is not created by user.
234 /// Only used for QFunctions dqf and dqfT. If implemented, a backend may
235 /// attempt to provide the action of these QFunctions.
236 /// @ingroup CeedQFunction
237 CEED_EXTERN CeedQFunction CEED_QFUNCTION_NONE;
238 
239 /// Denotes whether a linear transformation or its transpose should be applied
240 /// @ingroup CeedBasis
241 typedef enum {
242   /// Apply the linear transformation
243   CEED_NOTRANSPOSE,
244   /// Apply the transpose
245   CEED_TRANSPOSE
246 } CeedTransposeMode;
247 
248 CEED_EXTERN const char *const CeedTransposeModes[];
249 
250 /// Denotes whether a L-vector is ordered [component, node] or [node, component]
251 ///   with the right-most index being contiguous in memory
252 /// @ingroup CeedElemRestriction
253 typedef enum {
254   /// L-vector data is not interlaced, ordered [component, node]
255   CEED_NONINTERLACED,
256   /// L-vector data is interlaced, ordered [node, component]
257   CEED_INTERLACED
258 } CeedInterlaceMode;
259 
260 CEED_EXTERN const char *const CeedInterlaceModes[];
261 
262 /// Argument for CeedElemRestrictionCreateStrided that L-vector is in
263 /// the Ceed backend's preferred layout. This argument should only be used
264 /// with vectors created by a Ceed backend.
265 /// @ingroup CeedElemRestriction
266 CEED_EXTERN CeedInt CEED_STRIDES_BACKEND[3];
267 
268 CEED_EXTERN int CeedElemRestrictionCreate(Ceed ceed, CeedInterlaceMode imode,
269     CeedInt nelem, CeedInt elemsize, CeedInt nnodes, CeedInt ncomp,
270     CeedMemType mtype, CeedCopyMode cmode, const CeedInt *indices,
271     CeedElemRestriction *rstr);
272 CEED_EXTERN int CeedElemRestrictionCreateBlocked(Ceed ceed,
273     CeedInterlaceMode imode, CeedInt nelem, CeedInt elemsize, CeedInt blksize,
274     CeedInt nnodes, CeedInt ncomp, CeedMemType mtype, CeedCopyMode cmode,
275     const CeedInt *indices, CeedElemRestriction *rstr);
276 CEED_EXTERN int CeedElemRestrictionCreateStrided(Ceed ceed,
277     CeedInt nelem, CeedInt elemsize, CeedInt nnodes, CeedInt ncomp,
278     const CeedInt strides[3], CeedElemRestriction *rstr);
279 CEED_EXTERN int CeedElemRestrictionCreateBlockedStrided(Ceed ceed,
280     CeedInt nelem, CeedInt elemsize, CeedInt blksize, CeedInt nnodes,
281     CeedInt ncomp, const CeedInt strides[3], CeedElemRestriction *rstr);
282 CEED_EXTERN int CeedElemRestrictionCreateVector(CeedElemRestriction rstr,
283     CeedVector *lvec, CeedVector *evec);
284 CEED_EXTERN int CeedElemRestrictionApply(CeedElemRestriction rstr,
285     CeedTransposeMode tmode, CeedVector u, CeedVector ru, CeedRequest *request);
286 CEED_EXTERN int CeedElemRestrictionApplyBlock(CeedElemRestriction rstr,
287     CeedInt block, CeedTransposeMode tmode, CeedVector u, CeedVector ru,
288     CeedRequest *request);
289 CEED_EXTERN int CeedElemRestrictionGetIMode(CeedElemRestriction rstr,
290     CeedInterlaceMode *Imode);
291 CEED_EXTERN int CeedElemRestrictionGetNumElements(CeedElemRestriction rstr,
292     CeedInt *numelem);
293 CEED_EXTERN int CeedElemRestrictionGetElementSize(CeedElemRestriction rstr,
294     CeedInt *elemsize);
295 CEED_EXTERN int CeedElemRestrictionGetNumNodes(CeedElemRestriction rstr,
296     CeedInt *numnodes);
297 CEED_EXTERN int CeedElemRestrictionGetNumComponents(CeedElemRestriction rstr,
298     CeedInt *numcomp);
299 CEED_EXTERN int CeedElemRestrictionGetNumBlocks(CeedElemRestriction rstr,
300     CeedInt *numblk);
301 CEED_EXTERN int CeedElemRestrictionGetBlockSize(CeedElemRestriction rstr,
302     CeedInt *blksize);
303 CEED_EXTERN int CeedElemRestrictionGetMultiplicity(CeedElemRestriction rstr,
304     CeedVector mult);
305 CEED_EXTERN int CeedElemRestrictionView(CeedElemRestriction rstr, FILE *stream);
306 CEED_EXTERN int CeedElemRestrictionDestroy(CeedElemRestriction *rstr);
307 
308 /// The formalism here is that we have the structure
309 ///   \int_\Omega v^T f_0(u, \nabla u, qdata) + (\nabla v)^T f_1(u, \nabla u, qdata)
310 /// where gradients are with respect to the reference element.
311 
312 /// Basis evaluation mode
313 ///
314 /// Modes can be bitwise ORed when passing to most functions.
315 /// @ingroup CeedBasis
316 typedef enum {
317   /// Perform no evaluation (either because there is no data or it is already at
318   /// quadrature points)
319   CEED_EVAL_NONE   = 0,
320   /// Interpolate from nodes to quadrature points
321   CEED_EVAL_INTERP = 1,
322   /// Evaluate gradients at quadrature points from input in a nodal basis
323   CEED_EVAL_GRAD   = 2,
324   /// Evaluate divergence at quadrature points from input in a nodal basis
325   CEED_EVAL_DIV    = 4,
326   /// Evaluate curl at quadrature points from input in a nodal basis
327   CEED_EVAL_CURL   = 8,
328   /// Using no input, evaluate quadrature weights on the reference element
329   CEED_EVAL_WEIGHT = 16,
330 } CeedEvalMode;
331 
332 CEED_EXTERN const char *const CeedEvalModes[];
333 
334 /// Type of quadrature; also used for location of nodes
335 /// @ingroup CeedBasis
336 typedef enum {
337   /// Gauss-Legendre quadrature
338   CEED_GAUSS = 0,
339   /// Gauss-Legendre-Lobatto quadrature
340   CEED_GAUSS_LOBATTO = 1,
341 } CeedQuadMode;
342 
343 CEED_EXTERN const char *const CeedQuadModes[];
344 
345 /// Type of basis shape to create non-tensor H1 element basis
346 ///
347 /// Dimension can be extracted with bitwise AND
348 /// (CeedElemTopology & 2**(dim + 2)) == TRUE
349 /// @ingroup CeedBasis
350 typedef enum {
351   /// Line
352   CEED_LINE = 1 << 16 | 0,
353   /// Triangle - 2D shape
354   CEED_TRIANGLE = 2 << 16 | 1,
355   /// Quadralateral - 2D shape
356   CEED_QUAD = 2 << 16 | 2,
357   /// Tetrahedron - 3D shape
358   CEED_TET = 3 << 16 | 3,
359   /// Pyramid - 3D shape
360   CEED_PYRAMID = 3 << 16 | 4,
361   /// Prism - 3D shape
362   CEED_PRISM = 3 << 16 | 5,
363   /// Hexehedron - 3D shape
364   CEED_HEX = 3 << 16 | 6,
365 } CeedElemTopology;
366 
367 CEED_EXTERN const char *const CeedElemTopologies[];
368 
369 CEED_EXTERN int CeedBasisCreateTensorH1Lagrange(Ceed ceed, CeedInt dim,
370     CeedInt ncomp, CeedInt P, CeedInt Q, CeedQuadMode qmode, CeedBasis *basis);
371 CEED_EXTERN int CeedBasisCreateTensorH1(Ceed ceed, CeedInt dim, CeedInt ncomp,
372                                         CeedInt P1d, CeedInt Q1d,
373                                         const CeedScalar *interp1d,
374                                         const CeedScalar *grad1d,
375                                         const CeedScalar *qref1d,
376                                         const CeedScalar *qweight1d,
377                                         CeedBasis *basis);
378 CEED_EXTERN int CeedBasisCreateH1(Ceed ceed, CeedElemTopology topo,
379                                   CeedInt ncomp,
380                                   CeedInt nnodes, CeedInt nqpts,
381                                   const CeedScalar *interp,
382                                   const CeedScalar *grad,
383                                   const CeedScalar *qref,
384                                   const CeedScalar *qweight, CeedBasis *basis);
385 CEED_EXTERN int CeedBasisView(CeedBasis basis, FILE *stream);
386 CEED_EXTERN int CeedBasisGetNumNodes(CeedBasis basis, CeedInt *P);
387 CEED_EXTERN int CeedBasisGetNumQuadraturePoints(CeedBasis basis, CeedInt *Q);
388 CEED_EXTERN int CeedBasisApply(CeedBasis basis, CeedInt nelem,
389                                CeedTransposeMode tmode,
390                                CeedEvalMode emode, CeedVector u, CeedVector v);
391 CEED_EXTERN int CeedBasisDestroy(CeedBasis *basis);
392 
393 CEED_EXTERN int CeedGaussQuadrature(CeedInt Q, CeedScalar *qref1d,
394                                     CeedScalar *qweight1d);
395 CEED_EXTERN int CeedLobattoQuadrature(CeedInt Q, CeedScalar *qref1d,
396                                       CeedScalar *qweight1d);
397 CEED_EXTERN int CeedQRFactorization(Ceed ceed, CeedScalar *mat, CeedScalar *tau,
398                                     CeedInt m, CeedInt n);
399 CEED_EXTERN int CeedSymmetricSchurDecomposition(Ceed ceed, CeedScalar *mat,
400     CeedScalar *lambda, CeedInt n);
401 CEED_EXTERN int CeedSimultaneousDiagonalization(Ceed ceed, CeedScalar *matA,
402     CeedScalar *matB, CeedScalar *x, CeedScalar *lambda, CeedInt n);
403 
404 /** Handle for the object describing the user CeedQFunction
405 
406  @param ctx user-defined context set using CeedQFunctionSetContext() or NULL
407 
408  @param Q   number of quadrature points at which to evaluate
409 
410  @param in  array of pointers to each input argument in the order provided
411               by the user in CeedQFunctionAddInput().  Each array has shape
412               `[dim, ncomp, Q]` where `dim` is the geometric dimension for
413               \ref CEED_EVAL_GRAD (`dim=1` for \ref CEED_EVAL_INTERP) and
414               `ncomp` is the number of field components (`ncomp=1` for
415               scalar fields).  This results in indexing the `i`th input at
416               quadrature point `j` as `in[i][(d*ncomp + c)*Q + j]`.
417 
418  @param out array of pointers to each output array in the order provided
419               using CeedQFunctionAddOutput().  The shapes are as above for
420               \a in.
421 
422  @return An error code: 0 - success, otherwise - failure
423 
424  @ingroup CeedQFunction
425 **/
426 typedef int (*CeedQFunctionUser)(void *ctx, const CeedInt Q,
427                                  const CeedScalar *const *in,
428                                  CeedScalar *const *out);
429 
430 CEED_EXTERN int CeedQFunctionCreateInterior(Ceed ceed, CeedInt vlength,
431     CeedQFunctionUser f, const char *source, CeedQFunction *qf);
432 CEED_EXTERN int CeedQFunctionCreateInteriorByName(Ceed ceed, const char *name,
433     CeedQFunction *qf);
434 CEED_EXTERN int CeedQFunctionCreateIdentity(Ceed ceed, CeedInt size,
435     CeedEvalMode inmode, CeedEvalMode outmode, CeedQFunction *qf);
436 CEED_EXTERN int CeedQFunctionAddInput(CeedQFunction qf, const char *fieldname,
437                                       CeedInt size, CeedEvalMode emode);
438 CEED_EXTERN int CeedQFunctionAddOutput(CeedQFunction qf, const char *fieldname,
439                                        CeedInt size, CeedEvalMode emode);
440 CEED_EXTERN int CeedQFunctionSetContext(CeedQFunction qf, void *ctx,
441                                         size_t ctxsize);
442 CEED_EXTERN int CeedQFunctionView(CeedQFunction qf, FILE *stream);
443 CEED_EXTERN int CeedQFunctionApply(CeedQFunction qf, CeedInt Q,
444                                    CeedVector *u, CeedVector *v);
445 CEED_EXTERN int CeedQFunctionDestroy(CeedQFunction *qf);
446 
447 CEED_EXTERN int CeedOperatorCreate(Ceed ceed, CeedQFunction qf,
448                                    CeedQFunction dqf, CeedQFunction dqfT,
449                                    CeedOperator *op);
450 CEED_EXTERN int CeedCompositeOperatorCreate(Ceed ceed, CeedOperator *op);
451 CEED_EXTERN int CeedOperatorSetField(CeedOperator op, const char *fieldname,
452                                      CeedElemRestriction r, CeedBasis b,
453                                      CeedVector v);
454 CEED_EXTERN int CeedCompositeOperatorAddSub(CeedOperator compositeop,
455     CeedOperator subop);
456 CEED_EXTERN int CeedOperatorAssembleLinearQFunction(CeedOperator op,
457     CeedVector *assembled, CeedElemRestriction *rstr, CeedRequest *request);
458 CEED_EXTERN int CeedOperatorAssembleLinearDiagonal(CeedOperator op,
459     CeedVector *assembled, CeedRequest *request);
460 CEED_EXTERN int CeedOperatorView(CeedOperator op, FILE *stream);
461 CEED_EXTERN int CeedOperatorCreateFDMElementInverse(CeedOperator op,
462     CeedOperator *fdminv, CeedRequest *request);
463 CEED_EXTERN int CeedOperatorApply(CeedOperator op, CeedVector in,
464                                   CeedVector out, CeedRequest *request);
465 CEED_EXTERN int CeedOperatorApplyAdd(CeedOperator op, CeedVector in,
466                                      CeedVector out, CeedRequest *request);
467 CEED_EXTERN int CeedOperatorDestroy(CeedOperator *op);
468 
469 /**
470   @brief Return integer power
471 
472   @param[in] base   The base to exponentiate
473   @param[in] power  The power to raise the base to
474 
475   @return base^power
476 
477   @ref Utility
478 **/
479 static inline CeedInt CeedIntPow(CeedInt base, CeedInt power) {
480   CeedInt result = 1;
481   while (power) {
482     if (power & 1) result *= base;
483     power >>= 1;
484     base *= base;
485   }
486   return result;
487 }
488 
489 /**
490   @brief Return minimum of two integers
491 
492   @param[in] a  The first integer to compare
493   @param[in] b  The second integer to compare
494 
495   @return The minimum of the two integers
496 
497   @ref Utility
498 **/
499 static inline CeedInt CeedIntMin(CeedInt a, CeedInt b) { return a < b ? a : b; }
500 
501 #endif
502