xref: /libCEED/include/ceed/jit-source/gallery/ceed-identity.h (revision c0b5abf0f23b15c4f0ada76f8abe9f8d2b6fa247)
15aed82e4SJeremy L Thompson // Copyright (c) 2017-2024, Lawrence Livermore National Security, LLC and other CEED contributors.
2a0154adeSJed Brown // All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
3a0154adeSJed Brown //
4a0154adeSJed Brown // SPDX-License-Identifier: BSD-2-Clause
5a0154adeSJed Brown //
6a0154adeSJed Brown // This file is part of CEED:  http://github.com/ceed
7a0154adeSJed Brown 
8a0154adeSJed Brown /**
9a0154adeSJed Brown   @brief  Identity QFunction that copies inputs directly into outputs
10a0154adeSJed Brown **/
11a0154adeSJed Brown 
12*c0b5abf0SJeremy L Thompson #include <ceed/types.h>
13c9c2c079SJeremy L Thompson 
14a0154adeSJed Brown typedef struct {
15a0154adeSJed Brown   CeedInt size;
16a0154adeSJed Brown } IdentityCtx;
17a0154adeSJed Brown 
182b730f8bSJeremy L Thompson CEED_QFUNCTION(Identity)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) {
19a0154adeSJed Brown   // Ctx holds field size
20a0154adeSJed Brown   IdentityCtx   identity_ctx = *(IdentityCtx *)ctx;
21a0154adeSJed Brown   const CeedInt size         = identity_ctx.size;
22a0154adeSJed Brown 
23a0154adeSJed Brown   // in[0] is input, size (Q*size)
24a0154adeSJed Brown   const CeedScalar *input = in[0];
25a0154adeSJed Brown   // out[0] is output, size (Q*size)
26a0154adeSJed Brown   CeedScalar *output = out[0];
27a0154adeSJed Brown 
28a0154adeSJed Brown   // Quadrature point loop
292b730f8bSJeremy L Thompson   CeedPragmaSIMD for (CeedInt i = 0; i < Q * size; i++) { output[i] = input[i]; }  // End of Quadrature Point Loop
30a0154adeSJed Brown 
31a0154adeSJed Brown   return CEED_ERROR_SUCCESS;
32a0154adeSJed Brown }
33