1*9ba83ac0SJeremy L Thompson // Copyright (c) 2017-2026, Lawrence Livermore National Security, LLC and other CEED contributors.
296461910SJeremy L Thompson // All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
396461910SJeremy L Thompson //
496461910SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause
596461910SJeremy L Thompson //
696461910SJeremy L Thompson // This file is part of CEED: http://github.com/ceed
796461910SJeremy L Thompson
8c0b5abf0SJeremy L Thompson #include <ceed/types.h>
9c9c2c079SJeremy L Thompson
setup(void * ctx,const CeedInt Q,const CeedScalar * const * in,CeedScalar * const * out)102b730f8bSJeremy L Thompson CEED_QFUNCTION(setup)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) {
112b730f8bSJeremy L Thompson const CeedScalar *w = in[0], (*J)[2][CEED_Q_VLA] = (const CeedScalar(*)[2][CEED_Q_VLA])in[1];
1296461910SJeremy L Thompson CeedScalar(*q_data)[CEED_Q_VLA] = (CeedScalar(*)[CEED_Q_VLA])out[0];
1396461910SJeremy L Thompson
1496461910SJeremy L Thompson // Quadrature point loop
152b730f8bSJeremy L Thompson CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) {
1696461910SJeremy L Thompson // Qdata stored in Voigt convention
1796461910SJeremy L Thompson // J: 0 2 q_data: 0 2 adj(J): J11 -J01
1896461910SJeremy L Thompson // 1 3 2 1 -J10 J00
1996461910SJeremy L Thompson const CeedScalar J00 = J[0][0][i];
2096461910SJeremy L Thompson const CeedScalar J10 = J[0][1][i];
2196461910SJeremy L Thompson const CeedScalar J01 = J[1][0][i];
2296461910SJeremy L Thompson const CeedScalar J11 = J[1][1][i];
2396461910SJeremy L Thompson const CeedScalar qw = w[i] / (J00 * J11 - J10 * J01);
2496461910SJeremy L Thompson q_data[0][i] = qw * (J01 * J01 + J11 * J11);
2596461910SJeremy L Thompson q_data[1][i] = qw * (J00 * J00 + J10 * J10);
2696461910SJeremy L Thompson q_data[2][i] = -qw * (J00 * J01 + J10 * J11);
2796461910SJeremy L Thompson } // End of Quadrature Point Loop
2896461910SJeremy L Thompson
2996461910SJeremy L Thompson return 0;
3096461910SJeremy L Thompson }
3196461910SJeremy L Thompson
diff(void * ctx,const CeedInt Q,const CeedScalar * const * in,CeedScalar * const * out)322b730f8bSJeremy L Thompson CEED_QFUNCTION(diff)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) {
332b730f8bSJeremy L Thompson const CeedScalar(*q_data)[CEED_Q_VLA] = (const CeedScalar(*)[CEED_Q_VLA])in[0], (*ug)[2][CEED_Q_VLA] = (const CeedScalar(*)[2][CEED_Q_VLA])in[1];
3410a06a06SJeremy L Thompson CeedScalar(*vg)[2][CEED_Q_VLA] = (CeedScalar(*)[2][CEED_Q_VLA])out[0];
3596461910SJeremy L Thompson
3696461910SJeremy L Thompson const CeedInt dim = 2;
3710a06a06SJeremy L Thompson const CeedScalar num_comp = 2;
3896461910SJeremy L Thompson const CeedScalar scale[2][2] = {
3996461910SJeremy L Thompson {1.0, 2.0},
4096461910SJeremy L Thompson {3.0, 4.0},
4196461910SJeremy L Thompson };
4296461910SJeremy L Thompson
4396461910SJeremy L Thompson // Quadrature point loop
442b730f8bSJeremy L Thompson CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) {
4596461910SJeremy L Thompson // Read qdata (dXdxdXdxT symmetric matrix)
4696461910SJeremy L Thompson // Stored in Voigt convention
4796461910SJeremy L Thompson // 0 2
4896461910SJeremy L Thompson // 2 1
492b730f8bSJeremy L Thompson const CeedScalar dXdxdXdxT[2][2] = {
502b730f8bSJeremy L Thompson {q_data[0][i], q_data[2][i]},
512b730f8bSJeremy L Thompson {q_data[2][i], q_data[1][i]}
5296461910SJeremy L Thompson };
5396461910SJeremy L Thompson
5496461910SJeremy L Thompson // Apply Poisson operator
5596461910SJeremy L Thompson // j = direction of vg
5610a06a06SJeremy L Thompson for (CeedInt j = 0; j < dim; j++) {
5710a06a06SJeremy L Thompson for (CeedInt k = 0; k < num_comp; k++) {
582b730f8bSJeremy L Thompson vg[j][k][i] = (ug[0][k][i] * dXdxdXdxT[0][j] * scale[0][j] + ug[1][k][i] * dXdxdXdxT[1][j] * scale[1][j]);
5910a06a06SJeremy L Thompson }
6010a06a06SJeremy L Thompson }
6196461910SJeremy L Thompson } // End of Quadrature Point Loop
6296461910SJeremy L Thompson
6396461910SJeremy L Thompson return 0;
6496461910SJeremy L Thompson }
65