xref: /libCEED/examples/solids/qfunctions/manufactured-true.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 /// Linear elasticity manufactured solution true solution for solid mechanics example using PETSc
19*5754ecacSJeremy L Thompson 
20*5754ecacSJeremy L Thompson #ifndef MANUFACTURED_TRUE_H
21*5754ecacSJeremy L Thompson #define MANUFACTURED_TRUE_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 // -----------------------------------------------------------------------------
28*5754ecacSJeremy L Thompson // True solution for linear elasticity manufactured solution
29*5754ecacSJeremy L Thompson // -----------------------------------------------------------------------------
30*5754ecacSJeremy L Thompson CEED_QFUNCTION(MMSTrueSoln)(void *ctx, const CeedInt Q,
31*5754ecacSJeremy L Thompson                             const CeedScalar *const *in,
32*5754ecacSJeremy L Thompson                             CeedScalar *const *out) {
33*5754ecacSJeremy L Thompson   // Inputs
34*5754ecacSJeremy L Thompson   const CeedScalar *coords = in[0];
35*5754ecacSJeremy L Thompson 
36*5754ecacSJeremy L Thompson   // Outputs
37*5754ecacSJeremy L Thompson   CeedScalar *true_soln = out[0];
38*5754ecacSJeremy L Thompson 
39*5754ecacSJeremy L Thompson   // Quadrature Point Loop
40*5754ecacSJeremy L Thompson   CeedPragmaSIMD
41*5754ecacSJeremy L Thompson   for (CeedInt i=0; i<Q; i++) {
42*5754ecacSJeremy L Thompson     // Setup
43*5754ecacSJeremy L Thompson     CeedScalar x = coords[i+0*Q], y = coords[i+1*Q], z = coords[i+2*Q];
44*5754ecacSJeremy L Thompson 
45*5754ecacSJeremy L Thompson     // True solution
46*5754ecacSJeremy L Thompson     // -- Component 1
47*5754ecacSJeremy L Thompson     true_soln[i+0*Q] = exp(2*x)*sin(3*y)*cos(4*z)/1e8;
48*5754ecacSJeremy L Thompson 
49*5754ecacSJeremy L Thompson     // -- Component 2
50*5754ecacSJeremy L Thompson     true_soln[i+1*Q] = exp(3*y)*sin(4*z)*cos(2*x)/1e8;
51*5754ecacSJeremy L Thompson 
52*5754ecacSJeremy L Thompson     // -- Component 3
53*5754ecacSJeremy L Thompson     true_soln[i+2*Q] = exp(4*z)*sin(2*x)*cos(3*y)/1e8;
54*5754ecacSJeremy L Thompson 
55*5754ecacSJeremy L Thompson   } // End of Quadrature Point Loop
56*5754ecacSJeremy L Thompson 
57*5754ecacSJeremy L Thompson   return 0;
58*5754ecacSJeremy L Thompson }
59*5754ecacSJeremy L Thompson // -----------------------------------------------------------------------------
60*5754ecacSJeremy L Thompson 
61*5754ecacSJeremy L Thompson #endif // End MANUFACTURED_TRUE_H
62