1 // Copyright (c) 2017-2024, 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 #include <ceed.h> 9 10 CEED_QFUNCTION(SetupMass)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 11 const CeedScalar(*J)[3][CEED_Q_VLA] = (const CeedScalar(*)[3][CEED_Q_VLA])in[0]; 12 const CeedScalar *w = in[1]; 13 CeedScalar *q_data = out[0]; 14 15 // Quadrature point loop 16 CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) { 17 const CeedScalar B11 = J[1][1][i] * J[2][2][i] - J[1][2][i] * J[2][1][i]; 18 const CeedScalar B12 = J[0][2][i] * J[2][1][i] - J[0][1][i] * J[2][2][i]; 19 const CeedScalar B13 = J[0][1][i] * J[1][2][i] - J[0][2][i] * J[1][1][i]; 20 21 q_data[i] = w[i] * (J[0][0][i] * B11 + J[1][0][i] * B12 + J[2][0][i] * B13); 22 } 23 return 0; 24 } 25 26 CEED_QFUNCTION(Mass)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 27 const CeedScalar *rho = (const CeedScalar *)in[0]; 28 const CeedScalar(*u)[CEED_Q_VLA] = (const CeedScalar(*)[CEED_Q_VLA])in[1]; 29 CeedScalar(*v)[CEED_Q_VLA] = (CeedScalar(*)[CEED_Q_VLA])out[0]; 30 31 const CeedInt num_comp = *(CeedInt *)ctx; 32 // Quadrature point loop 33 CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) { 34 for (CeedInt j = 0; j < num_comp; j++) v[j][i] = rho[i] * u[j][i]; 35 } 36 return 0; 37 } 38