xref: /libCEED/tests/t537-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.
3d965c7a7SJeremy L Thompson //
4*3d8e8822SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause
5d965c7a7SJeremy L Thompson //
6*3d8e8822SJeremy L Thompson // This file is part of CEED:  http://github.com/ceed
7d965c7a7SJeremy L Thompson 
8d965c7a7SJeremy L Thompson CEED_QFUNCTION(setup)(void *ctx, const CeedInt Q,
9d965c7a7SJeremy L Thompson                       const CeedScalar *const *in,
10d965c7a7SJeremy L Thompson                       CeedScalar *const *out) {
11d965c7a7SJeremy L Thompson   const CeedScalar *weight = in[0], *J = in[1];
12d965c7a7SJeremy L Thompson   CeedScalar *rho = out[0];
13d965c7a7SJeremy L Thompson   for (CeedInt i=0; i<Q; i++) {
14d965c7a7SJeremy L Thompson     rho[i] = weight[i] * (J[i+Q*0]*J[i+Q*3] - J[i+Q*1]*J[i+Q*2]);
15d965c7a7SJeremy L Thompson   }
16d965c7a7SJeremy L Thompson   return 0;
17d965c7a7SJeremy L Thompson }
18d965c7a7SJeremy L Thompson 
19d965c7a7SJeremy L Thompson CEED_QFUNCTION(mass)(void *ctx, const CeedInt Q, const CeedScalar *const *in,
20d965c7a7SJeremy L Thompson                      CeedScalar *const *out) {
21d965c7a7SJeremy L Thompson   const CeedScalar *rho = in[0], *u = in[1];
22d965c7a7SJeremy L Thompson   CeedScalar *v = out[0];
23d965c7a7SJeremy L Thompson   for (CeedInt i=0; i<Q; i++) {
24d965c7a7SJeremy L Thompson     for (CeedInt c=0; c<2; c++)
25d965c7a7SJeremy L Thompson       v[i+Q*c] = rho[i] * u[i+Q*(c ? 0 : 1)];
26d965c7a7SJeremy L Thompson   }
27d965c7a7SJeremy L Thompson   return 0;
28d965c7a7SJeremy L Thompson }
29