xref: /libCEED/rust/libceed-sys/c-src/gallery/poisson/ceed-poisson2dbuild.c (revision 2b730f8b5a9c809740a0b3b302db43a719c636b1) !
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/backend.h>
9*2b730f8bSJeremy L Thompson #include <ceed/ceed.h>
10a0154adeSJed Brown #include <ceed/jit-source/gallery/ceed-poisson2dbuild.h>
11*2b730f8bSJeremy L Thompson #include <string.h>
126a6224a1SJeremy L Thompson 
136a6224a1SJeremy L Thompson /**
146a6224a1SJeremy L Thompson   @brief Set fields for Ceed QFunction building the geometric data for the 2D
156a6224a1SJeremy L Thompson            Poisson operator
166a6224a1SJeremy L Thompson **/
17*2b730f8bSJeremy L Thompson static int CeedQFunctionInit_Poisson2DBuild(Ceed ceed, const char *requested, CeedQFunction qf) {
186a6224a1SJeremy L Thompson   // Check QFunction name
196a6224a1SJeremy L Thompson   const char *name = "Poisson2DBuild";
20*2b730f8bSJeremy L Thompson   if (strcmp(name, requested)) {
216a6224a1SJeremy L Thompson     // LCOV_EXCL_START
22*2b730f8bSJeremy L Thompson     return CeedError(ceed, CEED_ERROR_UNSUPPORTED, "QFunction '%s' does not match requested name: %s", name, requested);
236a6224a1SJeremy L Thompson     // LCOV_EXCL_STOP
24*2b730f8bSJeremy L Thompson   }
256a6224a1SJeremy L Thompson 
266a6224a1SJeremy L Thompson   // Add QFunction fields
276a6224a1SJeremy L Thompson   const CeedInt dim = 2;
28*2b730f8bSJeremy L Thompson   CeedCall(CeedQFunctionAddInput(qf, "dx", dim * dim, CEED_EVAL_GRAD));
29*2b730f8bSJeremy L Thompson   CeedCall(CeedQFunctionAddInput(qf, "weights", 1, CEED_EVAL_WEIGHT));
30*2b730f8bSJeremy L Thompson   CeedCall(CeedQFunctionAddOutput(qf, "qdata", dim * (dim + 1) / 2, CEED_EVAL_NONE));
316a6224a1SJeremy L Thompson 
32*2b730f8bSJeremy L Thompson   CeedCall(CeedQFunctionSetUserFlopsEstimate(qf, 17));
336e15d496SJeremy L Thompson 
346a6224a1SJeremy L Thompson   return CEED_ERROR_SUCCESS;
356a6224a1SJeremy L Thompson }
366a6224a1SJeremy L Thompson 
376a6224a1SJeremy L Thompson /**
386a6224a1SJeremy L Thompson   @brief Register Ceed QFunction for building the geometric data for the 2D
396a6224a1SJeremy L Thompson            Poisson operator
406a6224a1SJeremy L Thompson **/
416a6224a1SJeremy L Thompson CEED_INTERN int CeedQFunctionRegister_Poisson2DBuild(void) {
42*2b730f8bSJeremy L Thompson   return CeedQFunctionRegister("Poisson2DBuild", Poisson2DBuild_loc, 1, Poisson2DBuild, CeedQFunctionInit_Poisson2DBuild);
436a6224a1SJeremy L Thompson }
44