1ccaff030SJeremy L Thompson // Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at 2ccaff030SJeremy L Thompson // the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights 3ccaff030SJeremy L Thompson // reserved. See files LICENSE and NOTICE for details. 4ccaff030SJeremy L Thompson // 5ccaff030SJeremy L Thompson // This file is part of CEED, a collection of benchmarks, miniapps, software 6ccaff030SJeremy L Thompson // libraries and APIs for efficient high-order finite element and spectral 7ccaff030SJeremy L Thompson // element discretizations for exascale applications. For more information and 8ccaff030SJeremy L Thompson // source code availability see http://github.com/ceed. 9ccaff030SJeremy L Thompson // 10ccaff030SJeremy L Thompson // The CEED research is supported by the Exascale Computing Project 17-SC-20-SC, 11ccaff030SJeremy L Thompson // a collaborative effort of two U.S. Department of Energy organizations (Office 12ccaff030SJeremy L Thompson // of Science and the National Nuclear Security Administration) responsible for 13ccaff030SJeremy L Thompson // the planning and preparation of a capable exascale ecosystem, including 14ccaff030SJeremy L Thompson // software, applications, hardware, advanced system engineering and early 15ccaff030SJeremy L Thompson // testbed platforms, in support of the nation's exascale computing imperative. 16ccaff030SJeremy L Thompson 17ccaff030SJeremy L Thompson /// @file 18ccaff030SJeremy L Thompson /// Geometric factors for solid mechanics example using PETSc 19ccaff030SJeremy L Thompson 20ccaff030SJeremy L Thompson #ifndef COMMON_H 21ccaff030SJeremy L Thompson #define COMMON_H 22ccaff030SJeremy L Thompson 23ccaff030SJeremy L Thompson // ----------------------------------------------------------------------------- 24ccaff030SJeremy L Thompson // This QFunction sets up the geometric factors required for integration and 25ccaff030SJeremy L Thompson // coordinate transformations 26ccaff030SJeremy L Thompson // 27ccaff030SJeremy L Thompson // Reference (parent) coordinates: X 28ccaff030SJeremy L Thompson // Physical (current) coordinates: x 29ccaff030SJeremy L Thompson // Change of coordinate matrix: dxdX_{i,j} = x_{i,j} (indicial notation) 30ccaff030SJeremy L Thompson // Inverse of change of coordinate matrix: dXdx_{i,j} = (detJ^-1) * X_{i,j} 31ccaff030SJeremy L Thompson // 32ccaff030SJeremy L Thompson // All quadrature data is stored in 10 field vector of quadrature data. 33ccaff030SJeremy L Thompson // 34ccaff030SJeremy L Thompson // We require the transpose of the inverse of the Jacobian to properly compute 35ccaff030SJeremy L Thompson // integrals of the form: int( gradv u ) 36ccaff030SJeremy L Thompson // 37ccaff030SJeremy L Thompson // Inverse of Jacobian: 38ccaff030SJeremy L Thompson // dXdx_i,j = Aij / detJ 39ccaff030SJeremy L Thompson // 40ccaff030SJeremy L Thompson // Stored: Aij / detJ 41ccaff030SJeremy L Thompson // in qdata[1:9] as 42ccaff030SJeremy L Thompson // [A11 A12 A13] 43ccaff030SJeremy L Thompson // (detJ^-1) * [A21 A22 A23] 44ccaff030SJeremy L Thompson // [A31 A32 A33] 45ccaff030SJeremy L Thompson // 46ccaff030SJeremy L Thompson // ----------------------------------------------------------------------------- 47ccaff030SJeremy L Thompson CEED_QFUNCTION(SetupGeo)(void *ctx, CeedInt Q, const CeedScalar *const *in, 48ccaff030SJeremy L Thompson CeedScalar *const *out) { 49ccaff030SJeremy L Thompson // *INDENT-OFF* 50ccaff030SJeremy L Thompson // Inputs 51ca585c42SJed Brown const CeedScalar (*J)[3][CEED_Q_VLA] = (const CeedScalar(*)[3][CEED_Q_VLA])in[0], 52ccaff030SJeremy L Thompson (*w) = in[1]; 53ccaff030SJeremy L Thompson 54ccaff030SJeremy L Thompson // Outputs 55ccaff030SJeremy L Thompson CeedScalar (*qdata)[CEED_Q_VLA] = (CeedScalar(*)[CEED_Q_VLA])out[0]; 56ccaff030SJeremy L Thompson // *INDENT-ON* 57ccaff030SJeremy L Thompson 58ccaff030SJeremy L Thompson CeedPragmaSIMD 59ccaff030SJeremy L Thompson // Quadrature Point Loop 60ccaff030SJeremy L Thompson for (CeedInt i=0; i<Q; i++) { 61ccaff030SJeremy L Thompson // Setup 62ccaff030SJeremy L Thompson const CeedScalar J11 = J[0][0][i]; 63ccaff030SJeremy L Thompson const CeedScalar J21 = J[0][1][i]; 64ccaff030SJeremy L Thompson const CeedScalar J31 = J[0][2][i]; 65ccaff030SJeremy L Thompson const CeedScalar J12 = J[1][0][i]; 66ccaff030SJeremy L Thompson const CeedScalar J22 = J[1][1][i]; 67ccaff030SJeremy L Thompson const CeedScalar J32 = J[1][2][i]; 68ccaff030SJeremy L Thompson const CeedScalar J13 = J[2][0][i]; 69ccaff030SJeremy L Thompson const CeedScalar J23 = J[2][1][i]; 70ccaff030SJeremy L Thompson const CeedScalar J33 = J[2][2][i]; 71ccaff030SJeremy L Thompson const CeedScalar A11 = J22*J33 - J23*J32; 72ccaff030SJeremy L Thompson const CeedScalar A12 = J13*J32 - J12*J33; 73ccaff030SJeremy L Thompson const CeedScalar A13 = J12*J23 - J13*J22; 74ccaff030SJeremy L Thompson const CeedScalar A21 = J23*J31 - J21*J33; 75ccaff030SJeremy L Thompson const CeedScalar A22 = J11*J33 - J13*J31; 76ccaff030SJeremy L Thompson const CeedScalar A23 = J13*J21 - J11*J23; 77ccaff030SJeremy L Thompson const CeedScalar A31 = J21*J32 - J22*J31; 78ccaff030SJeremy L Thompson const CeedScalar A32 = J12*J31 - J11*J32; 79ccaff030SJeremy L Thompson const CeedScalar A33 = J11*J22 - J12*J21; 80ccaff030SJeremy L Thompson const CeedScalar detJ = J11*A11 + J21*A12 + J31*A13; 81ccaff030SJeremy L Thompson 82ccaff030SJeremy L Thompson // Qdata 83ccaff030SJeremy L Thompson // -- Interp-to-Interp qdata 84ccaff030SJeremy L Thompson qdata[0][i] = w[i] * detJ; 85ccaff030SJeremy L Thompson 86ccaff030SJeremy L Thompson // -- Interp-to-Grad qdata 87ccaff030SJeremy L Thompson // Inverse of change of coordinate matrix: X_i,j 88ccaff030SJeremy L Thompson qdata[1][i] = A11 / detJ; 89ccaff030SJeremy L Thompson qdata[2][i] = A12 / detJ; 90ccaff030SJeremy L Thompson qdata[3][i] = A13 / detJ; 91ccaff030SJeremy L Thompson qdata[4][i] = A21 / detJ; 92ccaff030SJeremy L Thompson qdata[5][i] = A22 / detJ; 93ccaff030SJeremy L Thompson qdata[6][i] = A23 / detJ; 94ccaff030SJeremy L Thompson qdata[7][i] = A31 / detJ; 95ccaff030SJeremy L Thompson qdata[8][i] = A32 / detJ; 96ccaff030SJeremy L Thompson qdata[9][i] = A33 / detJ; 97ccaff030SJeremy L Thompson 98ccaff030SJeremy L Thompson } // End of Quadrature Point Loop 99ccaff030SJeremy L Thompson 100ccaff030SJeremy L Thompson return 0; 101ccaff030SJeremy L Thompson } 102ccaff030SJeremy L Thompson // ----------------------------------------------------------------------------- 103e0dd07dcSvaleriabarra 104*fe394131Sjeremylt // ----------------------------------------------------------------------------- 105*fe394131Sjeremylt // This QFunction computes the surface integral of the user traction vector on 106*fe394131Sjeremylt // the constrained faces. 107*fe394131Sjeremylt // 108*fe394131Sjeremylt // Reference (parent) 2D coordinates: X 109*fe394131Sjeremylt // Physical (current) 3D coordinates: x 110*fe394131Sjeremylt // Change of coordinate matrix: 111*fe394131Sjeremylt // dxdX_{i,j} = dx_i/dX_j (indicial notation) [3 * 2] 112*fe394131Sjeremylt // 113*fe394131Sjeremylt // (J1,J2,J3) is given by the cross product of the columns of dxdX_{i,j} 114*fe394131Sjeremylt // 115*fe394131Sjeremylt // detJb is the magnitude of (J1,J2,J3) 116*fe394131Sjeremylt // 117*fe394131Sjeremylt // Computed: 118*fe394131Sjeremylt // t * (w detJb) 119*fe394131Sjeremylt // 120*fe394131Sjeremylt // ----------------------------------------------------------------------------- 121*fe394131Sjeremylt CEED_QFUNCTION(SetupTractionBCs)(void *ctx, CeedInt Q, 122*fe394131Sjeremylt const CeedScalar *const *in, CeedScalar *const *out) { 123*fe394131Sjeremylt // *INDENT-OFF* 124*fe394131Sjeremylt // Inputs 125*fe394131Sjeremylt const CeedScalar(*J)[3][CEED_Q_VLA] = (const CeedScalar(*)[3][CEED_Q_VLA])in[0], 126*fe394131Sjeremylt (*w) = in[1]; 127*fe394131Sjeremylt // Outputs 128*fe394131Sjeremylt CeedScalar(*v)[CEED_Q_VLA] = (CeedScalar(*)[CEED_Q_VLA])out[0]; 129*fe394131Sjeremylt // *INDENT-ON* 130*fe394131Sjeremylt 131*fe394131Sjeremylt // User stress tensor 132*fe394131Sjeremylt const CeedScalar (*traction) = (const CeedScalar(*))ctx; 133*fe394131Sjeremylt 134*fe394131Sjeremylt CeedPragmaSIMD 135*fe394131Sjeremylt // Quadrature Point Loop 136*fe394131Sjeremylt for (CeedInt i = 0; i < Q; i++) { 137*fe394131Sjeremylt // Setup 138*fe394131Sjeremylt // *INDENT-OFF* 139*fe394131Sjeremylt const CeedScalar dxdX[3][2] = {{J[0][0][i], 140*fe394131Sjeremylt J[1][0][i]}, 141*fe394131Sjeremylt {J[0][1][i], 142*fe394131Sjeremylt J[1][1][i]}, 143*fe394131Sjeremylt {J[0][2][i], 144*fe394131Sjeremylt J[1][2][i]}}; 145*fe394131Sjeremylt // *INDENT-ON* 146*fe394131Sjeremylt // J1, J2, and J3 are given by the cross product of the columns of dxdX 147*fe394131Sjeremylt const CeedScalar J1 = dxdX[1][0] * dxdX[2][1] - dxdX[2][0] * dxdX[1][1]; 148*fe394131Sjeremylt const CeedScalar J2 = dxdX[2][0] * dxdX[0][1] - dxdX[0][0] * dxdX[2][1]; 149*fe394131Sjeremylt const CeedScalar J3 = dxdX[0][0] * dxdX[1][1] - dxdX[1][0] * dxdX[0][1]; 150*fe394131Sjeremylt 151*fe394131Sjeremylt // Qdata 152*fe394131Sjeremylt // -- Interp-to-Interp qdata 153*fe394131Sjeremylt CeedScalar wdetJb = w[i] * sqrt(J1 * J1 + J2 * J2 + J3 * J3); 154*fe394131Sjeremylt 155*fe394131Sjeremylt // Traction surface integral 156*fe394131Sjeremylt for (CeedInt j = 0; j < 3; j++) 157*fe394131Sjeremylt v[j][i] = traction[j] * wdetJb; 158*fe394131Sjeremylt 159*fe394131Sjeremylt } // End of Quadrature Point Loop 160*fe394131Sjeremylt 161*fe394131Sjeremylt // Return 162*fe394131Sjeremylt return 0; 163*fe394131Sjeremylt } 164*fe394131Sjeremylt // ----------------------------------------------------------------------------- 165*fe394131Sjeremylt 166ccaff030SJeremy L Thompson #endif // End of COMMON_H 167