xref: /libCEED/examples/fluids/qfunctions/mass.h (revision 8687e1d445b8fb5c2aba1a76f10bd56e6cda067d)
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 /// @file
9 /// Mass operator for Navier-Stokes example using PETSc
10 
11 #ifndef mass_h
12 #define mass_h
13 
14 #include <math.h>
15 #include <ceed.h>
16 
17 // *****************************************************************************
18 // This QFunction applies the mass matrix to five interlaced fields.
19 //
20 // Inputs:
21 //   u     - Input vector at quadrature points
22 //   q_data - Quadrature weights
23 //
24 // Output:
25 //   v - Output vector at quadrature points
26 //
27 // *****************************************************************************
28 CEED_QFUNCTION(Mass)(void *ctx, CeedInt Q,
29                      const CeedScalar *const *in, CeedScalar *const *out) {
30   // *INDENT-OFF*
31   // Inputs
32   const CeedScalar (*u)[CEED_Q_VLA] = (const CeedScalar(*)[CEED_Q_VLA])in[0],
33                    (*q_data) = in[1];
34 
35   // Outputs
36   CeedScalar (*v)[CEED_Q_VLA] = (CeedScalar(*)[CEED_Q_VLA])out[0];
37   // *INDENT-ON*
38 
39   CeedPragmaSIMD
40   for (CeedInt i=0; i<Q; i++) {
41     v[0][i] = q_data[i] * u[0][i];
42     v[1][i] = q_data[i] * u[1][i];
43     v[2][i] = q_data[i] * u[2][i];
44     v[3][i] = q_data[i] * u[3][i];
45     v[4][i] = q_data[i] * u[4][i];
46   }
47   return 0;
48 }
49 
50 // *****************************************************************************
51 
52 #endif // mass_h
53