xref: /libCEED/rust/libceed-sys/c-src/gallery/identity/ceed-identity-to-scalar.c (revision 0b6847a6bd8ae6afc56b1dc81e69df6d744052aa)
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-identity-to-scalar.h>
11 #include <stddef.h>
12 #include <string.h>
13 
14 /**
15   @brief Set fields identity `CeedQFunction` that copies first input component directly into output
16 **/
17 static int CeedQFunctionInit_IdentityScalar(Ceed ceed, const char *requested, CeedQFunction qf) {
18   // Check QFunction name
19   const char *name = "Identity to scalar";
20   CeedCheck(!strcmp(name, requested), ceed, CEED_ERROR_UNSUPPORTED, "QFunction '%s' does not match requested name: %s", name, requested);
21 
22   // QFunction fields 'input' and 'output' with requested emodes added by the library rather than being added here
23 
24   CeedCall(CeedQFunctionSetUserFlopsEstimate(qf, 0));
25   return CEED_ERROR_SUCCESS;
26 }
27 
28 /**
29   @brief Register identity `CeedQFunction` that copies first input component directly into output
30 **/
31 CEED_INTERN int CeedQFunctionRegister_IdentityScalar(void) {
32   return CeedQFunctionRegister("Identity to scalar", IdentityScalar_loc, 1, IdentityScalar, CeedQFunctionInit_IdentityScalar);
33 }
34