13d8e8822SJeremy L Thompson // Copyright (c) 2017-2022, 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. 35754ecacSJeremy L Thompson // 43d8e8822SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause 55754ecacSJeremy L Thompson // 63d8e8822SJeremy L Thompson // This file is part of CEED: http://github.com/ceed 75754ecacSJeremy L Thompson 85754ecacSJeremy L Thompson /// @file 95754ecacSJeremy L Thompson /// Geometric factors for solid mechanics example using PETSc 105754ecacSJeremy L Thompson 115754ecacSJeremy L Thompson #ifndef TRACTION_BOUNDARY_H 125754ecacSJeremy L Thompson #define TRACTION_BOUNDARY_H 135754ecacSJeremy L Thompson 14c9c2c079SJeremy L Thompson #include <ceed.h> 15c9c2c079SJeremy L Thompson 165754ecacSJeremy L Thompson // ----------------------------------------------------------------------------- 17*ea61e9acSJeremy L Thompson // This QFunction computes the surface integral of the user traction vector on the constrained faces. 185754ecacSJeremy L Thompson // 195754ecacSJeremy L Thompson // Reference (parent) 2D coordinates: X 205754ecacSJeremy L Thompson // Physical (current) 3D coordinates: x 215754ecacSJeremy L Thompson // Change of coordinate matrix: 225754ecacSJeremy L Thompson // dxdX_{i,j} = dx_i/dX_j (indicial notation) [3 * 2] 235754ecacSJeremy L Thompson // 245754ecacSJeremy L Thompson // (J1,J2,J3) is given by the cross product of the columns of dxdX_{i,j} 255754ecacSJeremy L Thompson // 265754ecacSJeremy L Thompson // detJb is the magnitude of (J1,J2,J3) 275754ecacSJeremy L Thompson // 285754ecacSJeremy L Thompson // Computed: 295754ecacSJeremy L Thompson // t * (w detJb) 305754ecacSJeremy L Thompson // ----------------------------------------------------------------------------- 312b730f8bSJeremy L Thompson CEED_QFUNCTION(SetupTractionBCs)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 325754ecacSJeremy L Thompson // Inputs 332b730f8bSJeremy L Thompson const CeedScalar(*J)[3][CEED_Q_VLA] = (const CeedScalar(*)[3][CEED_Q_VLA])in[0], (*w) = in[1]; 345754ecacSJeremy L Thompson // Outputs 355754ecacSJeremy L Thompson CeedScalar(*v)[CEED_Q_VLA] = (CeedScalar(*)[CEED_Q_VLA])out[0]; 365754ecacSJeremy L Thompson 375754ecacSJeremy L Thompson // User stress tensor 385754ecacSJeremy L Thompson const CeedScalar(*traction) = (const CeedScalar(*))ctx; 395754ecacSJeremy L Thompson 405754ecacSJeremy L Thompson CeedPragmaSIMD 415754ecacSJeremy L Thompson // Quadrature Point Loop 425754ecacSJeremy L Thompson for (CeedInt i = 0; i < Q; i++) { 435754ecacSJeremy L Thompson // Setup 442b730f8bSJeremy L Thompson const CeedScalar dxdX[3][2] = { 452b730f8bSJeremy L Thompson {J[0][0][i], J[1][0][i]}, 462b730f8bSJeremy L Thompson {J[0][1][i], J[1][1][i]}, 472b730f8bSJeremy L Thompson {J[0][2][i], J[1][2][i]} 482b730f8bSJeremy L Thompson }; 495754ecacSJeremy L Thompson // J1, J2, and J3 are given by the cross product of the columns of dxdX 505754ecacSJeremy L Thompson const CeedScalar J1 = dxdX[1][0] * dxdX[2][1] - dxdX[2][0] * dxdX[1][1]; 515754ecacSJeremy L Thompson const CeedScalar J2 = dxdX[2][0] * dxdX[0][1] - dxdX[0][0] * dxdX[2][1]; 525754ecacSJeremy L Thompson const CeedScalar J3 = dxdX[0][0] * dxdX[1][1] - dxdX[1][0] * dxdX[0][1]; 535754ecacSJeremy L Thompson 545754ecacSJeremy L Thompson // Qdata 555754ecacSJeremy L Thompson // -- Interp-to-Interp q_data 565754ecacSJeremy L Thompson CeedScalar wdetJb = w[i] * sqrt(J1 * J1 + J2 * J2 + J3 * J3); 575754ecacSJeremy L Thompson 585754ecacSJeremy L Thompson // Traction surface integral 592b730f8bSJeremy L Thompson for (CeedInt j = 0; j < 3; j++) v[j][i] = traction[j] * wdetJb; 605754ecacSJeremy L Thompson 615754ecacSJeremy L Thompson } // End of Quadrature Point Loop 625754ecacSJeremy L Thompson 635754ecacSJeremy L Thompson // Return 645754ecacSJeremy L Thompson return 0; 655754ecacSJeremy L Thompson } 665754ecacSJeremy L Thompson // ----------------------------------------------------------------------------- 675754ecacSJeremy L Thompson 685754ecacSJeremy L Thompson #endif // End of TRACTION_BOUNDARY_H 69