xref: /libCEED/tests/t406-qfunction.h (revision 29ec485eb72075150292bd9d6291eab6d473a1fc)
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 // Note: intentionally testing strange spacing in '#include's
9 // clang-format off
10 #include <ceed.h>
11 #  include  <math.h>
12 
13 #include "t406-qfunction-helper.h"
14 // Test duplicate includes of guarded files
15 // Also test include path with "/../"
16 #include "../tests/t406-qfunction-helper.h"
17 // Also test include path with "/../../"
18 #include "../../libCEED/tests/t406-qfunction-helper.h"
19 #  include "t406-qfunction-scales.h"
20 // clang-format on
21 
22 CEED_QFUNCTION(setup)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) {
23   const CeedScalar *w      = in[0];
24   CeedScalar       *q_data = out[0];
25   for (CeedInt i = 0; i < Q; i++) {
26     q_data[i] = w[i];
27   }
28   return 0;
29 }
30 
31 CEED_QFUNCTION(mass)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) {
32   const CeedScalar *q_data = in[0], *u = in[1];
33   CeedScalar       *v = out[0];
34   for (CeedInt i = 0; i < Q; i++) {
35     v[i] = q_data[i] * (times_two(u[i]) + times_three(u[i])) * sqrt(1.0 * SCALE_TWO);
36   }
37   return 0;
38 }
39