xref: /libCEED/rust/libceed-sys/c-src/gallery/poisson/ceed-poisson3dapply.c (revision a49029fe2b683c1941ca0e371db6091ee3c727b1)
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-poisson3dapply.h"
12 
13 /**
14   @brief Set fields for Ceed QFunction applying the 3D Poisson operator
15 **/
16 static int CeedQFunctionInit_Poisson3DApply(Ceed ceed, const char *requested,
17     CeedQFunction qf) {
18   int ierr;
19 
20   // Check QFunction name
21   const char *name = "Poisson3DApply";
22   if (strcmp(name, requested))
23     // LCOV_EXCL_START
24     return CeedError(ceed, CEED_ERROR_UNSUPPORTED,
25                      "QFunction '%s' does not match requested name: %s",
26                      name, requested);
27   // LCOV_EXCL_STOP
28 
29   // Add QFunction fields
30   const CeedInt dim = 3;
31   ierr = CeedQFunctionAddInput(qf, "du", dim, CEED_EVAL_GRAD); CeedChk(ierr);
32   ierr = CeedQFunctionAddInput(qf, "qdata", dim*(dim+1)/2, CEED_EVAL_NONE);
33   CeedChk(ierr);
34   ierr = CeedQFunctionAddOutput(qf, "dv", dim, CEED_EVAL_GRAD); CeedChk(ierr);
35 
36   ierr = CeedQFunctionSetUserFlopsEstimate(qf, 15); CeedChk(ierr);
37 
38   return CEED_ERROR_SUCCESS;
39 }
40 
41 /**
42   @brief Register Ceed QFunction for applying the 3D Poisson operator
43 **/
44 CEED_INTERN int CeedQFunctionRegister_Poisson3DApply(void) {
45   return CeedQFunctionRegister("Poisson3DApply", Poisson3DApply_loc, 1,
46                                Poisson3DApply, CeedQFunctionInit_Poisson3DApply);
47 }
48