xref: /libCEED/examples/solids/qfunctions/constant-force.h (revision df9b1082f3fea590280bb79ace83362d3424df46)
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 <math.h>
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,
29                                    const CeedScalar *const *in,
30                                    CeedScalar *const *out) {
31   // Inputs
32   const CeedScalar *q_data = in[1];
33 
34   // Outputs
35   CeedScalar *force = out[0];
36 
37   // Context
38   const CeedScalar *forcing_vector = (CeedScalar(*))ctx;
39 
40   // Quadrature Point Loop
41   CeedPragmaSIMD
42   for (CeedInt i=0; i<Q; i++) {
43     // Setup
44     CeedScalar wdetJ = q_data[i];
45 
46     // Forcing function
47     // -- Component 1
48     force[i+0*Q] = forcing_vector[0]*wdetJ;
49 
50     // -- Component 2
51     force[i+1*Q] = forcing_vector[1]*wdetJ;
52 
53     // -- Component 3
54     force[i+2*Q] = forcing_vector[2]*wdetJ;
55 
56   } // End of Quadrature Point Loop
57 
58   return 0;
59 }
60 // -----------------------------------------------------------------------------
61 
62 #endif // End of CONSTANT_H
63