xref: /libCEED/tests/t406-qfunction.h (revision 121d4b7fb417fe929bc878bd436cd4820a8e3053)
1 // Copyright (c) 2017-2022, 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 #include  <math.h>
10 #include "./t406-qfunction-scales.h"
11 # include   "t406-qfunction-helper.h"
12 
13 CEED_QFUNCTION(setup)(void *ctx, const CeedInt Q, const CeedScalar *const *in,
14                       CeedScalar *const *out) {
15   const CeedScalar *w = in[0];
16   CeedScalar *q_data = out[0];
17   for (CeedInt i=0; i<Q; i++) {
18     q_data[i] = w[i];
19   }
20   return 0;
21 }
22 
23 CEED_QFUNCTION(mass)(void *ctx, const CeedInt Q, const CeedScalar *const *in,
24                      CeedScalar *const *out) {
25   const CeedScalar *q_data = in[0], *u = in[1];
26   CeedScalar *v = out[0];
27   for (CeedInt i=0; i<Q; i++) {
28     v[i] = q_data[i] * (times_two(u[i]) + times_three(u[i])) * sqrt(
29              1.0 * SCALE_TWO);
30   }
31   return 0;
32 }
33