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