xref: /libCEED/tests/t400-qfunction.h (revision c9c2c07970382857cc7b4a28d359710237b91a3e)
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.
34d537eeaSYohann //
43d8e8822SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause
54d537eeaSYohann //
63d8e8822SJeremy L Thompson // This file is part of CEED:  http://github.com/ceed
74d537eeaSYohann 
8*c9c2c079SJeremy L Thompson #include <ceed.h>
9*c9c2c079SJeremy L Thompson 
104d537eeaSYohann CEED_QFUNCTION(setup)(void *ctx, const CeedInt Q,
114d537eeaSYohann                       const CeedScalar *const *in,
124d537eeaSYohann                       CeedScalar *const *out) {
134d537eeaSYohann   const CeedScalar *w = in[0];
14d1d35e2fSjeremylt   CeedScalar *q_data = out[0];
154d537eeaSYohann   for (CeedInt i=0; i<Q; i++) {
16d1d35e2fSjeremylt     q_data[i] = w[i];
174d537eeaSYohann   }
184d537eeaSYohann   return 0;
194d537eeaSYohann }
204d537eeaSYohann 
214d537eeaSYohann CEED_QFUNCTION(mass)(void *ctx, const CeedInt Q, const CeedScalar *const *in,
224d537eeaSYohann                      CeedScalar *const *out) {
23d1d35e2fSjeremylt   const CeedScalar *q_data = in[0], *u = in[1];
244d537eeaSYohann   CeedScalar *v = out[0];
254d537eeaSYohann   for (CeedInt i=0; i<Q; i++) {
26d1d35e2fSjeremylt     v[i] = q_data[i] * u[i];
274d537eeaSYohann   }
284d537eeaSYohann   return 0;
294d537eeaSYohann }
30