xref: /libCEED/gallery/mass/ceed-mass3dbuild.c (revision 356036fa84f714fa73ef64c9a80ce2028dde816f)
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-mass3dbuild.h>
11 #include <string.h>
12 
13 /**
14   @brief Set fields for Ceed QFunction building the geometric data for the 3D mass matrix
15 **/
16 static int CeedQFunctionInit_Mass3DBuild(Ceed ceed, const char *requested, CeedQFunction qf) {
17   // Check QFunction name
18   const char *name = "Mass3DBuild";
19   CeedCheck(!strcmp(name, requested), ceed, CEED_ERROR_UNSUPPORTED, "QFunction '%s' does not match requested name: %s", name, requested);
20 
21   // Add QFunction fields
22   const CeedInt dim = 3;
23   CeedCall(CeedQFunctionAddInput(qf, "dx", dim * dim, CEED_EVAL_GRAD));
24   CeedCall(CeedQFunctionAddInput(qf, "weights", 1, CEED_EVAL_WEIGHT));
25   CeedCall(CeedQFunctionAddOutput(qf, "qdata", 1, CEED_EVAL_NONE));
26 
27   CeedCall(CeedQFunctionSetUserFlopsEstimate(qf, 15));
28 
29   return CEED_ERROR_SUCCESS;
30 }
31 
32 /**
33   @brief Register Ceed QFunction for building the geometric data for the 3D mass matrix
34 **/
35 CEED_INTERN int CeedQFunctionRegister_Mass3DBuild(void) {
36   return CeedQFunctionRegister("Mass3DBuild", Mass3DBuild_loc, 1, Mass3DBuild, CeedQFunctionInit_Mass3DBuild);
37 }
38