xref: /libCEED/examples/solids/qfunctions/constant-force.h (revision 2b730f8b5a9c809740a0b3b302db43a719c636b1)
13d8e8822SJeremy L Thompson // Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors.
23d8e8822SJeremy L Thompson // All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
35754ecacSJeremy L Thompson //
43d8e8822SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause
55754ecacSJeremy L Thompson //
63d8e8822SJeremy L Thompson // This file is part of CEED:  http://github.com/ceed
75754ecacSJeremy L Thompson 
85754ecacSJeremy L Thompson /// @file
95754ecacSJeremy L Thompson /// Constant forcing term for solid mechanics example using PETSc
105754ecacSJeremy L Thompson 
115754ecacSJeremy L Thompson #ifndef CONSTANT_H
125754ecacSJeremy L Thompson #define CONSTANT_H
135754ecacSJeremy L Thompson 
14c9c2c079SJeremy L Thompson #include <ceed.h>
155754ecacSJeremy L Thompson #include <math.h>
165754ecacSJeremy L Thompson 
175754ecacSJeremy L Thompson #ifndef PHYSICS_STRUCT
185754ecacSJeremy L Thompson #define PHYSICS_STRUCT
195754ecacSJeremy L Thompson typedef struct Physics_private *Physics;
205754ecacSJeremy L Thompson struct Physics_private {
215754ecacSJeremy L Thompson   CeedScalar nu;  // Poisson's ratio
225754ecacSJeremy L Thompson   CeedScalar E;   // Young's Modulus
235754ecacSJeremy L Thompson };
245754ecacSJeremy L Thompson #endif
255754ecacSJeremy L Thompson 
265754ecacSJeremy L Thompson // -----------------------------------------------------------------------------
275754ecacSJeremy L Thompson // Constant forcing term along specified vector
285754ecacSJeremy L Thompson // -----------------------------------------------------------------------------
29*2b730f8bSJeremy L Thompson CEED_QFUNCTION(SetupConstantForce)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) {
305754ecacSJeremy L Thompson   // Inputs
315754ecacSJeremy L Thompson   const CeedScalar *q_data = in[1];
325754ecacSJeremy L Thompson 
335754ecacSJeremy L Thompson   // Outputs
345754ecacSJeremy L Thompson   CeedScalar *force = out[0];
355754ecacSJeremy L Thompson 
365754ecacSJeremy L Thompson   // Context
375754ecacSJeremy L Thompson   const CeedScalar *forcing_vector = (CeedScalar(*))ctx;
385754ecacSJeremy L Thompson 
395754ecacSJeremy L Thompson   // Quadrature Point Loop
40*2b730f8bSJeremy L Thompson   CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) {
415754ecacSJeremy L Thompson     // Setup
425754ecacSJeremy L Thompson     CeedScalar wdetJ = q_data[i];
435754ecacSJeremy L Thompson 
445754ecacSJeremy L Thompson     // Forcing function
455754ecacSJeremy L Thompson     // -- Component 1
465754ecacSJeremy L Thompson     force[i + 0 * Q] = forcing_vector[0] * wdetJ;
475754ecacSJeremy L Thompson 
485754ecacSJeremy L Thompson     // -- Component 2
495754ecacSJeremy L Thompson     force[i + 1 * Q] = forcing_vector[1] * wdetJ;
505754ecacSJeremy L Thompson 
515754ecacSJeremy L Thompson     // -- Component 3
525754ecacSJeremy L Thompson     force[i + 2 * Q] = forcing_vector[2] * wdetJ;
535754ecacSJeremy L Thompson   }  // End of Quadrature Point Loop
545754ecacSJeremy L Thompson 
555754ecacSJeremy L Thompson   return 0;
565754ecacSJeremy L Thompson }
575754ecacSJeremy L Thompson // -----------------------------------------------------------------------------
585754ecacSJeremy L Thompson 
595754ecacSJeremy L Thompson #endif  // End of CONSTANT_H
60