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