196461910SJeremy L Thompson // Copyright (c) 2017-2022, 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 8c9c2c079SJeremy L Thompson #include <ceed.h> 9c9c2c079SJeremy L Thompson 10*2b730f8bSJeremy L Thompson CEED_QFUNCTION(setup)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 1196461910SJeremy L Thompson // *INDENT-OFF* 12*2b730f8bSJeremy L Thompson const CeedScalar *w = in[0], (*J)[2][CEED_Q_VLA] = (const CeedScalar(*)[2][CEED_Q_VLA])in[1]; 1396461910SJeremy L Thompson CeedScalar(*q_data)[CEED_Q_VLA] = (CeedScalar(*)[CEED_Q_VLA])out[0]; 1496461910SJeremy L Thompson // *INDENT-ON* 1596461910SJeremy L Thompson 1696461910SJeremy L Thompson // Quadrature point loop 17*2b730f8bSJeremy L Thompson CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) { 1896461910SJeremy L Thompson // Qdata stored in Voigt convention 1996461910SJeremy L Thompson // J: 0 2 q_data: 0 2 adj(J): J11 -J01 2096461910SJeremy L Thompson // 1 3 2 1 -J10 J00 2196461910SJeremy L Thompson const CeedScalar J00 = J[0][0][i]; 2296461910SJeremy L Thompson const CeedScalar J10 = J[0][1][i]; 2396461910SJeremy L Thompson const CeedScalar J01 = J[1][0][i]; 2496461910SJeremy L Thompson const CeedScalar J11 = J[1][1][i]; 2596461910SJeremy L Thompson const CeedScalar qw = w[i] / (J00 * J11 - J10 * J01); 2696461910SJeremy L Thompson q_data[0][i] = qw * (J01 * J01 + J11 * J11); 2796461910SJeremy L Thompson q_data[1][i] = qw * (J00 * J00 + J10 * J10); 2896461910SJeremy L Thompson q_data[2][i] = -qw * (J00 * J01 + J10 * J11); 2996461910SJeremy L Thompson } // End of Quadrature Point Loop 3096461910SJeremy L Thompson 3196461910SJeremy L Thompson return 0; 3296461910SJeremy L Thompson } 3396461910SJeremy L Thompson 34*2b730f8bSJeremy L Thompson CEED_QFUNCTION(diff)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 3596461910SJeremy L Thompson // *INDENT-OFF* 36*2b730f8bSJeremy 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]; 3710a06a06SJeremy L Thompson CeedScalar(*vg)[2][CEED_Q_VLA] = (CeedScalar(*)[2][CEED_Q_VLA])out[0]; 3896461910SJeremy L Thompson // *INDENT-ON* 3996461910SJeremy L Thompson 4096461910SJeremy L Thompson const CeedInt dim = 2; 4110a06a06SJeremy L Thompson const CeedScalar num_comp = 2; 4296461910SJeremy L Thompson const CeedScalar scale[2][2] = { 4396461910SJeremy L Thompson {1.0, 2.0}, 4496461910SJeremy L Thompson {3.0, 4.0}, 4596461910SJeremy L Thompson }; 4696461910SJeremy L Thompson 4796461910SJeremy L Thompson // Quadrature point loop 48*2b730f8bSJeremy L Thompson CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) { 4996461910SJeremy L Thompson // Read qdata (dXdxdXdxT symmetric matrix) 5096461910SJeremy L Thompson // Stored in Voigt convention 5196461910SJeremy L Thompson // 0 2 5296461910SJeremy L Thompson // 2 1 5396461910SJeremy L Thompson // *INDENT-OFF* 54*2b730f8bSJeremy L Thompson const CeedScalar dXdxdXdxT[2][2] = { 55*2b730f8bSJeremy L Thompson {q_data[0][i], q_data[2][i]}, 56*2b730f8bSJeremy L Thompson {q_data[2][i], q_data[1][i]} 5796461910SJeremy L Thompson }; 5896461910SJeremy L Thompson // *INDENT-ON* 5996461910SJeremy L Thompson 6096461910SJeremy L Thompson // Apply Poisson operator 6196461910SJeremy L Thompson // j = direction of vg 6210a06a06SJeremy L Thompson for (CeedInt j = 0; j < dim; j++) { 6310a06a06SJeremy L Thompson for (CeedInt k = 0; k < num_comp; k++) { 64*2b730f8bSJeremy 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]); 6510a06a06SJeremy L Thompson } 6610a06a06SJeremy L Thompson } 6796461910SJeremy L Thompson } // End of Quadrature Point Loop 6896461910SJeremy L Thompson 6996461910SJeremy L Thompson return 0; 7096461910SJeremy L Thompson } 71