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