xref: /libCEED/examples/solids/qfunctions/manufactured-true.h (revision 07d5b98a8feba68a643190b8ea9bcdac5c3e6570)
1 // Copyright (c) 2017-2024, 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 #include <ceed.h>
12 #include <math.h>
13 
14 // -----------------------------------------------------------------------------
15 // True solution for linear elasticity manufactured solution
16 // -----------------------------------------------------------------------------
17 CEED_QFUNCTION(MMSTrueSoln)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) {
18   // Inputs
19   const CeedScalar *coords = in[0];
20 
21   // Outputs
22   CeedScalar *true_soln = out[0];
23 
24   // Quadrature Point Loop
25   CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) {
26     // Setup
27     CeedScalar x = coords[i + 0 * Q], y = coords[i + 1 * Q], z = coords[i + 2 * Q];
28 
29     // True solution
30     // -- Component 1
31     true_soln[i + 0 * Q] = exp(2 * x) * sin(3 * y) * cos(4 * z) / 1e8;
32 
33     // -- Component 2
34     true_soln[i + 1 * Q] = exp(3 * y) * sin(4 * z) * cos(2 * x) / 1e8;
35 
36     // -- Component 3
37     true_soln[i + 2 * Q] = exp(4 * z) * sin(2 * x) * cos(3 * y) / 1e8;
38 
39   }  // End of Quadrature Point Loop
40 
41   return 0;
42 }
43 // -----------------------------------------------------------------------------
44