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 /// @file 9 /// Geometric factors for solid mechanics example using PETSc 10 11 #ifndef TRACTION_BOUNDARY_H 12 #define TRACTION_BOUNDARY_H 13 14 // ----------------------------------------------------------------------------- 15 // This QFunction computes the surface integral of the user traction vector on 16 // the constrained faces. 17 // 18 // Reference (parent) 2D coordinates: X 19 // Physical (current) 3D coordinates: x 20 // Change of coordinate matrix: 21 // dxdX_{i,j} = dx_i/dX_j (indicial notation) [3 * 2] 22 // 23 // (J1,J2,J3) is given by the cross product of the columns of dxdX_{i,j} 24 // 25 // detJb is the magnitude of (J1,J2,J3) 26 // 27 // Computed: 28 // t * (w detJb) 29 // 30 // ----------------------------------------------------------------------------- 31 CEED_QFUNCTION(SetupTractionBCs)(void *ctx, CeedInt Q, 32 const CeedScalar *const *in, CeedScalar *const *out) { 33 // *INDENT-OFF* 34 // Inputs 35 const CeedScalar(*J)[3][CEED_Q_VLA] = (const CeedScalar(*)[3][CEED_Q_VLA])in[0], 36 (*w) = in[1]; 37 // Outputs 38 CeedScalar(*v)[CEED_Q_VLA] = (CeedScalar(*)[CEED_Q_VLA])out[0]; 39 // *INDENT-ON* 40 41 // User stress tensor 42 const CeedScalar (*traction) = (const CeedScalar(*))ctx; 43 44 CeedPragmaSIMD 45 // Quadrature Point Loop 46 for (CeedInt i = 0; i < Q; i++) { 47 // Setup 48 // *INDENT-OFF* 49 const CeedScalar dxdX[3][2] = {{J[0][0][i], 50 J[1][0][i]}, 51 {J[0][1][i], 52 J[1][1][i]}, 53 {J[0][2][i], 54 J[1][2][i]}}; 55 // *INDENT-ON* 56 // J1, J2, and J3 are given by the cross product of the columns of dxdX 57 const CeedScalar J1 = dxdX[1][0] * dxdX[2][1] - dxdX[2][0] * dxdX[1][1]; 58 const CeedScalar J2 = dxdX[2][0] * dxdX[0][1] - dxdX[0][0] * dxdX[2][1]; 59 const CeedScalar J3 = dxdX[0][0] * dxdX[1][1] - dxdX[1][0] * dxdX[0][1]; 60 61 // Qdata 62 // -- Interp-to-Interp q_data 63 CeedScalar wdetJb = w[i] * sqrt(J1 * J1 + J2 * J2 + J3 * J3); 64 65 // Traction surface integral 66 for (CeedInt j = 0; j < 3; j++) 67 v[j][i] = traction[j] * wdetJb; 68 69 } // End of Quadrature Point Loop 70 71 // Return 72 return 0; 73 } 74 // ----------------------------------------------------------------------------- 75 76 #endif // End of TRACTION_BOUNDARY_H 77