Nektar++
Loading...
Searching...
No Matches
BndCondWallCFEKernels.hpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: BndCondWallCFEKernels.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 viscous wall boundary condition.
32//
33///////////////////////////////////////////////////////////////////////////////
34
35#pragma once
36
38
39namespace Nektar::detail
40{
41
42/**
43 * @brief Set the exterior energy on a block so that the trace average of the
44 * internal energy sits at the wall temperature.
45 */
46template <typename ExecSpace, typename TData, typename EoSParamType>
48 const size_t nPts, const size_t compStride, const unsigned coordDim,
49 const size_t eng, const EoSParamType EoS, const TData Twall,
50 const TData *interior, TData *ext, const unsigned int streamID = 0)
51{
53
54 Nektar::parallel_for<ExecSpace>(
55 0u, nPts, NEKTAR_LAMBDA(const size_t i) {
56 const TData rhoFwd = interior[i];
57 const TData rhoBwd = ext[i];
58 const TData rhoAve = TData(0.5) * (rhoFwd + rhoBwd);
59
60 TData momSqFwd = TData(0.0);
61 TData momSqBwd = TData(0.0);
62 for (unsigned d = 1; d <= coordDim; ++d)
63 {
64 const size_t od = d * compStride + i;
65 momSqFwd += interior[od] * interior[od];
66 momSqBwd += ext[od] * ext[od];
67 }
68
69 // Interior internal energy, as the kernel forms it.
70 const TData eIntFwd =
71 interior[eng * compStride + i] - TData(0.5) * momSqFwd / rhoFwd;
72
73 const TData eWall = GetIntEnergyFromTemperature(EoS, rhoAve, Twall);
74
75 // Exterior internal energy that puts the average on the wall
76 // value, then back to a total energy.
77 const TData eIntBwd = TData(2.0) * rhoAve * eWall - eIntFwd;
78
79 ext[eng * compStride + i] =
80 eIntBwd + TData(0.5) * momSqBwd / rhoBwd;
81 });
82
84}
85
86/**
87 * @brief Reverse the momentum of a block's seeded interior state, leaving
88 * density and energy as they are.
89 */
90template <typename ExecSpace, typename TData>
92 const size_t stride, const unsigned coordDim, TData *bndPtr,
93 const unsigned int streamID = 0)
94{
96
97 Nektar::parallel_for<ExecSpace>(
98 0u, stride, NEKTAR_LAMBDA(const size_t i) {
99 for (unsigned d = 1; d <= coordDim; ++d)
100 {
101 bndPtr[d * stride + i] = -bndPtr[d * stride + i];
102 }
103 });
104
106}
107
108} // namespace Nektar::detail
#define NEKTAR_LAMBDA
#define NEK_FORCE_INLINE
Definition NekInline.hpp:46
static NEK_FORCE_INLINE void ReverseMomentumBlock(const size_t stride, const unsigned coordDim, TData *bndPtr, const unsigned int streamID=0)
Reverse the momentum of a block's seeded interior state, leaving density and energy as they are.
NEK_HOSTDEVICE_INLINE TData GetIntEnergyFromTemperature(const IdealGasEoS< TScalar > &EoS, const TData &rho, const TData &T)
Specific internal energy at a prescribed temperature; the inverse of GetTemperature().
static NEK_FORCE_INLINE void ImposeIsothermalWallEnergyBlock(const size_t nPts, const size_t compStride, const unsigned coordDim, const size_t eng, const EoSParamType EoS, const TData Twall, const TData *interior, TData *ext, const unsigned int streamID=0)
Set the exterior energy on a block so that the trace average of the internal energy sits at the wall ...
static void LoopExecutionSetStreamID(const unsigned int streamID)