Nektar++
Loading...
Searching...
No Matches
AdvTraceFluxCFEKernels.hpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: AdvTraceFluxCFEKernels.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: Launcher for the Riemann solve of the compressible Euler
32// trace flux: rotates the two states into the trace-normal frame, evaluates
33// the flux and rotates it back.
34//
35///////////////////////////////////////////////////////////////////////////////
36
37#pragma once
38
39#include <cstdlib>
40
44#include <SolverCore/RiemannSolver/RiemannSolverKernels.hpp>
45
46#include <type_traits>
47
48namespace Nektar::detail
49{
50
51/**
52 * @brief Solve the Riemann problem on one padded trace block, in Cartesian
53 * components through the trace normal.
54 *
55 * The Euler equations are rotationally invariant, and the tangential
56 * velocity enters the interface flux only through invariant combinations,
57 * so the solvers are written against the normal directly (as the legacy
58 * compressible Riemann solvers are) and need no rotation into a
59 * normal-aligned frame and back.
60 *
61 * @tparam RiemannKernel Flux function, as a class template on execution space,
62 * equation-of-state parameters and dimension.
63 * @tparam EoSParamType Equation-of-state parameter pack.
64 * @tparam ExecSpace Execution space; selects the SIMD width.
65 * @tparam NDIM Spatial dimension.
66 * @tparam TData Floating-point representation.
67 *
68 * @param EoS - Equation-of-state parameters.
69 * @param blksize - Padded number of points in the block.
70 * @param normalPtr - Trace normals, @p NDIM components.
71 * @param fwdPtr - Forward-side conserved state.
72 * @param bwdPtr - Backward-side conserved state.
73 * @param fluxPtr - Output flux in Cartesian coordinates.
74 * @param streamID - Stream the launches run in; reset to the default
75 * afterwards.
76 */
77template <template <typename, typename, unsigned int> typename RiemannKernel,
78 typename EoSParamType, typename ExecSpace, unsigned int NDIM,
79 typename TData>
81 const EoSParamType &EoS, const size_t blksize, const TData *normalPtr,
82 const TData *fwdPtr, const TData *bwdPtr, TData *fluxPtr,
83 const unsigned int streamID = 0)
84{
86
87 // Explicit vectorisation for AVX backend, vec_t =
88 // tinysimd::simd<TData> for AVX, vec_t = TData otherwise.
89 using vec_t =
91 TData>::type;
92 constexpr unsigned int vec_width =
93 (std::is_same_v<ExecSpace, NektarSpaces::AVX>)
95 : 1;
96
97 // Checked here, on the host: the kernels below assume it and may not
98 // assert.
99 ASSERTL1(blksize % vec_width == 0,
100 "The block size is not a multiple of the vector width.");
101 const size_t groupsize = blksize / vec_width;
102
103 Nektar::parallel_for<ExecSpace>(
104 0u, groupsize, NEKTAR_LAMBDA(const size_t i) {
105 RiemannKernel<ExecSpace, EoSParamType, NDIM>()(
106 EoS, groupsize, reinterpret_cast<const vec_t *>(fwdPtr) + i,
107 reinterpret_cast<const vec_t *>(bwdPtr) + i,
108 reinterpret_cast<const vec_t *>(normalPtr) + i,
109 reinterpret_cast<vec_t *>(fluxPtr) + i);
110 });
111
113}
114
115/**
116 * @brief The inviscid flux of one trace point, as the in-place trace flux
117 * kernels take it (the point flux of
118 * SolverCore/TraceFlux/TraceFluxKernels.hpp): the Riemann flux through the
119 * normal, with no second input and no penalty.
120 *
121 * @tparam RiemannKernel Flux function, as a class template on execution space,
122 * equation-of-state parameters and dimension.
123 * @tparam ExecSpace Execution space; selects the SIMD width.
124 * @tparam EoSParamType Equation-of-state parameter pack.
125 * @tparam NDIM Spatial dimension.
126 */
127template <template <typename, typename, unsigned int> typename RiemannKernel,
128 typename ExecSpace, typename EoSParamType, unsigned int NDIM>
130{
131 static constexpr unsigned numVar = NDIM + 2;
132 static constexpr unsigned secondPerVar = 0;
133 static constexpr bool usesPenalty = false;
134
135 EoSParamType EoS;
136
137 template <typename TData>
138 NEK_HOSTDEVICE_INLINE void operator()(const TData *fwd, const TData *bwd,
139 [[maybe_unused]] const TData *second0,
140 [[maybe_unused]] const TData *second1,
141 const TData *normal,
142 [[maybe_unused]] const TData penalty,
143 TData *flux) const
144 {
145 RiemannKernel<ExecSpace, EoSParamType, NDIM>()(EoS, 1, fwd, bwd, normal,
146 flux);
147 }
148};
149
150} // namespace Nektar::detail
#define NEK_HOSTDEVICE_INLINE
Definition Backends.hpp:268
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
#define NEKTAR_LAMBDA
#define NEK_FORCE_INLINE
Definition NekInline.hpp:46
static NEK_FORCE_INLINE void RiemannKernelLauncher(const EoSParamType &EoS, const size_t blksize, const TData *normalPtr, const TData *fwdPtr, const TData *bwdPtr, TData *fluxPtr, const unsigned int streamID=0)
Solve the Riemann problem on one padded trace block, in Cartesian components through the trace normal...
static void LoopExecutionSetStreamID(const unsigned int streamID)
tinysimd::simd< NekDouble > vec_t
typename abi< ScalarType, width >::type simd
Definition tinysimd.hpp:138
The inviscid flux of one trace point, as the in-place trace flux kernels take it (the point flux of S...
NEK_HOSTDEVICE_INLINE void operator()(const TData *fwd, const TData *bwd, const TData *second0, const TData *second1, const TData *normal, const TData penalty, TData *flux) const