Nektar++
Loading...
Searching...
No Matches
CFLVelocityCFEOp.hpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: CFLVelocityCFEOp.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: Velocity and sound speed for the Courant estimate.
32//
33///////////////////////////////////////////////////////////////////////////////
34
35#pragma once
36
38
40
42
43namespace Nektar
44{
45
46/**
47 * @brief Convert conserved variables to the wave speeds the Courant
48 * estimate needs.
49 *
50 * Writes the @p ndim velocity components followed by the speed of sound,
51 * which is what MaxStdVelocityOp consumes with its sound speed factor set
52 * to one. The conversion is kept out of MaxStdVelocityOp so that the
53 * latter stays free of any equation of state and remains usable by the
54 * incompressible and advection-diffusion solvers, which have no sound
55 * speed to supply.
56 */
57template <typename TData>
59{
60public:
61 static std::shared_ptr<CFLVelocityCFEOp<TData>> Create(
62 const MultiRegions::ExpListSharedPtr &expansionList,
63 const std::vector<std::string> &components,
64 const std::string &execStr = "")
65 {
66 auto session = expansionList->GetSession();
67
68 std::string EoSName;
69 if (session->DefinesEquationOfState())
70 {
71 EoSName =
72 StringUtils::ToUpperCopy(session->GetEquationOfState().type);
73 }
74 else
75 {
77 "No EquationOfState section defined in session file");
78 }
79
80 std::string execStr0 =
81 (execStr == "")
83 : execStr;
84
85 // The key carries the equation of state between the name and the
86 // execution space, so the factory is asked directly rather than
87 // through Operator::Create, which would prepend the name a second
88 // time.
89 const std::string requestedKey = name + EoSName + execStr0;
90
92 MultiRegions::GetOperatorFactory<TData>();
93
94 if (!factory.ModuleExists(requestedKey))
95 {
96 std::stringstream msg;
97 msg << "No such operator: " << requestedKey << std::endl;
98 factory.PrintAvailableClasses(msg);
99 NEKERROR(ErrorUtil::efatal, msg.str());
100 }
101
102 return std::static_pointer_cast<CFLVelocityCFEOp<TData>>(
103 factory.CreateInstance(requestedKey, expansionList, components));
104 }
105
106 static inline const std::string name = "CFLVelocityCFE";
107
113
119
120protected:
122 const std::vector<std::string> &components)
123 : MultiRegions::Operator<TData>(expansionList, components)
124 {
125 }
126
127 ~CFLVelocityCFEOp() override = default;
128
131};
132
133} // namespace Nektar
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
Whole-field operator base class and factory machinery shared by every operator family in the MultiReg...
LibUtilities::SessionReaderSharedPtr session
Convert conserved variables to the wave speeds the Courant estimate needs.
static std::shared_ptr< CFLVelocityCFEOp< TData > > Create(const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components, const std::string &execStr="")
virtual void v_Apply(LibUtilities::Field< TData, FieldState::Phys > &in, LibUtilities::Field< TData, FieldState::Phys > &out)=0
void operator()(LibUtilities::Field< TData, FieldState::Phys > &in, LibUtilities::Field< TData, FieldState::Phys > &out)
CFLVelocityCFEOp(const MultiRegions::ExpListSharedPtr &expansionList, const std::vector< std::string > &components)
void Apply(LibUtilities::Field< TData, FieldState::Phys > &in, LibUtilities::Field< TData, FieldState::Phys > &out)
~CFLVelocityCFEOp() override=default
static const std::string name
A Field represents expansion data to be operated on.
bool ModuleExists(tKey idKey)
Checks if a particular module is available.
tBasePtr CreateInstance(tKey idKey, tParam... args)
Create an instance of the class referred to by idKey.
void PrintAvailableClasses(std::ostream &pOut=std::cout)
Prints the available classes to stdout.
Common base class of the operator family interfaces: holds the expansion list, component names and da...
Definition Operator.hpp:100
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
std::string ToUpperCopy(std::string str)