1*9ba83ac0SJeremy L Thompson // Copyright (c) 2017-2026, Lawrence Livermore National Security, LLC and other CEED contributors. 27b3ff069SJeremy L Thompson // All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 37b3ff069SJeremy L Thompson // 47b3ff069SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause 57b3ff069SJeremy L Thompson // 67b3ff069SJeremy L Thompson // This file is part of CEED: http://github.com/ceed 77b3ff069SJeremy L Thompson #pragma once 87b3ff069SJeremy L Thompson 97b3ff069SJeremy L Thompson #include <ceed/types.h> 107b3ff069SJeremy L Thompson #include "ex-common.h" 117b3ff069SJeremy L Thompson 127b3ff069SJeremy L Thompson /// libCEED Q-function for building quadrature data for a mass operator 137b3ff069SJeremy L Thompson CEED_QFUNCTION(build_mass)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 147b3ff069SJeremy L Thompson // in[0] is Jacobians with shape [dim, dim, Q] 157b3ff069SJeremy L Thompson // in[1] is quadrature weights with shape [1, Q] 167b3ff069SJeremy L Thompson const CeedScalar *w = in[1]; 177b3ff069SJeremy L Thompson CeedScalar *q_data = out[0]; 187b3ff069SJeremy L Thompson struct BuildContext *build_data = (struct BuildContext *)ctx; 197b3ff069SJeremy L Thompson 207b3ff069SJeremy L Thompson switch (build_data->dim + 10 * build_data->space_dim) { 217b3ff069SJeremy L Thompson case 11: { 227b3ff069SJeremy L Thompson const CeedScalar(*J)[1][CEED_Q_VLA] = (const CeedScalar(*)[1][CEED_Q_VLA])in[0]; 237b3ff069SJeremy L Thompson 247b3ff069SJeremy L Thompson // Quadrature Point Loop 257b3ff069SJeremy L Thompson CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) { q_data[i] = J[0][0][i] * w[i]; } // End of Quadrature Point Loop 267b3ff069SJeremy L Thompson } break; 277b3ff069SJeremy L Thompson case 22: { 287b3ff069SJeremy L Thompson const CeedScalar(*J)[2][CEED_Q_VLA] = (const CeedScalar(*)[2][CEED_Q_VLA])in[0]; 297b3ff069SJeremy L Thompson 307b3ff069SJeremy L Thompson // Quadrature Point Loop 317b3ff069SJeremy L Thompson CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) { 327b3ff069SJeremy L Thompson q_data[i] = (J[0][0][i] * J[1][1][i] - J[0][1][i] * J[1][0][i]) * w[i]; 337b3ff069SJeremy L Thompson } // End of Quadrature Point Loop 347b3ff069SJeremy L Thompson } break; 357b3ff069SJeremy L Thompson case 33: { 367b3ff069SJeremy L Thompson const CeedScalar(*J)[3][CEED_Q_VLA] = (const CeedScalar(*)[3][CEED_Q_VLA])in[0]; 377b3ff069SJeremy L Thompson 387b3ff069SJeremy L Thompson // Quadrature Point Loop 397b3ff069SJeremy L Thompson CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) { 407b3ff069SJeremy L Thompson q_data[i] = 417b3ff069SJeremy 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]) + 427b3ff069SJeremy L Thompson J[0][2][i] * (J[1][0][i] * J[2][1][i] - J[1][1][i] * J[2][0][i])) * 437b3ff069SJeremy L Thompson w[i]; 447b3ff069SJeremy L Thompson } // End of Quadrature Point Loop 457b3ff069SJeremy L Thompson } break; 467b3ff069SJeremy L Thompson } 477b3ff069SJeremy L Thompson return CEED_ERROR_SUCCESS; 487b3ff069SJeremy L Thompson } 497b3ff069SJeremy L Thompson 507b3ff069SJeremy L Thompson /// libCEED Q-function for applying a mass operator 517b3ff069SJeremy L Thompson CEED_QFUNCTION(apply_mass)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 527b3ff069SJeremy L Thompson // in[0], out[0] are solution variables with shape [1, Q] 537b3ff069SJeremy L Thompson // in[1] is quadrature data with shape [1, Q] 547b3ff069SJeremy L Thompson const CeedScalar *u = in[0], *q_data = in[1]; 557b3ff069SJeremy L Thompson CeedScalar *v = out[0]; 567b3ff069SJeremy L Thompson 577b3ff069SJeremy L Thompson // Quadrature Point Loop 587b3ff069SJeremy L Thompson CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) { v[i] = q_data[i] * u[i]; } // End of Quadrature Point Loop 597b3ff069SJeremy L Thompson return CEED_ERROR_SUCCESS; 607b3ff069SJeremy L Thompson } 61