Nektar++
StandardExtrapolate.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: StandardExtrapolate.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 StandardExtrapolate.
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
37 
38 namespace Nektar
39 {
41  { 1.0, -1., 0.0, 0.0},
42  { 2.5, -4.0, 1.5, 0.0},
43  { 13./3., -9.5, 7.0, -11.0/6.0}};
44 
45  /**
46  * Registers the class with the Factory.
47  */
49  "Standard",
51  "Standard");
52 
57  const Array<OneD, int> pVel,
58  const SolverUtils::AdvectionSharedPtr advObject)
59  : Extrapolate(pSession,pFields,pPressure,pVel,advObject)
60  {
61  }
62 
64  {
65  }
66 
67 
68  /**
69  * Function to extrapolate the new pressure boundary condition.
70  * Based on the velocity field and on the advection term.
71  * Acceleration term is also computed.
72  * This routine is a general one for 2d and 3D application and it can be called
73  * directly from velocity correction scheme. Specialisation on dimensionality is
74  * redirected to the CalcNeumannPressureBCs method.
75  */
77  const Array<OneD, const Array<OneD, NekDouble> > &fields,
78  const Array<OneD, const Array<OneD, NekDouble> > &N,
79  NekDouble kinvis)
80  {
82  if(m_HBCnumber>0)
83  {
84  // Calculate non-linear and viscous BCs at current level
85  // and put in m_pressureHBCs[0]
86  CalcNeumannPressureBCs(fields,N,kinvis);
87 
88  // Extrapolate to n+1
90 
91  // Add (phi,Du/Dt) term to m_presureHBC
92  AddDuDt();
93 
94  // Copy m_pressureHBCs to m_PbndExp
96  }
97 
98  CalcOutflowBCs(fields, kinvis);
99  }
100 
101 
102  /**
103  *
104  */
106  const LibUtilities::TimeIntegrationSchemeSharedPtr & IntegrationScheme )
107  {
108  if ( IntegrationScheme->GetName() == "IMEX" ||
109  IntegrationScheme->GetName() == "IMEXGear" )
110  {
111  m_intSteps = IntegrationScheme->GetOrder();
112  }
113  else
114  {
115  NEKERROR(ErrorUtil::efatal, "Integration method not suitable: "
116  "Options include IMEXGear or IMEXOrder{1,2,3,4}");
117  }
118  }
119 
120  /**
121  *
122  */
124  const Array<OneD, const Array<OneD, NekDouble> > &inarray,
125  NekDouble Aii_DT,
126  NekDouble kinvis)
127  {
128  }
129 
130 
131  /**
132  *
133  */
135  int nstep,
136  NekDouble time )
137  {
138  }
139 
140 
141  /**
142  *
143  */
145  int nstep)
146  {
147  }
148 
149  /**
150  *
151  */
153  int HBCdata,
154  NekDouble kinvis,
157  {
158  Vmath::Svtvp(HBCdata,-kinvis,Q,1,Advection,1,Q,1);
159  }
160 
161  /**
162  * At the start, the newest value is stored in array[nlevels-1]
163  * and the previous values in the first positions
164  * At the end, the acceleration from BDF is stored in array[nlevels-1]
165  * and the storage has been updated to included the new value
166  */
169  {
170  int nlevels = array.size();
171  int nPts = array[0].size();
172 
173 
174  if(nPts)
175  {
176  // Update array
177  RollOver(array);
178 
179  // Calculate acceleration using Backward Differentiation Formula
180  Array<OneD, NekDouble> accelerationTerm (nPts, 0.0);
181  if (m_pressureCalls > 2)
182  {
183  int acc_order = min(m_pressureCalls-2,m_intSteps);
184  Vmath::Smul(nPts,
185  DuDt_Coeffs[acc_order-1][0],
186  array[0], 1,
187  accelerationTerm, 1);
188 
189  for(int i = 0; i < acc_order; i++)
190  {
191  Vmath::Svtvp(nPts,
192  DuDt_Coeffs[acc_order-1][i+1],
193  array[i+1], 1,
194  accelerationTerm, 1,
195  accelerationTerm, 1);
196  }
197  }
198  array[nlevels-1] = accelerationTerm;
199  }
200  }
201 }
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
Definition: ErrorUtil.hpp:209
Array< OneD, Array< OneD, NekDouble > > m_pressureHBCs
Storage for current and previous levels of high order pressure boundary conditions.
Definition: Extrapolate.h:259
void CopyPressureHBCsToPbndExp(void)
int m_intSteps
Maximum points used in pressure BC evaluation.
Definition: Extrapolate.h:254
void CalcNeumannPressureBCs(const Array< OneD, const Array< OneD, NekDouble > > &fields, const Array< OneD, const Array< OneD, NekDouble > > &N, NekDouble kinvis)
Definition: Extrapolate.h:186
void ExtrapolateArray(Array< OneD, Array< OneD, NekDouble > > &array)
void RollOver(Array< OneD, Array< OneD, NekDouble > > &input)
int m_pressureCalls
number of times the high-order pressure BCs have been called
Definition: Extrapolate.h:245
void CalcOutflowBCs(const Array< OneD, const Array< OneD, NekDouble > > &fields, NekDouble kinvis)
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:200
An abstract base class encapsulating the concept of advection of a vector field.
Definition: Advection.h:73
virtual void v_EvaluatePressureBCs(const Array< OneD, const Array< OneD, NekDouble > > &fields, const Array< OneD, const Array< OneD, NekDouble > > &N, NekDouble kinvis)
static std::string className
Name of class.
virtual void v_SubStepAdvance(int nstep, NekDouble time)
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.
static NekDouble DuDt_Coeffs[3][4]
virtual void v_SubStepSetPressureBCs(const Array< OneD, const Array< OneD, NekDouble > > &inarray, NekDouble Aii_DT, NekDouble kinvis)
virtual void v_SubSteppingTimeIntegration(const LibUtilities::TimeIntegrationSchemeSharedPtr &IntegrationScheme)
virtual void v_SubStepSaveFields(int nstep)
StandardExtrapolate(const LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields, MultiRegions::ExpListSharedPtr pPressure, const Array< OneD, int > pVel, const SolverUtils::AdvectionSharedPtr advObject)
virtual void v_AccelerationBDF(Array< OneD, Array< OneD, NekDouble > > &array)
virtual void v_MountHOPBCs(int HBCdata, NekDouble kinvis, Array< OneD, NekDouble > &Q, Array< OneD, const NekDouble > &Advection)
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< TimeIntegrationScheme > TimeIntegrationSchemeSharedPtr
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:291
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:1
ExtrapolateFactory & GetExtrapolateFactory()
Definition: Extrapolate.cpp:49
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:565
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