xref: /libCEED/rust/libceed-sys/c-src/gallery/identity/ceed-identity.c (revision 0219ea01e2c00bd70a330a05b50ef0218d6ddcb0)
1*0219ea01SJeremy L Thompson // Copyright (c) 2017-2018, Lawrence Livermore National Security, LLC.
2*0219ea01SJeremy L Thompson // Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707.
3*0219ea01SJeremy L Thompson // All Rights reserved. See files LICENSE and NOTICE for details.
4*0219ea01SJeremy L Thompson //
5*0219ea01SJeremy L Thompson // This file is part of CEED, a collection of benchmarks, miniapps, software
6*0219ea01SJeremy L Thompson // libraries and APIs for efficient high-order finite element and spectral
7*0219ea01SJeremy L Thompson // element discretizations for exascale applications. For more information and
8*0219ea01SJeremy L Thompson // source code availability see http://github.com/ceed.
9*0219ea01SJeremy L Thompson //
10*0219ea01SJeremy L Thompson // The CEED research is supported by the Exascale Computing Project 17-SC-20-SC,
11*0219ea01SJeremy L Thompson // a collaborative effort of two U.S. Department of Energy organizations (Office
12*0219ea01SJeremy L Thompson // of Science and the National Nuclear Security Administration) responsible for
13*0219ea01SJeremy L Thompson // the planning and preparation of a capable exascale ecosystem, including
14*0219ea01SJeremy L Thompson // software, applications, hardware, advanced system engineering and early
15*0219ea01SJeremy L Thompson // testbed platforms, in support of the nation's exascale computing imperative.
16*0219ea01SJeremy L Thompson 
17*0219ea01SJeremy L Thompson #include <string.h>
18*0219ea01SJeremy L Thompson #include "ceed-backend.h"
19*0219ea01SJeremy L Thompson #include "ceed-identity.h"
20*0219ea01SJeremy L Thompson 
21*0219ea01SJeremy L Thompson /**
22*0219ea01SJeremy L Thompson   @brief Set fields identity QFunction that copies inputs directly into outputs
23*0219ea01SJeremy L Thompson **/
24*0219ea01SJeremy L Thompson static int CeedQFunctionInit_Identity(Ceed ceed, const char *requested,
25*0219ea01SJeremy L Thompson     CeedQFunction qf) {
26*0219ea01SJeremy L Thompson   int ierr;
27*0219ea01SJeremy L Thompson 
28*0219ea01SJeremy L Thompson   // Check QFunction name
29*0219ea01SJeremy L Thompson   const char *name = "Identity";
30*0219ea01SJeremy L Thompson   if (strcmp(name, requested))
31*0219ea01SJeremy L Thompson     return CeedError(ceed, 1, "QFunction '%s' does not match requested name: %s",
32*0219ea01SJeremy L Thompson                      name, requested);
33*0219ea01SJeremy L Thompson 
34*0219ea01SJeremy L Thompson   // Add QFunction fields
35*0219ea01SJeremy L Thompson   ierr = CeedQFunctionAddInput(qf, "input", 1, CEED_EVAL_INTERP); CeedChk(ierr);
36*0219ea01SJeremy L Thompson   ierr = CeedQFunctionAddOutput(qf, "output", 1, CEED_EVAL_INTERP);
37*0219ea01SJeremy L Thompson   CeedChk(ierr);
38*0219ea01SJeremy L Thompson 
39*0219ea01SJeremy L Thompson   return 0;
40*0219ea01SJeremy L Thompson }
41*0219ea01SJeremy L Thompson 
42*0219ea01SJeremy L Thompson /**
43*0219ea01SJeremy L Thompson   @brief Register identity QFunction that copies inputs directly into outputs
44*0219ea01SJeremy L Thompson **/
45*0219ea01SJeremy L Thompson __attribute__((constructor))
46*0219ea01SJeremy L Thompson static void Register(void) {
47*0219ea01SJeremy L Thompson   CeedQFunctionRegister("Identity", Identity_loc, 1, Identity,
48*0219ea01SJeremy L Thompson                         CeedQFunctionInit_Identity);
49*0219ea01SJeremy L Thompson }
50