xref: /libCEED/include/ceed/jit-source/gallery/ceed-vectorpoisson2dapply.h (revision 47fa654bdb0443fad7121e250bf7da7adb8330de)
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 2D Poisson operator
10            on a vector system with three components
11 **/
12 
13 #ifndef vectorpoisson2dapply_h
14 #define vectorpoisson2dapply_h
15 
16 #include <ceed.h>
17 
18 CEED_QFUNCTION(Vector3Poisson2DApply)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) {
19   // in[0] is gradient u, shape [2, nc=3, Q]
20   // in[1] is quadrature data, size (3*Q)
21   const CeedScalar(*ug)[3][CEED_Q_VLA] = (const CeedScalar(*)[3][CEED_Q_VLA])in[0], (*q_data)[CEED_Q_VLA] = (const CeedScalar(*)[CEED_Q_VLA])in[1];
22   // out[0] is output to multiply against gradient v, shape [2, nc=3, Q]
23   CeedScalar(*vg)[3][CEED_Q_VLA] = (CeedScalar(*)[3][CEED_Q_VLA])out[0];
24 
25   const CeedInt dim = 2, num_comp = 3;
26 
27   // Quadrature point loop
28   CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) {
29     // Read qdata (dXdxdXdxT symmetric matrix)
30     // Stored in Voigt convention
31     // 0 2
32     // 2 1
33     const CeedScalar dXdxdXdxT[2][2] = {
34         {q_data[0][i], q_data[2][i]},
35         {q_data[2][i], q_data[1][i]}
36     };
37 
38     // Apply Poisson operator
39     // j = direction of vg
40     for (CeedInt j = 0; j < dim; j++)
41       for (CeedInt c = 0; c < num_comp; c++) vg[j][c][i] = (ug[0][c][i] * dXdxdXdxT[0][j] + ug[1][c][i] * dXdxdXdxT[1][j]);
42   }  // End of Quadrature Point Loop
43 
44   return CEED_ERROR_SUCCESS;
45 }
46 
47 #endif  // vectorpoisson2dapply_h
48