xref: /libCEED/tests/t540-operator.h (revision d4cc18453651bd0f94c1a2e078b2646a92dafdcc)
1 // Copyright (c) 2017-2026, Lawrence Livermore National Security, LLC and other CEED contributors.
2 // All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
3 //
4 // SPDX-License-Identifier: BSD-2-Clause
5 //
6 // This file is part of CEED:  http://github.com/ceed
7 
8 #include <ceed/types.h>
9 
setup_mass(void * ctx,const CeedInt Q,const CeedScalar * const * in,CeedScalar * const * out)10 CEED_QFUNCTION(setup_mass)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) {
11   const CeedScalar *J = in[0], *weight = in[1];
12   CeedScalar       *rho = out[0];
13   for (CeedInt i = 0; i < Q; i++) {
14     rho[i] = weight[i] * (J[i + Q * 0] * J[i + Q * 3] - J[i + Q * 1] * J[i + Q * 2]);
15   }
16   return 0;
17 }
18 
apply(void * ctx,const CeedInt Q,const CeedScalar * const * in,CeedScalar * const * out)19 CEED_QFUNCTION(apply)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) {
20   // in[0] is u, size (Q)
21   // in[1] is mass quadrature data, size (Q)
22   const CeedScalar *u = in[0], *qd_mass = in[1];
23 
24   // out[0] is output to multiply against v, size (Q)
25   CeedScalar *v = out[0];
26 
27   // Quadrature point loop
28   for (CeedInt i = 0; i < Q; i++) {
29     // Mass
30     v[i] = qd_mass[i] * u[i];
31   }
32 
33   return 0;
34 }
35