xref: /libCEED/include/ceed/jit-source/gallery/ceed-vectormassapply.h (revision cd4035ff32b1ddface7e7603292a8647e8b8628f)
1 // Copyright (c) 2017-2022, 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 /**
9   @brief Ceed QFunction for applying the mass matrix on a vector system
10            with three components
11 **/
12 
13 #ifndef vectormassapply_h
14 #define vectormassapply_h
15 
16 #include <ceed.h>
17 
18 CEED_QFUNCTION(Vector3MassApply)(void *ctx, const CeedInt Q,
19                                  const CeedScalar *const *in, CeedScalar *const *out) {
20   // *INDENT-OFF*
21   // in[0] is u, size (Q)
22   // in[1] is quadrature data, size (Q)
23   const CeedScalar (*u)[CEED_Q_VLA] = (const CeedScalar(*)[CEED_Q_VLA])in[0],
24                             *q_data = in[1];
25   // out[0] is v, size (Q)
26   CeedScalar       (*v)[CEED_Q_VLA] = (CeedScalar(*)[CEED_Q_VLA])out[0];
27   // *INDENT-ON*
28 
29   const CeedInt num_comp = 3;
30 
31   // Quadrature point loop
32   CeedPragmaSIMD
33   for (CeedInt i=0; i<Q; i++) {
34     for (CeedInt c=0; c<num_comp; c++) {
35       v[c][i] = u[c][i] * q_data[i];
36     }
37   } // End of Quadrature Point Loop
38 
39   return CEED_ERROR_SUCCESS;
40 }
41 
42 #endif // vectormassapply_h
43