xref: /libCEED/rust/libceed-sys/c-src/gallery/poisson-vector/ceed-vectorpoisson3dapply.c (revision 33490f6ef26c584470cb54133cdd71c442f1841b)
19ba83ac0SJeremy L Thompson // Copyright (c) 2017-2026, Lawrence Livermore National Security, LLC and other CEED contributors.
23d8e8822SJeremy L Thompson // All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
36a6224a1SJeremy L Thompson //
43d8e8822SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause
56a6224a1SJeremy L Thompson //
63d8e8822SJeremy L Thompson // This file is part of CEED:  http://github.com/ceed
76a6224a1SJeremy L Thompson 
849aac155SJeremy L Thompson #include <ceed.h>
96a6224a1SJeremy L Thompson #include <ceed/backend.h>
10a0154adeSJed Brown #include <ceed/jit-source/gallery/ceed-vectorpoisson3dapply.h>
112b730f8bSJeremy L Thompson #include <string.h>
126a6224a1SJeremy L Thompson 
136a6224a1SJeremy L Thompson /**
14ca94c3ddSJeremy L Thompson   @brief Set fields for `CeedQFunction` applying the 3D Poisson operator on a vector system with three components
156a6224a1SJeremy L Thompson **/
CeedQFunctionInit_Vector3Poisson3DApply(Ceed ceed,const char * requested,CeedQFunction qf)162b730f8bSJeremy L Thompson static int CeedQFunctionInit_Vector3Poisson3DApply(Ceed ceed, const char *requested, CeedQFunction qf) {
176a6224a1SJeremy L Thompson   // Check QFunction name
18dfb517d7SJeremy L Thompson   const char *name = "Vector3Poisson3DApply";
19*6261a418SJeremy L Thompson 
206574a04fSJeremy L Thompson   CeedCheck(!strcmp(name, requested), ceed, CEED_ERROR_UNSUPPORTED, "QFunction '%s' does not match requested name: %s", name, requested);
216a6224a1SJeremy L Thompson 
226a6224a1SJeremy L Thompson   // Add QFunction fields
236a6224a1SJeremy L Thompson   const CeedInt dim = 3, num_comp = 3;
24*6261a418SJeremy L Thompson 
252b730f8bSJeremy L Thompson   CeedCall(CeedQFunctionAddInput(qf, "du", num_comp * dim, CEED_EVAL_GRAD));
262b730f8bSJeremy L Thompson   CeedCall(CeedQFunctionAddInput(qf, "qdata", dim * (dim + 1) / 2, CEED_EVAL_NONE));
272b730f8bSJeremy L Thompson   CeedCall(CeedQFunctionAddOutput(qf, "dv", num_comp * dim, CEED_EVAL_GRAD));
286a6224a1SJeremy L Thompson 
292b730f8bSJeremy L Thompson   CeedCall(CeedQFunctionSetUserFlopsEstimate(qf, num_comp * 15));
306a6224a1SJeremy L Thompson   return CEED_ERROR_SUCCESS;
316a6224a1SJeremy L Thompson }
326a6224a1SJeremy L Thompson 
336a6224a1SJeremy L Thompson /**
34ca94c3ddSJeremy L Thompson   @brief Register `CeedQFunction` for applying the 3D Poisson operator on a vector system with three components
356a6224a1SJeremy L Thompson **/
CeedQFunctionRegister_Vector3Poisson3DApply(void)36dfb517d7SJeremy L Thompson CEED_INTERN int CeedQFunctionRegister_Vector3Poisson3DApply(void) {
372b730f8bSJeremy L Thompson   return CeedQFunctionRegister("Vector3Poisson3DApply", Vector3Poisson3DApply_loc, 1, Vector3Poisson3DApply, CeedQFunctionInit_Vector3Poisson3DApply);
386a6224a1SJeremy L Thompson }
39