Nektar++
Loading...
Searching...
No Matches
BndCondPressureOutflowCFEKernels.hpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: BndCondPressureOutflowCFEKernels.hpp
4//
5// For more information, please see: http://www.nektar.info
6//
7// The MIT License
8//
9// Copyright (c) 2006 Division of Applied Mathematics, Brown University (USA),
10// Department of Aeronautics, Imperial College London (UK), and Scientific
11// Computing and Imaging Institute, University of Utah (USA).
12//
13// Permission is hereby granted, free of charge, to any person obtaining a
14// copy of this software and associated documentation files (the "Software"),
15// to deal in the Software without restriction, including without limitation
16// the rights to use, copy, modify, merge, publish, distribute, sublicense,
17// and/or sell copies of the Software, and to permit persons to whom the
18// Software is furnished to do so, subject to the following conditions:
19//
20// The above copyright notice and this permission notice shall be included
21// in all copies or substantial portions of the Software.
22//
23// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
24// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
25// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
26// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
27// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
28// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
29// DEALINGS IN THE SOFTWARE.
30//
31// Description: Block kernels of the pressure outflow boundary condition.
32//
33///////////////////////////////////////////////////////////////////////////////
34
35#pragma once
36
37#include <cmath>
38
40
41namespace Nektar::detail
42{
43
44/**
45 * @brief Copy the prescribed pressure out of the energy slot of a block's
46 * session-evaluated storage.
47 */
48template <typename ExecSpace, typename TData>
50 const size_t stride, const size_t eng, const TData *bndPtr, TData *pOut,
51 const unsigned int streamID = 0)
52{
54
55 Nektar::parallel_for<ExecSpace>(
56 0u, stride,
57 NEKTAR_LAMBDA(const size_t i) { pOut[i] = bndPtr[eng * stride + i]; });
58
60}
61
62/**
63 * @brief Impose the prescribed pressure on a block's seeded interior state
64 * where the outflow is subsonic; supersonic points keep the extrapolated
65 * state.
66 */
67template <typename ExecSpace, typename TData, typename EoSParamType>
69 const size_t stride, const unsigned coordDim, const size_t eng,
70 const EoSParamType EoS, const TData *pOut, const TData *norms,
71 TData *bndPtr, const unsigned int streamID = 0)
72{
74
75 Nektar::parallel_for<ExecSpace>(
76 0u, stride, NEKTAR_LAMBDA(const size_t i) {
77 using std::abs;
78 using std::sqrt;
79
80 const TData rho = bndPtr[i];
81
82 // Kinetic energy and normal momentum from the extrapolated
83 // state. The normals share the storage layout, so they are
84 // indexed exactly as the momentum components are.
85 TData momSq = TData(0.0);
86 TData momDotN = TData(0.0);
87 for (unsigned d = 1; d <= coordDim; ++d)
88 {
89 const TData m = bndPtr[d * stride + i];
90 momSq += m * m;
91 momDotN += m * norms[(d - 1) * stride + i];
92 }
93 const TData Ek = TData(0.5) * momSq / rho;
94
95 const TData eInt = (bndPtr[eng * stride + i] - Ek) / rho;
96 const TData c = GetSoundSpeed(EoS, rho, eInt);
97
98 // Normal Mach number: it is the characteristic crossing the
99 // boundary that decides whether anything may be imposed,
100 // so the test is on n.u and not on the speed.
101 const TData MachN = abs(momDotN) / (rho * c);
102
103 if (MachN < TData(0.99))
104 {
105 // Subsonic: one characteristic enters, so impose the
106 // pressure through the energy and leave rho and
107 // momentum extrapolated.
108 const TData eOut = GetIntEnergyFromPressure(EoS, rho, pOut[i]);
109 bndPtr[eng * stride + i] = rho * eOut + Ek;
110 }
111 // Supersonic: no characteristic enters, nothing may be
112 // imposed, and the whole state is extrapolated. The seed is
113 // already that state, so there is deliberately nothing to
114 // do - the branch is kept so that the choice is visible.
115 });
116
118}
119
120} // namespace Nektar::detail
#define NEKTAR_LAMBDA
#define NEK_FORCE_INLINE
Definition NekInline.hpp:46
static NEK_FORCE_INLINE void ApplyPressureOutflowBlock(const size_t stride, const unsigned coordDim, const size_t eng, const EoSParamType EoS, const TData *pOut, const TData *norms, TData *bndPtr, const unsigned int streamID=0)
Impose the prescribed pressure on a block's seeded interior state where the outflow is subsonic; supe...
NEK_HOSTDEVICE_INLINE TData GetSoundSpeed(const IdealGasEoS< TScalar > &EoS, const TData &rho, const TData &e)
NEK_HOSTDEVICE_INLINE TData GetIntEnergyFromPressure(const IdealGasEoS< TScalar > &EoS, const TData &rho, const TData &p)
Specific internal energy at a prescribed pressure; the inverse of GetPressure() in its second argumen...
static NEK_FORCE_INLINE void CopyPrescribedPressureBlock(const size_t stride, const size_t eng, const TData *bndPtr, TData *pOut, const unsigned int streamID=0)
Copy the prescribed pressure out of the energy slot of a block's session-evaluated storage.
static void LoopExecutionSetStreamID(const unsigned int streamID)
scalarT< T > abs(scalarT< T > in)
Definition scalar.hpp:294