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