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