Nektar++
Loading...
Searching...
No Matches
CFLVelocityCFEOpImpl.hpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: CFLVelocityCFEOpImpl.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: CFL velocity operator implementation.
32//
33///////////////////////////////////////////////////////////////////////////////
34
35#pragma once
36
39
41
42namespace Nektar::detail
43{
44
45template <typename ExecSpace, typename EqnOfSParams, typename TData>
47{
48 using MemSpace = typename ExecSpace::memory_space;
49
50public:
52 const std::vector<std::string> &components)
53 : CFLVelocityCFEOp<TData>(expansionList, components)
54 {
55 m_dimension = expansionList->GetExp(0)->GetShapeDimension();
56
57 // The size contract is fixed here, once: the operator is built for
58 // its outputs - one velocity component per dimension with the sound
59 // speed after them - and reads the conserved variables rho, rho*u_i
60 // and E from the field it is applied to. Apply() relies on both
61 // without re-checking.
62 ASSERTL1(components.size() == m_dimension + 1,
63 "CFLVelocityCFE is built for one velocity component per "
64 "dimension and the sound speed after them.");
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 components);
80 }
81
82protected:
83 unsigned int m_dimension;
84 EqnOfSParams m_EoS;
85
88 {
89 for (unsigned int blk = 0; blk < in.GetBlocks().size(); ++blk)
90 {
91 const unsigned int streamID = blk + 1;
92
93 auto &inblock = in.GetBlocks()[blk];
94 auto &outblock = out.GetBlocks()[blk];
95
96 auto inbase = inblock.template GetPtr<MemSpace, ReadOnly>(streamID);
97 auto outbase =
98 outblock.template GetPtr<MemSpace, WriteOnly>(streamID);
99
100 const auto npts = outblock.CompSize();
101 const auto inStride = inblock.CompSize();
102 const auto outStride = outblock.CompSize();
103
104 CFLVelocityCFEKernel<ExecSpace, EqnOfSParams>(
105 m_EoS, npts, m_dimension, inStride, outStride, inbase, outbase,
106 streamID);
107 }
108 // The kernel is pointwise: the output has the layout of the state.
109 out.SetInterleaveWidth(in);
110 }
111};
112
113} // namespace Nektar::detail
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
Convert conserved variables to the wave speeds the Courant estimate needs.
A Field represents expansion data to be operated on.
static std::unique_ptr< MultiRegions::Operator< TData > > Instantiate(const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components)
CFLVelocityCFEOpImpl(const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components)
typename ExecSpace::memory_space MemSpace
void v_Apply(LibUtilities::Field< TData, FieldState::Phys > &in, LibUtilities::Field< TData, FieldState::Phys > &out) override
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
void SetUpEquationOfState(LibUtilities::SessionReaderSharedPtr session, IdealGasEoS< TData > &EoS)