xref: /libCEED/tests/t405-qfunction.h (revision 3d8e882215d238700cdceb37404f76ca7fa24eaa)
1*3d8e8822SJeremy L Thompson // Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors.
2*3d8e8822SJeremy L Thompson // All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
377841947SLeila Ghaffari //
4*3d8e8822SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause
577841947SLeila Ghaffari //
6*3d8e8822SJeremy L Thompson // This file is part of CEED:  http://github.com/ceed
777841947SLeila Ghaffari 
877841947SLeila Ghaffari CEED_QFUNCTION(setup)(void *ctx, const CeedInt Q,
977841947SLeila Ghaffari                       const CeedScalar *const *in,
1077841947SLeila Ghaffari                       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 
1977841947SLeila Ghaffari CEED_QFUNCTION_HELPER CeedScalar times_two(CeedScalar x) {
2077841947SLeila Ghaffari   return 2 * x;
2177841947SLeila Ghaffari }
2277841947SLeila Ghaffari 
2377841947SLeila Ghaffari CEED_QFUNCTION(mass)(void *ctx, const CeedInt Q, const CeedScalar *const *in,
2477841947SLeila Ghaffari                      CeedScalar *const *out) {
2577841947SLeila Ghaffari   const CeedScalar *q_data = in[0], *u = in[1];
2677841947SLeila Ghaffari   CeedScalar *v = out[0];
2777841947SLeila Ghaffari   for (CeedInt i=0; i<Q; i++) {
2877841947SLeila Ghaffari     v[i] = q_data[i] * times_two(u[i]);
2977841947SLeila Ghaffari   }
3077841947SLeila Ghaffari   return 0;
3177841947SLeila Ghaffari }
32