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 Scaling QFunction that scales inputs
10 **/
11 #include <ceed/types.h>
12
ScaleScalar(void * ctx,const CeedInt Q,const CeedScalar * const * in,CeedScalar * const * out)13 CEED_QFUNCTION(ScaleScalar)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) {
14 // Ctx holds field size
15 const CeedInt size = *(CeedInt *)ctx;
16
17 // in[0] is input, size (Q*size)
18 // in[1] is scaling factor, size (Q*size)
19 const CeedScalar *input = in[0];
20 const CeedScalar *scale = in[1];
21 // out[0] is output, size (Q*size)
22 CeedScalar *output = out[0];
23
24 // Quadrature point loop
25 CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) {
26 for (CeedInt j = 0; j < size; j++) output[i + j * Q] = input[i + j * Q] * scale[i];
27 } // End of Quadrature Point Loop
28 return CEED_ERROR_SUCCESS;
29 }
30