xref: /libCEED/tests/t507-operator.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.
31da99368SJeremy L Thompson //
4*3d8e8822SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause
51da99368SJeremy L Thompson //
6*3d8e8822SJeremy L Thompson // This file is part of CEED:  http://github.com/ceed
71da99368SJeremy L Thompson 
81da99368SJeremy L Thompson CEED_QFUNCTION(setup)(void *ctx, const CeedInt Q,
91da99368SJeremy L Thompson                       const CeedScalar *const *in,
101da99368SJeremy L Thompson                       CeedScalar *const *out) {
111da99368SJeremy L Thompson   const CeedScalar *weight = in[0], *dxdX = in[1];
121da99368SJeremy L Thompson   CeedScalar *rho = out[0];
131da99368SJeremy L Thompson 
141da99368SJeremy L Thompson   for (CeedInt i=0; i<Q; i++) {
151da99368SJeremy L Thompson     rho[i] = weight[i] * dxdX[i];
161da99368SJeremy L Thompson   }
171da99368SJeremy L Thompson   return 0;
181da99368SJeremy L Thompson }
191da99368SJeremy L Thompson 
201da99368SJeremy L Thompson CEED_QFUNCTION(mass)(void *ctx, const CeedInt Q, const CeedScalar *const *in,
211da99368SJeremy L Thompson                      CeedScalar *const *out) {
221da99368SJeremy L Thompson   // *INDENT-OFF*
231da99368SJeremy L Thompson   const CeedScalar             *rho = in[0],
241da99368SJeremy L Thompson                    (*u)[CEED_Q_VLA] = (const CeedScalar(*)[CEED_Q_VLA])in[1];
251da99368SJeremy L Thompson   CeedScalar       (*v)[CEED_Q_VLA] = (CeedScalar(*)[CEED_Q_VLA])out[0];
261da99368SJeremy L Thompson   // *INDENT-ON*
271da99368SJeremy L Thompson 
281da99368SJeremy L Thompson   for (CeedInt i=0; i<Q; i++) {
291da99368SJeremy L Thompson     v[0][i] = rho[i] * u[0][i];
301da99368SJeremy L Thompson     v[1][i] = rho[i] * u[1][i];
311da99368SJeremy L Thompson   }
321da99368SJeremy L Thompson   return 0;
331da99368SJeremy L Thompson }
34