1 // Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. 2 // All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 3 // 4 // SPDX-License-Identifier: BSD-2-Clause 5 // 6 // This file is part of CEED: http://github.com/ceed 7 8 #ifndef bp1_h 9 #define bp1_h 10 11 /// A structure used to pass additional data to f_build_mass 12 struct BuildContext { CeedInt dim, space_dim; }; 13 14 /// libCEED Q-function for building quadrature data for a mass operator 15 CEED_QFUNCTION(f_build_mass)(void *ctx, const CeedInt Q, 16 const CeedScalar *const *in, CeedScalar *const *out) { 17 // in[0] is Jacobians with shape [dim, nc=dim, Q] 18 // in[1] is quadrature weights, size (Q) 19 BuildContext *bc = (BuildContext *)ctx; 20 const CeedScalar *J = in[0], *w = in[1]; 21 CeedScalar *qdata = out[0]; 22 23 switch (bc->dim + 10*bc->space_dim) { 24 case 11: 25 // Quadrature Point Loop 26 CeedPragmaSIMD 27 for (CeedInt i=0; i<Q; i++) { 28 qdata[i] = J[i] * w[i]; 29 } 30 break; 31 case 22: 32 // Quadrature Point Loop 33 CeedPragmaSIMD 34 for (CeedInt i=0; i<Q; i++) { 35 // 0 2 36 // 1 3 37 qdata[i] = (J[i+Q*0]*J[i+Q*3] - J[i+Q*1]*J[i+Q*2]) * w[i]; 38 } 39 break; 40 case 33: 41 // Quadrature Point Loop 42 CeedPragmaSIMD 43 for (CeedInt i=0; i<Q; i++) { 44 // 0 3 6 45 // 1 4 7 46 // 2 5 8 47 qdata[i] = (J[i+Q*0]*(J[i+Q*4]*J[i+Q*8] - J[i+Q*5]*J[i+Q*7]) - 48 J[i+Q*1]*(J[i+Q*3]*J[i+Q*8] - J[i+Q*5]*J[i+Q*6]) + 49 J[i+Q*2]*(J[i+Q*3]*J[i+Q*7] - J[i+Q*4]*J[i+Q*6])) * w[i]; 50 } 51 break; 52 } 53 return 0; 54 } 55 56 /// libCEED Q-function for applying a mass operator 57 CEED_QFUNCTION(f_apply_mass)(void *ctx, const CeedInt Q, 58 const CeedScalar *const *in, CeedScalar *const *out) { 59 const CeedScalar *u = in[0], *qdata = in[1]; 60 CeedScalar *v = out[0]; 61 62 // Quadrature Point Loop 63 CeedPragmaSIMD 64 for (CeedInt i=0; i<Q; i++) { 65 v[i] = qdata[i] * u[i]; 66 } 67 return 0; 68 } 69 70 #endif // bp1_h 71