xref: /libCEED/tests/t406-qfunction.h (revision 4753b775a3a8f79e2dd83c2aab10890a6a04e913)
15aed82e4SJeremy 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 
8b13efd58SJeremy L Thompson // Note: intentionally testing strange spacing in include's
9509d4af6SJeremy L Thompson // clang-format off
10c0b5abf0SJeremy L Thompson // Note - ceed/types.h should be used over ceed.h
11c9c2c079SJeremy L Thompson #include <ceed.h>
12c0b5abf0SJeremy L Thompson // Note - system headers like math.h and std*.h should be guarded
13c0b5abf0SJeremy L Thompson #ifndef CEED_RUNNING_JIT_PASS
142b730f8bSJeremy L Thompson #  include <math.h>
15c0b5abf0SJeremy L Thompson #endif
162b730f8bSJeremy L Thompson 
17ccec5866SJeremy L Thompson #include "t406-qfunction-helper.h"
187cbc98eeSJeremy L Thompson // Test duplicate includes of guarded files
197cbc98eeSJeremy L Thompson // Also test include path with "/../"
207cbc98eeSJeremy L Thompson #include "../tests/t406-qfunction-helper.h"
2142c7156fSJeremy L Thompson // Also test include path with "/../../"
2242c7156fSJeremy L Thompson #include "../../libCEED/tests/t406-qfunction-helper.h"
23e38d11baSSebastian Grimberg #  include "t406-qfunction-scales.h"
24509d4af6SJeremy L Thompson // clang-format on
25ccec5866SJeremy L Thompson 
26*4753b775SJeremy L Thompson // Extra define set via CeedAddJitDefine() during JiT
27*4753b775SJeremy L Thompson #ifndef CEED_RUNNING_JIT_PASS
28*4753b775SJeremy L Thompson #define COMPILER_DEFINED_SCALE 42
29*4753b775SJeremy L Thompson #endif
30*4753b775SJeremy L Thompson 
312b730f8bSJeremy L Thompson CEED_QFUNCTION(setup)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) {
32ccec5866SJeremy L Thompson   const CeedScalar *w      = in[0];
33ccec5866SJeremy L Thompson   CeedScalar       *q_data = out[0];
34ccec5866SJeremy L Thompson   for (CeedInt i = 0; i < Q; i++) {
35ccec5866SJeremy L Thompson     q_data[i] = w[i];
36ccec5866SJeremy L Thompson   }
37ccec5866SJeremy L Thompson   return 0;
38ccec5866SJeremy L Thompson }
39ccec5866SJeremy L Thompson 
402b730f8bSJeremy L Thompson CEED_QFUNCTION(mass)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) {
41ccec5866SJeremy L Thompson   const CeedScalar *q_data = in[0], *u = in[1];
42ccec5866SJeremy L Thompson   CeedScalar       *v = out[0];
43ccec5866SJeremy L Thompson   for (CeedInt i = 0; i < Q; i++) {
44*4753b775SJeremy L Thompson     v[i] = q_data[i] * COMPILER_DEFINED_SCALE * (times_two(u[i]) + times_three(u[i])) * sqrt(1.0 * SCALE_TWO);
45ccec5866SJeremy L Thompson   }
46ccec5866SJeremy L Thompson   return 0;
47ccec5866SJeremy L Thompson }
48