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