Nektar++
WallViscousBC.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: WallViscousBC.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: No-slip wall boundary condition
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #include <boost/core/ignore_unused.hpp>
36 
37 #include "WallViscousBC.h"
38 
39 using namespace std;
40 
41 namespace Nektar
42 {
43 
44 std::string WallViscousBC::classNameViscous = GetCFSBndCondFactory().
45  RegisterCreatorFunction("WallViscous",
46  WallViscousBC::create,
47  "No-slip (viscous) wall boundary condition.");
48 
49 std::string WallViscousBC::classNameAdiabatic = GetCFSBndCondFactory().
50  RegisterCreatorFunction("WallAdiabatic",
51  WallViscousBC::create,
52  "Adiabatic wall boundary condition.");
53 
54 WallViscousBC::WallViscousBC(const LibUtilities::SessionReaderSharedPtr& pSession,
56  const Array<OneD, Array<OneD, NekDouble> >& pTraceNormals,
57  const int pSpaceDim,
58  const int bcRegion,
59  const int cnt)
60  : CFSBndCond(pSession, pFields, pTraceNormals, pSpaceDim, bcRegion, cnt)
61 {
63 
65 }
66 
69  Array<OneD, Array<OneD, NekDouble> > &physarray,
70  const NekDouble &time)
71 {
72  boost::ignore_unused(time);
73 
74  int i;
75  int nVariables = physarray.size();
76 
77  // Find the fields whose WallViscous/Adiabatic-BC is time-dependent
78  // Update variables on the boundaries of these fields
79  // Get the updated variables on the WallViscous/Adiabatic boundary
80  //
81  // Maybe the EvaluateBoundaryConditions() should be put upstream to
82  // CompressibleFlowSystem::NumCalRiemFluxJac(), So that the BCs will not
83  // be repeatedly updated when there are more than one time-dependent BC.
84  std::string varName;
85  for (i = 0; i < nVariables; ++i)
86  {
87  if (m_fields[i]->GetBndConditions()[m_bcRegion]->IsTimeDependent())
88  {
89  varName = m_session->GetVariable(i);
90  m_fields[i]->EvaluateBoundaryConditions(time, varName);
91 
92  m_bndPhys[i] = m_fields[i]->GetBndCondExpansions()[m_bcRegion]
93  ->UpdatePhys();
94  }
95  }
96 
97 
98  const Array<OneD, const int> &traceBndMap
99  = m_fields[0]->GetTraceBndMap();
100 
101  // Take into account that for PDE based shock capturing, eps = 0 at the
102  // wall. Adjust the physical values of the trace to take user defined
103  // boundaries into account
104  int e, id1, id2, nBCEdgePts, eMax;
105 
106  eMax = m_fields[0]->GetBndCondExpansions()[m_bcRegion]->GetExpSize();
107 
108  for (e = 0; e < eMax; ++e)
109  {
110  nBCEdgePts = m_fields[0]->GetBndCondExpansions()[m_bcRegion]->
111  GetExp(e)->GetTotPoints();
112  id1 = m_fields[0]->GetBndCondExpansions()[m_bcRegion]->
113  GetPhys_Offset(e);
114  id2 = m_fields[0]->GetTrace()->GetPhys_Offset(traceBndMap[m_offset+e]);
115 
116  // Boundary condition for epsilon term.
117  if (nVariables == m_spacedim+3)
118  {
119  Vmath::Zero(nBCEdgePts, &Fwd[nVariables-1][id2], 1);
120  }
121 
122  // V = - Vin
123  for (i = 0; i < m_spacedim; i++)
124  {
125  Vmath::Neg(nBCEdgePts, &Fwd[i+1][id2], 1);
126  }
127 
128  // Superimpose the perturbation
129  for (i = 0; i < nVariables; ++i)
130  {
131  if (m_fields[i]->GetBndConditions()[m_bcRegion]->IsTimeDependent())
132  {
133  Vmath::Vadd(nBCEdgePts, &m_bndPhys[i][id1], 1,
134  &Fwd[i][id2], 1, &Fwd[i][id2], 1);
135  }
136  }
137 
138  // Copy boundary adjusted values into the boundary expansion
139  for (i = 0; i < nVariables; ++i)
140  {
141  Vmath::Vcopy(nBCEdgePts, &Fwd[i][id2], 1,
142  &(m_fields[i]->GetBndCondExpansions()[m_bcRegion]->
143  UpdatePhys())[id1], 1);
144  }
145  }
146 }
147 
148 }
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
LibUtilities::SessionReaderSharedPtr m_session
Session reader.
Definition: CFSBndCond.h:89
int m_spacedim
Space dimension.
Definition: CFSBndCond.h:95
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
Array< OneD, Array< OneD, NekDouble > > m_bndPhys
Definition: WallViscousBC.h:74
virtual void v_Apply(Array< OneD, Array< OneD, NekDouble > > &Fwd, Array< OneD, Array< OneD, NekDouble > > &physarray, const NekDouble &time)
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 Neg(int n, T *x, const int incx)
Negate x = -x.
Definition: Vmath.cpp:461
void Vadd(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Add vector z = x+y.
Definition: Vmath.cpp:322
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