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 #include <ceed.h> 9 10 CEED_QFUNCTION(setup)(void *ctx, const CeedInt Q, 11 const CeedScalar *const *in, 12 CeedScalar *const *out) { 13 const CeedScalar *qw = in[0], *J = in[1]; 14 CeedScalar *qd = out[0]; 15 16 for (CeedInt i=0; i<Q; i++) { 17 // Qdata stored in Voigt convention 18 // J: 0 2 qd: 0 2 adj(J): J22 -J12 19 // 1 3 2 1 -J21 J11 20 const CeedScalar J11 = J[i+Q*0]; 21 const CeedScalar J21 = J[i+Q*1]; 22 const CeedScalar J12 = J[i+Q*2]; 23 const CeedScalar J22 = J[i+Q*3]; 24 const CeedScalar w = qw[i] / (J11*J22 - J21*J12); 25 qd[i+Q*0] = w * (J12*J12 + J22*J22); 26 qd[i+Q*1] = w * (J11*J11 + J21*J21); 27 qd[i+Q*2] = - w * (J11*J12 + J21*J22); 28 } // End of Quadrature Point Loop 29 return 0; 30 } 31 32 CEED_QFUNCTION(diff)(void *ctx, const CeedInt Q, const CeedScalar *const *in, 33 CeedScalar *const *out) { 34 const CeedScalar *qd = in[0], *ug = in[1]; 35 CeedScalar *vg = out[0]; 36 37 for (CeedInt i=0; i<Q; i++) { 38 // Read spatial derivatives of u 39 const CeedScalar du[2] = {ug[i+Q*0], 40 ug[i+Q*1] 41 }; 42 43 // Read qdata (dXdxdXdxT symmetric matrix) 44 // Stored in Voigt convention 45 // 0 2 46 // 2 1 47 // *INDENT-OFF* 48 const CeedScalar dXdxdXdxT[2][2] = {{qd[i+0*Q], 49 qd[i+2*Q]}, 50 {qd[i+2*Q], 51 qd[i+1*Q]} 52 }; 53 // *INDENT-ON* 54 // j = direction of vg 55 for (int j=0; j<2; j++) 56 vg[i+j*Q] = (du[0] * dXdxdXdxT[0][j] + 57 du[1] * dXdxdXdxT[1][j]); 58 } 59 return 0; 60 } 61