xref: /libCEED/gallery/mass/ceed-mass3dbuild.c (revision a49029fe2b683c1941ca0e371db6091ee3c727b1)
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-mass3dbuild.h"
12 
13 /**
14   @brief Set fields for Ceed QFunction building the geometric data for the 3D
15            mass matrix
16 **/
17 static int CeedQFunctionInit_Mass3DBuild(Ceed ceed, const char *requested,
18     CeedQFunction qf) {
19   int ierr;
20 
21   // Check QFunction name
22   const char *name = "Mass3DBuild";
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 dim = 3;
32   ierr = CeedQFunctionAddInput(qf, "dx", dim*dim, CEED_EVAL_GRAD);
33   CeedChk(ierr);
34   ierr = CeedQFunctionAddInput(qf, "weights", 1, CEED_EVAL_WEIGHT);
35   CeedChk(ierr);
36   ierr = CeedQFunctionAddOutput(qf, "qdata", 1, CEED_EVAL_NONE); CeedChk(ierr);
37 
38   ierr = CeedQFunctionSetUserFlopsEstimate(qf, 15); CeedChk(ierr);
39 
40   return CEED_ERROR_SUCCESS;
41 }
42 
43 /**
44   @brief Register Ceed QFunction for building the geometric data for the 3D mass
45            matrix
46 **/
47 CEED_INTERN int CeedQFunctionRegister_Mass3DBuild(void) {
48   return CeedQFunctionRegister("Mass3DBuild", Mass3DBuild_loc, 1, Mass3DBuild,
49                                CeedQFunctionInit_Mass3DBuild);
50 }
51