Nektar++
WeakPressureExtrapolate.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: WeakPressureExtrapolate.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: Abstract base class for WeakPressureExtrapolate.
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
37 
38 namespace Nektar
39 {
40 /**
41  * Registers the class with the Factory.
42  */
45  "WeakPressure", WeakPressureExtrapolate::create, "WeakPressure");
46 
51  const SolverUtils::AdvectionSharedPtr advObject)
52  : StandardExtrapolate(pSession, pFields, pPressure, pVel, advObject)
53 {
54 }
55 
57 {
58 }
59 
60 /**
61  * Function to extrapolate the new pressure boundary condition.
62  * Based on the velocity field and on the advection term.
63  * Acceleration term is also computed. This routine is a general
64  * one for 2d and 3D application and it can be called directly
65  * from velocity correction scheme. Specialisation on
66  * dimensionality is redirected to the CalcNeumannPressureBCs
67  * method.
68  */
70  const Array<OneD, const Array<OneD, NekDouble>> &fields,
71  const Array<OneD, const Array<OneD, NekDouble>> &N, NekDouble kinvis)
72 {
74  if (m_HBCnumber > 0)
75  {
76  // Calculate just viscous BCs at current level and put in
77  // m_pressureHBCs[nlevels-1]
78  CalcNeumannPressureBCs(fields, N, kinvis);
79 
80  // Extrapolate to m_pressureHBCs to n+1
82 
83  // \int_bnd q n.u^{n} ds update current normal of field
84  // add m_pressureHBCs to gamma_0/Dt * m_acceleration[0]
85  AddVelBC();
86 
87  // Copy m_pressureHBCs to m_PbndExp
89  }
90 
91  // Evaluate High order outflow conditions if required.
92  CalcOutflowBCs(fields, kinvis);
93 }
94 
95 // In weak pressure formulation we also require \int q u.n ds on
96 // outflow boundary
98  const int noutflow, const int nreg, Array<OneD, Array<OneD, NekDouble>> &u)
99 {
100  boost::ignore_unused(noutflow);
101 
102  if (!m_houtflow.get()) // no outflow on partition so just return
103  {
104  return;
105  }
106 
107  int nbcoeffs = m_PBndExp[nreg]->GetNcoeffs();
108  // int nqb = m_PBndExp[nreg]->GetTotPoints();
109 
110  Array<OneD, NekDouble> IProdVnTmp(nbcoeffs);
111 
112 #if 0
114 
115  for(int i = 0; i < m_curl_dim; ++i)
116  {
117  EvaluateBDFArray(m_houtflow->m_outflowVelBnd[noutflow][i]);
118 
119  ubnd[i] = m_houtflow->m_outflowVelBnd[noutflow][i][m_intSteps-1];
120 
121  // point input u to the first part of the array for later uee.
122  // u[i] = m_houtflow->m_outflowVelBnd[noutflow][i][0];
123  u[i] = ubnd[i];
124  }
125 
126  m_PBndExp[nreg]->NormVectorIProductWRTBase(ubnd,IProdVnTmp);
127 #endif
128  m_PBndExp[nreg]->NormVectorIProductWRTBase(u, IProdVnTmp);
129 
130  Vmath::Svtvp(nbcoeffs, -1.0 / m_timestep, IProdVnTmp, 1,
131  m_PBndExp[nreg]->UpdateCoeffs(), 1,
132  m_PBndExp[nreg]->UpdateCoeffs(), 1);
133 }
134 
135 /**
136  * vritual function which only puts in the curl operator into the bcs
137  */
139  int HBCdata, NekDouble kinvis, Array<OneD, NekDouble> &Q,
141 {
142  boost::ignore_unused(Advection);
143 
144  Vmath::Smul(HBCdata, -kinvis, Q, 1, Q, 1);
145 }
146 
147 } // namespace Nektar
Array< OneD, Array< OneD, NekDouble > > m_pressureHBCs
Storage for current and previous levels of high order pressure boundary conditions.
Definition: Extrapolate.h:241
void CalcNeumannPressureBCs(const Array< OneD, const Array< OneD, NekDouble >> &fields, const Array< OneD, const Array< OneD, NekDouble >> &N, NekDouble kinvis)
Definition: Extrapolate.h:170
int m_curl_dim
Curl-curl dimensionality.
Definition: Extrapolate.h:214
void EvaluateBDFArray(Array< OneD, Array< OneD, NekDouble >> &array)
void CopyPressureHBCsToPbndExp(void)
void ExtrapolateArray(Array< OneD, Array< OneD, NekDouble >> &array)
int m_intSteps
Maximum points used in pressure BC evaluation.
Definition: Extrapolate.h:235
void CalcOutflowBCs(const Array< OneD, const Array< OneD, NekDouble >> &fields, NekDouble kinvis)
HighOrderOutflowSharedPtr m_houtflow
Definition: Extrapolate.h:255
NekDouble m_timestep
Definition: Extrapolate.h:237
Array< OneD, MultiRegions::ExpListSharedPtr > m_PBndExp
pressure boundary conditions expansion container
Definition: Extrapolate.h:223
int m_pressureCalls
number of times the high-order pressure BCs have been called
Definition: Extrapolate.h:226
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:198
An abstract base class encapsulating the concept of advection of a vector field.
Definition: Advection.h:70
virtual void v_MountHOPBCs(int HBCdata, NekDouble kinvis, Array< OneD, NekDouble > &Q, Array< OneD, const NekDouble > &Advection) override
static std::string className
Name of class.
virtual void v_EvaluatePressureBCs(const Array< OneD, const Array< OneD, NekDouble >> &fields, const Array< OneD, const Array< OneD, NekDouble >> &N, NekDouble kinvis) override
virtual void v_AddNormVelOnOBC(const int nbcoeffs, const int nreg, Array< OneD, Array< OneD, NekDouble >> &u) override
static ExtrapolateSharedPtr create(const LibUtilities::SessionReaderSharedPtr &pSession, Array< OneD, MultiRegions::ExpListSharedPtr > &pFields, MultiRegions::ExpListSharedPtr &pPressure, const Array< OneD, int > &pVel, const SolverUtils::AdvectionSharedPtr &advObject)
Creates an instance of this class.
WeakPressureExtrapolate(const LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields, MultiRegions::ExpListSharedPtr pPressure, const Array< OneD, int > pVel, const SolverUtils::AdvectionSharedPtr advObject)
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
std::shared_ptr< Advection > AdvectionSharedPtr
A shared pointer to an Advection object.
Definition: Advection.h:278
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
ExtrapolateFactory & GetExtrapolateFactory()
Definition: Extrapolate.cpp:48
double NekDouble
void Svtvp(int n, const T alpha, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
svtvp (scalar times vector plus vector): z = alpha*x + y
Definition: Vmath.cpp:622
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:248