xref: /libCEED/tests/t406-qfunction.h (revision 7173c8dc81de0c321ecbfa65814b28460552c1f4)
13d8e8822SJeremy L Thompson // Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors.
23d8e8822SJeremy L Thompson // All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
3ccec5866SJeremy L Thompson //
43d8e8822SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause
5ccec5866SJeremy L Thompson //
63d8e8822SJeremy L Thompson // This file is part of CEED:  http://github.com/ceed
7ccec5866SJeremy L Thompson 
8ccec5866SJeremy L Thompson // Note: intentionally testing strange spacing in '#include's
9ccec5866SJeremy L Thompson #include  <math.h>
10*7173c8dcSJeremy L Thompson #include "./t406-qfunction-scales.h"
11ccec5866SJeremy L Thompson # include   "t406-qfunction-helper.h"
12ccec5866SJeremy L Thompson 
13ccec5866SJeremy L Thompson CEED_QFUNCTION(setup)(void *ctx, const CeedInt Q, const CeedScalar *const *in,
14ccec5866SJeremy L Thompson                       CeedScalar *const *out) {
15ccec5866SJeremy L Thompson   const CeedScalar *w = in[0];
16ccec5866SJeremy L Thompson   CeedScalar *q_data = out[0];
17ccec5866SJeremy L Thompson   for (CeedInt i=0; i<Q; i++) {
18ccec5866SJeremy L Thompson     q_data[i] = w[i];
19ccec5866SJeremy L Thompson   }
20ccec5866SJeremy L Thompson   return 0;
21ccec5866SJeremy L Thompson }
22ccec5866SJeremy L Thompson 
23ccec5866SJeremy L Thompson CEED_QFUNCTION(mass)(void *ctx, const CeedInt Q, const CeedScalar *const *in,
24ccec5866SJeremy L Thompson                      CeedScalar *const *out) {
25ccec5866SJeremy L Thompson   const CeedScalar *q_data = in[0], *u = in[1];
26ccec5866SJeremy L Thompson   CeedScalar *v = out[0];
27ccec5866SJeremy L Thompson   for (CeedInt i=0; i<Q; i++) {
28*7173c8dcSJeremy L Thompson     v[i] = q_data[i] * (times_two(u[i]) + times_three(u[i])) * sqrt(
29*7173c8dcSJeremy L Thompson              1.0 * SCALE_TWO);
30ccec5866SJeremy L Thompson   }
31ccec5866SJeremy L Thompson   return 0;
32ccec5866SJeremy L Thompson }
33