1 // Copyright (c) 2017-2018, Lawrence Livermore National Security, LLC. 2 // Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707. 3 // All Rights 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 #ifndef ex1_volume_h 18 #define ex1_volume_h 19 #include <ceed.h> 20 21 /// A structure used to pass additional data to f_build_mass 22 struct BuildContext { CeedInt dim, space_dim; }; 23 24 /// libCEED Q-function for building quadrature data for a mass operator 25 CEED_QFUNCTION(f_build_mass)(void *ctx, const CeedInt Q, 26 const CeedScalar *const *in, CeedScalar *const *out) { 27 // in[0] is Jacobians with shape [dim, nc=dim, Q] 28 // in[1] is quadrature weights, size (Q) 29 struct BuildContext *bc = (struct BuildContext *)ctx; 30 const CeedScalar *J = in[0], *w = in[1]; 31 CeedScalar *qdata = out[0]; 32 33 switch (bc->dim + 10*bc->space_dim) { 34 case 11: 35 // Quadrature Point Loop 36 CeedPragmaSIMD 37 for (CeedInt i=0; i<Q; i++) { 38 qdata[i] = J[i] * w[i]; 39 } // End of Quadrature Point Loop 40 break; 41 case 22: 42 // Quadrature Point Loop 43 CeedPragmaSIMD 44 for (CeedInt i=0; i<Q; i++) { 45 // 0 2 46 // 1 3 47 qdata[i] = (J[i+Q*0]*J[i+Q*3] - J[i+Q*1]*J[i+Q*2]) * w[i]; 48 } // End of Quadrature Point Loop 49 break; 50 case 33: 51 // Quadrature Point Loop 52 CeedPragmaSIMD 53 for (CeedInt i=0; i<Q; i++) { 54 // 0 3 6 55 // 1 4 7 56 // 2 5 8 57 qdata[i] = (J[i+Q*0]*(J[i+Q*4]*J[i+Q*8] - J[i+Q*5]*J[i+Q*7]) - 58 J[i+Q*1]*(J[i+Q*3]*J[i+Q*8] - J[i+Q*5]*J[i+Q*6]) + 59 J[i+Q*2]*(J[i+Q*3]*J[i+Q*7] - J[i+Q*4]*J[i+Q*6])) * w[i]; 60 } // End of Quadrature Point Loop 61 break; 62 } 63 return 0; 64 } 65 66 /// libCEED Q-function for applying a mass operator 67 CEED_QFUNCTION(f_apply_mass)(void *ctx, const CeedInt Q, 68 const CeedScalar *const *in, CeedScalar *const *out) { 69 const CeedScalar *u = in[0], *qdata = in[1]; 70 CeedScalar *v = out[0]; 71 72 // Quadrature Point Loop 73 CeedPragmaSIMD 74 for (CeedInt i=0; i<Q; i++) { 75 v[i] = qdata[i] * u[i]; 76 } // End of Quadrature Point Loop 77 return 0; 78 } 79 80 #endif // ex1_volume_h 81