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