1*ccaff030SJeremy L Thompson // Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at 2*ccaff030SJeremy L Thompson // the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights 3*ccaff030SJeremy L Thompson // reserved. See files LICENSE and NOTICE for details. 4*ccaff030SJeremy L Thompson // 5*ccaff030SJeremy L Thompson // This file is part of CEED, a collection of benchmarks, miniapps, software 6*ccaff030SJeremy L Thompson // libraries and APIs for efficient high-order finite element and spectral 7*ccaff030SJeremy L Thompson // element discretizations for exascale applications. For more information and 8*ccaff030SJeremy L Thompson // source code availability see http://github.com/ceed. 9*ccaff030SJeremy L Thompson // 10*ccaff030SJeremy L Thompson // The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, 11*ccaff030SJeremy L Thompson // a collaborative effort of two U.S. Department of Energy organizations (Office 12*ccaff030SJeremy L Thompson // of Science and the National Nuclear Security Administration) responsible for 13*ccaff030SJeremy L Thompson // the planning and preparation of a capable exascale ecosystem, including 14*ccaff030SJeremy L Thompson // software, applications, hardware, advanced system engineering and early 15*ccaff030SJeremy L Thompson // testbed platforms, in support of the nation's exascale computing imperative. 16*ccaff030SJeremy L Thompson 17*ccaff030SJeremy L Thompson /// @file 18*ccaff030SJeremy L Thompson /// Geometric factors for solid mechanics example using PETSc 19*ccaff030SJeremy L Thompson 20*ccaff030SJeremy L Thompson #ifndef COMMON_H 21*ccaff030SJeremy L Thompson #define COMMON_H 22*ccaff030SJeremy L Thompson 23*ccaff030SJeremy L Thompson // ----------------------------------------------------------------------------- 24*ccaff030SJeremy L Thompson // This QFunction sets up the geometric factors required for integration and 25*ccaff030SJeremy L Thompson // coordinate transformations 26*ccaff030SJeremy L Thompson // 27*ccaff030SJeremy L Thompson // Reference (parent) coordinates: X 28*ccaff030SJeremy L Thompson // Physical (current) coordinates: x 29*ccaff030SJeremy L Thompson // Change of coordinate matrix: dxdX_{i,j} = x_{i,j} (indicial notation) 30*ccaff030SJeremy L Thompson // Inverse of change of coordinate matrix: dXdx_{i,j} = (detJ^-1) * X_{i,j} 31*ccaff030SJeremy L Thompson // 32*ccaff030SJeremy L Thompson // All quadrature data is stored in 10 field vector of quadrature data. 33*ccaff030SJeremy L Thompson // 34*ccaff030SJeremy L Thompson // We require the transpose of the inverse of the Jacobian to properly compute 35*ccaff030SJeremy L Thompson // integrals of the form: int( gradv u ) 36*ccaff030SJeremy L Thompson // 37*ccaff030SJeremy L Thompson // Inverse of Jacobian: 38*ccaff030SJeremy L Thompson // dXdx_i,j = Aij / detJ 39*ccaff030SJeremy L Thompson // 40*ccaff030SJeremy L Thompson // Stored: Aij / detJ 41*ccaff030SJeremy L Thompson // in qdata[1:9] as 42*ccaff030SJeremy L Thompson // [A11 A12 A13] 43*ccaff030SJeremy L Thompson // (detJ^-1) * [A21 A22 A23] 44*ccaff030SJeremy L Thompson // [A31 A32 A33] 45*ccaff030SJeremy L Thompson // 46*ccaff030SJeremy L Thompson // ----------------------------------------------------------------------------- 47*ccaff030SJeremy L Thompson CEED_QFUNCTION(SetupGeo)(void *ctx, CeedInt Q, const CeedScalar *const *in, 48*ccaff030SJeremy L Thompson CeedScalar *const *out) { 49*ccaff030SJeremy L Thompson // *INDENT-OFF* 50*ccaff030SJeremy L Thompson // Inputs 51*ccaff030SJeremy L Thompson const CeedScalar (*J)[3][CEED_Q_VLA] = (CeedScalar(*)[3][CEED_Q_VLA])in[0], 52*ccaff030SJeremy L Thompson (*w) = in[1]; 53*ccaff030SJeremy L Thompson 54*ccaff030SJeremy L Thompson // Outputs 55*ccaff030SJeremy L Thompson CeedScalar (*qdata)[CEED_Q_VLA] = (CeedScalar(*)[CEED_Q_VLA])out[0]; 56*ccaff030SJeremy L Thompson // *INDENT-ON* 57*ccaff030SJeremy L Thompson 58*ccaff030SJeremy L Thompson CeedPragmaSIMD 59*ccaff030SJeremy L Thompson // Quadrature Point Loop 60*ccaff030SJeremy L Thompson for (CeedInt i=0; i<Q; i++) { 61*ccaff030SJeremy L Thompson // Setup 62*ccaff030SJeremy L Thompson const CeedScalar J11 = J[0][0][i]; 63*ccaff030SJeremy L Thompson const CeedScalar J21 = J[0][1][i]; 64*ccaff030SJeremy L Thompson const CeedScalar J31 = J[0][2][i]; 65*ccaff030SJeremy L Thompson const CeedScalar J12 = J[1][0][i]; 66*ccaff030SJeremy L Thompson const CeedScalar J22 = J[1][1][i]; 67*ccaff030SJeremy L Thompson const CeedScalar J32 = J[1][2][i]; 68*ccaff030SJeremy L Thompson const CeedScalar J13 = J[2][0][i]; 69*ccaff030SJeremy L Thompson const CeedScalar J23 = J[2][1][i]; 70*ccaff030SJeremy L Thompson const CeedScalar J33 = J[2][2][i]; 71*ccaff030SJeremy L Thompson const CeedScalar A11 = J22*J33 - J23*J32; 72*ccaff030SJeremy L Thompson const CeedScalar A12 = J13*J32 - J12*J33; 73*ccaff030SJeremy L Thompson const CeedScalar A13 = J12*J23 - J13*J22; 74*ccaff030SJeremy L Thompson const CeedScalar A21 = J23*J31 - J21*J33; 75*ccaff030SJeremy L Thompson const CeedScalar A22 = J11*J33 - J13*J31; 76*ccaff030SJeremy L Thompson const CeedScalar A23 = J13*J21 - J11*J23; 77*ccaff030SJeremy L Thompson const CeedScalar A31 = J21*J32 - J22*J31; 78*ccaff030SJeremy L Thompson const CeedScalar A32 = J12*J31 - J11*J32; 79*ccaff030SJeremy L Thompson const CeedScalar A33 = J11*J22 - J12*J21; 80*ccaff030SJeremy L Thompson const CeedScalar detJ = J11*A11 + J21*A12 + J31*A13; 81*ccaff030SJeremy L Thompson 82*ccaff030SJeremy L Thompson // Qdata 83*ccaff030SJeremy L Thompson // -- Interp-to-Interp qdata 84*ccaff030SJeremy L Thompson qdata[0][i] = w[i] * detJ; 85*ccaff030SJeremy L Thompson 86*ccaff030SJeremy L Thompson // -- Interp-to-Grad qdata 87*ccaff030SJeremy L Thompson // Inverse of change of coordinate matrix: X_i,j 88*ccaff030SJeremy L Thompson qdata[1][i] = A11 / detJ; 89*ccaff030SJeremy L Thompson qdata[2][i] = A12 / detJ; 90*ccaff030SJeremy L Thompson qdata[3][i] = A13 / detJ; 91*ccaff030SJeremy L Thompson qdata[4][i] = A21 / detJ; 92*ccaff030SJeremy L Thompson qdata[5][i] = A22 / detJ; 93*ccaff030SJeremy L Thompson qdata[6][i] = A23 / detJ; 94*ccaff030SJeremy L Thompson qdata[7][i] = A31 / detJ; 95*ccaff030SJeremy L Thompson qdata[8][i] = A32 / detJ; 96*ccaff030SJeremy L Thompson qdata[9][i] = A33 / detJ; 97*ccaff030SJeremy L Thompson 98*ccaff030SJeremy L Thompson } // End of Quadrature Point Loop 99*ccaff030SJeremy L Thompson 100*ccaff030SJeremy L Thompson return 0; 101*ccaff030SJeremy L Thompson } 102*ccaff030SJeremy L Thompson // ----------------------------------------------------------------------------- 103*ccaff030SJeremy L Thompson #endif // End of COMMON_H 104