xref: /libCEED/rust/libceed-sys/c-src/gallery/identity/ceed-identity.c (revision f0d2f928220c74787e2a8b65d655802dcef082ab)
10219ea01SJeremy L Thompson // Copyright (c) 2017-2018, Lawrence Livermore National Security, LLC.
20219ea01SJeremy L Thompson // Produced at the Lawrence Livermore National Laboratory. LLNL-CODE-734707.
30219ea01SJeremy L Thompson // All Rights reserved. See files LICENSE and NOTICE for details.
40219ea01SJeremy L Thompson //
50219ea01SJeremy L Thompson // This file is part of CEED, a collection of benchmarks, miniapps, software
60219ea01SJeremy L Thompson // libraries and APIs for efficient high-order finite element and spectral
70219ea01SJeremy L Thompson // element discretizations for exascale applications. For more information and
80219ea01SJeremy L Thompson // source code availability see http://github.com/ceed.
90219ea01SJeremy L Thompson //
100219ea01SJeremy L Thompson // The CEED research is supported by the Exascale Computing Project 17-SC-20-SC,
110219ea01SJeremy L Thompson // a collaborative effort of two U.S. Department of Energy organizations (Office
120219ea01SJeremy L Thompson // of Science and the National Nuclear Security Administration) responsible for
130219ea01SJeremy L Thompson // the planning and preparation of a capable exascale ecosystem, including
140219ea01SJeremy L Thompson // software, applications, hardware, advanced system engineering and early
150219ea01SJeremy L Thompson // testbed platforms, in support of the nation's exascale computing imperative.
160219ea01SJeremy L Thompson 
170219ea01SJeremy L Thompson #include <string.h>
180219ea01SJeremy L Thompson #include "ceed-backend.h"
190219ea01SJeremy L Thompson #include "ceed-identity.h"
200219ea01SJeremy L Thompson 
210219ea01SJeremy L Thompson /**
220219ea01SJeremy L Thompson   @brief Set fields identity QFunction that copies inputs directly into outputs
230219ea01SJeremy L Thompson **/
240219ea01SJeremy L Thompson static int CeedQFunctionInit_Identity(Ceed ceed, const char *requested,
250219ea01SJeremy L Thompson                                       CeedQFunction qf) {
260219ea01SJeremy L Thompson   int ierr;
270219ea01SJeremy L Thompson 
280219ea01SJeremy L Thompson   // Check QFunction name
290219ea01SJeremy L Thompson   const char *name = "Identity";
300219ea01SJeremy L Thompson   if (strcmp(name, requested))
31*f0d2f928Sjeremylt     // LCOV_EXCL_START
320219ea01SJeremy L Thompson     return CeedError(ceed, 1, "QFunction '%s' does not match requested name: %s",
330219ea01SJeremy L Thompson                      name, requested);
34*f0d2f928Sjeremylt   // LCOV_EXCL_STOP
350219ea01SJeremy L Thompson 
360219ea01SJeremy L Thompson   // Add QFunction fields
370219ea01SJeremy L Thompson   ierr = CeedQFunctionAddInput(qf, "input", 1, CEED_EVAL_INTERP); CeedChk(ierr);
380219ea01SJeremy L Thompson   ierr = CeedQFunctionAddOutput(qf, "output", 1, CEED_EVAL_INTERP);
390219ea01SJeremy L Thompson   CeedChk(ierr);
400219ea01SJeremy L Thompson 
410219ea01SJeremy L Thompson   return 0;
420219ea01SJeremy L Thompson }
430219ea01SJeremy L Thompson 
440219ea01SJeremy L Thompson /**
450219ea01SJeremy L Thompson   @brief Register identity QFunction that copies inputs directly into outputs
460219ea01SJeremy L Thompson **/
470219ea01SJeremy L Thompson __attribute__((constructor))
480219ea01SJeremy L Thompson static void Register(void) {
490219ea01SJeremy L Thompson   CeedQFunctionRegister("Identity", Identity_loc, 1, Identity,
500219ea01SJeremy L Thompson                         CeedQFunctionInit_Identity);
510219ea01SJeremy L Thompson }
52