xref: /libCEED/gallery/mass/ceed-massapply.c (revision b2e3f8ecbfa285d0f4ffde9b24c57cc13f0319fb)
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.h>
9 #include <ceed/backend.h>
10 #include <ceed/jit-source/gallery/ceed-massapply.h>
11 #include <string.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, CeedQFunction qf) {
17   // Check QFunction name
18   const char *name = "MassApply";
19   if (strcmp(name, requested)) {
20     // LCOV_EXCL_START
21     return CeedError(ceed, CEED_ERROR_UNSUPPORTED, "QFunction '%s' does not match requested name: %s", name, requested);
22     // LCOV_EXCL_STOP
23   }
24 
25   // Add QFunction fields
26   CeedCall(CeedQFunctionAddInput(qf, "u", 1, CEED_EVAL_INTERP));
27   CeedCall(CeedQFunctionAddInput(qf, "qdata", 1, CEED_EVAL_NONE));
28   CeedCall(CeedQFunctionAddOutput(qf, "v", 1, CEED_EVAL_INTERP));
29 
30   CeedCall(CeedQFunctionSetUserFlopsEstimate(qf, 1));
31 
32   return CEED_ERROR_SUCCESS;
33 }
34 
35 /**
36   @brief Register Ceed QFunction for applying the mass matrix
37 **/
38 CEED_INTERN int CeedQFunctionRegister_MassApply(void) {
39   return CeedQFunctionRegister("MassApply", MassApply_loc, 1, MassApply, CeedQFunctionInit_MassApply);
40 }
41