xref: /libCEED/gallery/mass/ceed-mass2dbuild.c (revision cdf95791513f7c35170bef3ba2e19f272fe04533)
1 // Copyright (c) 2017-2018, Lawrence Livermore National Security, LLC.
2 // Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707.
3 // All Rights reserved. See files LICENSE and NOTICE for details.
4 //
5 // This file is part of CEED, a collection of benchmarks, miniapps, software
6 // libraries and APIs for efficient high-order finite element and spectral
7 // element discretizations for exascale applications. For more information and
8 // source code availability see http://github.com/ceed.
9 //
10 // The CEED research is supported by the Exascale Computing Project 17-SC-20-SC,
11 // a collaborative effort of two U.S. Department of Energy organizations (Office
12 // of Science and the National Nuclear Security Administration) responsible for
13 // the planning and preparation of a capable exascale ecosystem, including
14 // software, applications, hardware, advanced system engineering and early
15 // testbed platforms, in support of the nation's exascale computing imperative.
16 
17 #include <ceed/ceed.h>
18 #include <ceed/backend.h>
19 #include <string.h>
20 #include "ceed-mass2dbuild.h"
21 
22 /**
23   @brief Set fields for Ceed QFunction building the geometric data for the 2D
24            mass matrix
25 **/
26 static int CeedQFunctionInit_Mass2DBuild(Ceed ceed, const char *requested,
27     CeedQFunction qf) {
28   int ierr;
29 
30   // Check QFunction name
31   const char *name = "Mass2DBuild";
32   if (strcmp(name, requested))
33     // LCOV_EXCL_START
34     return CeedError(ceed, CEED_ERROR_UNSUPPORTED,
35                      "QFunction '%s' does not match requested name: %s",
36                      name, requested);
37   // LCOV_EXCL_STOP
38 
39   // Add QFunction fields
40   const CeedInt dim = 2;
41   ierr = CeedQFunctionAddInput(qf, "dx", dim*dim, CEED_EVAL_GRAD);
42   CeedChk(ierr);
43   ierr = CeedQFunctionAddInput(qf, "weights", 1, CEED_EVAL_WEIGHT);
44   CeedChk(ierr);
45   ierr = CeedQFunctionAddOutput(qf, "qdata", 1, CEED_EVAL_NONE); CeedChk(ierr);
46 
47   return CEED_ERROR_SUCCESS;
48 }
49 
50 /**
51   @brief Register Ceed QFunction for building the geometric data for the 2D mass
52            matrix
53 **/
54 CEED_INTERN int CeedQFunctionRegister_Mass2DBuild(void) {
55   return CeedQFunctionRegister("Mass2DBuild", Mass2DBuild_loc, 1, Mass2DBuild,
56                                CeedQFunctionInit_Mass2DBuild);
57 }
58