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