1 // Copyright (c) 2017-2024, 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 /// Constant forcing term for solid mechanics example using PETSc 10 11 #include <ceed.h> 12 #include <math.h> 13 14 #ifndef PHYSICS_STRUCT 15 #define PHYSICS_STRUCT 16 typedef struct Physics_private *Physics; 17 struct Physics_private { 18 CeedScalar nu; // Poisson's ratio 19 CeedScalar E; // Young's Modulus 20 }; 21 #endif 22 23 // ----------------------------------------------------------------------------- 24 // Constant forcing term along specified vector 25 // ----------------------------------------------------------------------------- 26 CEED_QFUNCTION(SetupConstantForce)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 27 // Inputs 28 const CeedScalar *q_data = in[1]; 29 30 // Outputs 31 CeedScalar *force = out[0]; 32 33 // Context 34 const CeedScalar *forcing_vector = (CeedScalar(*))ctx; 35 36 // Quadrature Point Loop 37 CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) { 38 // Setup 39 CeedScalar wdetJ = q_data[i]; 40 41 // Forcing function 42 // -- Component 1 43 force[i + 0 * Q] = forcing_vector[0] * wdetJ; 44 45 // -- Component 2 46 force[i + 1 * Q] = forcing_vector[1] * wdetJ; 47 48 // -- Component 3 49 force[i + 2 * Q] = forcing_vector[2] * wdetJ; 50 } // End of Quadrature Point Loop 51 52 return 0; 53 } 54 // ----------------------------------------------------------------------------- 55