1 // Copyright (c) 2017-2026, 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 //------------------------------------------------------------------------------ 9 // Setup 1D mass matrix 10 //------------------------------------------------------------------------------ 11 CEED_QFUNCTION(setup_mass)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 12 // in[0] is quadrature weights, size (Q) 13 // in[1] is Jacobians, size (Q) 14 const CeedScalar *w = in[0], *J = in[1]; 15 16 // out[0] is quadrature data, size (Q) 17 CeedScalar *qdata = out[0]; 18 19 // Quadrature point loop 20 CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) { qdata[i] = J[i] * w[i]; } 21 22 return 0; 23 } 24 25 //------------------------------------------------------------------------------ 26 // Setup 2D mass matrix 27 //------------------------------------------------------------------------------ 28 CEED_QFUNCTION(setup_mass_2d)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 29 // in[0] is quadrature weights, size (Q) 30 // in[1] is Jacobians with shape [2, nc=2, Q] 31 const CeedScalar *w = in[0], *J = in[1]; 32 33 // out[0] is quadrature data, size (Q) 34 CeedScalar *qdata = out[0]; 35 36 // Quadrature point loop 37 CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) { qdata[i] = w[i] * (J[i + Q * 0] * J[i + Q * 3] - J[i + Q * 1] * J[i + Q * 2]); } 38 39 return 0; 40 } 41 42 //------------------------------------------------------------------------------ 43 // Apply mass matrix 44 //------------------------------------------------------------------------------ 45 CEED_QFUNCTION(apply_mass)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 46 // Get scaling factor, if set 47 const CeedScalar *scale_array = ctx ? (CeedScalar *)ctx : NULL; 48 const CeedScalar scale = ctx ? scale_array[4] : 1.; 49 50 // in[0] is quadrature data, size (Q) 51 // in[1] is u, size (Q) 52 const CeedScalar *qdata = in[0], *u = in[1]; 53 54 // out[0] is v, size (Q) 55 CeedScalar *v = out[0]; 56 57 // Quadrature point loop 58 CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) { v[i] = scale * qdata[i] * u[i]; } 59 60 return 0; 61 } 62 63 //------------------------------------------------------------------------------ 64 // Apply mass matrix to two components 65 //------------------------------------------------------------------------------ 66 CEED_QFUNCTION(apply_mass_two)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 67 // in[0] is quadrature data, size (Q) 68 // in[1] is u, size (2*Q) 69 const CeedScalar *qdata = in[0], *u = in[1]; 70 71 // out[0] is v, size (2*Q) 72 CeedScalar *v = out[0]; 73 74 // Quadrature point loop 75 CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) { 76 v[i] = qdata[i] * u[i]; 77 v[Q + i] = qdata[i] * u[Q + i]; 78 } 79 80 return 0; 81 } 82 83 //------------------------------------------------------------------------------ 84