1*9ba83ac0SJeremy L Thompson // Copyright (c) 2017-2026, Lawrence Livermore National Security, LLC and other CEED contributors. 23d8e8822SJeremy L Thompson // All Rights Reserved. See the top-level LICENSE and NOTICE files for details. 3ccaff030SJeremy L Thompson // 43d8e8822SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause 5ccaff030SJeremy L Thompson // 63d8e8822SJeremy L Thompson // This file is part of CEED: http://github.com/ceed 7ccaff030SJeremy L Thompson 8ccaff030SJeremy L Thompson /// @file 9ccaff030SJeremy L Thompson /// Geometric factors for solid mechanics example using PETSc 10ccaff030SJeremy L Thompson 11c0b5abf0SJeremy L Thompson #include <ceed/types.h> 12c9c2c079SJeremy L Thompson 13ccaff030SJeremy L Thompson // ----------------------------------------------------------------------------- 14ea61e9acSJeremy L Thompson // This QFunction sets up the geometric factors required for integration and coordinate transformations 15ccaff030SJeremy L Thompson // 16ccaff030SJeremy L Thompson // Reference (parent) coordinates: X 17ccaff030SJeremy L Thompson // Physical (current) coordinates: x 18ccaff030SJeremy L Thompson // Change of coordinate matrix: dxdX_{i,j} = x_{i,j} (indicial notation) 19ccaff030SJeremy L Thompson // Inverse of change of coordinate matrix: dXdx_{i,j} = (detJ^-1) * X_{i,j} 20ccaff030SJeremy L Thompson // 21ccaff030SJeremy L Thompson // All quadrature data is stored in 10 field vector of quadrature data. 22ccaff030SJeremy L Thompson // 23ea61e9acSJeremy L Thompson // We require the transpose of the inverse of the Jacobian to properly compute integrals of the form: int( gradv u ) 24ccaff030SJeremy L Thompson // 25ccaff030SJeremy L Thompson // Inverse of Jacobian: 26ccaff030SJeremy L Thompson // dXdx_i,j = Aij / detJ 27ccaff030SJeremy L Thompson // 28ccaff030SJeremy L Thompson // Stored: Aij / detJ 29d1d35e2fSjeremylt // in q_data[1:9] as 30ccaff030SJeremy L Thompson // [A11 A12 A13] 31ccaff030SJeremy L Thompson // (detJ^-1) * [A21 A22 A23] 32ccaff030SJeremy L Thompson // [A31 A32 A33] 33ccaff030SJeremy L Thompson // ----------------------------------------------------------------------------- 342b730f8bSJeremy L Thompson CEED_QFUNCTION(SetupGeo)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 35ccaff030SJeremy L Thompson // Inputs 362b730f8bSJeremy L Thompson const CeedScalar(*J)[3][CEED_Q_VLA] = (const CeedScalar(*)[3][CEED_Q_VLA])in[0], (*w) = in[1]; 37ccaff030SJeremy L Thompson 38ccaff030SJeremy L Thompson // Outputs 39d1d35e2fSjeremylt CeedScalar(*q_data)[CEED_Q_VLA] = (CeedScalar(*)[CEED_Q_VLA])out[0]; 40ccaff030SJeremy L Thompson 41ccaff030SJeremy L Thompson CeedPragmaSIMD 42ccaff030SJeremy L Thompson // Quadrature Point Loop 43ccaff030SJeremy L Thompson for (CeedInt i = 0; i < Q; i++) { 44ccaff030SJeremy L Thompson // Setup 45ccaff030SJeremy L Thompson const CeedScalar J11 = J[0][0][i]; 46ccaff030SJeremy L Thompson const CeedScalar J21 = J[0][1][i]; 47ccaff030SJeremy L Thompson const CeedScalar J31 = J[0][2][i]; 48ccaff030SJeremy L Thompson const CeedScalar J12 = J[1][0][i]; 49ccaff030SJeremy L Thompson const CeedScalar J22 = J[1][1][i]; 50ccaff030SJeremy L Thompson const CeedScalar J32 = J[1][2][i]; 51ccaff030SJeremy L Thompson const CeedScalar J13 = J[2][0][i]; 52ccaff030SJeremy L Thompson const CeedScalar J23 = J[2][1][i]; 53ccaff030SJeremy L Thompson const CeedScalar J33 = J[2][2][i]; 54ccaff030SJeremy L Thompson const CeedScalar A11 = J22 * J33 - J23 * J32; 55ccaff030SJeremy L Thompson const CeedScalar A12 = J13 * J32 - J12 * J33; 56ccaff030SJeremy L Thompson const CeedScalar A13 = J12 * J23 - J13 * J22; 57ccaff030SJeremy L Thompson const CeedScalar A21 = J23 * J31 - J21 * J33; 58ccaff030SJeremy L Thompson const CeedScalar A22 = J11 * J33 - J13 * J31; 59ccaff030SJeremy L Thompson const CeedScalar A23 = J13 * J21 - J11 * J23; 60ccaff030SJeremy L Thompson const CeedScalar A31 = J21 * J32 - J22 * J31; 61ccaff030SJeremy L Thompson const CeedScalar A32 = J12 * J31 - J11 * J32; 62ccaff030SJeremy L Thompson const CeedScalar A33 = J11 * J22 - J12 * J21; 63ccaff030SJeremy L Thompson const CeedScalar detJ = J11 * A11 + J21 * A12 + J31 * A13; 64ccaff030SJeremy L Thompson 65ccaff030SJeremy L Thompson // Qdata 66d1d35e2fSjeremylt // -- Interp-to-Interp q_data 67d1d35e2fSjeremylt q_data[0][i] = w[i] * detJ; 68ccaff030SJeremy L Thompson 69d1d35e2fSjeremylt // -- Interp-to-Grad q_data 70ccaff030SJeremy L Thompson // Inverse of change of coordinate matrix: X_i,j 71d1d35e2fSjeremylt q_data[1][i] = A11 / detJ; 72d1d35e2fSjeremylt q_data[2][i] = A12 / detJ; 73d1d35e2fSjeremylt q_data[3][i] = A13 / detJ; 74d1d35e2fSjeremylt q_data[4][i] = A21 / detJ; 75d1d35e2fSjeremylt q_data[5][i] = A22 / detJ; 76d1d35e2fSjeremylt q_data[6][i] = A23 / detJ; 77d1d35e2fSjeremylt q_data[7][i] = A31 / detJ; 78d1d35e2fSjeremylt q_data[8][i] = A32 / detJ; 79d1d35e2fSjeremylt q_data[9][i] = A33 / detJ; 80ccaff030SJeremy L Thompson 81ccaff030SJeremy L Thompson } // End of Quadrature Point Loop 82ccaff030SJeremy L Thompson 83ccaff030SJeremy L Thompson return 0; 84ccaff030SJeremy L Thompson } 85ccaff030SJeremy L Thompson // ----------------------------------------------------------------------------- 86