xref: /libCEED/gallery/mass-vector/ceed-vectormassapply.c (revision a0154adecfab8547cdc0febbbf40ac009dbe9d1d)
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-vectormassapply.h>
12 
13 /**
14   @brief Set fields for Ceed QFunction for applying the mass matrix
15            on a vector system with three components
16 **/
17 static int CeedQFunctionInit_Vector3MassApply(Ceed ceed, const char *requested,
18     CeedQFunction qf) {
19   int ierr;
20 
21   // Check QFunction name
22   const char *name = "Vector3MassApply";
23   if (strcmp(name, requested))
24     // LCOV_EXCL_START
25     return CeedError(ceed, CEED_ERROR_UNSUPPORTED,
26                      "QFunction '%s' does not match requested name: %s",
27                      name, requested);
28   // LCOV_EXCL_STOP
29 
30   // Add QFunction fields
31   const CeedInt num_comp = 3;
32   ierr = CeedQFunctionAddInput(qf, "u", num_comp, CEED_EVAL_INTERP);
33   CeedChk(ierr);
34   ierr = CeedQFunctionAddInput(qf, "qdata", 1, CEED_EVAL_NONE); CeedChk(ierr);
35   ierr = CeedQFunctionAddOutput(qf, "v", num_comp, CEED_EVAL_INTERP);
36   CeedChk(ierr);
37 
38   ierr = CeedQFunctionSetUserFlopsEstimate(qf, num_comp); CeedChk(ierr);
39 
40   return CEED_ERROR_SUCCESS;
41 }
42 
43 /**
44   @brief Register Ceed QFunction for applying the mass matrix on a vector system
45            with three components
46 **/
47 CEED_INTERN int CeedQFunctionRegister_Vector3MassApply(void) {
48   return CeedQFunctionRegister("Vector3MassApply", Vector3MassApply_loc, 1,
49                                Vector3MassApply, CeedQFunctionInit_Vector3MassApply);
50 }
51