xref: /libCEED/rust/libceed-sys/c-src/gallery/mass-vector/ceed-vectormassapply.c (revision dfb517d7db93183aa0109a86f5ac340e64a692d6)
16a6224a1SJeremy L Thompson // Copyright (c) 2017-2018, Lawrence Livermore National Security, LLC.
26a6224a1SJeremy L Thompson // Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707.
36a6224a1SJeremy L Thompson // All Rights reserved. See files LICENSE and NOTICE for details.
46a6224a1SJeremy L Thompson //
56a6224a1SJeremy L Thompson // This file is part of CEED, a collection of benchmarks, miniapps, software
66a6224a1SJeremy L Thompson // libraries and APIs for efficient high-order finite element and spectral
76a6224a1SJeremy L Thompson // element discretizations for exascale applications. For more information and
86a6224a1SJeremy L Thompson // source code availability see http://github.com/ceed.
96a6224a1SJeremy L Thompson //
106a6224a1SJeremy L Thompson // The CEED research is supported by the Exascale Computing Project 17-SC-20-SC,
116a6224a1SJeremy L Thompson // a collaborative effort of two U.S. Department of Energy organizations (Office
126a6224a1SJeremy L Thompson // of Science and the National Nuclear Security Administration) responsible for
136a6224a1SJeremy L Thompson // the planning and preparation of a capable exascale ecosystem, including
146a6224a1SJeremy L Thompson // software, applications, hardware, advanced system engineering and early
156a6224a1SJeremy L Thompson // testbed platforms, in support of the nation's exascale computing imperative.
166a6224a1SJeremy L Thompson 
176a6224a1SJeremy L Thompson #include <ceed/ceed.h>
186a6224a1SJeremy L Thompson #include <ceed/backend.h>
196a6224a1SJeremy L Thompson #include <string.h>
206a6224a1SJeremy L Thompson #include "ceed-vectormassapply.h"
216a6224a1SJeremy L Thompson 
226a6224a1SJeremy L Thompson /**
236a6224a1SJeremy L Thompson   @brief Set fields for Ceed QFunction for applying the mass matrix
246a6224a1SJeremy L Thompson            on a vector system with three components
256a6224a1SJeremy L Thompson **/
26*dfb517d7SJeremy L Thompson static int CeedQFunctionInit_Vector3MassApply(Ceed ceed, const char *requested,
276a6224a1SJeremy L Thompson     CeedQFunction qf) {
286a6224a1SJeremy L Thompson   int ierr;
296a6224a1SJeremy L Thompson 
306a6224a1SJeremy L Thompson   // Check QFunction name
31*dfb517d7SJeremy L Thompson   const char *name = "Vector3MassApply";
326a6224a1SJeremy L Thompson   if (strcmp(name, requested))
336a6224a1SJeremy L Thompson     // LCOV_EXCL_START
346a6224a1SJeremy L Thompson     return CeedError(ceed, CEED_ERROR_UNSUPPORTED,
356a6224a1SJeremy L Thompson                      "QFunction '%s' does not match requested name: %s",
366a6224a1SJeremy L Thompson                      name, requested);
376a6224a1SJeremy L Thompson   // LCOV_EXCL_STOP
386a6224a1SJeremy L Thompson 
396a6224a1SJeremy L Thompson   // Add QFunction fields
406a6224a1SJeremy L Thompson   const CeedInt num_comp = 3;
416a6224a1SJeremy L Thompson   ierr = CeedQFunctionAddInput(qf, "u", num_comp, CEED_EVAL_INTERP);
426a6224a1SJeremy L Thompson   CeedChk(ierr);
436a6224a1SJeremy L Thompson   ierr = CeedQFunctionAddInput(qf, "qdata", 1, CEED_EVAL_NONE); CeedChk(ierr);
446a6224a1SJeremy L Thompson   ierr = CeedQFunctionAddOutput(qf, "v", num_comp, CEED_EVAL_INTERP);
456a6224a1SJeremy L Thompson   CeedChk(ierr);
466a6224a1SJeremy L Thompson 
476a6224a1SJeremy L Thompson   return CEED_ERROR_SUCCESS;
486a6224a1SJeremy L Thompson }
496a6224a1SJeremy L Thompson 
506a6224a1SJeremy L Thompson /**
516a6224a1SJeremy L Thompson   @brief Register Ceed QFunction for applying the mass matrix on a vector system
526a6224a1SJeremy L Thompson            with three components
536a6224a1SJeremy L Thompson **/
54*dfb517d7SJeremy L Thompson CEED_INTERN int CeedQFunctionRegister_Vector3MassApply(void) {
55*dfb517d7SJeremy L Thompson   return CeedQFunctionRegister("Vector3MassApply", Vector3MassApply_loc, 1,
56*dfb517d7SJeremy L Thompson                                Vector3MassApply, CeedQFunctionInit_Vector3MassApply);
576a6224a1SJeremy L Thompson }
58