Nektar++
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 // 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: Isentropic vortex boundary condition
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #include <boost/core/ignore_unused.hpp>
36 
37 #include "IsentropicVortexBC.h"
38 
39 using namespace std;
40 
41 namespace Nektar
42 {
43 
44 std::string IsentropicVortexBC::className = GetCFSBndCondFactory().
45  RegisterCreatorFunction("IsentropicVortex",
46  IsentropicVortexBC::create,
47  "Isentropic vortex boundary condition.");
48 
49 IsentropicVortexBC::IsentropicVortexBC(const LibUtilities::SessionReaderSharedPtr& pSession,
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 }
58 
61  Array<OneD, Array<OneD, NekDouble> > &physarray,
62  const NekDouble &time)
63 {
64  int nvariables = physarray.size();
65 
66  const Array<OneD, const int> &bndTraceMap = m_fields[0]->GetTraceBndMap();
67  // loop over Boundary Regions
68  int npoints, id1, id2, e_max;
69 
70  e_max = m_fields[0]->GetBndCondExpansions()[m_bcRegion]->GetExpSize();
71 
72  for(int e = 0; e < e_max; ++e)
73  {
74  npoints = m_fields[0]->
75  GetBndCondExpansions()[m_bcRegion]->GetExp(e)->GetTotPoints();
76  id1 = m_fields[0]->
77  GetBndCondExpansions()[m_bcRegion]->GetPhys_Offset(e);
78  id2 = m_fields[0]->GetTrace()->GetPhys_Offset(bndTraceMap[m_offset+e]);
79 
80  Array<OneD,NekDouble> x(npoints, 0.0);
81  Array<OneD,NekDouble> y(npoints, 0.0);
82  Array<OneD,NekDouble> z(npoints, 0.0);
83 
84  m_fields[0]->GetBndCondExpansions()[m_bcRegion]->
85  GetExp(e)->GetCoords(x, y, z);
86 
87  EvaluateIsentropicVortex(x, y, z, Fwd, time, id2);
88 
89  for (int i = 0; i < nvariables; ++i)
90  {
91  Vmath::Vcopy(npoints, &Fwd[i][id2], 1,
92  &(m_fields[i]->GetBndCondExpansions()[m_bcRegion]->
93  UpdatePhys())[id1], 1);
94  }
95  }
96 }
97 
99  const Array<OneD, NekDouble> &x,
100  const Array<OneD, NekDouble> &y,
101  const Array<OneD, NekDouble> &z,
103  NekDouble time,
104  const int o)
105 {
106  boost::ignore_unused(z);
107 
108  int nq = x.size();
109 
110  // Flow parameters
111  const NekDouble x0 = 5.0;
112  const NekDouble y0 = 0.0;
113  const NekDouble beta = 5.0;
114  const NekDouble u0 = 1.0;
115  const NekDouble v0 = 0.5;
116  const NekDouble gamma = m_gamma;
117  NekDouble r, xbar, ybar, tmp;
118  NekDouble fac = 1.0/(16.0*gamma*M_PI*M_PI);
119 
120  // In 3D zero rhow field.
121  if (m_spacedim == 3)
122  {
123  Vmath::Zero(nq, &u[3][o], 1);
124  }
125 
126  // Fill storage
127  for (int i = 0; i < nq; ++i)
128  {
129  xbar = x[i] - u0*time - x0;
130  ybar = y[i] - v0*time - y0;
131  r = sqrt(xbar*xbar + ybar*ybar);
132  tmp = beta*exp(1-r*r);
133  u[0][i+o] = pow(1.0 - (gamma-1.0)*tmp*tmp*fac, 1.0/(gamma-1.0));
134  u[1][i+o] = u[0][i+o]*(u0 - tmp*ybar/(2*M_PI));
135  u[2][i+o] = u[0][i+o]*(v0 + tmp*xbar/(2*M_PI));
136  u[m_spacedim+1][i+o] = pow(u[0][i+o], gamma)/(gamma-1.0) +
137  0.5*(u[1][i+o]*u[1][i+o] + u[2][i+o]*u[2][i+o]) / u[0][i+o];
138  }
139 }
140 
141 }
Encapsulates the user-defined boundary conditions for compressible flow solver.
Definition: CFSBndCond.h:71
int m_spacedim
Space dimension.
Definition: CFSBndCond.h:95
NekDouble m_gamma
Parameters of the flow.
Definition: CFSBndCond.h:102
int m_bcRegion
Id of the boundary region.
Definition: CFSBndCond.h:109
int m_offset
Offset.
Definition: CFSBndCond.h:111
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Array of fields.
Definition: CFSBndCond.h:91
virtual void v_Apply(Array< OneD, Array< OneD, NekDouble > > &Fwd, Array< OneD, Array< OneD, NekDouble > > &physarray, const NekDouble &time)
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)
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 Zero(int n, T *x, const int incx)
Zero vector.
Definition: Vmath.cpp:436
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.cpp:1199
scalarT< T > sqrt(scalarT< T > in)
Definition: scalar.hpp:267