Nektar++
WallBC.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: WallBC.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: Slip wall boundary condition
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #include <boost/core/ignore_unused.hpp>
36 
37 #include "WallBC.h"
38 
39 using namespace std;
40 
41 namespace Nektar
42 {
43 
44 std::string WallBC::className = GetCFSBndCondFactory().
45  RegisterCreatorFunction("Wall",
46  WallBC::create,
47  "Slip wall boundary condition.");
48 
49 WallBC::WallBC(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 {
58 }
59 
62  Array<OneD, Array<OneD, NekDouble> > &physarray,
63  const NekDouble &time)
64 {
65  boost::ignore_unused(time);
66 
67  int i;
68  int nVariables = physarray.size();
69 
70  const Array<OneD, const int> &traceBndMap
71  = m_fields[0]->GetTraceBndMap();
72 
73  // Adjust the physical values of the trace to take
74  // user defined boundaries into account
75  int e, id1, id2, nBCEdgePts, eMax;
76 
77  eMax = m_fields[0]->GetBndCondExpansions()[m_bcRegion]->GetExpSize();
78 
79  for (e = 0; e < eMax; ++e)
80  {
81  nBCEdgePts = m_fields[0]->GetBndCondExpansions()[m_bcRegion]->
82  GetExp(e)->GetTotPoints();
83  id1 = m_fields[0]->GetBndCondExpansions()[m_bcRegion]->
84  GetPhys_Offset(e);
85  id2 = m_fields[0]->GetTrace()->GetPhys_Offset(traceBndMap[m_offset+e]);
86 
87  // Boundary condition for epsilon term.
88  if (nVariables == m_spacedim+3)
89  {
90  Vmath::Zero(nBCEdgePts, &Fwd[nVariables-1][id2], 1);
91  }
92 
93  // For 2D/3D, define: v* = v - 2(v.n)n
94  Array<OneD, NekDouble> tmp(nBCEdgePts, 0.0);
95 
96  // Calculate (v.n)
97  for (i = 0; i < m_spacedim; ++i)
98  {
99  Vmath::Vvtvp(nBCEdgePts,
100  &Fwd[1+i][id2], 1,
101  &m_traceNormals[i][id2], 1,
102  &tmp[0], 1,
103  &tmp[0], 1);
104  }
105 
106  // Calculate 2.0(v.n)
107  Vmath::Smul(nBCEdgePts, -2.0, &tmp[0], 1, &tmp[0], 1);
108 
109  // Calculate v* = v - 2.0(v.n)n
110  for (i = 0; i < m_spacedim; ++i)
111  {
112  Vmath::Vvtvp(nBCEdgePts,
113  &tmp[0], 1,
114  &m_traceNormals[i][id2], 1,
115  &Fwd[1+i][id2], 1,
116  &Fwd[1+i][id2], 1);
117  }
118 
119  // Copy boundary adjusted values into the boundary expansion
120  for (i = 0; i < nVariables; ++i)
121  {
122  Vmath::Vcopy(nBCEdgePts, &Fwd[i][id2], 1,
123  &(m_fields[i]->GetBndCondExpansions()[m_bcRegion]->
124  UpdatePhys())[id1], 1);
125  }
126  }
127 }
128 
129 }
Encapsulates the user-defined boundary conditions for compressible flow solver.
Definition: CFSBndCond.h:71
NekDouble m_diffusionAveWeight
Weight for average calculation of diffusion term.
Definition: CFSBndCond.h:99
int m_spacedim
Space dimension.
Definition: CFSBndCond.h:95
Array< OneD, Array< OneD, NekDouble > > m_traceNormals
Trace normals.
Definition: CFSBndCond.h:93
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)
Definition: WallBC.cpp:60
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 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:513
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 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