15aed82e4SJeremy L Thompson // Copyright (c) 2017-2024, 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 11*c0b5abf0SJeremy L Thompson #include <ceed/types.h> 12c9c2c079SJeremy L Thompson 135754ecacSJeremy L Thompson // ----------------------------------------------------------------------------- 14ea61e9acSJeremy L Thompson // This QFunction computes the surface integral of the user traction vector on the constrained faces. 155754ecacSJeremy L Thompson // 165754ecacSJeremy L Thompson // Reference (parent) 2D coordinates: X 175754ecacSJeremy L Thompson // Physical (current) 3D coordinates: x 185754ecacSJeremy L Thompson // Change of coordinate matrix: 195754ecacSJeremy L Thompson // dxdX_{i,j} = dx_i/dX_j (indicial notation) [3 * 2] 205754ecacSJeremy L Thompson // 215754ecacSJeremy L Thompson // (J1,J2,J3) is given by the cross product of the columns of dxdX_{i,j} 225754ecacSJeremy L Thompson // 235754ecacSJeremy L Thompson // detJb is the magnitude of (J1,J2,J3) 245754ecacSJeremy L Thompson // 255754ecacSJeremy L Thompson // Computed: 265754ecacSJeremy L Thompson // t * (w detJb) 275754ecacSJeremy L Thompson // ----------------------------------------------------------------------------- 282b730f8bSJeremy L Thompson CEED_QFUNCTION(SetupTractionBCs)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 295754ecacSJeremy L Thompson // Inputs 302b730f8bSJeremy L Thompson const CeedScalar(*J)[3][CEED_Q_VLA] = (const CeedScalar(*)[3][CEED_Q_VLA])in[0], (*w) = in[1]; 315754ecacSJeremy L Thompson // Outputs 325754ecacSJeremy L Thompson CeedScalar(*v)[CEED_Q_VLA] = (CeedScalar(*)[CEED_Q_VLA])out[0]; 335754ecacSJeremy L Thompson 345754ecacSJeremy L Thompson // User stress tensor 355754ecacSJeremy L Thompson const CeedScalar(*traction) = (const CeedScalar(*))ctx; 365754ecacSJeremy L Thompson 375754ecacSJeremy L Thompson CeedPragmaSIMD 385754ecacSJeremy L Thompson // Quadrature Point Loop 395754ecacSJeremy L Thompson for (CeedInt i = 0; i < Q; i++) { 405754ecacSJeremy L Thompson // Setup 412b730f8bSJeremy L Thompson const CeedScalar dxdX[3][2] = { 422b730f8bSJeremy L Thompson {J[0][0][i], J[1][0][i]}, 432b730f8bSJeremy L Thompson {J[0][1][i], J[1][1][i]}, 442b730f8bSJeremy L Thompson {J[0][2][i], J[1][2][i]} 452b730f8bSJeremy L Thompson }; 465754ecacSJeremy L Thompson // J1, J2, and J3 are given by the cross product of the columns of dxdX 475754ecacSJeremy L Thompson const CeedScalar J1 = dxdX[1][0] * dxdX[2][1] - dxdX[2][0] * dxdX[1][1]; 485754ecacSJeremy L Thompson const CeedScalar J2 = dxdX[2][0] * dxdX[0][1] - dxdX[0][0] * dxdX[2][1]; 495754ecacSJeremy L Thompson const CeedScalar J3 = dxdX[0][0] * dxdX[1][1] - dxdX[1][0] * dxdX[0][1]; 505754ecacSJeremy L Thompson 515754ecacSJeremy L Thompson // Qdata 525754ecacSJeremy L Thompson // -- Interp-to-Interp q_data 535754ecacSJeremy L Thompson CeedScalar wdetJb = w[i] * sqrt(J1 * J1 + J2 * J2 + J3 * J3); 545754ecacSJeremy L Thompson 555754ecacSJeremy L Thompson // Traction surface integral 562b730f8bSJeremy L Thompson for (CeedInt j = 0; j < 3; j++) v[j][i] = traction[j] * wdetJb; 575754ecacSJeremy L Thompson 585754ecacSJeremy L Thompson } // End of Quadrature Point Loop 595754ecacSJeremy L Thompson 605754ecacSJeremy L Thompson // Return 615754ecacSJeremy L Thompson return 0; 625754ecacSJeremy L Thompson } 635754ecacSJeremy L Thompson // ----------------------------------------------------------------------------- 64