xref: /libCEED/tests/t406-qfunction.h (revision 7cbc98ee6c81dcfdc133295c4388d23367d79bb6)
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 #  include "t406-qfunction-scales.h"
18 // clang-format on
19 
20 CEED_QFUNCTION(setup)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) {
21   const CeedScalar *w      = in[0];
22   CeedScalar       *q_data = out[0];
23   for (CeedInt i = 0; i < Q; i++) {
24     q_data[i] = w[i];
25   }
26   return 0;
27 }
28 
29 CEED_QFUNCTION(mass)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) {
30   const CeedScalar *q_data = in[0], *u = in[1];
31   CeedScalar       *v = out[0];
32   for (CeedInt i = 0; i < Q; i++) {
33     v[i] = q_data[i] * (times_two(u[i]) + times_three(u[i])) * sqrt(1.0 * SCALE_TWO);
34   }
35   return 0;
36 }
37