Nektar++
Loading...
Searching...
No Matches
LinearAdvVolumeFluxOpImpl.hpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: LinearAdvVolumeFluxOpImpl.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: Linear advection volume flux operator implementation.
32//
33///////////////////////////////////////////////////////////////////////////////
34
35#pragma once
36
40
42
43namespace Nektar::detail
44{
45
46template <typename ExecSpace, typename TData>
48{
49 using MemSpace = typename ExecSpace::memory_space;
50
51public:
53 const MultiRegions::ExpListSharedPtr &expansionList,
54 const std::vector<std::string> &components)
55 : LinearAdvVolumeFluxOp<TData>(std::move(expansionList), components)
56 {
57 }
58
59 // className - for OperatorFactory
60 static std::string className;
61
62 // instantiation function for CreatorFunction in OperatorFactory
63 static std::unique_ptr<MultiRegions::Operator<TData>> Instantiate(
64 const MultiRegions::ExpListSharedPtr &expansionList,
65 const std::vector<std::string> &components)
66 {
67 return std::make_unique<LinearAdvVolumeFluxOpImpl<ExecSpace, TData>>(
68 expansionList, components);
69 }
70
71protected:
74 {
75 for (unsigned int blk = 0; blk < in.GetBlocks().size(); ++blk)
76 {
77 const unsigned int streamID = blk + 1;
78
79 auto &inblock = in.GetBlocks()[blk];
80 auto &outblock = out.GetBlocks()[blk];
81 auto &velblock = this->m_advVel->GetBlocks()[blk];
82
83 // A pointwise product, in the state's layout: the velocity is
84 // brought to it, and the flux leaves in it.
85 const auto interleaveWidth = inblock.GetInterleaveWidth();
86 velblock.ReshapeStorage(interleaveWidth, ExecSpace::name, streamID);
87 outblock.template SetInterleaveWidth<TData>(interleaveWidth);
88
89 auto inbase = inblock.template GetPtr<MemSpace, ReadOnly>(streamID);
90 auto outbase =
91 outblock.template GetPtr<MemSpace, WriteOnly>(streamID);
92 auto velbase =
93 velblock.template GetPtr<MemSpace, ReadOnly>(streamID);
94
95 const auto npts = outblock.CompSize();
96 const auto inStride = inblock.CompSize();
97 const auto outStride = outblock.CompSize();
98 const auto velStride = velblock.CompSize();
99
100 const auto nvarComps = inblock.GetNumComponents();
101 const auto velComps = velblock.GetNumComponents();
102
103 switch (velComps)
104 {
105 case 1:
106 LinearAdvVolumeFluxKernelLauncher<ExecSpace, 1>(
107 npts, nvarComps, velStride, inStride, outStride,
108 velbase, inbase, outbase, streamID);
109 break;
110 case 2:
111 LinearAdvVolumeFluxKernelLauncher<ExecSpace, 2>(
112 npts, nvarComps, velStride, inStride, outStride,
113 velbase, inbase, outbase, streamID);
114 break;
115 case 3:
116 LinearAdvVolumeFluxKernelLauncher<ExecSpace, 3>(
117 npts, nvarComps, velStride, inStride, outStride,
118 velbase, inbase, outbase, streamID);
119 break;
120 default:
122 "The linear advection volume flux is for one, "
123 "two and three velocity components.");
124 }
125 }
126
127 out.SetInterleaveWidth(in);
128 }
129};
130
131} // namespace Nektar::detail
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
A Field represents expansion data to be operated on.
LinearAdvVolumeFluxOpImpl(const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components)
void v_Apply(LibUtilities::Field< TData, FieldState::Phys > &in, LibUtilities::Field< TData, FieldState::Phys > &out) override
static std::unique_ptr< MultiRegions::Operator< TData > > Instantiate(const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components)
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
STL namespace.