xref: /libCEED/tests/t530-operator.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.
31d102b48SJeremy L Thompson //
43d8e8822SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause
51d102b48SJeremy L Thompson //
63d8e8822SJeremy L Thompson // This file is part of CEED:  http://github.com/ceed
71d102b48SJeremy L Thompson 
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) {
111d102b48SJeremy L Thompson   const CeedScalar *weight = in[0], *J = in[1];
121d102b48SJeremy L Thompson   CeedScalar       *rho = out[0];
131d102b48SJeremy L Thompson   for (CeedInt i = 0; i < Q; i++) {
141d102b48SJeremy L Thompson     rho[i] = weight[i] * (J[i + Q * 0] * J[i + Q * 3] - J[i + Q * 1] * J[i + Q * 2]);
151d102b48SJeremy L Thompson   }
161d102b48SJeremy L Thompson   return 0;
171d102b48SJeremy L Thompson }
181d102b48SJeremy L Thompson 
mass(void * ctx,const CeedInt Q,const CeedScalar * const * in,CeedScalar * const * out)192b730f8bSJeremy L Thompson CEED_QFUNCTION(mass)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) {
201d102b48SJeremy L Thompson   const CeedScalar *rho = in[0], *u = in[1];
211d102b48SJeremy L Thompson   CeedScalar       *v = out[0];
221d102b48SJeremy L Thompson   for (CeedInt i = 0; i < Q; i++) {
231d102b48SJeremy L Thompson     v[i] = rho[i] * u[i];
241d102b48SJeremy L Thompson   }
251d102b48SJeremy L Thompson   return 0;
261d102b48SJeremy L Thompson }
27