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