xref: /libCEED/examples/solids/qfunctions/manufactured-true.h (revision 3f21f6b10abeb5d85d3454ea5cd38498737dc88a)
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 #include <math.h>
24 
25 // -----------------------------------------------------------------------------
26 // True solution for linear elasticity manufactured solution
27 // -----------------------------------------------------------------------------
28 CEED_QFUNCTION(MMSTrueSoln)(void *ctx, const CeedInt Q,
29                             const CeedScalar *const *in,
30                             CeedScalar *const *out) {
31   // Inputs
32   const CeedScalar *coords = in[0];
33 
34   // Outputs
35   CeedScalar *true_soln = out[0];
36 
37   // Quadrature Point Loop
38   CeedPragmaSIMD
39   for (CeedInt i=0; i<Q; i++) {
40     // Setup
41     CeedScalar x = coords[i+0*Q], y = coords[i+1*Q], z = coords[i+2*Q];
42 
43     // True solution
44     // -- Component 1
45     true_soln[i+0*Q] = exp(2*x)*sin(3*y)*cos(4*z)/1e8;
46 
47     // -- Component 2
48     true_soln[i+1*Q] = exp(3*y)*sin(4*z)*cos(2*x)/1e8;
49 
50     // -- Component 3
51     true_soln[i+2*Q] = exp(4*z)*sin(2*x)*cos(3*y)/1e8;
52 
53   } // End of Quadrature Point Loop
54 
55   return 0;
56 }
57 // -----------------------------------------------------------------------------
58 
59 #endif // End MANUFACTURED_TRUE_H
60