1*96461910SJeremy L Thompson // Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors. 2*96461910SJeremy L Thompson // All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 3*96461910SJeremy L Thompson // 4*96461910SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause 5*96461910SJeremy L Thompson // 6*96461910SJeremy L Thompson // This file is part of CEED: http://github.com/ceed 7*96461910SJeremy L Thompson 8*96461910SJeremy L Thompson CEED_QFUNCTION(setup)(void *ctx, const CeedInt Q, 9*96461910SJeremy L Thompson const CeedScalar *const *in, 10*96461910SJeremy L Thompson CeedScalar *const *out) { 11*96461910SJeremy L Thompson // *INDENT-OFF* 12*96461910SJeremy L Thompson const CeedScalar *w = in[0], 13*96461910SJeremy L Thompson (*J)[2][CEED_Q_VLA] = (const CeedScalar(*)[2][CEED_Q_VLA])in[1]; 14*96461910SJeremy L Thompson CeedScalar (*q_data)[CEED_Q_VLA] = (CeedScalar(*)[CEED_Q_VLA])out[0]; 15*96461910SJeremy L Thompson // *INDENT-ON* 16*96461910SJeremy L Thompson 17*96461910SJeremy L Thompson // Quadrature point loop 18*96461910SJeremy L Thompson CeedPragmaSIMD 19*96461910SJeremy L Thompson for (CeedInt i=0; i<Q; i++) { 20*96461910SJeremy L Thompson // Qdata stored in Voigt convention 21*96461910SJeremy L Thompson // J: 0 2 q_data: 0 2 adj(J): J11 -J01 22*96461910SJeremy L Thompson // 1 3 2 1 -J10 J00 23*96461910SJeremy L Thompson const CeedScalar J00 = J[0][0][i]; 24*96461910SJeremy L Thompson const CeedScalar J10 = J[0][1][i]; 25*96461910SJeremy L Thompson const CeedScalar J01 = J[1][0][i]; 26*96461910SJeremy L Thompson const CeedScalar J11 = J[1][1][i]; 27*96461910SJeremy L Thompson const CeedScalar qw = w[i] / (J00*J11 - J10*J01); 28*96461910SJeremy L Thompson q_data[0][i] = qw * (J01*J01 + J11*J11); 29*96461910SJeremy L Thompson q_data[1][i] = qw * (J00*J00 + J10*J10); 30*96461910SJeremy L Thompson q_data[2][i] = - qw * (J00*J01 + J10*J11); 31*96461910SJeremy L Thompson } // End of Quadrature Point Loop 32*96461910SJeremy L Thompson 33*96461910SJeremy L Thompson return 0; 34*96461910SJeremy L Thompson } 35*96461910SJeremy L Thompson 36*96461910SJeremy L Thompson CEED_QFUNCTION(diff)(void *ctx, const CeedInt Q, const CeedScalar *const *in, 37*96461910SJeremy L Thompson CeedScalar *const *out) { 38*96461910SJeremy L Thompson // *INDENT-OFF* 39*96461910SJeremy L Thompson const CeedScalar (*q_data)[CEED_Q_VLA] = (const CeedScalar(*)[CEED_Q_VLA])in[0], 40*96461910SJeremy L Thompson (*ug)[CEED_Q_VLA] = (const CeedScalar(*)[CEED_Q_VLA])in[1]; 41*96461910SJeremy L Thompson CeedScalar (*vg)[CEED_Q_VLA] = (CeedScalar(*)[CEED_Q_VLA])out[0]; 42*96461910SJeremy L Thompson // *INDENT-ON* 43*96461910SJeremy L Thompson 44*96461910SJeremy L Thompson const CeedInt dim = 2; 45*96461910SJeremy L Thompson const CeedScalar scale[2][2] = { 46*96461910SJeremy L Thompson {1.0, 2.0}, 47*96461910SJeremy L Thompson {3.0, 4.0}, 48*96461910SJeremy L Thompson }; 49*96461910SJeremy L Thompson 50*96461910SJeremy L Thompson // Quadrature point loop 51*96461910SJeremy L Thompson CeedPragmaSIMD 52*96461910SJeremy L Thompson for (CeedInt i=0; i<Q; i++) { 53*96461910SJeremy L Thompson // Read qdata (dXdxdXdxT symmetric matrix) 54*96461910SJeremy L Thompson // Stored in Voigt convention 55*96461910SJeremy L Thompson // 0 2 56*96461910SJeremy L Thompson // 2 1 57*96461910SJeremy L Thompson // *INDENT-OFF* 58*96461910SJeremy L Thompson const CeedScalar dXdxdXdxT[2][2] = {{q_data[0][i], 59*96461910SJeremy L Thompson q_data[2][i]}, 60*96461910SJeremy L Thompson {q_data[2][i], 61*96461910SJeremy L Thompson q_data[1][i]} 62*96461910SJeremy L Thompson }; 63*96461910SJeremy L Thompson // *INDENT-ON* 64*96461910SJeremy L Thompson 65*96461910SJeremy L Thompson // Apply Poisson operator 66*96461910SJeremy L Thompson // j = direction of vg 67*96461910SJeremy L Thompson for (CeedInt j=0; j<dim; j++) 68*96461910SJeremy L Thompson vg[j][i] = (ug[0][i] * dXdxdXdxT[0][j] * scale[0][j] + 69*96461910SJeremy L Thompson ug[1][i] * dXdxdXdxT[1][j] * scale[1][j]); 70*96461910SJeremy L Thompson } // End of Quadrature Point Loop 71*96461910SJeremy L Thompson 72*96461910SJeremy L Thompson return 0; 73*96461910SJeremy L Thompson } 74