xref: /libCEED/examples/solids/qfunctions/manufactured-true.h (revision d83b856e16e1a05ebd491d7f65187d3c08a4ff17)
1 // Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at
2 // the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights
3 // reserved. See files LICENSE and NOTICE for details.
4 //
5 // This file is part of CEED, a collection of benchmarks, miniapps, software
6 // libraries and APIs for efficient high-order finite element and spectral
7 // element discretizations for exascale applications. For more information and
8 // source code availability see http://github.com/ceed.
9 //
10 // The CEED research is supported by the Exascale Computing Project 17-SC-20-SC,
11 // a collaborative effort of two U.S. Department of Energy organizations (Office
12 // of Science and the National Nuclear Security Administration) responsible for
13 // the planning and preparation of a capable exascale ecosystem, including
14 // software, applications, hardware, advanced system engineering and early
15 // testbed platforms, in support of the nation's exascale computing imperative.
16 
17 /// @file
18 /// Linear elasticity manufactured solution true solution for solid mechanics example using PETSc
19 
20 #ifndef MANUFACTURED_TRUE_H
21 #define MANUFACTURED_TRUE_H
22 
23 #ifndef __CUDACC__
24 #  include <math.h>
25 #endif
26 
27 // -----------------------------------------------------------------------------
28 // True solution for linear elasticity manufactured solution
29 // -----------------------------------------------------------------------------
30 CEED_QFUNCTION(MMSTrueSoln)(void *ctx, const CeedInt Q,
31                             const CeedScalar *const *in,
32                             CeedScalar *const *out) {
33   // Inputs
34   const CeedScalar *coords = in[0];
35 
36   // Outputs
37   CeedScalar *true_soln = out[0];
38 
39   // Quadrature Point Loop
40   CeedPragmaSIMD
41   for (CeedInt i=0; i<Q; i++) {
42     // Setup
43     CeedScalar x = coords[i+0*Q], y = coords[i+1*Q], z = coords[i+2*Q];
44 
45     // True solution
46     // -- Component 1
47     true_soln[i+0*Q] = exp(2*x)*sin(3*y)*cos(4*z)/1e8;
48 
49     // -- Component 2
50     true_soln[i+1*Q] = exp(3*y)*sin(4*z)*cos(2*x)/1e8;
51 
52     // -- Component 3
53     true_soln[i+2*Q] = exp(4*z)*sin(2*x)*cos(3*y)/1e8;
54 
55   } // End of Quadrature Point Loop
56 
57   return 0;
58 }
59 // -----------------------------------------------------------------------------
60 
61 #endif // End MANUFACTURED_TRUE_H
62