xref: /libCEED/rust/libceed-sys/c-src/gallery/poisson/ceed-poisson2dbuild.c (revision 2b730f8b5a9c809740a0b3b302db43a719c636b1)
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/backend.h>
9 #include <ceed/ceed.h>
10 #include <ceed/jit-source/gallery/ceed-poisson2dbuild.h>
11 #include <string.h>
12 
13 /**
14   @brief Set fields for Ceed QFunction building the geometric data for the 2D
15            Poisson operator
16 **/
17 static int CeedQFunctionInit_Poisson2DBuild(Ceed ceed, const char *requested, CeedQFunction qf) {
18   // Check QFunction name
19   const char *name = "Poisson2DBuild";
20   if (strcmp(name, requested)) {
21     // LCOV_EXCL_START
22     return CeedError(ceed, CEED_ERROR_UNSUPPORTED, "QFunction '%s' does not match requested name: %s", name, requested);
23     // LCOV_EXCL_STOP
24   }
25 
26   // Add QFunction fields
27   const CeedInt dim = 2;
28   CeedCall(CeedQFunctionAddInput(qf, "dx", dim * dim, CEED_EVAL_GRAD));
29   CeedCall(CeedQFunctionAddInput(qf, "weights", 1, CEED_EVAL_WEIGHT));
30   CeedCall(CeedQFunctionAddOutput(qf, "qdata", dim * (dim + 1) / 2, CEED_EVAL_NONE));
31 
32   CeedCall(CeedQFunctionSetUserFlopsEstimate(qf, 17));
33 
34   return CEED_ERROR_SUCCESS;
35 }
36 
37 /**
38   @brief Register Ceed QFunction for building the geometric data for the 2D
39            Poisson operator
40 **/
41 CEED_INTERN int CeedQFunctionRegister_Poisson2DBuild(void) {
42   return CeedQFunctionRegister("Poisson2DBuild", Poisson2DBuild_loc, 1, Poisson2DBuild, CeedQFunctionInit_Poisson2DBuild);
43 }
44