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 896461910SJeremy L Thompson CEED_QFUNCTION(setup)(void *ctx, const CeedInt Q, 996461910SJeremy L Thompson const CeedScalar *const *in, 1096461910SJeremy L Thompson CeedScalar *const *out) { 1196461910SJeremy L Thompson // *INDENT-OFF* 1296461910SJeremy L Thompson const CeedScalar *w = in[0], 1396461910SJeremy L Thompson (*J)[2][CEED_Q_VLA] = (const CeedScalar(*)[2][CEED_Q_VLA])in[1]; 1496461910SJeremy L Thompson CeedScalar (*q_data)[CEED_Q_VLA] = (CeedScalar(*)[CEED_Q_VLA])out[0]; 1596461910SJeremy L Thompson // *INDENT-ON* 1696461910SJeremy L Thompson 1796461910SJeremy L Thompson // Quadrature point loop 1896461910SJeremy L Thompson CeedPragmaSIMD 1996461910SJeremy L Thompson for (CeedInt i=0; i<Q; i++) { 2096461910SJeremy L Thompson // Qdata stored in Voigt convention 2196461910SJeremy L Thompson // J: 0 2 q_data: 0 2 adj(J): J11 -J01 2296461910SJeremy L Thompson // 1 3 2 1 -J10 J00 2396461910SJeremy L Thompson const CeedScalar J00 = J[0][0][i]; 2496461910SJeremy L Thompson const CeedScalar J10 = J[0][1][i]; 2596461910SJeremy L Thompson const CeedScalar J01 = J[1][0][i]; 2696461910SJeremy L Thompson const CeedScalar J11 = J[1][1][i]; 2796461910SJeremy L Thompson const CeedScalar qw = w[i] / (J00*J11 - J10*J01); 2896461910SJeremy L Thompson q_data[0][i] = qw * (J01*J01 + J11*J11); 2996461910SJeremy L Thompson q_data[1][i] = qw * (J00*J00 + J10*J10); 3096461910SJeremy L Thompson q_data[2][i] = - qw * (J00*J01 + J10*J11); 3196461910SJeremy L Thompson } // End of Quadrature Point Loop 3296461910SJeremy L Thompson 3396461910SJeremy L Thompson return 0; 3496461910SJeremy L Thompson } 3596461910SJeremy L Thompson 3696461910SJeremy L Thompson CEED_QFUNCTION(diff)(void *ctx, const CeedInt Q, const CeedScalar *const *in, 3796461910SJeremy L Thompson CeedScalar *const *out) { 3896461910SJeremy L Thompson // *INDENT-OFF* 3996461910SJeremy L Thompson const CeedScalar (*q_data)[CEED_Q_VLA] = (const CeedScalar(*)[CEED_Q_VLA])in[0], 40*10a06a06SJeremy L Thompson (*ug)[2][CEED_Q_VLA] = (const CeedScalar(*)[2][CEED_Q_VLA])in[1]; 41*10a06a06SJeremy L Thompson CeedScalar (*vg)[2][CEED_Q_VLA] = (CeedScalar(*)[2][CEED_Q_VLA])out[0]; 4296461910SJeremy L Thompson // *INDENT-ON* 4396461910SJeremy L Thompson 4496461910SJeremy L Thompson const CeedInt dim = 2; 45*10a06a06SJeremy L Thompson const CeedScalar num_comp = 2; 4696461910SJeremy L Thompson const CeedScalar scale[2][2] = { 4796461910SJeremy L Thompson {1.0, 2.0}, 4896461910SJeremy L Thompson {3.0, 4.0}, 4996461910SJeremy L Thompson }; 5096461910SJeremy L Thompson 5196461910SJeremy L Thompson // Quadrature point loop 5296461910SJeremy L Thompson CeedPragmaSIMD 5396461910SJeremy L Thompson for (CeedInt i=0; i<Q; i++) { 5496461910SJeremy L Thompson // Read qdata (dXdxdXdxT symmetric matrix) 5596461910SJeremy L Thompson // Stored in Voigt convention 5696461910SJeremy L Thompson // 0 2 5796461910SJeremy L Thompson // 2 1 5896461910SJeremy L Thompson // *INDENT-OFF* 5996461910SJeremy L Thompson const CeedScalar dXdxdXdxT[2][2] = {{q_data[0][i], 6096461910SJeremy L Thompson q_data[2][i]}, 6196461910SJeremy L Thompson {q_data[2][i], 6296461910SJeremy L Thompson q_data[1][i]} 6396461910SJeremy L Thompson }; 6496461910SJeremy L Thompson // *INDENT-ON* 6596461910SJeremy L Thompson 6696461910SJeremy L Thompson // Apply Poisson operator 6796461910SJeremy L Thompson // j = direction of vg 68*10a06a06SJeremy L Thompson for (CeedInt j=0; j<dim; j++) { 69*10a06a06SJeremy L Thompson for (CeedInt k=0; k<num_comp; k++) { 70*10a06a06SJeremy L Thompson vg[j][k][i] = (ug[0][k][i] * dXdxdXdxT[0][j] * scale[0][j] + 71*10a06a06SJeremy L Thompson ug[1][k][i] * dXdxdXdxT[1][j] * scale[1][j]); 72*10a06a06SJeremy L Thompson } 73*10a06a06SJeremy L Thompson } 7496461910SJeremy L Thompson } // End of Quadrature Point Loop 7596461910SJeremy L Thompson 7696461910SJeremy L Thompson return 0; 7796461910SJeremy L Thompson } 78