xref: /libCEED/gallery/poisson-vector/ceed-vectorpoisson1dapply.c (revision 3d8e882215d238700cdceb37404f76ca7fa24eaa)
1*3d8e8822SJeremy L Thompson // Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors.
2*3d8e8822SJeremy L Thompson // All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
36a6224a1SJeremy L Thompson //
4*3d8e8822SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause
56a6224a1SJeremy L Thompson //
6*3d8e8822SJeremy 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>
116a6224a1SJeremy L Thompson #include "ceed-vectorpoisson1dapply.h"
126a6224a1SJeremy L Thompson 
136a6224a1SJeremy L Thompson /**
146a6224a1SJeremy L Thompson   @brief Set fields for Ceed QFunction applying the 1D Poisson operator
156a6224a1SJeremy L Thompson            on a vector system with three components
166a6224a1SJeremy L Thompson **/
17dfb517d7SJeremy L Thompson static int CeedQFunctionInit_Vector3Poisson1DApply(Ceed ceed,
186a6224a1SJeremy L Thompson     const char *requested,
196a6224a1SJeremy L Thompson     CeedQFunction qf) {
206a6224a1SJeremy L Thompson   int ierr;
216a6224a1SJeremy L Thompson 
226a6224a1SJeremy L Thompson   // Check QFunction name
23dfb517d7SJeremy L Thompson   const char *name = "Vector3Poisson1DApply";
246a6224a1SJeremy L Thompson   if (strcmp(name, requested))
256a6224a1SJeremy L Thompson     // LCOV_EXCL_START
266a6224a1SJeremy L Thompson     return CeedError(ceed, CEED_ERROR_UNSUPPORTED,
276a6224a1SJeremy L Thompson                      "QFunction '%s' does not match requested name: %s",
286a6224a1SJeremy L Thompson                      name, requested);
296a6224a1SJeremy L Thompson   // LCOV_EXCL_STOP
306a6224a1SJeremy L Thompson 
316a6224a1SJeremy L Thompson   // Add QFunction fields
326a6224a1SJeremy L Thompson   const CeedInt dim = 1, num_comp = 3;
336a6224a1SJeremy L Thompson   ierr = CeedQFunctionAddInput(qf, "du", num_comp*dim, CEED_EVAL_GRAD);
346a6224a1SJeremy L Thompson   CeedChk(ierr);
356a6224a1SJeremy L Thompson   ierr = CeedQFunctionAddInput(qf, "qdata", dim*(dim+1)/2, CEED_EVAL_NONE);
366a6224a1SJeremy L Thompson   CeedChk(ierr);
376a6224a1SJeremy L Thompson   ierr = CeedQFunctionAddOutput(qf, "dv", num_comp*dim, CEED_EVAL_GRAD);
386a6224a1SJeremy L Thompson   CeedChk(ierr);
396a6224a1SJeremy L Thompson 
406a6224a1SJeremy L Thompson   return CEED_ERROR_SUCCESS;
416a6224a1SJeremy L Thompson }
426a6224a1SJeremy L Thompson 
436a6224a1SJeremy L Thompson /**
446a6224a1SJeremy L Thompson   @brief Register Ceed QFunction for applying the 1D Poisson operator
456a6224a1SJeremy L Thompson            on a vector system with three components
466a6224a1SJeremy L Thompson **/
47dfb517d7SJeremy L Thompson CEED_INTERN int CeedQFunctionRegister_Vector3Poisson1DApply(void) {
48dfb517d7SJeremy L Thompson   return CeedQFunctionRegister("Vector3Poisson1DApply", Vector3Poisson1DApply_loc,
49dfb517d7SJeremy L Thompson                                1, Vector3Poisson1DApply,
50dfb517d7SJeremy L Thompson                                CeedQFunctionInit_Vector3Poisson1DApply);
516a6224a1SJeremy L Thompson }
52