xref: /libCEED/examples/solids/qfunctions/traction-boundary.h (revision 3d8e882215d238700cdceb37404f76ca7fa24eaa)
1*3d8e8822SJeremy L Thompson // Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors.
2*3d8e8822SJeremy L Thompson // All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
35754ecacSJeremy L Thompson //
4*3d8e8822SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause
55754ecacSJeremy L Thompson //
6*3d8e8822SJeremy 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 
145754ecacSJeremy L Thompson // -----------------------------------------------------------------------------
155754ecacSJeremy L Thompson // This QFunction computes the surface integral of the user traction vector on
165754ecacSJeremy L Thompson //   the constrained faces.
175754ecacSJeremy L Thompson //
185754ecacSJeremy L Thompson // Reference (parent) 2D coordinates: X
195754ecacSJeremy L Thompson // Physical (current) 3D coordinates: x
205754ecacSJeremy L Thompson // Change of coordinate matrix:
215754ecacSJeremy L Thompson //   dxdX_{i,j} = dx_i/dX_j (indicial notation) [3 * 2]
225754ecacSJeremy L Thompson //
235754ecacSJeremy L Thompson // (J1,J2,J3) is given by the cross product of the columns of dxdX_{i,j}
245754ecacSJeremy L Thompson //
255754ecacSJeremy L Thompson // detJb is the magnitude of (J1,J2,J3)
265754ecacSJeremy L Thompson //
275754ecacSJeremy L Thompson // Computed:
285754ecacSJeremy L Thompson //   t * (w detJb)
295754ecacSJeremy L Thompson //
305754ecacSJeremy L Thompson // -----------------------------------------------------------------------------
315754ecacSJeremy L Thompson CEED_QFUNCTION(SetupTractionBCs)(void *ctx, CeedInt Q,
325754ecacSJeremy L Thompson                                  const CeedScalar *const *in, CeedScalar *const *out) {
335754ecacSJeremy L Thompson   // *INDENT-OFF*
345754ecacSJeremy L Thompson   // Inputs
355754ecacSJeremy L Thompson   const CeedScalar(*J)[3][CEED_Q_VLA] = (const CeedScalar(*)[3][CEED_Q_VLA])in[0],
365754ecacSJeremy L Thompson         (*w) = in[1];
375754ecacSJeremy L Thompson   // Outputs
385754ecacSJeremy L Thompson   CeedScalar(*v)[CEED_Q_VLA] = (CeedScalar(*)[CEED_Q_VLA])out[0];
395754ecacSJeremy L Thompson   // *INDENT-ON*
405754ecacSJeremy L Thompson 
415754ecacSJeremy L Thompson   // User stress tensor
425754ecacSJeremy L Thompson   const CeedScalar (*traction) = (const CeedScalar(*))ctx;
435754ecacSJeremy L Thompson 
445754ecacSJeremy L Thompson   CeedPragmaSIMD
455754ecacSJeremy L Thompson   // Quadrature Point Loop
465754ecacSJeremy L Thompson   for (CeedInt i = 0; i < Q; i++) {
475754ecacSJeremy L Thompson     // Setup
485754ecacSJeremy L Thompson     // *INDENT-OFF*
495754ecacSJeremy L Thompson     const CeedScalar dxdX[3][2] = {{J[0][0][i],
505754ecacSJeremy L Thompson                                     J[1][0][i]},
515754ecacSJeremy L Thompson                                    {J[0][1][i],
525754ecacSJeremy L Thompson                                     J[1][1][i]},
535754ecacSJeremy L Thompson                                    {J[0][2][i],
545754ecacSJeremy L Thompson                                     J[1][2][i]}};
555754ecacSJeremy L Thompson     // *INDENT-ON*
565754ecacSJeremy L Thompson     // J1, J2, and J3 are given by the cross product of the columns of dxdX
575754ecacSJeremy L Thompson     const CeedScalar J1 = dxdX[1][0] * dxdX[2][1] - dxdX[2][0] * dxdX[1][1];
585754ecacSJeremy L Thompson     const CeedScalar J2 = dxdX[2][0] * dxdX[0][1] - dxdX[0][0] * dxdX[2][1];
595754ecacSJeremy L Thompson     const CeedScalar J3 = dxdX[0][0] * dxdX[1][1] - dxdX[1][0] * dxdX[0][1];
605754ecacSJeremy L Thompson 
615754ecacSJeremy L Thompson     // Qdata
625754ecacSJeremy L Thompson     // -- Interp-to-Interp q_data
635754ecacSJeremy L Thompson     CeedScalar wdetJb = w[i] * sqrt(J1 * J1 + J2 * J2 + J3 * J3);
645754ecacSJeremy L Thompson 
655754ecacSJeremy L Thompson     // Traction surface integral
665754ecacSJeremy L Thompson     for (CeedInt j = 0; j < 3; j++)
675754ecacSJeremy L Thompson       v[j][i] = traction[j] * wdetJb;
685754ecacSJeremy L Thompson 
695754ecacSJeremy L Thompson   } // End of Quadrature Point Loop
705754ecacSJeremy L Thompson 
715754ecacSJeremy L Thompson   // Return
725754ecacSJeremy L Thompson   return 0;
735754ecacSJeremy L Thompson }
745754ecacSJeremy L Thompson // -----------------------------------------------------------------------------
755754ecacSJeremy L Thompson 
765754ecacSJeremy L Thompson #endif // End of TRACTION_BOUNDARY_H
77