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