xref: /libCEED/tests/t406-qfunction.h (revision ccec58666b8929dfb32358838fe858499801da8c)
1*ccec5866SJeremy L Thompson // Copyright (c) 2017-2018, Lawrence Livermore National Security, LLC.
2*ccec5866SJeremy L Thompson // Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707.
3*ccec5866SJeremy L Thompson // All Rights reserved. See files LICENSE and NOTICE for details.
4*ccec5866SJeremy L Thompson //
5*ccec5866SJeremy L Thompson // This file is part of CEED, a collection of benchmarks, miniapps, software
6*ccec5866SJeremy L Thompson // libraries and APIs for efficient high-order finite element and spectral
7*ccec5866SJeremy L Thompson // element discretizations for exascale applications. For more information and
8*ccec5866SJeremy L Thompson // source code availability see http://github.com/ceed.
9*ccec5866SJeremy L Thompson //
10*ccec5866SJeremy L Thompson // The CEED research is supported by the Exascale Computing Project 17-SC-20-SC,
11*ccec5866SJeremy L Thompson // a collaborative effort of two U.S. Department of Energy organizations (Office
12*ccec5866SJeremy L Thompson // of Science and the National Nuclear Security Administration) responsible for
13*ccec5866SJeremy L Thompson // the planning and preparation of a capable exascale ecosystem, including
14*ccec5866SJeremy L Thompson // software, applications, hardware, advanced system engineering and early
15*ccec5866SJeremy L Thompson // testbed platforms, in support of the nation's exascale computing imperative.
16*ccec5866SJeremy L Thompson 
17*ccec5866SJeremy L Thompson // Note: intentionally testing strange spacing in '#include's
18*ccec5866SJeremy L Thompson #include  <math.h>
19*ccec5866SJeremy L Thompson # include   "t406-qfunction-helper.h"
20*ccec5866SJeremy L Thompson 
21*ccec5866SJeremy L Thompson CEED_QFUNCTION(setup)(void *ctx, const CeedInt Q, const CeedScalar *const *in,
22*ccec5866SJeremy L Thompson                       CeedScalar *const *out) {
23*ccec5866SJeremy L Thompson   const CeedScalar *w = in[0];
24*ccec5866SJeremy L Thompson   CeedScalar *q_data = out[0];
25*ccec5866SJeremy L Thompson   for (CeedInt i=0; i<Q; i++) {
26*ccec5866SJeremy L Thompson     q_data[i] = w[i];
27*ccec5866SJeremy L Thompson   }
28*ccec5866SJeremy L Thompson   return 0;
29*ccec5866SJeremy L Thompson }
30*ccec5866SJeremy L Thompson 
31*ccec5866SJeremy L Thompson CEED_QFUNCTION(mass)(void *ctx, const CeedInt Q, const CeedScalar *const *in,
32*ccec5866SJeremy L Thompson                      CeedScalar *const *out) {
33*ccec5866SJeremy L Thompson   const CeedScalar *q_data = in[0], *u = in[1];
34*ccec5866SJeremy L Thompson   CeedScalar *v = out[0];
35*ccec5866SJeremy L Thompson   for (CeedInt i=0; i<Q; i++) {
36*ccec5866SJeremy L Thompson     v[i] = q_data[i] * (times_two(u[i]) + times_three(u[i])) * sqrt(2.);
37*ccec5866SJeremy L Thompson   }
38*ccec5866SJeremy L Thompson   return 0;
39*ccec5866SJeremy L Thompson }
40