xref: /libCEED/rust/libceed-sys/c-src/gallery/identity/ceed-identity-to-scalar.c (revision 33490f6ef26c584470cb54133cdd71c442f1841b)
10b6847a6SJeremy L Thompson // Copyright (c) 2017-2026, Lawrence Livermore National Security, LLC and other CEED contributors.
20b6847a6SJeremy L Thompson // All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
30b6847a6SJeremy L Thompson //
40b6847a6SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause
50b6847a6SJeremy L Thompson //
60b6847a6SJeremy L Thompson // This file is part of CEED:  http://github.com/ceed
70b6847a6SJeremy L Thompson 
80b6847a6SJeremy L Thompson #include <ceed.h>
90b6847a6SJeremy L Thompson #include <ceed/backend.h>
100b6847a6SJeremy L Thompson #include <ceed/jit-source/gallery/ceed-identity-to-scalar.h>
110b6847a6SJeremy L Thompson #include <stddef.h>
120b6847a6SJeremy L Thompson #include <string.h>
130b6847a6SJeremy L Thompson 
140b6847a6SJeremy L Thompson /**
150b6847a6SJeremy L Thompson   @brief Set fields identity `CeedQFunction` that copies first input component directly into output
160b6847a6SJeremy L Thompson **/
CeedQFunctionInit_IdentityScalar(Ceed ceed,const char * requested,CeedQFunction qf)170b6847a6SJeremy L Thompson static int CeedQFunctionInit_IdentityScalar(Ceed ceed, const char *requested, CeedQFunction qf) {
180b6847a6SJeremy L Thompson   // Check QFunction name
190b6847a6SJeremy L Thompson   const char *name = "Identity to scalar";
20*6261a418SJeremy L Thompson 
210b6847a6SJeremy L Thompson   CeedCheck(!strcmp(name, requested), ceed, CEED_ERROR_UNSUPPORTED, "QFunction '%s' does not match requested name: %s", name, requested);
220b6847a6SJeremy L Thompson 
230b6847a6SJeremy L Thompson   // QFunction fields 'input' and 'output' with requested emodes added by the library rather than being added here
240b6847a6SJeremy L Thompson 
250b6847a6SJeremy L Thompson   CeedCall(CeedQFunctionSetUserFlopsEstimate(qf, 0));
260b6847a6SJeremy L Thompson   return CEED_ERROR_SUCCESS;
270b6847a6SJeremy L Thompson }
280b6847a6SJeremy L Thompson 
290b6847a6SJeremy L Thompson /**
300b6847a6SJeremy L Thompson   @brief Register identity `CeedQFunction` that copies first input component directly into output
310b6847a6SJeremy L Thompson **/
CeedQFunctionRegister_IdentityScalar(void)320b6847a6SJeremy L Thompson CEED_INTERN int CeedQFunctionRegister_IdentityScalar(void) {
330b6847a6SJeremy L Thompson   return CeedQFunctionRegister("Identity to scalar", IdentityScalar_loc, 1, IdentityScalar, CeedQFunctionInit_IdentityScalar);
340b6847a6SJeremy L Thompson }
35