xref: /libCEED/include/ceed/jit-source/gallery/ceed-identity.h (revision d310b3d31eeeddd20725517a3a61881a36d919f0)
1 // Copyright (c) 2017-2022, 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 
12 #ifndef identity_h
13 #define identity_h
14 
15 #include <ceed.h>
16 
17 typedef struct {
18   CeedInt size;
19 } IdentityCtx;
20 
21 CEED_QFUNCTION(Identity)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) {
22   // Ctx holds field size
23   IdentityCtx   identity_ctx = *(IdentityCtx *)ctx;
24   const CeedInt size         = identity_ctx.size;
25 
26   // in[0] is input, size (Q*size)
27   const CeedScalar *input = in[0];
28   // out[0] is output, size (Q*size)
29   CeedScalar *output = out[0];
30 
31   // Quadrature point loop
32   CeedPragmaSIMD for (CeedInt i = 0; i < Q * size; i++) { output[i] = input[i]; }  // End of Quadrature Point Loop
33 
34   return CEED_ERROR_SUCCESS;
35 }
36 
37 #endif  // identity_h
38