19ba83ac0SJeremy L Thompson // Copyright (c) 2017-2026, Lawrence Livermore National Security, LLC and other CEED contributors. 23d8e8822SJeremy L Thompson // All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 366087c08SValeria Barra // 43d8e8822SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause 566087c08SValeria Barra // 63d8e8822SJeremy L Thompson // This file is part of CEED: http://github.com/ceed 766087c08SValeria Barra 8c0b5abf0SJeremy L Thompson #include <ceed/types.h> 9c9c2c079SJeremy L Thompson 1066087c08SValeria Barra /// A structure used to pass additional data to f_build_mass 112b730f8bSJeremy L Thompson struct BuildContext { 122b730f8bSJeremy L Thompson CeedInt dim, space_dim; 132b730f8bSJeremy L Thompson }; 1466087c08SValeria Barra 1566087c08SValeria Barra /// libCEED Q-function for building quadrature data for a mass operator 16d37d859eSJeremy L Thompson CEED_QFUNCTION(build_mass)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 17*860dc821SJeremy L Thompson struct BuildContext *build_data = (struct BuildContext *)ctx; 18*860dc821SJeremy L Thompson 190a242873SJeremy L Thompson // in[0] is Jacobians with shape [dim, dim, Q] 200a242873SJeremy L Thompson // in[1] is quadrature weights with shape [1, Q] 210a242873SJeremy L Thompson const CeedScalar *w = in[1]; 22d1d35e2fSjeremylt CeedScalar *q_data = out[0]; 2366087c08SValeria Barra 24d37d859eSJeremy L Thompson switch (build_data->dim + 10 * build_data->space_dim) { 250a242873SJeremy L Thompson case 11: { 260a242873SJeremy L Thompson const CeedScalar(*J)[1][CEED_Q_VLA] = (const CeedScalar(*)[1][CEED_Q_VLA])in[0]; 270a242873SJeremy L Thompson 2866087c08SValeria Barra // Quadrature Point Loop 290a242873SJeremy L Thompson CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) { q_data[i] = J[0][0][i] * w[i]; } // End of Quadrature Point Loop 300a242873SJeremy L Thompson } break; 310a242873SJeremy L Thompson case 22: { 320a242873SJeremy L Thompson const CeedScalar(*J)[2][CEED_Q_VLA] = (const CeedScalar(*)[2][CEED_Q_VLA])in[0]; 330a242873SJeremy L Thompson 3466087c08SValeria Barra // Quadrature Point Loop 352b730f8bSJeremy L Thompson CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) { 360a242873SJeremy L Thompson q_data[i] = (J[0][0][i] * J[1][1][i] - J[0][1][i] * J[1][0][i]) * w[i]; 3766087c08SValeria Barra } // End of Quadrature Point Loop 380a242873SJeremy L Thompson } break; 390a242873SJeremy L Thompson case 33: { 400a242873SJeremy L Thompson const CeedScalar(*J)[3][CEED_Q_VLA] = (const CeedScalar(*)[3][CEED_Q_VLA])in[0]; 410a242873SJeremy L Thompson 4266087c08SValeria Barra // Quadrature Point Loop 432b730f8bSJeremy L Thompson CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) { 440a242873SJeremy L Thompson q_data[i] = 450a242873SJeremy 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]) + 460a242873SJeremy L Thompson J[0][2][i] * (J[1][0][i] * J[2][1][i] - J[1][1][i] * J[2][0][i])) * 472b730f8bSJeremy L Thompson w[i]; 4866087c08SValeria Barra } // End of Quadrature Point Loop 490a242873SJeremy L Thompson } break; 5066087c08SValeria Barra } 510b96b02dSJeremy L Thompson return CEED_ERROR_SUCCESS; 5266087c08SValeria Barra } 5366087c08SValeria Barra 5466087c08SValeria Barra /// libCEED Q-function for applying a mass operator 55d37d859eSJeremy L Thompson CEED_QFUNCTION(apply_mass)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 560a242873SJeremy L Thompson // in[0], out[0] are solution variables with shape [1, Q] 570a242873SJeremy L Thompson // in[1] is quadrature data with shape [1, Q] 58d1d35e2fSjeremylt const CeedScalar *u = in[0], *q_data = in[1]; 5966087c08SValeria Barra CeedScalar *v = out[0]; 6066087c08SValeria Barra 6166087c08SValeria Barra // Quadrature Point Loop 622b730f8bSJeremy L Thompson CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) { v[i] = q_data[i] * u[i]; } // End of Quadrature Point Loop 630b96b02dSJeremy L Thompson return CEED_ERROR_SUCCESS; 6466087c08SValeria Barra } 65