Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PressureOutflowFileBC.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: PressureOutflowFileBC.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 // License for the specific language governing rights and limitations under
14 // Permission is hereby granted, free of charge, to any person obtaining a
15 // copy of this software and associated documentation files (the "Software"),
16 // to deal in the Software without restriction, including without limitation
17 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 // and/or sell copies of the Software, and to permit persons to whom the
19 // Software is furnished to do so, subject to the following conditions:
20 //
21 // The above copyright notice and this permission notice shall be included
22 // in all copies or substantial portions of the Software.
23 //
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30 // DEALINGS IN THE SOFTWARE.
31 //
32 // Description: Pressure outflow boundary condition
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
36 #include "PressureOutflowFileBC.h"
37 
38 using namespace std;
39 
40 namespace Nektar
41 {
42 
43 std::string PressureOutflowFileBC::className = GetCFSBndCondFactory().
44  RegisterCreatorFunction("PressureOutflowFile",
45  PressureOutflowFileBC::create,
46  "Pressure outflow (file) boundary condition.");
47 
48 PressureOutflowFileBC::PressureOutflowFileBC(
51  const Array<OneD, Array<OneD, NekDouble> >& pTraceNormals,
52  const int pSpaceDim,
53  const int bcRegion,
54  const int cnt)
55  : CFSBndCond(pSession, pFields, pTraceNormals, pSpaceDim, bcRegion, cnt)
56 {
57  int nvariables = m_fields.num_elements();
58  // Loop over Boundary Regions for PressureOutflowFileBC
59 
60  Array<OneD, Array<OneD, NekDouble> > tmpStorage(nvariables);
61 
62  int numBCPts = m_fields[0]->
63  GetBndCondExpansions()[m_bcRegion]->GetNpoints();
65  for (int i = 0; i < nvariables; ++i)
66  {
67  tmpStorage[i] = Array<OneD, NekDouble>(numBCPts, 0.0);
68 
70  numBCPts,
71  m_fields[i]->GetBndCondExpansions()[m_bcRegion]->GetPhys(), 1,
72  tmpStorage[i], 1);
73  }
74 
75  // Get Pressure
76  m_pressureStorage = Array<OneD, NekDouble> (numBCPts, 0.0);
77  m_varConv->GetPressure(tmpStorage, m_pressureStorage);
78 }
79 
82  Array<OneD, Array<OneD, NekDouble> > &physarray,
83  const NekDouble &time)
84 {
85  int i, j;
86  int nTracePts = m_fields[0]->GetTrace()->GetNpoints();
87  int nVariables = physarray.num_elements();
88  int nDimensions = m_spacedim;
89 
90  const Array<OneD, const int> &traceBndMap
91  = m_fields[0]->GetTraceBndMap();
92 
93  NekDouble gammaMinusOne = m_gamma - 1.0;
94  NekDouble gammaMinusOneInv = 1.0 / gammaMinusOne;
95 
96  // Computing the normal velocity for characteristics coming
97  // from inside the computational domain
98  Array<OneD, NekDouble > Vn (nTracePts, 0.0);
99  Array<OneD, NekDouble > Vel(nTracePts, 0.0);
100  for (i = 0; i < nDimensions; ++i)
101  {
102  Vmath::Vdiv(nTracePts, Fwd[i+1], 1, Fwd[0], 1, Vel, 1);
103  Vmath::Vvtvp(nTracePts, m_traceNormals[i], 1, Vel, 1, Vn, 1, Vn, 1);
104  }
105 
106  // Computing the absolute value of the velocity in order to compute the
107  // Mach number to decide whether supersonic or subsonic
108  Array<OneD, NekDouble > absVel(nTracePts, 0.0);
109  m_varConv->GetAbsoluteVelocity(Fwd, absVel);
110 
111  // Get speed of sound
112  Array<OneD, NekDouble > pressure (nTracePts);
113  Array<OneD, NekDouble > soundSpeed(nTracePts);
114 
115  m_varConv->GetPressure(Fwd, pressure);
116  m_varConv->GetSoundSpeed(Fwd, pressure, soundSpeed);
117 
118  // Get Mach
119  Array<OneD, NekDouble > Mach(nTracePts, 0.0);
120  Vmath::Vdiv(nTracePts, Vn, 1, soundSpeed, 1, Mach, 1);
121  Vmath::Vabs(nTracePts, Mach, 1, Mach, 1);
122 
123  // Auxiliary variables
124  int e, id1, id2, npts, pnt;
125  NekDouble rhoeb;
126 
127  // Loop on the m_bcRegions
128  for (e = 0; e < m_fields[0]->GetBndCondExpansions()[m_bcRegion]->
129  GetExpSize(); ++e)
130  {
131  npts = m_fields[0]->GetBndCondExpansions()[m_bcRegion]->
132  GetExp(e)->GetTotPoints();
133  id1 = m_fields[0]->GetBndCondExpansions()[m_bcRegion]->
134  GetPhys_Offset(e);
135  id2 = m_fields[0]->GetTrace()->GetPhys_Offset(traceBndMap[m_offset+e]);
136 
137  // Loop on points of m_bcRegion 'e'
138  for (i = 0; i < npts; i++)
139  {
140  pnt = id2+i;
141 
142  // Subsonic flows
143  if (Mach[pnt] < 0.99)
144  {
145  // Kinetic energy calculation
146  NekDouble Ek = 0.0;
147  for (j = 1; j < nVariables-1; ++j)
148  {
149  Ek += 0.5 * (Fwd[j][pnt] * Fwd[j][pnt]) / Fwd[0][pnt];
150  }
151 
152  rhoeb = m_pressureStorage[id1+i] * gammaMinusOneInv + Ek;
153 
154  // Partial extrapolation for subsonic cases
155  for (j = 0; j < nVariables-1; ++j)
156  {
157  (m_fields[j]->GetBndCondExpansions()[m_bcRegion]->
158  UpdatePhys())[id1+i] = Fwd[j][pnt];
159  }
160 
161  (m_fields[nVariables-1]->GetBndCondExpansions()[m_bcRegion]->
162  UpdatePhys())[id1+i] = rhoeb;
163  }
164  // Supersonic flows
165  else
166  {
167  for (j = 0; j < nVariables; ++j)
168  {
169  // Extrapolation for supersonic cases
170  (m_fields[j]->GetBndCondExpansions()[m_bcRegion]->
171  UpdatePhys())[id1+i] = Fwd[j][pnt];
172  }
173  }
174  }
175  }
176 }
177 
178 }
int m_spacedim
Space dimension.
Definition: CFSBndCond.h:90
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
Definition: Vmath.cpp:442
STL namespace.
void Vdiv(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:241
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array of fields.
Definition: CFSBndCond.h:86
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
Definition: MeshPartition.h:51
void Vabs(int n, const T *x, const int incx, T *y, const int incy)
vabs: y = |x|
Definition: Vmath.cpp:424
CFSBndCondFactory & GetCFSBndCondFactory()
Declaration of the boundary condition factory singleton.
Definition: CFSBndCond.cpp:42
Array< OneD, NekDouble > m_pressureStorage
static std::string npts
Definition: InputFld.cpp:43
Encapsulates the user-defined boundary conditions for compressible flow solver.
Definition: CFSBndCond.h:71
double NekDouble
NekDouble m_gamma
Parameters of the flow.
Definition: CFSBndCond.h:95
VariableConverterSharedPtr m_varConv
Auxiliary object to convert variables.
Definition: CFSBndCond.h:92
int m_offset
Offset.
Definition: CFSBndCond.h:103
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1061
Array< OneD, Array< OneD, NekDouble > > m_traceNormals
Trace normals.
Definition: CFSBndCond.h:88
virtual void v_Apply(Array< OneD, Array< OneD, NekDouble > > &Fwd, Array< OneD, Array< OneD, NekDouble > > &physarray, const NekDouble &time)
int m_bcRegion
Id of the boundary region.
Definition: CFSBndCond.h:101