xref: /libCEED/tests/t406-qfunction.h (revision 5aed82e4fa97acf4ba24a7f10a35f5303a6798e0) !
1*5aed82e4SJeremy L Thompson // Copyright (c) 2017-2024, 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
9c9c2c079SJeremy L Thompson #include <ceed.h>
102b730f8bSJeremy L Thompson #include <math.h>
112b730f8bSJeremy L Thompson 
12ccec5866SJeremy L Thompson #include "t406-qfunction-helper.h"
13e38d11baSSebastian Grimberg #include "t406-qfunction-scales.h"
14ccec5866SJeremy L Thompson 
152b730f8bSJeremy L Thompson CEED_QFUNCTION(setup)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) {
16ccec5866SJeremy L Thompson   const CeedScalar *w      = in[0];
17ccec5866SJeremy L Thompson   CeedScalar       *q_data = out[0];
18ccec5866SJeremy L Thompson   for (CeedInt i = 0; i < Q; i++) {
19ccec5866SJeremy L Thompson     q_data[i] = w[i];
20ccec5866SJeremy L Thompson   }
21ccec5866SJeremy L Thompson   return 0;
22ccec5866SJeremy L Thompson }
23ccec5866SJeremy L Thompson 
242b730f8bSJeremy L Thompson CEED_QFUNCTION(mass)(void *ctx, const CeedInt Q, const CeedScalar *const *in, 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++) {
282b730f8bSJeremy L Thompson     v[i] = q_data[i] * (times_two(u[i]) + times_three(u[i])) * sqrt(1.0 * SCALE_TWO);
29ccec5866SJeremy L Thompson   }
30ccec5866SJeremy L Thompson   return 0;
31ccec5866SJeremy L Thompson }
32