xref: /libCEED/examples/fluids/qfunctions/advection.h (revision 4bdcf5bfc9c975d3aa92ea92b76d44b784a519ec)
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 /// Advection initial condition and operator for Navier-Stokes example using PETSc
10 
11 #ifndef advection_h
12 #define advection_h
13 
14 #include <ceed.h>
15 #include <math.h>
16 
17 #include "advection_generic.h"
18 #include "advection_types.h"
19 #include "newtonian_state.h"
20 #include "newtonian_types.h"
21 #include "stabilization_types.h"
22 #include "utils.h"
23 
24 // *****************************************************************************
25 // This QFunction sets the initial conditions for 3D advection
26 // *****************************************************************************
27 CEED_QFUNCTION(ICsAdvection)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) {
28   const CeedScalar(*X)[CEED_Q_VLA] = (const CeedScalar(*)[CEED_Q_VLA])in[0];
29   CeedScalar(*q0)[CEED_Q_VLA]      = (CeedScalar(*)[CEED_Q_VLA])out[0];
30 
31   CeedPragmaSIMD for (CeedInt i = 0; i < Q; i++) {
32     const CeedScalar x[]  = {X[0][i], X[1][i], X[2][i]};
33     CeedScalar       q[5] = {0.};
34 
35     Exact_AdvectionGeneric(3, 0., x, 5, q, ctx);
36     for (CeedInt j = 0; j < 5; j++) q0[j][i] = q[j];
37   }
38   return 0;
39 }
40 
41 // *****************************************************************************
42 // This QFunction implements the following formulation of the advection equation
43 //
44 // This is 3D advection given in two formulations based upon the weak form.
45 //
46 // State Variables: q = ( rho, U1, U2, U3, E )
47 //   rho - Mass Density
48 //   Ui  - Momentum Density    ,  Ui = rho ui
49 //   E   - Total Energy Density
50 //
51 // Advection Equation:
52 //   dE/dt + div( E u ) = 0
53 // *****************************************************************************
54 CEED_QFUNCTION(Advection)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) {
55   RHSFunction_AdvectionGeneric(ctx, Q, in, out, 3);
56   return 0;
57 }
58 
59 CEED_QFUNCTION(IFunction_Advection)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) {
60   IFunction_AdvectionGeneric(ctx, Q, in, out, 3);
61   return 0;
62 }
63 
64 CEED_QFUNCTION(Advection_InOutFlow)(void *ctx, CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) {
65   Advection_InOutFlowGeneric(ctx, Q, in, out, 3);
66   return 0;
67 }
68 
69 #endif  // advection_h
70