xref: /libCEED/examples/solids/qfunctions/constant-force.h (revision 28d09c206720ba8516c835daf824672e3380cdbd)
1 // Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at
2 // the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights
3 // reserved. See files LICENSE and NOTICE for details.
4 //
5 // This file is part of CEED, a collection of benchmarks, miniapps, software
6 // libraries and APIs for efficient high-order finite element and spectral
7 // element discretizations for exascale applications. For more information and
8 // source code availability see http://github.com/ceed.
9 //
10 // The CEED research is supported by the Exascale Computing Project 17-SC-20-SC,
11 // a collaborative effort of two U.S. Department of Energy organizations (Office
12 // of Science and the National Nuclear Security Administration) responsible for
13 // the planning and preparation of a capable exascale ecosystem, including
14 // software, applications, hardware, advanced system engineering and early
15 // testbed platforms, in support of the nation's exascale computing imperative.
16 
17 /// @file
18 /// Constant forcing term for solid mechanics example using PETSc
19 
20 #ifndef CONSTANT_H
21 #define CONSTANT_H
22 
23 #ifndef __CUDACC__
24 #  include <math.h>
25 #endif
26 
27 #ifndef PHYSICS_STRUCT
28 #define PHYSICS_STRUCT
29 typedef struct Physics_private *Physics;
30 struct Physics_private {
31   CeedScalar   nu;      // Poisson's ratio
32   CeedScalar   E;       // Young's Modulus
33 };
34 #endif
35 
36 // -----------------------------------------------------------------------------
37 // Constant forcing term along specified vector
38 // -----------------------------------------------------------------------------
39 CEED_QFUNCTION(SetupConstantForce)(void *ctx, const CeedInt Q,
40                                    const CeedScalar *const *in,
41                                    CeedScalar *const *out) {
42   // Inputs
43   const CeedScalar *q_data = in[1];
44 
45   // Outputs
46   CeedScalar *force = out[0];
47 
48   // Context
49   const CeedScalar *forcing_vector = (CeedScalar(*))ctx;
50 
51   // Quadrature Point Loop
52   CeedPragmaSIMD
53   for (CeedInt i=0; i<Q; i++) {
54     // Setup
55     CeedScalar wdetJ = q_data[i];
56 
57     // Forcing function
58     // -- Component 1
59     force[i+0*Q] = forcing_vector[0]*wdetJ;
60 
61     // -- Component 2
62     force[i+1*Q] = forcing_vector[1]*wdetJ;
63 
64     // -- Component 3
65     force[i+2*Q] = forcing_vector[2]*wdetJ;
66 
67   } // End of Quadrature Point Loop
68 
69   return 0;
70 }
71 // -----------------------------------------------------------------------------
72 
73 #endif // End of CONSTANT_H
74