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