xref: /libCEED/tests/t405-qfunction.h (revision d4cc18453651bd0f94c1a2e078b2646a92dafdcc)
1*9ba83ac0SJeremy L Thompson // Copyright (c) 2017-2026, 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.
377841947SLeila Ghaffari //
43d8e8822SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause
577841947SLeila Ghaffari //
63d8e8822SJeremy L Thompson // This file is part of CEED:  http://github.com/ceed
777841947SLeila Ghaffari 
8c0b5abf0SJeremy L Thompson #include <ceed/types.h>
9c9c2c079SJeremy L Thompson 
setup(void * ctx,const CeedInt Q,const CeedScalar * const * in,CeedScalar * const * out)102b730f8bSJeremy L Thompson CEED_QFUNCTION(setup)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) {
1177841947SLeila Ghaffari   const CeedScalar *w      = in[0];
1277841947SLeila Ghaffari   CeedScalar       *q_data = out[0];
1377841947SLeila Ghaffari   for (CeedInt i = 0; i < Q; i++) {
1477841947SLeila Ghaffari     q_data[i] = w[i];
1577841947SLeila Ghaffari   }
1677841947SLeila Ghaffari   return 0;
1777841947SLeila Ghaffari }
1877841947SLeila Ghaffari 
times_two(CeedScalar x)192b730f8bSJeremy L Thompson CEED_QFUNCTION_HELPER CeedScalar times_two(CeedScalar x) { return 2 * x; }
2077841947SLeila Ghaffari 
mass(void * ctx,const CeedInt Q,const CeedScalar * const * in,CeedScalar * const * out)212b730f8bSJeremy L Thompson CEED_QFUNCTION(mass)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) {
2277841947SLeila Ghaffari   const CeedScalar *q_data = in[0], *u = in[1];
2377841947SLeila Ghaffari   CeedScalar       *v = out[0];
2477841947SLeila Ghaffari   for (CeedInt i = 0; i < Q; i++) {
2577841947SLeila Ghaffari     v[i] = q_data[i] * times_two(u[i]);
2677841947SLeila Ghaffari   }
2777841947SLeila Ghaffari   return 0;
2877841947SLeila Ghaffari }
29