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 "WallViscousBC.h"
36
37namespace Nektar
38{
39
42 "WallViscous", WallViscousBC::create,
43 "No-slip (viscous) wall boundary condition.");
44
47 "WallAdiabatic", WallViscousBC::create,
48 "Adiabatic wall boundary condition.");
49
53 const Array<OneD, Array<OneD, NekDouble>> &pTraceNormals,
54 const Array<OneD, Array<OneD, NekDouble>> &pGridVelocity,
55 const int pSpaceDim, const int bcRegion, const int cnt)
56 : CFSBndCond(pSession, pFields, pTraceNormals, pGridVelocity, pSpaceDim,
57 bcRegion, cnt)
58{
60
62}
63
66 [[maybe_unused]] const NekDouble &time)
67{
68 int i;
69 int nVariables = physarray.size();
70
71 // Find the fields whose WallViscous/Adiabatic-BC is time-dependent
72 // Update variables on the boundaries of these fields
73 // Get the updated variables on the WallViscous/Adiabatic boundary
74 //
75 // Maybe the EvaluateBoundaryConditions() should be put upstream to
76 // CompressibleFlowSystem::NumCalRiemFluxJac(), So that the BCs will not
77 // be repeatedly updated when there are more than one time-dependent BC.
78 std::string varName;
79 for (i = 0; i < nVariables; ++i)
80 {
81 if (m_fields[i]->GetBndConditions()[m_bcRegion]->IsTimeDependent())
82 {
83 varName = m_session->GetVariable(i);
84 m_fields[i]->EvaluateBoundaryConditions(time, varName);
85
86 m_bndPhys[i] =
87 m_fields[i]->GetBndCondExpansions()[m_bcRegion]->UpdatePhys();
88 }
89 }
90
91 const Array<OneD, const int> &traceBndMap = m_fields[0]->GetTraceBndMap();
92
93 // Take into account that for PDE based shock capturing, eps = 0 at the
94 // wall. Adjust the physical values of the trace to take user defined
95 // boundaries into account
96 int e, id1, id2, nBCEdgePts, eMax;
97
98 eMax = m_fields[0]->GetBndCondExpansions()[m_bcRegion]->GetExpSize();
99
100 for (e = 0; e < eMax; ++e)
101 {
102 nBCEdgePts = m_fields[0]
103 ->GetBndCondExpansions()[m_bcRegion]
104 ->GetExp(e)
105 ->GetTotPoints();
106 id1 =
107 m_fields[0]->GetBndCondExpansions()[m_bcRegion]->GetPhys_Offset(e);
108 id2 =
109 m_fields[0]->GetTrace()->GetPhys_Offset(traceBndMap[m_offset + e]);
110
111 // Boundary condition for epsilon term.
112 if (nVariables == m_spacedim + 3)
113 {
114 Vmath::Zero(nBCEdgePts, &Fwd[nVariables - 1][id2], 1);
115 }
116
117 // V = - Vin
118 for (i = 0; i < m_spacedim; i++)
119 {
120 // V = -Vin
121 // Vmath::Neg(nBCEdgePts, &Fwd[i+1][id2], 1);
122
123 // This now does Vg * rho + Vin
124 // Vmath::Vvtvp(nBCEdgePts, &m_gridVelocityTrace[i][id2], 1,
125 // &Fwd[0][id2], 1, &Fwd[i+1][id2], 1, &Fwd[i+1][id2], 1);
126
127 for (int j = 0; j < nBCEdgePts; ++j)
128 {
129 Fwd[i + 1][id2 + j] =
130 2 * m_gridVelocityTrace[i][id2 + j] * Fwd[0][id2 + j] -
131 Fwd[i + 1][id2 + j];
132 }
133 }
134
135 // Superimpose the perturbation
136 for (i = 0; i < nVariables; ++i)
137 {
138 if (m_fields[i]->GetBndConditions()[m_bcRegion]->IsTimeDependent())
139 {
140 Vmath::Vadd(nBCEdgePts, &m_bndPhys[i][id1], 1, &Fwd[i][id2], 1,
141 &Fwd[i][id2], 1);
142 }
143 }
144
145 // Copy boundary adjusted values into the boundary expansion
146 for (i = 0; i < nVariables; ++i)
147 {
148 Vmath::Vcopy(nBCEdgePts, &Fwd[i][id2], 1,
149 &(m_fields[i]
150 ->GetBndCondExpansions()[m_bcRegion]
151 ->UpdatePhys())[id1],
152 1);
153 }
154 }
155}
156
157} // namespace Nektar
Encapsulates the user-defined boundary conditions for compressible flow solver.
Definition: CFSBndCond.h:72
NekDouble m_diffusionAveWeight
Weight for average calculation of diffusion term.
Definition: CFSBndCond.h:102
LibUtilities::SessionReaderSharedPtr m_session
Session reader.
Definition: CFSBndCond.h:90
int m_spacedim
Space dimension.
Definition: CFSBndCond.h:98
Array< OneD, Array< OneD, NekDouble > > m_gridVelocityTrace
Grid Velocity.
Definition: CFSBndCond.h:96
int m_bcRegion
Id of the boundary region.
Definition: CFSBndCond.h:113
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 std::string classNameAdiabatic
Definition: WallViscousBC.h:67
Array< OneD, Array< OneD, NekDouble > > m_bndPhys
Definition: WallViscousBC.h:72
void v_Apply(Array< OneD, Array< OneD, NekDouble > > &Fwd, Array< OneD, Array< OneD, NekDouble > > &physarray, const NekDouble &time) override
WallViscousBC(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 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.
Definition: WallViscousBC.h:52
static std::string classNameViscous
Name of the class.
Definition: WallViscousBC.h:66
std::shared_ptr< SessionReader > SessionReaderSharedPtr
CFSBndCondFactory & GetCFSBndCondFactory()
Declaration of the boundary condition factory singleton.
Definition: CFSBndCond.cpp:40
double NekDouble
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.hpp:180
void Zero(int n, T *x, const int incx)
Zero vector.
Definition: Vmath.hpp:273
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
Definition: Vmath.hpp:825