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