xref: /libCEED/rust/libceed-sys/c-src/gallery/poisson/ceed-poisson1dbuild.c (revision 6a6224a1a47cd78a9f5d31ac282da39a8c250ecc)
1*6a6224a1SJeremy L Thompson // Copyright (c) 2017-2018, Lawrence Livermore National Security, LLC.
2*6a6224a1SJeremy L Thompson // Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707.
3*6a6224a1SJeremy L Thompson // All Rights reserved. See files LICENSE and NOTICE for details.
4*6a6224a1SJeremy L Thompson //
5*6a6224a1SJeremy L Thompson // This file is part of CEED, a collection of benchmarks, miniapps, software
6*6a6224a1SJeremy L Thompson // libraries and APIs for efficient high-order finite element and spectral
7*6a6224a1SJeremy L Thompson // element discretizations for exascale applications. For more information and
8*6a6224a1SJeremy L Thompson // source code availability see http://github.com/ceed.
9*6a6224a1SJeremy L Thompson //
10*6a6224a1SJeremy L Thompson // The CEED research is supported by the Exascale Computing Project 17-SC-20-SC,
11*6a6224a1SJeremy L Thompson // a collaborative effort of two U.S. Department of Energy organizations (Office
12*6a6224a1SJeremy L Thompson // of Science and the National Nuclear Security Administration) responsible for
13*6a6224a1SJeremy L Thompson // the planning and preparation of a capable exascale ecosystem, including
14*6a6224a1SJeremy L Thompson // software, applications, hardware, advanced system engineering and early
15*6a6224a1SJeremy L Thompson // testbed platforms, in support of the nation's exascale computing imperative.
16*6a6224a1SJeremy L Thompson 
17*6a6224a1SJeremy L Thompson #include <ceed/ceed.h>
18*6a6224a1SJeremy L Thompson #include <ceed/backend.h>
19*6a6224a1SJeremy L Thompson #include <string.h>
20*6a6224a1SJeremy L Thompson #include "ceed-poisson1dbuild.h"
21*6a6224a1SJeremy L Thompson 
22*6a6224a1SJeremy L Thompson /**
23*6a6224a1SJeremy L Thompson   @brief Set fields for Ceed QFunction building the geometric data for the 1D
24*6a6224a1SJeremy L Thompson            Poisson operator
25*6a6224a1SJeremy L Thompson **/
26*6a6224a1SJeremy L Thompson static int CeedQFunctionInit_Poisson1DBuild(Ceed ceed, const char *requested,
27*6a6224a1SJeremy L Thompson     CeedQFunction qf) {
28*6a6224a1SJeremy L Thompson   int ierr;
29*6a6224a1SJeremy L Thompson 
30*6a6224a1SJeremy L Thompson   // Check QFunction name
31*6a6224a1SJeremy L Thompson   const char *name = "Poisson1DBuild";
32*6a6224a1SJeremy L Thompson   if (strcmp(name, requested))
33*6a6224a1SJeremy L Thompson     // LCOV_EXCL_START
34*6a6224a1SJeremy L Thompson     return CeedError(ceed, CEED_ERROR_UNSUPPORTED,
35*6a6224a1SJeremy L Thompson                      "QFunction '%s' does not match requested name: %s",
36*6a6224a1SJeremy L Thompson                      name, requested);
37*6a6224a1SJeremy L Thompson   // LCOV_EXCL_STOP
38*6a6224a1SJeremy L Thompson 
39*6a6224a1SJeremy L Thompson   // Add QFunction fields
40*6a6224a1SJeremy L Thompson   const CeedInt dim = 1;
41*6a6224a1SJeremy L Thompson   ierr = CeedQFunctionAddInput(qf, "dx", dim*dim, CEED_EVAL_GRAD);
42*6a6224a1SJeremy L Thompson   CeedChk(ierr);
43*6a6224a1SJeremy L Thompson   ierr = CeedQFunctionAddInput(qf, "weights", 1, CEED_EVAL_WEIGHT);
44*6a6224a1SJeremy L Thompson   CeedChk(ierr);
45*6a6224a1SJeremy L Thompson   ierr = CeedQFunctionAddOutput(qf, "qdata", dim*(dim+1)/2, CEED_EVAL_NONE);
46*6a6224a1SJeremy L Thompson   CeedChk(ierr);
47*6a6224a1SJeremy L Thompson 
48*6a6224a1SJeremy L Thompson   return CEED_ERROR_SUCCESS;
49*6a6224a1SJeremy L Thompson }
50*6a6224a1SJeremy L Thompson 
51*6a6224a1SJeremy L Thompson /**
52*6a6224a1SJeremy L Thompson   @brief Register Ceed QFunction for building the geometric data for the 1D
53*6a6224a1SJeremy L Thompson            Poisson operator
54*6a6224a1SJeremy L Thompson **/
55*6a6224a1SJeremy L Thompson CEED_INTERN int CeedQFunctionRegister_Poisson1DBuild(void) {
56*6a6224a1SJeremy L Thompson   return CeedQFunctionRegister("Poisson1DBuild", Poisson1DBuild_loc, 1,
57*6a6224a1SJeremy L Thompson                                Poisson1DBuild, CeedQFunctionInit_Poisson1DBuild);
58*6a6224a1SJeremy L Thompson }
59