1*860dc821SJeremy L Thompson // Copyright (c) 2017-2026, Lawrence Livermore National Security, LLC and other CEED contributors. 2*860dc821SJeremy L Thompson // All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 3*860dc821SJeremy L Thompson // 4*860dc821SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause 5*860dc821SJeremy L Thompson // 6*860dc821SJeremy L Thompson // This file is part of CEED: http://github.com/ceed 7*860dc821SJeremy L Thompson 8*860dc821SJeremy L Thompson #include <ceed/types.h> 9*860dc821SJeremy L Thompson 10*860dc821SJeremy L Thompson /// libCEED Q-function for building quadrature data for a mass operator 11*860dc821SJeremy L Thompson CEED_QFUNCTION(build_mass)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 12*860dc821SJeremy L Thompson long long int *build_data = (long long int *)ctx; 13*860dc821SJeremy L Thompson 14*860dc821SJeremy L Thompson // in[0] is Jacobians with shape [dim, dim, Q] 15*860dc821SJeremy L Thompson // in[1] is quadrature weights with shape [1, Q] 16*860dc821SJeremy L Thompson const CeedScalar *w = in[1]; 17*860dc821SJeremy L Thompson CeedScalar *q_data = out[0]; 18*860dc821SJeremy L Thompson 19*860dc821SJeremy L Thompson switch (build_data[0] + 10 * build_data[1]) { 20*860dc821SJeremy L Thompson case 11: { 21*860dc821SJeremy L Thompson const CeedScalar(*J)[1][CEED_Q_VLA] = (const CeedScalar(*)[1][CEED_Q_VLA])in[0]; 22*860dc821SJeremy L Thompson 23*860dc821SJeremy L Thompson // Quadrature Point Loop 24*860dc821SJeremy L Thompson CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) { q_data[i] = J[0][0][i] * w[i]; } // End of Quadrature Point Loop 25*860dc821SJeremy L Thompson } break; 26*860dc821SJeremy L Thompson case 22: { 27*860dc821SJeremy L Thompson const CeedScalar(*J)[2][CEED_Q_VLA] = (const CeedScalar(*)[2][CEED_Q_VLA])in[0]; 28*860dc821SJeremy L Thompson 29*860dc821SJeremy L Thompson // Quadrature Point Loop 30*860dc821SJeremy L Thompson CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) { 31*860dc821SJeremy L Thompson q_data[i] = (J[0][0][i] * J[1][1][i] - J[0][1][i] * J[1][0][i]) * w[i]; 32*860dc821SJeremy L Thompson } // End of Quadrature Point Loop 33*860dc821SJeremy L Thompson } break; 34*860dc821SJeremy L Thompson case 33: { 35*860dc821SJeremy L Thompson const CeedScalar(*J)[3][CEED_Q_VLA] = (const CeedScalar(*)[3][CEED_Q_VLA])in[0]; 36*860dc821SJeremy L Thompson 37*860dc821SJeremy L Thompson // Quadrature Point Loop 38*860dc821SJeremy L Thompson CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) { 39*860dc821SJeremy L Thompson q_data[i] = 40*860dc821SJeremy L Thompson (J[0][0][i] * (J[1][1][i] * J[2][2][i] - J[1][2][i] * J[2][1][i]) - J[0][1][i] * (J[1][0][i] * J[2][2][i] - J[1][2][i] * J[2][0][i]) + 41*860dc821SJeremy L Thompson J[0][2][i] * (J[1][0][i] * J[2][1][i] - J[1][1][i] * J[2][0][i])) * 42*860dc821SJeremy L Thompson w[i]; 43*860dc821SJeremy L Thompson } // End of Quadrature Point Loop 44*860dc821SJeremy L Thompson } break; 45*860dc821SJeremy L Thompson } 46*860dc821SJeremy L Thompson return CEED_ERROR_SUCCESS; 47*860dc821SJeremy L Thompson } 48*860dc821SJeremy L Thompson 49*860dc821SJeremy L Thompson /// libCEED Q-function for applying a mass operator 50*860dc821SJeremy L Thompson CEED_QFUNCTION(apply_mass)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 51*860dc821SJeremy L Thompson // in[0], out[0] are solution variables with shape [1, Q] 52*860dc821SJeremy L Thompson // in[1] is quadrature data with shape [1, Q] 53*860dc821SJeremy L Thompson const CeedScalar *u = in[0], *q_data = in[1]; 54*860dc821SJeremy L Thompson CeedScalar *v = out[0]; 55*860dc821SJeremy L Thompson 56*860dc821SJeremy L Thompson // Quadrature Point Loop 57*860dc821SJeremy L Thompson CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) { v[i] = q_data[i] * u[i]; } // End of Quadrature Point Loop 58*860dc821SJeremy L Thompson return CEED_ERROR_SUCCESS; 59*860dc821SJeremy L Thompson } 60