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 //------------------------------------------------------------------------------ 18 // Setup 1D mass matrix 19 //------------------------------------------------------------------------------ 20 CEED_QFUNCTION(setup_mass)(void *ctx, const CeedInt Q, 21 const CeedScalar *const *in, 22 CeedScalar *const *out) { 23 // in[0] is quadrature weights, size (Q) 24 // in[1] is Jacobians, size (Q) 25 const CeedScalar *w = in[0], *J = in[1]; 26 27 // out[0] is quadrature data, size (Q) 28 CeedScalar *qdata = out[0]; 29 30 // Quadrature point loop 31 CeedPragmaSIMD 32 for (CeedInt i=0; i<Q; i++) { 33 qdata[i] = J[i] * w[i]; 34 } 35 36 return 0; 37 } 38 39 //------------------------------------------------------------------------------ 40 // Setup 2D mass matrix 41 //------------------------------------------------------------------------------ 42 CEED_QFUNCTION(setup_mass_2d)(void *ctx, const CeedInt Q, 43 const CeedScalar *const *in, 44 CeedScalar *const *out) { 45 // in[0] is quadrature weights, size (Q) 46 // in[1] is Jacobians with shape [2, nc=2, Q] 47 const CeedScalar *w = in[0], *J = in[1]; 48 49 // out[0] is quadrature data, size (Q) 50 CeedScalar *qdata = out[0]; 51 52 // Quadrature point loop 53 CeedPragmaSIMD 54 for (CeedInt i=0; i<Q; i++) { 55 qdata[i] = w[i] * (J[i+Q*0]*J[i+Q*3] - J[i+Q*1]*J[i+Q*2]); 56 } 57 58 return 0; 59 } 60 61 //------------------------------------------------------------------------------ 62 // Apply mass matrix 63 //------------------------------------------------------------------------------ 64 CEED_QFUNCTION(apply_mass)(void *ctx, const CeedInt Q, 65 const CeedScalar *const *in, 66 CeedScalar *const *out) { 67 // Get scaling factor, if set 68 const CeedScalar *scale_array = ctx ? (CeedScalar *)ctx : NULL; 69 const CeedScalar scale = ctx ? scale_array[4] : 1.; 70 71 // in[0] is quadrature data, size (Q) 72 // in[1] is u, size (Q) 73 const CeedScalar *qdata = in[0], *u = in[1]; 74 75 // out[0] is v, size (Q) 76 CeedScalar *v = out[0]; 77 78 // Quadrature point loop 79 CeedPragmaSIMD 80 for (CeedInt i=0; i<Q; i++) { 81 v[i] = scale * qdata[i] * u[i]; 82 } 83 84 return 0; 85 } 86 87 //------------------------------------------------------------------------------ 88 // Apply mass matrix to two components 89 //------------------------------------------------------------------------------ 90 CEED_QFUNCTION(apply_mass_two)(void *ctx, const CeedInt Q, 91 const CeedScalar *const *in, 92 CeedScalar *const *out) { 93 // in[0] is quadrature data, size (Q) 94 // in[1] is u, size (2*Q) 95 const CeedScalar *qdata = in[0], *u = in[1]; 96 97 // out[0] is v, size (2*Q) 98 CeedScalar *v = out[0]; 99 100 // Quadrature point loop 101 CeedPragmaSIMD 102 for (CeedInt i=0; i<Q; i++) { 103 v[i] = qdata[i] * u[i]; 104 v[Q+i] = qdata[i] * u[Q+i]; 105 } 106 107 return 0; 108 } 109 110 //------------------------------------------------------------------------------ 111