xref: /libCEED/examples/fluids/qfunctions/mass.h (revision c9c2c07970382857cc7b4a28d359710237b91a3e)
13d8e8822SJeremy L Thompson // Copyright (c) 2017-2022, Lawrence Livermore National Security, LLC and other CEED contributors.
23d8e8822SJeremy L Thompson // All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
377841947SLeila Ghaffari //
43d8e8822SJeremy L Thompson // SPDX-License-Identifier: BSD-2-Clause
577841947SLeila Ghaffari //
63d8e8822SJeremy L Thompson // This file is part of CEED:  http://github.com/ceed
777841947SLeila Ghaffari 
877841947SLeila Ghaffari /// @file
977841947SLeila Ghaffari /// Mass operator for Navier-Stokes example using PETSc
1077841947SLeila Ghaffari 
1177841947SLeila Ghaffari #ifndef mass_h
1277841947SLeila Ghaffari #define mass_h
1377841947SLeila Ghaffari 
14ba6664aeSJames Wright #include <ceed.h>
15*c9c2c079SJeremy L Thompson #include <math.h>
1677841947SLeila Ghaffari 
1777841947SLeila Ghaffari // *****************************************************************************
1877841947SLeila Ghaffari // This QFunction applies the mass matrix to five interlaced fields.
1977841947SLeila Ghaffari //
2077841947SLeila Ghaffari // Inputs:
2177841947SLeila Ghaffari //   u     - Input vector at quadrature points
2277841947SLeila Ghaffari //   q_data - Quadrature weights
2377841947SLeila Ghaffari //
2477841947SLeila Ghaffari // Output:
2577841947SLeila Ghaffari //   v - Output vector at quadrature points
2677841947SLeila Ghaffari //
2777841947SLeila Ghaffari // *****************************************************************************
2877841947SLeila Ghaffari CEED_QFUNCTION(Mass)(void *ctx, CeedInt Q,
2977841947SLeila Ghaffari                      const CeedScalar *const *in, CeedScalar *const *out) {
3077841947SLeila Ghaffari   // *INDENT-OFF*
3177841947SLeila Ghaffari   // Inputs
3277841947SLeila Ghaffari   const CeedScalar (*u)[CEED_Q_VLA] = (const CeedScalar(*)[CEED_Q_VLA])in[0],
3377841947SLeila Ghaffari                    (*q_data) = in[1];
3477841947SLeila Ghaffari 
3577841947SLeila Ghaffari   // Outputs
3677841947SLeila Ghaffari   CeedScalar (*v)[CEED_Q_VLA] = (CeedScalar(*)[CEED_Q_VLA])out[0];
3777841947SLeila Ghaffari   // *INDENT-ON*
3877841947SLeila Ghaffari 
3977841947SLeila Ghaffari   CeedPragmaSIMD
4077841947SLeila Ghaffari   for (CeedInt i=0; i<Q; i++) {
4177841947SLeila Ghaffari     v[0][i] = q_data[i] * u[0][i];
4277841947SLeila Ghaffari     v[1][i] = q_data[i] * u[1][i];
4377841947SLeila Ghaffari     v[2][i] = q_data[i] * u[2][i];
4477841947SLeila Ghaffari     v[3][i] = q_data[i] * u[3][i];
4577841947SLeila Ghaffari     v[4][i] = q_data[i] * u[4][i];
4677841947SLeila Ghaffari   }
4777841947SLeila Ghaffari   return 0;
4877841947SLeila Ghaffari }
4977841947SLeila Ghaffari 
5077841947SLeila Ghaffari // *****************************************************************************
5177841947SLeila Ghaffari 
5277841947SLeila Ghaffari #endif // mass_h
53