Nektar++
PressureOutflowBC.cpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: PressureOutflowBC.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: Pressure outflow boundary condition
32//
33///////////////////////////////////////////////////////////////////////////////
34
35#include "PressureOutflowBC.h"
36
37using namespace std;
38
39namespace Nektar
40{
41
44 "PressureOutflow", PressureOutflowBC::create,
45 "Pressure outflow boundary condition.");
46
50 const Array<OneD, Array<OneD, NekDouble>> &pTraceNormals,
51 const Array<OneD, Array<OneD, NekDouble>> &pGridVelocity,
52 const int pSpaceDim, const int bcRegion, const int cnt)
53 : CFSBndCond(pSession, pFields, pTraceNormals, pGridVelocity, pSpaceDim,
54 bcRegion, cnt)
55{
56 int numBCPts =
57 m_fields[0]->GetBndCondExpansions()[m_bcRegion]->GetNpoints();
59
60 // Get Pressure
62 numBCPts,
63 m_fields[m_spacedim + 1]->GetBndCondExpansions()[m_bcRegion]->GetPhys(),
64 1, m_pressureStorage, 1);
65}
66
69 [[maybe_unused]] const NekDouble &time)
70{
71 int i, j;
72 int nTracePts = m_fields[0]->GetTrace()->GetNpoints();
73 int nVariables = physarray.size();
74 int nDimensions = m_spacedim;
75
76 const Array<OneD, const int> &traceBndMap = m_fields[0]->GetTraceBndMap();
77
78 // Computing the normal velocity for characteristics coming
79 // from inside the computational domain
80 Array<OneD, NekDouble> Vn(nTracePts, 0.0);
81 Array<OneD, NekDouble> Vel(nTracePts, 0.0);
82 for (i = 0; i < nDimensions; ++i)
83 {
84 Vmath::Vdiv(nTracePts, Fwd[i + 1], 1, Fwd[0], 1, Vel, 1);
85 Vmath::Vvtvp(nTracePts, m_traceNormals[i], 1, Vel, 1, Vn, 1, Vn, 1);
86 }
87
88 // Computing the absolute value of the velocity in order to compute the
89 // Mach number to decide whether supersonic or subsonic
90 Array<OneD, NekDouble> absVel(nTracePts, 0.0);
91 m_varConv->GetAbsoluteVelocity(Fwd, absVel);
92
93 // Get speed of sound
94 Array<OneD, NekDouble> soundSpeed(nTracePts);
95 m_varConv->GetSoundSpeed(Fwd, soundSpeed);
96
97 // Get Mach
98 Array<OneD, NekDouble> Mach(nTracePts, 0.0);
99 Vmath::Vdiv(nTracePts, Vn, 1, soundSpeed, 1, Mach, 1);
100 Vmath::Vabs(nTracePts, Mach, 1, Mach, 1);
101
102 // Auxiliary variables
103 int e, id1, id2, npts, pnt;
104 NekDouble rhoeb;
105
106 // Loop on the m_bcRegions
107 for (e = 0;
108 e < m_fields[0]->GetBndCondExpansions()[m_bcRegion]->GetExpSize(); ++e)
109 {
110 npts = m_fields[0]
111 ->GetBndCondExpansions()[m_bcRegion]
112 ->GetExp(e)
113 ->GetTotPoints();
114 id1 =
115 m_fields[0]->GetBndCondExpansions()[m_bcRegion]->GetPhys_Offset(e);
116 id2 =
117 m_fields[0]->GetTrace()->GetPhys_Offset(traceBndMap[m_offset + e]);
118
119 // Get internal energy
121 Array<OneD, NekDouble> rho(npts, Fwd[0] + id2);
122 Array<OneD, NekDouble> Ei(npts);
123 m_varConv->GetEFromRhoP(rho, pressure, Ei);
124
125 // Loop on points of m_bcRegion 'e'
126 for (i = 0; i < npts; i++)
127 {
128 pnt = id2 + i;
129
130 // Subsonic flows
131 if (Mach[pnt] < 0.99)
132 {
133 // Kinetic energy calculation
134 NekDouble Ek = 0.0;
135 for (j = 1; j < nVariables - 1; ++j)
136 {
137 Ek += 0.5 * (Fwd[j][pnt] * Fwd[j][pnt]) / Fwd[0][pnt];
138 }
139
140 rhoeb = Fwd[0][pnt] * Ei[i] + Ek;
141
142 // Partial extrapolation for subsonic cases
143 for (j = 0; j < nVariables - 1; ++j)
144 {
145 (m_fields[j]
146 ->GetBndCondExpansions()[m_bcRegion]
147 ->UpdatePhys())[id1 + i] = Fwd[j][pnt];
148 }
149
150 (m_fields[nVariables - 1]
151 ->GetBndCondExpansions()[m_bcRegion]
152 ->UpdatePhys())[id1 + i] = rhoeb;
153 }
154 // Supersonic flows
155 else
156 {
157 for (j = 0; j < nVariables; ++j)
158 {
159 // Extrapolation for supersonic cases
160 (m_fields[j]
161 ->GetBndCondExpansions()[m_bcRegion]
162 ->UpdatePhys())[id1 + i] = Fwd[j][pnt];
163 }
164 }
165 }
166 }
167}
168
169} // 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
Array< OneD, Array< OneD, NekDouble > > m_traceNormals
Trace normals.
Definition: CFSBndCond.h:94
int m_bcRegion
Id of the boundary region.
Definition: CFSBndCond.h:113
VariableConverterSharedPtr m_varConv
Auxiliary object to convert variables.
Definition: CFSBndCond.h:100
int m_offset
Offset.
Definition: CFSBndCond.h:115
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.
Array< OneD, NekDouble > m_pressureStorage
PressureOutflowBC(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)
static std::string className
Name of the class.
void v_Apply(Array< OneD, Array< OneD, NekDouble > > &Fwd, Array< OneD, Array< OneD, NekDouble > > &physarray, const NekDouble &time) override
std::shared_ptr< SessionReader > SessionReaderSharedPtr
CFSBndCondFactory & GetCFSBndCondFactory()
Declaration of the boundary condition factory singleton.
Definition: CFSBndCond.cpp:41
double NekDouble
void Vabs(int n, const T *x, const int incx, T *y, const int incy)
vabs: y = |x|
Definition: Vmath.hpp:352
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.hpp:366
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.hpp:126
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.hpp:825
STL namespace.