xref: /libCEED/examples/fluids/qfunctions/mass.h (revision eab5b1a2bf6b5384761bd0b9e014e873aafcca6d)
1 // Copyright (c) 2017, Lawrence Livermore National Security, LLC. Produced at
2 // the Lawrence Livermore National Laboratory. LLNL-CODE-734707. All Rights
3 // reserved. See files LICENSE and NOTICE for details.
4 //
5 // This file is part of CEED, a collection of benchmarks, miniapps, software
6 // libraries and APIs for efficient high-order finite element and spectral
7 // element discretizations for exascale applications. For more information and
8 // source code availability see http://github.com/ceed.
9 //
10 // The CEED research is supported by the Exascale Computing Project 17-SC-20-SC,
11 // a collaborative effort of two U.S. Department of Energy organizations (Office
12 // of Science and the National Nuclear Security Administration) responsible for
13 // the planning and preparation of a capable exascale ecosystem, including
14 // software, applications, hardware, advanced system engineering and early
15 // testbed platforms, in support of the nation's exascale computing imperative.
16 
17 /// @file
18 /// Mass operator for Navier-Stokes example using PETSc
19 
20 #ifndef mass_h
21 #define mass_h
22 
23 #include <math.h>
24 
25 // *****************************************************************************
26 // This QFunction applies the mass matrix to five interlaced fields.
27 //
28 // Inputs:
29 //   u     - Input vector at quadrature points
30 //   q_data - Quadrature weights
31 //
32 // Output:
33 //   v - Output vector at quadrature points
34 //
35 // *****************************************************************************
36 CEED_QFUNCTION(Mass)(void *ctx, CeedInt Q,
37                      const CeedScalar *const *in, CeedScalar *const *out) {
38   // *INDENT-OFF*
39   // Inputs
40   const CeedScalar (*u)[CEED_Q_VLA] = (const CeedScalar(*)[CEED_Q_VLA])in[0],
41                    (*q_data) = in[1];
42 
43   // Outputs
44   CeedScalar (*v)[CEED_Q_VLA] = (CeedScalar(*)[CEED_Q_VLA])out[0];
45   // *INDENT-ON*
46 
47   CeedPragmaSIMD
48   for (CeedInt i=0; i<Q; i++) {
49     v[0][i] = q_data[i] * u[0][i];
50     v[1][i] = q_data[i] * u[1][i];
51     v[2][i] = q_data[i] * u[2][i];
52     v[3][i] = q_data[i] * u[3][i];
53     v[4][i] = q_data[i] * u[4][i];
54   }
55   return 0;
56 }
57 
58 // *****************************************************************************
59 
60 #endif // mass_h
61