xref: /libCEED/include/ceed/jit-source/gallery/ceed-vectorpoisson1dapply.h (revision 2b730f8b5a9c809740a0b3b302db43a719c636b1)
1a0154adeSJed Brown // Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors.
2a0154adeSJed Brown // All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
3a0154adeSJed Brown //
4a0154adeSJed Brown // SPDX-License-Identifier: BSD-2-Clause
5a0154adeSJed Brown //
6a0154adeSJed Brown // This file is part of CEED:  http://github.com/ceed
7a0154adeSJed Brown 
8a0154adeSJed Brown /**
9a0154adeSJed Brown   @brief Ceed QFunction for applying the 1D Poisson operator
10a0154adeSJed Brown            on a vector system with three components
11a0154adeSJed Brown **/
12a0154adeSJed Brown 
13a0154adeSJed Brown #ifndef vectorpoisson1dapply_h
14a0154adeSJed Brown #define vectorpoisson1dapply_h
15a0154adeSJed Brown 
16c9c2c079SJeremy L Thompson #include <ceed.h>
17c9c2c079SJeremy L Thompson 
18*2b730f8bSJeremy L Thompson CEED_QFUNCTION(Vector3Poisson1DApply)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) {
19a0154adeSJed Brown   // *INDENT-OFF*
20a0154adeSJed Brown   // in[0] is gradient u, shape [1, nc=3, Q]
21a0154adeSJed Brown   // in[1] is quadrature data, size (Q)
22*2b730f8bSJeremy L Thompson   const CeedScalar(*ug)[CEED_Q_VLA] = (const CeedScalar(*)[CEED_Q_VLA])in[0], (*q_data) = in[1];
23a0154adeSJed Brown   // out[0] is output to multiply against gradient v, shape [1, nc=3, Q]
24a0154adeSJed Brown   CeedScalar(*vg)[CEED_Q_VLA] = (CeedScalar(*)[CEED_Q_VLA])out[0];
25a0154adeSJed Brown   // *INDENT-ON*
26a0154adeSJed Brown 
27a0154adeSJed Brown   const CeedInt num_comp = 3;
28a0154adeSJed Brown 
29a0154adeSJed Brown   // Quadrature point loop
30*2b730f8bSJeremy L Thompson   CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) {
31a0154adeSJed Brown     for (CeedInt c = 0; c < num_comp; c++) {
32a0154adeSJed Brown       vg[c][i] = ug[c][i] * q_data[i];
33a0154adeSJed Brown     }
34a0154adeSJed Brown   }  // End of Quadrature Point Loop
35a0154adeSJed Brown 
36a0154adeSJed Brown   return CEED_ERROR_SUCCESS;
37a0154adeSJed Brown }
38a0154adeSJed Brown 
39a0154adeSJed Brown #endif  // vectorpoisson1dapply_h
40