xref: /libCEED/gallery/poisson-vector/ceed-vectorpoisson2dapply.c (revision 53ee81eed7fe6a54158b819b478dad66ca478dc3)
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.h>
9 #include <ceed/backend.h>
10 #include <ceed/jit-source/gallery/ceed-vectorpoisson2dapply.h>
11 #include <string.h>
12 
13 /**
14   @brief Set fields for `CeedQFunction` applying the 2D Poisson operator on a vector system with three components
15 **/
16 static int CeedQFunctionInit_Vector3Poisson2DApply(Ceed ceed, const char *requested, CeedQFunction qf) {
17   // Check QFunction name
18   const char *name = "Vector3Poisson2DApply";
19 
20   CeedCheck(!strcmp(name, requested), ceed, CEED_ERROR_UNSUPPORTED, "QFunction '%s' does not match requested name: %s", name, requested);
21 
22   // Add QFunction fields
23   const CeedInt dim = 2, num_comp = 3;
24 
25   CeedCall(CeedQFunctionAddInput(qf, "du", num_comp * dim, CEED_EVAL_GRAD));
26   CeedCall(CeedQFunctionAddInput(qf, "qdata", dim * (dim + 1) / 2, CEED_EVAL_NONE));
27   CeedCall(CeedQFunctionAddOutput(qf, "dv", num_comp * dim, CEED_EVAL_GRAD));
28 
29   CeedCall(CeedQFunctionSetUserFlopsEstimate(qf, num_comp * 6));
30   return CEED_ERROR_SUCCESS;
31 }
32 
33 /**
34   @brief Register `CeedQFunction` for applying the 2D Poisson operator on a vector system with three components
35 **/
36 CEED_INTERN int CeedQFunctionRegister_Vector3Poisson2DApply(void) {
37   return CeedQFunctionRegister("Vector3Poisson2DApply", Vector3Poisson2DApply_loc, 1, Vector3Poisson2DApply, CeedQFunctionInit_Vector3Poisson2DApply);
38 }
39