1*9ba83ac0SJeremy L Thompson // Copyright (c) 2017-2026, 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 11c0b5abf0SJeremy L Thompson #include <ceed/types.h> 12c0b5abf0SJeremy L Thompson #ifndef CEED_RUNNING_JIT_PASS 135754ecacSJeremy L Thompson #include <math.h> 14c0b5abf0SJeremy L Thompson #endif 155754ecacSJeremy L Thompson 165754ecacSJeremy L Thompson #ifndef PHYSICS_STRUCT 175754ecacSJeremy L Thompson #define PHYSICS_STRUCT 185754ecacSJeremy L Thompson typedef struct Physics_private *Physics; 195754ecacSJeremy L Thompson struct Physics_private { 205754ecacSJeremy L Thompson CeedScalar nu; // Poisson's ratio 215754ecacSJeremy L Thompson CeedScalar E; // Young's Modulus 225754ecacSJeremy L Thompson }; 235754ecacSJeremy L Thompson #endif 245754ecacSJeremy L Thompson 255754ecacSJeremy L Thompson // ----------------------------------------------------------------------------- 265754ecacSJeremy L Thompson // Constant forcing term along specified vector 275754ecacSJeremy L Thompson // ----------------------------------------------------------------------------- SetupConstantForce(void * ctx,const CeedInt Q,const CeedScalar * const * in,CeedScalar * const * out)282b730f8bSJeremy L ThompsonCEED_QFUNCTION(SetupConstantForce)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { 295754ecacSJeremy L Thompson // Inputs 305754ecacSJeremy L Thompson const CeedScalar *q_data = in[1]; 315754ecacSJeremy L Thompson 325754ecacSJeremy L Thompson // Outputs 335754ecacSJeremy L Thompson CeedScalar *force = out[0]; 345754ecacSJeremy L Thompson 355754ecacSJeremy L Thompson // Context 365754ecacSJeremy L Thompson const CeedScalar *forcing_vector = (CeedScalar(*))ctx; 375754ecacSJeremy L Thompson 385754ecacSJeremy L Thompson // Quadrature Point Loop 392b730f8bSJeremy L Thompson CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) { 405754ecacSJeremy L Thompson // Setup 415754ecacSJeremy L Thompson CeedScalar wdetJ = q_data[i]; 425754ecacSJeremy L Thompson 435754ecacSJeremy L Thompson // Forcing function 445754ecacSJeremy L Thompson // -- Component 1 455754ecacSJeremy L Thompson force[i + 0 * Q] = forcing_vector[0] * wdetJ; 465754ecacSJeremy L Thompson 475754ecacSJeremy L Thompson // -- Component 2 485754ecacSJeremy L Thompson force[i + 1 * Q] = forcing_vector[1] * wdetJ; 495754ecacSJeremy L Thompson 505754ecacSJeremy L Thompson // -- Component 3 515754ecacSJeremy L Thompson force[i + 2 * Q] = forcing_vector[2] * wdetJ; 525754ecacSJeremy L Thompson } // End of Quadrature Point Loop 535754ecacSJeremy L Thompson 545754ecacSJeremy L Thompson return 0; 555754ecacSJeremy L Thompson } 565754ecacSJeremy L Thompson // ----------------------------------------------------------------------------- 57