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