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