xref: /libCEED/include/ceed/jit-source/gallery/ceed-identity.h (revision d4cc18453651bd0f94c1a2e078b2646a92dafdcc)
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 /**
9   @brief  Identity QFunction that copies inputs directly into outputs
10 **/
11 #include <ceed/types.h>
12 
13 typedef struct {
14   CeedInt size;
15 } IdentityCtx;
16 
17 CEED_QFUNCTION(Identity)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) {
18   // Ctx holds field size
19   IdentityCtx   identity_ctx = *(IdentityCtx *)ctx;
20   const CeedInt size         = identity_ctx.size;
21 
22   // in[0] is input, size (Q*size)
23   const CeedScalar *input = in[0];
24   // out[0] is output, size (Q*size)
25   CeedScalar *output = out[0];
26 
27   // Quadrature point loop
28   CeedPragmaSIMD for (CeedInt i = 0; i < Q * size; i++) { output[i] = input[i]; }  // End of Quadrature Point Loop
29 
30   return CEED_ERROR_SUCCESS;
31 }
32