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 
36 #include <boost/core/ignore_unused.hpp>
37 
39 
40 using namespace std;
41 
42 namespace Nektar
43 {
44 
45 std::string PressureMachTemperatureBC::className = GetCFSBndCondFactory().
46  RegisterCreatorFunction("PressureMachTemperature",
47  PressureMachTemperatureBC::create,
48  "BC prescribed in terms of p, Ma and T.");
49 
50 PressureMachTemperatureBC::PressureMachTemperatureBC(
53  const Array<OneD, Array<OneD, NekDouble> >& pTraceNormals,
54  const int pSpaceDim,
55  const int bcRegion,
56  const int cnt)
57  : CFSBndCond(pSession, pFields, pTraceNormals, pSpaceDim, bcRegion, cnt)
58 {
59  int nvariables = m_fields.size();
60  int numBCPts = m_fields[0]->
61  GetBndCondExpansions()[m_bcRegion]->GetNpoints();
62 
63  // Array for storing conserved variables on the boundary
65  for (int i = 0; i < nvariables; ++i)
66  {
67  m_bcStorage[i] = Array<OneD, NekDouble> (numBCPts, 0.0);
68  }
69 
70  // We assume that the pressure is given in entry [0] of
71  // the BC ("rho" position) and the temperature in entry m_spacedim+1
72  // ("E" position)
74  m_fields[0]->GetBndCondExpansions()[m_bcRegion]->GetPhys();
75  const Array<OneD, const NekDouble> temperature =
76  m_fields[m_spacedim+1]->GetBndCondExpansions()[m_bcRegion]->GetPhys();
77 
78  // Calculate density
79  m_varConv->GetRhoFromPT(pressure, temperature, m_bcStorage[0]);
80  // Calculate the internal energy times density
81  m_varConv->GetEFromRhoP(m_bcStorage[0], pressure,
83  Vmath::Vmul(numBCPts, m_bcStorage[m_spacedim+1], 1,
84  m_bcStorage[0], 1,
85  m_bcStorage[m_spacedim+1], 1);
86  // We can now obtain the sound speed at this (rho,e) condition
87  Array<OneD, NekDouble> soundSpeed (numBCPts);
88  m_varConv->GetSoundSpeed(m_bcStorage, soundSpeed);
89 
90  // Now update momentum and add kinetic energy to E
91  Array<OneD, NekDouble> tmp (numBCPts);
92  for (int i = 0; i < m_spacedim; ++i)
93  {
94  // tmp = velocity in i direction
95  Vmath::Vmul(numBCPts,
96  m_fields[i+1]->GetBndCondExpansions()[m_bcRegion]->GetPhys(), 1,
97  soundSpeed, 1,
98  tmp, 1);
99  // rho*u
100  Vmath::Vmul(numBCPts,
101  m_bcStorage[0], 1,
102  tmp, 1,
103  m_bcStorage[i+1], 1);
104  // tmp = 0.5 * rho *(rhou) in vel
105  Vmath::Vmul(numBCPts,
106  m_bcStorage[i+1], 1,
107  tmp, 1,
108  tmp, 1);
109  Vmath::Smul(numBCPts,
110  0.5,
111  tmp, 1,
112  tmp, 1);
113  // Add to E
114  Vmath::Vadd(numBCPts,
115  m_bcStorage[m_spacedim+1], 1,
116  tmp, 1,
117  m_bcStorage[m_spacedim+1], 1);
118  }
119 
120  // Copy to boundary condition
121  for (int i = 0; i < nvariables; ++i)
122  {
123  Vmath::Vcopy(
124  numBCPts,
125  m_bcStorage[i], 1,
126  m_fields[i]->GetBndCondExpansions()[m_bcRegion]->UpdatePhys(), 1);
127  }
128 }
129 
132  Array<OneD, Array<OneD, NekDouble> > &physarray,
133  const NekDouble &time)
134 {
135  boost::ignore_unused(Fwd, physarray, time);
136 
137  int nvariables = m_fields.size();
138  int numBCPts = m_fields[0]->
139  GetBndCondExpansions()[m_bcRegion]->GetNpoints();
140  // Copy conserved variables to boundary condition
141  for (int i = 0; i < nvariables; ++i)
142  {
143  Vmath::Vcopy(
144  numBCPts,
145  m_bcStorage[i], 1,
146  m_fields[i]->GetBndCondExpansions()[m_bcRegion]->UpdatePhys(), 1);
147  }
148 }
149 
150 }
Encapsulates the user-defined boundary conditions for compressible flow solver.
Definition: CFSBndCond.h:71
int m_spacedim
Space dimension.
Definition: CFSBndCond.h:95
int m_bcRegion
Id of the boundary region.
Definition: CFSBndCond.h:109
VariableConverterSharedPtr m_varConv
Auxiliary object to convert variables.
Definition: CFSBndCond.h:97
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array of fields.
Definition: CFSBndCond.h:91
Array< OneD, Array< OneD, NekDouble > > m_bcStorage
virtual void v_Apply(Array< OneD, Array< OneD, NekDouble > > &Fwd, Array< OneD, Array< OneD, NekDouble > > &physarray, const NekDouble &time)
std::shared_ptr< SessionReader > SessionReaderSharedPtr
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:1
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.cpp:192
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.cpp:322
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.cpp:225
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1199