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 /// Linear elasticity manufactured solution forcing term for solid mechanics example using PETSc 19*5754ecacSJeremy L Thompson 20*5754ecacSJeremy L Thompson #ifndef MANUFACTURED_H 21*5754ecacSJeremy L Thompson #define MANUFACTURED_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 // Forcing term for linear elasticity manufactured solution 38*5754ecacSJeremy L Thompson // ----------------------------------------------------------------------------- 39*5754ecacSJeremy L Thompson CEED_QFUNCTION(SetupMMSForce)(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 *coords = in[0], *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 Physics context = (Physics)ctx; 50*5754ecacSJeremy L Thompson const CeedScalar E = context->E; 51*5754ecacSJeremy L Thompson const CeedScalar nu = context->nu; 52*5754ecacSJeremy L Thompson 53*5754ecacSJeremy L Thompson // Quadrature Point Loop 54*5754ecacSJeremy L Thompson CeedPragmaSIMD 55*5754ecacSJeremy L Thompson for (CeedInt i=0; i<Q; i++) { 56*5754ecacSJeremy L Thompson // Setup 57*5754ecacSJeremy L Thompson CeedScalar x = coords[i+0*Q], y = coords[i+1*Q], z = coords[i+2*Q]; 58*5754ecacSJeremy L Thompson CeedScalar wdetJ = q_data[i]; 59*5754ecacSJeremy L Thompson 60*5754ecacSJeremy L Thompson // Forcing function 61*5754ecacSJeremy L Thompson // -- Component 1 62*5754ecacSJeremy L Thompson force[i+0*Q] = (-(E*(cos(x*2.0)*cos(y*3.0)*exp(z*4.0)*4.0 - 63*5754ecacSJeremy L Thompson cos(z*4.0)*sin( y*3.0)*exp(x*2.0)*8.0)*(nu-0.5))/ 64*5754ecacSJeremy L Thompson ((nu*2.0-1.0)*(nu+1.0)) + 65*5754ecacSJeremy L Thompson (E*(cos(z*4.0)*sin(y*3.0)*exp(x*2.0)*(4.5) + 66*5754ecacSJeremy L Thompson sin(x*2.0)*sin(z*4.0)*exp( y*3.0)*3.0)*(nu-0.5))/ 67*5754ecacSJeremy L Thompson ((nu*2.0-1.0)*(nu+1.0)) + 68*5754ecacSJeremy L Thompson (E*nu*cos(x*2.0)*cos(y*3.0)*exp(z*4.0)*8.0)/ 69*5754ecacSJeremy L Thompson ((nu*2.0-1.0)*(nu+1.0)) - 70*5754ecacSJeremy L Thompson (E*nu*sin(x*2.0)*sin(z*4.0)*exp(y*3.0)*6.0)/ 71*5754ecacSJeremy L Thompson ((nu*2.0-1.0)*(nu+1.0)) - 72*5754ecacSJeremy L Thompson (E*cos(z*4.0)*sin(y*3.0)*exp(x*2.0)*(nu-1.0)*4.0)/ 73*5754ecacSJeremy L Thompson ((nu*2.0-1.0)*(nu+1.0))) * wdetJ / 1e8; 74*5754ecacSJeremy L Thompson 75*5754ecacSJeremy L Thompson // -- Component 2 76*5754ecacSJeremy L Thompson force[i+1*Q] = (-(E*(cos(y*3.0)*cos(z*4.0)*exp(x*2.0)*3.0 - 77*5754ecacSJeremy L Thompson cos(x*2.0)*sin( z*4.0)*exp(y*3.0)*2.0)*(nu-0.5))/ 78*5754ecacSJeremy L Thompson ((nu*2.0-1.0)*(nu+1.0)) + 79*5754ecacSJeremy L Thompson (E*(cos(x*2.0)*sin(z*4.0)*exp(y*3.0)*8.0 + 80*5754ecacSJeremy L Thompson sin(x*2.0)*sin(y*3.0)*exp(z*4.0)*6.0)*(nu-0.5))/ 81*5754ecacSJeremy L Thompson ((nu*2.0-1.0)*(nu+1.0)) + 82*5754ecacSJeremy L Thompson (E*nu*cos(y*3.0)*cos(z*4.0)*exp(x*2.0)*6.0)/ 83*5754ecacSJeremy L Thompson ((nu*2.0-1.0)*(nu+1.0)) - 84*5754ecacSJeremy L Thompson (E*nu*sin( x*2.0)*sin(y*3.0)*exp(z*4.0)*12.0)/ 85*5754ecacSJeremy L Thompson ((nu*2.0-1.0)*(nu+1.0)) - 86*5754ecacSJeremy L Thompson (E*cos(x*2.0)*sin(z*4.0)*exp(y*3.0)*(nu-1.0)*9.0)/ 87*5754ecacSJeremy L Thompson ((nu*2.0-1.0)*(nu+1.0))) * wdetJ / 1e8; 88*5754ecacSJeremy L Thompson 89*5754ecacSJeremy L Thompson // -- Component 3 90*5754ecacSJeremy L Thompson force[i+2*Q] = (-(E*(cos(x*2.0)*cos(z*4.0)*exp(y*3.0)*6.0 - 91*5754ecacSJeremy L Thompson cos(y*3.0)*sin( x*2.0)*exp(z*4.0)*(4.5))*(nu-0.5))/ 92*5754ecacSJeremy L Thompson ((nu*2.0-1.0)*(nu+1.0)) + 93*5754ecacSJeremy L Thompson (E*(cos(y*3.0)*sin(x*2.0)*exp(z*4.0)*2.0 + 94*5754ecacSJeremy L Thompson sin(y*3.0)*sin(z*4.0)*exp(x*2.0)*4.0)*(nu-0.5))/ 95*5754ecacSJeremy L Thompson ((nu*2.0-1.0)*(nu+1.0)) + 96*5754ecacSJeremy L Thompson (E*nu*cos(x*2.0)*cos(z*4.0)*exp(y*3.0)*12.0)/ 97*5754ecacSJeremy L Thompson ((nu*2.0-1.0)*(nu+1.0)) - 98*5754ecacSJeremy L Thompson (E*nu*sin( y*3.0)*sin(z*4.0)*exp(x*2.0)*8.0)/ 99*5754ecacSJeremy L Thompson ((nu*2.0-1.0)*(nu+1.0)) - 100*5754ecacSJeremy L Thompson (E*cos(y*3.0)*sin(x*2.0)*exp(z*4.0)*(nu-1.0)*16.0)/ 101*5754ecacSJeremy L Thompson ((nu*2.0-1.0)*(nu+1.0))) * wdetJ / 1e8; 102*5754ecacSJeremy L Thompson 103*5754ecacSJeremy L Thompson } // End of Quadrature Point Loop 104*5754ecacSJeremy L Thompson 105*5754ecacSJeremy L Thompson return 0; 106*5754ecacSJeremy L Thompson } 107*5754ecacSJeremy L Thompson // ----------------------------------------------------------------------------- 108*5754ecacSJeremy L Thompson 109*5754ecacSJeremy L Thompson #endif // End MANUFACTURED_H 110