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