xref: /libCEED/include/ceed/jit-source/gallery/ceed-vectorpoisson2dapply.h (revision 33490f6ef26c584470cb54133cdd71c442f1841b)
1*9ba83ac0SJeremy L Thompson // Copyright (c) 2017-2026, 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 /**
9ea61e9acSJeremy L Thompson   @brief Ceed QFunction for applying the 2D Poisson operator on a vector system with three components
10a0154adeSJed Brown **/
11c0b5abf0SJeremy L Thompson #include <ceed/types.h>
12c9c2c079SJeremy L Thompson 
Vector3Poisson2DApply(void * ctx,const CeedInt Q,const CeedScalar * const * in,CeedScalar * const * out)132b730f8bSJeremy L Thompson CEED_QFUNCTION(Vector3Poisson2DApply)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) {
14a0154adeSJed Brown   // in[0] is gradient u, shape [2, nc=3, Q]
15a0154adeSJed Brown   // in[1] is quadrature data, size (3*Q)
162b730f8bSJeremy L Thompson   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];
17a0154adeSJed Brown   // out[0] is output to multiply against gradient v, shape [2, nc=3, Q]
18a0154adeSJed Brown   CeedScalar(*vg)[3][CEED_Q_VLA] = (CeedScalar(*)[3][CEED_Q_VLA])out[0];
19a0154adeSJed Brown 
20a0154adeSJed Brown   const CeedInt dim = 2, num_comp = 3;
21a0154adeSJed Brown 
22a0154adeSJed Brown   // Quadrature point loop
232b730f8bSJeremy L Thompson   CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) {
24a0154adeSJed Brown     // Read qdata (dXdxdXdxT symmetric matrix)
25a0154adeSJed Brown     // Stored in Voigt convention
26a0154adeSJed Brown     // 0 2
27a0154adeSJed Brown     // 2 1
282b730f8bSJeremy L Thompson     const CeedScalar dXdxdXdxT[2][2] = {
292b730f8bSJeremy L Thompson         {q_data[0][i], q_data[2][i]},
302b730f8bSJeremy L Thompson         {q_data[2][i], q_data[1][i]}
31a0154adeSJed Brown     };
32a0154adeSJed Brown 
33a0154adeSJed Brown     // Apply Poisson operator
34a0154adeSJed Brown     // j = direction of vg
35a0154adeSJed Brown     for (CeedInt j = 0; j < dim; j++)
362b730f8bSJeremy L Thompson       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]);
37a0154adeSJed Brown   }  // End of Quadrature Point Loop
38a0154adeSJed Brown   return CEED_ERROR_SUCCESS;
39a0154adeSJed Brown }
40