Nektar++
Loading...
Searching...
No Matches
LinearAdvVolumeFluxKernels.hpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: LinearAdvVolumeFluxKernels.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: Volume flux kernels for linear advection
32//
33///////////////////////////////////////////////////////////////////////////////
34
35#pragma once
36
38
39namespace Nektar::detail
40{
41template <typename ExecSpace, unsigned int NDIM, typename TData>
43 const unsigned int npts, const unsigned int nvarComps,
44 const unsigned int velStride, const unsigned int inStride,
45 const unsigned int outStride, const TData *velbase, const TData *inbase,
46 TData *outbase, const unsigned int streamID)
47{
48 using vec_t =
50 TData>::type;
51 constexpr unsigned int vec_width =
52 (std::is_same_v<ExecSpace, NektarSpaces::AVX>)
54 : 1;
55
56 const size_t groupsize = npts / vec_width;
57 const size_t velVecStride = velStride / vec_width;
58 const size_t inVecStride = inStride / vec_width;
59 const size_t outVecStride = outStride / vec_width;
60 const auto velvec = reinterpret_cast<const vec_t *>(velbase);
61 const auto invec = reinterpret_cast<const vec_t *>(inbase);
62 auto outvec = reinterpret_cast<vec_t *>(outbase);
63
65
66 // Parallelize over point groups; each i is independent.
67 Nektar::parallel_for<ExecSpace>(
68 0u, groupsize, NEKTAR_LAMBDA(const size_t i) {
69 for (unsigned int nvar = 0; nvar < nvarComps; ++nvar)
70 {
71 const size_t in_off = nvar * inVecStride + i;
72 const vec_t in_val = invec[in_off];
73
74 for (unsigned int ndim = 0; ndim < NDIM; ++ndim)
75 {
76 const size_t vel_off = ndim * velVecStride + i;
77 const size_t out_off =
78 (nvar * NDIM + ndim) * outVecStride + i;
79
80 outvec[out_off] = in_val * velvec[vel_off];
81 }
82 }
83 });
84
86}
87} // namespace Nektar::detail
#define NEKTAR_LAMBDA
#define NEK_FORCE_INLINE
Definition NekInline.hpp:46
static NEK_FORCE_INLINE void LinearAdvVolumeFluxKernelLauncher(const unsigned int npts, const unsigned int nvarComps, const unsigned int velStride, const unsigned int inStride, const unsigned int outStride, const TData *velbase, const TData *inbase, TData *outbase, const unsigned int streamID)
static void LoopExecutionSetStreamID(const unsigned int streamID)
tinysimd::simd< NekDouble > vec_t
typename abi< ScalarType, width >::type simd
Definition tinysimd.hpp:138