xref: /libCEED/examples/solids/qfunctions/manufactured-true.h (revision 2b730f8b5a9c809740a0b3b302db43a719c636b1)
1 // Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors.
2 // All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
3 //
4 // SPDX-License-Identifier: BSD-2-Clause
5 //
6 // This file is part of CEED:  http://github.com/ceed
7 
8 /// @file
9 /// Linear elasticity manufactured solution true solution for solid mechanics example using PETSc
10 
11 #ifndef MANUFACTURED_TRUE_H
12 #define MANUFACTURED_TRUE_H
13 
14 #include <ceed.h>
15 #include <math.h>
16 
17 // -----------------------------------------------------------------------------
18 // True solution for linear elasticity manufactured solution
19 // -----------------------------------------------------------------------------
20 CEED_QFUNCTION(MMSTrueSoln)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) {
21   // Inputs
22   const CeedScalar *coords = in[0];
23 
24   // Outputs
25   CeedScalar *true_soln = out[0];
26 
27   // Quadrature Point Loop
28   CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) {
29     // Setup
30     CeedScalar x = coords[i + 0 * Q], y = coords[i + 1 * Q], z = coords[i + 2 * Q];
31 
32     // True solution
33     // -- Component 1
34     true_soln[i + 0 * Q] = exp(2 * x) * sin(3 * y) * cos(4 * z) / 1e8;
35 
36     // -- Component 2
37     true_soln[i + 1 * Q] = exp(3 * y) * sin(4 * z) * cos(2 * x) / 1e8;
38 
39     // -- Component 3
40     true_soln[i + 2 * Q] = exp(4 * z) * sin(2 * x) * cos(3 * y) / 1e8;
41 
42   }  // End of Quadrature Point Loop
43 
44   return 0;
45 }
46 // -----------------------------------------------------------------------------
47 
48 #endif  // End MANUFACTURED_TRUE_H
49