Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
IsentropicVortexBC.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: IsentropicVortexBC.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: Isentropic vortex boundary condition
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
36 #include "IsentropicVortexBC.h"
37 
38 using namespace std;
39 
40 namespace Nektar
41 {
42 
43 std::string IsentropicVortexBC::className = GetCFSBndCondFactory().
44  RegisterCreatorFunction("IsentropicVortex",
45  IsentropicVortexBC::create,
46  "Isentropic vortex boundary condition.");
47 
48 IsentropicVortexBC::IsentropicVortexBC(const LibUtilities::SessionReaderSharedPtr& pSession,
50  const Array<OneD, Array<OneD, NekDouble> >& pTraceNormals,
51  const int pSpaceDim,
52  const int bcRegion,
53  const int cnt)
54  : CFSBndCond(pSession, pFields, pTraceNormals, pSpaceDim, bcRegion, cnt)
55 {
56 }
57 
60  Array<OneD, Array<OneD, NekDouble> > &physarray,
61  const NekDouble &time)
62 {
63  int nvariables = physarray.num_elements();
64 
65  const Array<OneD, const int> &bndTraceMap = m_fields[0]->GetTraceBndMap();
66  // loop over Boundary Regions
67  int npoints, id1, id2, e_max;
68 
69  e_max = m_fields[0]->GetBndCondExpansions()[m_bcRegion]->GetExpSize();
70 
71  for(int e = 0; e < e_max; ++e)
72  {
73  npoints = m_fields[0]->
74  GetBndCondExpansions()[m_bcRegion]->GetExp(e)->GetTotPoints();
75  id1 = m_fields[0]->
76  GetBndCondExpansions()[m_bcRegion]->GetPhys_Offset(e);
77  id2 = m_fields[0]->GetTrace()->GetPhys_Offset(bndTraceMap[m_offset+e]);
78 
79  Array<OneD,NekDouble> x(npoints, 0.0);
80  Array<OneD,NekDouble> y(npoints, 0.0);
81  Array<OneD,NekDouble> z(npoints, 0.0);
82 
83  m_fields[0]->GetBndCondExpansions()[m_bcRegion]->
84  GetExp(e)->GetCoords(x, y, z);
85 
86  EvaluateIsentropicVortex(x, y, z, Fwd, time, id2);
87 
88  for (int i = 0; i < nvariables; ++i)
89  {
90  Vmath::Vcopy(npoints, &Fwd[i][id2], 1,
91  &(m_fields[i]->GetBndCondExpansions()[m_bcRegion]->
92  UpdatePhys())[id1], 1);
93  }
94  }
95 }
96 
98  const Array<OneD, NekDouble> &x,
99  const Array<OneD, NekDouble> &y,
100  const Array<OneD, NekDouble> &z,
102  NekDouble time,
103  const int o)
104 {
105  int nq = x.num_elements();
106 
107  // Flow parameters
108  const NekDouble x0 = 5.0;
109  const NekDouble y0 = 0.0;
110  const NekDouble beta = 5.0;
111  const NekDouble u0 = 1.0;
112  const NekDouble v0 = 0.5;
113  const NekDouble gamma = m_gamma;
114  NekDouble r, xbar, ybar, tmp;
115  NekDouble fac = 1.0/(16.0*gamma*M_PI*M_PI);
116 
117  // In 3D zero rhow field.
118  if (m_spacedim == 3)
119  {
120  Vmath::Zero(nq, &u[3][o], 1);
121  }
122 
123  // Fill storage
124  for (int i = 0; i < nq; ++i)
125  {
126  xbar = x[i] - u0*time - x0;
127  ybar = y[i] - v0*time - y0;
128  r = sqrt(xbar*xbar + ybar*ybar);
129  tmp = beta*exp(1-r*r);
130  u[0][i+o] = pow(1.0 - (gamma-1.0)*tmp*tmp*fac, 1.0/(gamma-1.0));
131  u[1][i+o] = u[0][i+o]*(u0 - tmp*ybar/(2*M_PI));
132  u[2][i+o] = u[0][i+o]*(v0 + tmp*xbar/(2*M_PI));
133  u[m_spacedim+1][i+o] = pow(u[0][i+o], gamma)/(gamma-1.0) +
134  0.5*(u[1][i+o]*u[1][i+o] + u[2][i+o]*u[2][i+o]) / u[0][i+o];
135  }
136 }
137 
138 }
int m_spacedim
Space dimension.
Definition: CFSBndCond.h:90
void EvaluateIsentropicVortex(const Array< OneD, NekDouble > &x, const Array< OneD, NekDouble > &y, const Array< OneD, NekDouble > &z, Array< OneD, Array< OneD, NekDouble > > &u, NekDouble time, const int o=0)
STL namespace.
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array of fields.
Definition: CFSBndCond.h:86
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
Definition: MeshPartition.h:51
CFSBndCondFactory & GetCFSBndCondFactory()
Declaration of the boundary condition factory singleton.
Definition: CFSBndCond.cpp:42
virtual void v_Apply(Array< OneD, Array< OneD, NekDouble > > &Fwd, Array< OneD, Array< OneD, NekDouble > > &physarray, const NekDouble &time)
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
int m_offset
Offset.
Definition: CFSBndCond.h:103
void Zero(int n, T *x, const int incx)
Zero vector.
Definition: Vmath.cpp:373
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1061
int m_bcRegion
Id of the boundary region.
Definition: CFSBndCond.h:101