xref: /honee/qfunctions/mass.h (revision 7ecf6641c340caefd7fa9f7fc7a6efebf89ae19d)
1ae2b091fSJames Wright // SPDX-FileCopyrightText: Copyright (c) 2017-2024, HONEE contributors.
2ae2b091fSJames Wright // SPDX-License-Identifier: Apache-2.0 OR BSD-2-Clause
3a515125bSLeila Ghaffari 
4a515125bSLeila Ghaffari /// @file
5ea615d4cSJames Wright /// Mass operator for HONEE
63e17a7a1SJames Wright #include <ceed/types.h>
7a515125bSLeila Ghaffari 
8a515125bSLeila Ghaffari // *****************************************************************************
971acc5eeSJames Wright // This QFunction applies the mass matrix to N components
10a515125bSLeila Ghaffari //
11a515125bSLeila Ghaffari // Inputs:
12a515125bSLeila Ghaffari //   u      - Input vector at quadrature points
13a515125bSLeila Ghaffari //   q_data - Quadrature weights
14a515125bSLeila Ghaffari //
15a515125bSLeila Ghaffari // Output:
16a515125bSLeila Ghaffari //   v - Output vector at quadrature points
17a515125bSLeila Ghaffari //
18a515125bSLeila Ghaffari // *****************************************************************************
Mass_N(void * ctx,CeedInt Q,const CeedScalar * const * in,CeedScalar * const * out,const CeedInt N)199f59f36eSJames Wright CEED_QFUNCTION_HELPER int Mass_N(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out, const CeedInt N) {
203d65b166SJames Wright   const CeedScalar(*u)[CEED_Q_VLA] = (const CeedScalar(*)[CEED_Q_VLA])in[0];
213d65b166SJames Wright   const CeedScalar(*q_data)        = in[1];
22a515125bSLeila Ghaffari   CeedScalar(*v)[CEED_Q_VLA]       = (CeedScalar(*)[CEED_Q_VLA])out[0];
23a515125bSLeila Ghaffari 
24*14bd2a07SJames Wright   CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) CeedPragmaSIMD for (CeedInt j = 0; j < N; j++) v[j][i] = q_data[i] * u[j][i];
25a515125bSLeila Ghaffari   return 0;
26a515125bSLeila Ghaffari }
27a515125bSLeila Ghaffari 
Mass_1(void * ctx,CeedInt Q,const CeedScalar * const * in,CeedScalar * const * out)289f59f36eSJames Wright CEED_QFUNCTION(Mass_1)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { return Mass_N(ctx, Q, in, out, 1); }
299f59f36eSJames Wright 
Mass_2(void * ctx,CeedInt Q,const CeedScalar * const * in,CeedScalar * const * out)3040b78511SJames Wright CEED_QFUNCTION(Mass_2)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { return Mass_N(ctx, Q, in, out, 2); }
3140b78511SJames Wright 
Mass_3(void * ctx,CeedInt Q,const CeedScalar * const * in,CeedScalar * const * out)3240b78511SJames Wright CEED_QFUNCTION(Mass_3)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { return Mass_N(ctx, Q, in, out, 3); }
3340b78511SJames Wright 
Mass_4(void * ctx,CeedInt Q,const CeedScalar * const * in,CeedScalar * const * out)348c85b835SJames Wright CEED_QFUNCTION(Mass_4)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { return Mass_N(ctx, Q, in, out, 4); }
358c85b835SJames Wright 
Mass_5(void * ctx,CeedInt Q,const CeedScalar * const * in,CeedScalar * const * out)369f59f36eSJames Wright CEED_QFUNCTION(Mass_5)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { return Mass_N(ctx, Q, in, out, 5); }
379f59f36eSJames Wright 
Mass_6(void * ctx,CeedInt Q,const CeedScalar * const * in,CeedScalar * const * out)38b30619f6SJames Wright CEED_QFUNCTION(Mass_6)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { return Mass_N(ctx, Q, in, out, 6); }
39b30619f6SJames Wright 
Mass_7(void * ctx,CeedInt Q,const CeedScalar * const * in,CeedScalar * const * out)40c38c977aSJames Wright CEED_QFUNCTION(Mass_7)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { return Mass_N(ctx, Q, in, out, 7); }
41c38c977aSJames Wright 
Mass_9(void * ctx,CeedInt Q,const CeedScalar * const * in,CeedScalar * const * out)429f59f36eSJames Wright CEED_QFUNCTION(Mass_9)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { return Mass_N(ctx, Q, in, out, 9); }
439f59f36eSJames Wright 
Mass_12(void * ctx,CeedInt Q,const CeedScalar * const * in,CeedScalar * const * out)448c85b835SJames Wright CEED_QFUNCTION(Mass_12)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { return Mass_N(ctx, Q, in, out, 12); }
458c85b835SJames Wright 
Mass_22(void * ctx,CeedInt Q,const CeedScalar * const * in,CeedScalar * const * out)469f59f36eSJames Wright CEED_QFUNCTION(Mass_22)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) { return Mass_N(ctx, Q, in, out, 22); }
47