xref: /libCEED/gallery/mass/ceed-massapply.c (revision 6eb0d8b4aff72517bac7a1ace48e04610a8fe084)
1 // Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors.
2 // All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
3 //
4 // SPDX-License-Identifier: BSD-2-Clause
5 //
6 // This file is part of CEED:  http://github.com/ceed
7 
8 #include <ceed/ceed.h>
9 #include <ceed/backend.h>
10 #include <string.h>
11 #include <ceed-jit-source/gallery/ceed-massapply.h>
12 
13 /**
14   @brief Set fields for Ceed QFunction for applying the mass matrix
15 **/
16 static int CeedQFunctionInit_MassApply(Ceed ceed, const char *requested,
17                                        CeedQFunction qf) {
18   int ierr;
19 
20   // Check QFunction name
21   const char *name = "MassApply";
22   if (strcmp(name, requested))
23     // LCOV_EXCL_START
24     return CeedError(ceed, CEED_ERROR_UNSUPPORTED,
25                      "QFunction '%s' does not match requested name: %s",
26                      name, requested);
27   // LCOV_EXCL_STOP
28 
29   // Add QFunction fields
30   ierr = CeedQFunctionAddInput(qf, "u", 1, CEED_EVAL_INTERP); CeedChk(ierr);
31   ierr = CeedQFunctionAddInput(qf, "qdata", 1, CEED_EVAL_NONE); CeedChk(ierr);
32   ierr = CeedQFunctionAddOutput(qf, "v", 1, CEED_EVAL_INTERP); CeedChk(ierr);
33 
34   ierr = CeedQFunctionSetUserFlopsEstimate(qf, 1); CeedChk(ierr);
35 
36   return CEED_ERROR_SUCCESS;
37 }
38 
39 /**
40   @brief Register Ceed QFunction for applying the mass matrix
41 **/
42 CEED_INTERN int CeedQFunctionRegister_MassApply(void) {
43   return CeedQFunctionRegister("MassApply", MassApply_loc, 1, MassApply,
44                                CeedQFunctionInit_MassApply);
45 }
46