xref: /libCEED/rust/libceed-sys/c-src/gallery/poisson/ceed-poisson3dbuild.c (revision a0154adecfab8547cdc0febbbf40ac009dbe9d1d)
13d8e8822SJeremy L Thompson // Copyright (c) 2017-2022, 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 
86a6224a1SJeremy L Thompson #include <ceed/ceed.h>
96a6224a1SJeremy L Thompson #include <ceed/backend.h>
106a6224a1SJeremy L Thompson #include <string.h>
11*a0154adeSJed Brown #include <ceed/jit-source/gallery/ceed-poisson3dbuild.h>
126a6224a1SJeremy L Thompson 
136a6224a1SJeremy L Thompson /**
146a6224a1SJeremy L Thompson   @brief Set fields for Ceed QFunction building the geometric data for the 3D
156a6224a1SJeremy L Thompson            Poisson operator
166a6224a1SJeremy L Thompson **/
176a6224a1SJeremy L Thompson static int CeedQFunctionInit_Poisson3DBuild(Ceed ceed, const char *requested,
186a6224a1SJeremy L Thompson     CeedQFunction qf) {
196a6224a1SJeremy L Thompson   int ierr;
206a6224a1SJeremy L Thompson 
216a6224a1SJeremy L Thompson   // Check QFunction name
226a6224a1SJeremy L Thompson   const char *name = "Poisson3DBuild";
236a6224a1SJeremy L Thompson   if (strcmp(name, requested))
246a6224a1SJeremy L Thompson     // LCOV_EXCL_START
256a6224a1SJeremy L Thompson     return CeedError(ceed, CEED_ERROR_UNSUPPORTED,
266a6224a1SJeremy L Thompson                      "QFunction '%s' does not match requested name: %s",
276a6224a1SJeremy L Thompson                      name, requested);
286a6224a1SJeremy L Thompson   // LCOV_EXCL_STOP
296a6224a1SJeremy L Thompson 
306a6224a1SJeremy L Thompson   // Add QFunction fields
316a6224a1SJeremy L Thompson   const CeedInt dim = 3;
326a6224a1SJeremy L Thompson   ierr = CeedQFunctionAddInput(qf, "dx", dim*dim, CEED_EVAL_GRAD);
336a6224a1SJeremy L Thompson   CeedChk(ierr);
346a6224a1SJeremy L Thompson   ierr = CeedQFunctionAddInput(qf, "weights", 1, CEED_EVAL_WEIGHT);
356a6224a1SJeremy L Thompson   CeedChk(ierr);
366a6224a1SJeremy L Thompson   ierr = CeedQFunctionAddOutput(qf, "qdata", dim*(dim+1)/2, CEED_EVAL_NONE);
376a6224a1SJeremy L Thompson   CeedChk(ierr);
386a6224a1SJeremy L Thompson 
396e15d496SJeremy L Thompson   ierr = CeedQFunctionSetUserFlopsEstimate(qf, 69); CeedChk(ierr);
406e15d496SJeremy L Thompson 
416a6224a1SJeremy L Thompson   return CEED_ERROR_SUCCESS;
426a6224a1SJeremy L Thompson }
436a6224a1SJeremy L Thompson 
446a6224a1SJeremy L Thompson /**
456a6224a1SJeremy L Thompson   @brief Register Ceed QFunction for building the geometric data for the 3D
466a6224a1SJeremy L Thompson            Poisson operator
476a6224a1SJeremy L Thompson **/
486a6224a1SJeremy L Thompson CEED_INTERN int CeedQFunctionRegister_Poisson3DBuild(void) {
496a6224a1SJeremy L Thompson   return CeedQFunctionRegister("Poisson3DBuild", Poisson3DBuild_loc, 1,
506a6224a1SJeremy L Thompson                                Poisson3DBuild, CeedQFunctionInit_Poisson3DBuild);
516a6224a1SJeremy L Thompson }
52