Nektar++
PressureMachTemperatureBC.cpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: PressureMachTemperatureBC.cpp
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: Boundary condition specified in terms of pressure, Mach number
32// and temperature
33//
34///////////////////////////////////////////////////////////////////////////////
35
37
38using namespace std;
39
40namespace Nektar
41{
42
45 "PressureMachTemperature", PressureMachTemperatureBC::create,
46 "BC prescribed in terms of p, Ma and T.");
47
51 const Array<OneD, Array<OneD, NekDouble>> &pTraceNormals,
52 const Array<OneD, Array<OneD, NekDouble>> &pGridVelocity,
53 const int pSpaceDim, const int bcRegion, const int cnt)
54 : CFSBndCond(pSession, pFields, pTraceNormals, pGridVelocity, pSpaceDim,
55 bcRegion, cnt)
56{
57 int nvariables = m_fields.size();
58 int numBCPts =
59 m_fields[0]->GetBndCondExpansions()[m_bcRegion]->GetNpoints();
60
61 // Array for storing conserved variables on the boundary
63 for (int i = 0; i < nvariables; ++i)
64 {
65 m_bcStorage[i] = Array<OneD, NekDouble>(numBCPts, 0.0);
66 }
67
68 // We assume that the pressure is given in entry [0] of
69 // the BC ("rho" position) and the temperature in entry m_spacedim+1
70 // ("E" position)
72 m_fields[0]->GetBndCondExpansions()[m_bcRegion]->GetPhys();
73 const Array<OneD, const NekDouble> temperature =
74 m_fields[m_spacedim + 1]->GetBndCondExpansions()[m_bcRegion]->GetPhys();
75
76 // Calculate density
77 m_varConv->GetRhoFromPT(pressure, temperature, m_bcStorage[0]);
78 // Calculate the internal energy times density
79 m_varConv->GetEFromRhoP(m_bcStorage[0], pressure,
81 Vmath::Vmul(numBCPts, m_bcStorage[m_spacedim + 1], 1, m_bcStorage[0], 1,
82 m_bcStorage[m_spacedim + 1], 1);
83 // We can now obtain the sound speed at this (rho,e) condition
84 Array<OneD, NekDouble> soundSpeed(numBCPts);
85 m_varConv->GetSoundSpeed(m_bcStorage, soundSpeed);
86
87 // Now update momentum and add kinetic energy to E
88 Array<OneD, NekDouble> tmp(numBCPts);
89 for (int i = 0; i < m_spacedim; ++i)
90 {
91 // tmp = velocity in i direction
93 numBCPts,
94 m_fields[i + 1]->GetBndCondExpansions()[m_bcRegion]->GetPhys(), 1,
95 soundSpeed, 1, tmp, 1);
96 // rho*u
97 Vmath::Vmul(numBCPts, m_bcStorage[0], 1, tmp, 1, m_bcStorage[i + 1], 1);
98 // tmp = 0.5 * rho *(rhou) in vel
99 Vmath::Vmul(numBCPts, m_bcStorage[i + 1], 1, tmp, 1, tmp, 1);
100 Vmath::Smul(numBCPts, 0.5, tmp, 1, tmp, 1);
101 // Add to E
102 Vmath::Vadd(numBCPts, m_bcStorage[m_spacedim + 1], 1, tmp, 1,
103 m_bcStorage[m_spacedim + 1], 1);
104 }
105
106 // Copy to boundary condition
107 for (int i = 0; i < nvariables; ++i)
108 {
110 numBCPts, m_bcStorage[i], 1,
111 m_fields[i]->GetBndCondExpansions()[m_bcRegion]->UpdatePhys(), 1);
112 }
113}
114
116 [[maybe_unused]] Array<OneD, Array<OneD, NekDouble>> &Fwd,
117 [[maybe_unused]] Array<OneD, Array<OneD, NekDouble>> &physarray,
118 [[maybe_unused]] const NekDouble &time)
119{
120 int nvariables = m_fields.size();
121 int numBCPts =
122 m_fields[0]->GetBndCondExpansions()[m_bcRegion]->GetNpoints();
123 // Copy conserved variables to boundary condition
124 for (int i = 0; i < nvariables; ++i)
125 {
127 numBCPts, m_bcStorage[i], 1,
128 m_fields[i]->GetBndCondExpansions()[m_bcRegion]->UpdatePhys(), 1);
129 }
130}
131
132} // namespace Nektar
Encapsulates the user-defined boundary conditions for compressible flow solver.
Definition: CFSBndCond.h:71
int m_spacedim
Space dimension.
Definition: CFSBndCond.h:98
int m_bcRegion
Id of the boundary region.
Definition: CFSBndCond.h:113
VariableConverterSharedPtr m_varConv
Auxiliary object to convert variables.
Definition: CFSBndCond.h:100
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array of fields.
Definition: CFSBndCond.h:92
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
static CFSBndCondSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const Array< OneD, Array< OneD, NekDouble > > &pTraceNormals, const Array< OneD, Array< OneD, NekDouble > > &pGridVelocity, const int pSpaceDim, const int bcRegion, const int cnt)
Creates an instance of this class.
static std::string className
Name of the class.
PressureMachTemperatureBC(const LibUtilities::SessionReaderSharedPtr &pSession, const Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, const Array< OneD, Array< OneD, NekDouble > > &pTraceNormals, const Array< OneD, Array< OneD, NekDouble > > &pGridVelocity, const int pSpaceDim, const int bcRegion, const int cnt)
void v_Apply(Array< OneD, Array< OneD, NekDouble > > &Fwd, Array< OneD, Array< OneD, NekDouble > > &physarray, const NekDouble &time) override
Array< OneD, Array< OneD, NekDouble > > m_bcStorage
std::shared_ptr< SessionReader > SessionReaderSharedPtr
CFSBndCondFactory & GetCFSBndCondFactory()
Declaration of the boundary condition factory singleton.
Definition: CFSBndCond.cpp:41
double NekDouble
void Vmul(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x*y.
Definition: Vmath.hpp:72
void Vadd(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Add vector z = x+y.
Definition: Vmath.hpp:180
void Smul(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha*x.
Definition: Vmath.hpp:100
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.hpp:825
STL namespace.