xref: /libCEED/tests/t530-operator.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.
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 
8*c9c2c079SJeremy L Thompson #include <ceed.h>
9*c9c2c079SJeremy L Thompson 
101d102b48SJeremy L Thompson CEED_QFUNCTION(setup)(void *ctx, const CeedInt Q,
111d102b48SJeremy L Thompson                       const CeedScalar *const *in,
121d102b48SJeremy L Thompson                       CeedScalar *const *out) {
131d102b48SJeremy L Thompson   const CeedScalar *weight = in[0], *J = in[1];
141d102b48SJeremy L Thompson   CeedScalar *rho = out[0];
151d102b48SJeremy L Thompson   for (CeedInt i=0; i<Q; i++) {
161d102b48SJeremy L Thompson     rho[i] = weight[i] * (J[i+Q*0]*J[i+Q*3] - J[i+Q*1]*J[i+Q*2]);
171d102b48SJeremy L Thompson   }
181d102b48SJeremy L Thompson   return 0;
191d102b48SJeremy L Thompson }
201d102b48SJeremy L Thompson 
211d102b48SJeremy L Thompson CEED_QFUNCTION(mass)(void *ctx, const CeedInt Q, const CeedScalar *const *in,
221d102b48SJeremy L Thompson                      CeedScalar *const *out) {
231d102b48SJeremy L Thompson   const CeedScalar *rho = in[0], *u = in[1];
241d102b48SJeremy L Thompson   CeedScalar *v = out[0];
251d102b48SJeremy L Thompson   for (CeedInt i=0; i<Q; i++) {
261d102b48SJeremy L Thompson     v[i] = rho[i] * u[i];
271d102b48SJeremy L Thompson   }
281d102b48SJeremy L Thompson   return 0;
291d102b48SJeremy L Thompson }
30