xref: /libCEED/gallery/mass/ceed-massapply.c (revision 2459f3f1cd4d7d2e210e1c26d669bd2fde41a0b6)
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-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   return CEED_ERROR_SUCCESS;
35 }
36 
37 /**
38   @brief Register Ceed QFunction for applying the mass matrix
39 **/
40 CEED_INTERN int CeedQFunctionRegister_MassApply(void) {
41   return CeedQFunctionRegister("MassApply", MassApply_loc, 1, MassApply,
42                                CeedQFunctionInit_MassApply);
43 }
44