xref: /libCEED/rust/libceed-sys/c-src/gallery/poisson-vector/ceed-vectorpoisson2dapply.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-vectorpoisson2dapply.h"
21*6a6224a1SJeremy L Thompson 
22*6a6224a1SJeremy L Thompson /**
23*6a6224a1SJeremy L Thompson   @brief Set fields for Ceed QFunction applying the 2D Poisson operator
24*6a6224a1SJeremy L Thompson            on a vector system with three components
25*6a6224a1SJeremy L Thompson **/
26*6a6224a1SJeremy L Thompson static int CeedQFunctionInit_VectorPoisson2DApply(Ceed ceed,
27*6a6224a1SJeremy L Thompson     const char *requested,
28*6a6224a1SJeremy L Thompson     CeedQFunction qf) {
29*6a6224a1SJeremy L Thompson   int ierr;
30*6a6224a1SJeremy L Thompson 
31*6a6224a1SJeremy L Thompson   // Check QFunction name
32*6a6224a1SJeremy L Thompson   const char *name = "VectorPoisson2DApply";
33*6a6224a1SJeremy L Thompson   if (strcmp(name, requested))
34*6a6224a1SJeremy L Thompson     // LCOV_EXCL_START
35*6a6224a1SJeremy L Thompson     return CeedError(ceed, CEED_ERROR_UNSUPPORTED,
36*6a6224a1SJeremy L Thompson                      "QFunction '%s' does not match requested name: %s",
37*6a6224a1SJeremy L Thompson                      name, requested);
38*6a6224a1SJeremy L Thompson   // LCOV_EXCL_STOP
39*6a6224a1SJeremy L Thompson 
40*6a6224a1SJeremy L Thompson   // Add QFunction fields
41*6a6224a1SJeremy L Thompson   const CeedInt dim = 2, num_comp = 3;
42*6a6224a1SJeremy L Thompson   ierr = CeedQFunctionAddInput(qf, "du", num_comp*dim, CEED_EVAL_GRAD);
43*6a6224a1SJeremy L Thompson   CeedChk(ierr);
44*6a6224a1SJeremy L Thompson   ierr = CeedQFunctionAddInput(qf, "qdata", dim*(dim+1)/2, CEED_EVAL_NONE);
45*6a6224a1SJeremy L Thompson   CeedChk(ierr);
46*6a6224a1SJeremy L Thompson   ierr = CeedQFunctionAddOutput(qf, "dv", num_comp*dim, CEED_EVAL_GRAD);
47*6a6224a1SJeremy L Thompson   CeedChk(ierr);
48*6a6224a1SJeremy L Thompson 
49*6a6224a1SJeremy L Thompson   return CEED_ERROR_SUCCESS;
50*6a6224a1SJeremy L Thompson }
51*6a6224a1SJeremy L Thompson 
52*6a6224a1SJeremy L Thompson /**
53*6a6224a1SJeremy L Thompson   @brief Register Ceed QFunction for applying the 2D Poisson operator
54*6a6224a1SJeremy L Thompson            on a vector system with three components
55*6a6224a1SJeremy L Thompson **/
56*6a6224a1SJeremy L Thompson CEED_INTERN int CeedQFunctionRegister_VectorPoisson2DApply(void) {
57*6a6224a1SJeremy L Thompson   return CeedQFunctionRegister("VectorPoisson2DApply", VectorPoisson2DApply_loc,
58*6a6224a1SJeremy L Thompson                                1, VectorPoisson2DApply,
59*6a6224a1SJeremy L Thompson                                CeedQFunctionInit_VectorPoisson2DApply);
60*6a6224a1SJeremy L Thompson }
61