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