Nektar++
Loading...
Searching...
No Matches
EulerVolumeFluxOpImpl.hpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: EulerVolumeFluxOpImpl.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: Euler volume flux operator implementation.
32//
33///////////////////////////////////////////////////////////////////////////////
34
35#pragma once
36
38
41
43
44namespace Nektar::detail
45{
46
47template <typename ExecSpace, typename EqnOfSParams, typename TData>
49{
50 using MemSpace = typename ExecSpace::memory_space;
51
52public:
54 const std::vector<std::string> &components)
55 : EulerVolumeFluxOp<TData>(std::move(expansionList), components)
56 {
57 m_dimension = expansionList->GetExp(0)->GetShapeDimension();
58
59 // The size contract is fixed here, once: the operator is built for
60 // the conserved variables rho, rho*u_i and E, and Apply() relies on
61 // it without re-checking.
62 ASSERTL0(components.size() == m_dimension + 2,
63 "EulerVolumeFlux is built for the density, one momentum "
64 "component per dimension and the energy.");
65
66 SetUpEquationOfState(expansionList->GetSession(), m_EoS);
67 }
68
69 // className - for OperatorFactory
70 static std::string className;
71
72 // instantiation function for CreatorFunction in OperatorFactory
73 static std::unique_ptr<MultiRegions::Operator<TData>> Instantiate(
74 const MultiRegions::ExpListSharedPtr &expansionList,
75 const std::vector<std::string> &components)
76 {
77 return std::make_unique<
79 expansionList, components);
80 }
81
82protected:
83 unsigned int m_dimension;
84 EqnOfSParams m_EoS;
85
88 {
89 if (this->m_append)
90 {
91 EulerFlux<true>(in, out);
92 }
93 else
94 {
95 EulerFlux<false>(in, out);
96 }
97 }
98
99 /// The Euler flux, block by block.
100 template <bool APPEND>
103 {
104 for (unsigned int blk = 0; blk < in.GetBlocks().size(); ++blk)
105 {
106 const unsigned int streamID = blk + 1;
107
108 auto &inblock = in.GetBlocks()[blk];
109 auto &outblock = out.GetBlocks()[blk];
110
111 auto inbase = inblock.template GetPtr<MemSpace, ReadOnly>(streamID);
112 auto outbase =
113 APPEND
114 ? outblock.template GetPtr<MemSpace, ReadWrite>(streamID)
115 : outblock.template GetPtr<MemSpace, WriteOnly>(streamID);
116
117 const auto npts = outblock.CompSize();
118 const auto inStride = inblock.CompSize();
119 const auto outStride = outblock.CompSize();
120
121 switch (m_dimension)
122 {
123 case 1:
124 EulerVolumeFluxKernelLauncher<ExecSpace, 1, APPEND>(
125 m_EoS, npts, inStride, outStride, inbase, outbase,
126 this->m_scale, streamID);
127 break;
128 case 2:
129 EulerVolumeFluxKernelLauncher<ExecSpace, 2, APPEND>(
130 m_EoS, npts, inStride, outStride, inbase, outbase,
131 this->m_scale, streamID);
132 break;
133 case 3:
134 EulerVolumeFluxKernelLauncher<ExecSpace, 3, APPEND>(
135 m_EoS, npts, inStride, outStride, inbase, outbase,
136 this->m_scale, streamID);
137 break;
138 default:
140 "The Euler volume flux is for one, two and three "
141 "dimensions.");
142 }
143 }
144 // The kernel is pointwise: the flux has the layout of the state.
145 out.SetInterleaveWidth(in);
146 }
147};
148
149} // namespace Nektar::detail
#define ASSERTL0(condition, msg)
#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.
EulerVolumeFluxOpImpl(const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components)
void EulerFlux(LibUtilities::Field< TData, FieldState::Phys > &in, LibUtilities::Field< TData, FieldState::Phys > &out)
The Euler flux, block by block.
static std::unique_ptr< MultiRegions::Operator< TData > > Instantiate(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
typename ExecSpace::memory_space MemSpace
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
void SetUpEquationOfState(LibUtilities::SessionReaderSharedPtr session, IdealGasEoS< TData > &EoS)
STL namespace.