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  */
50  "Standard", StandardExtrapolate::create, "Standard");
51 
56  const SolverUtils::AdvectionSharedPtr advObject)
57  : Extrapolate(pSession, pFields, pPressure, pVel, advObject)
58 {
59 }
60 
62 {
63 }
64 
65 /**
66  * Function to extrapolate the new pressure boundary condition.
67  * Based on the velocity field and on the advection term.
68  * Acceleration term is also computed.
69  * This routine is a general one for 2d and 3D application and it can be called
70  * directly from velocity correction scheme. Specialisation on dimensionality is
71  * redirected to the CalcNeumannPressureBCs method.
72  */
74  const Array<OneD, const Array<OneD, NekDouble>> &fields,
75  const Array<OneD, const Array<OneD, NekDouble>> &N, NekDouble kinvis)
76 {
78  if (m_HBCnumber > 0)
79  {
80  // Calculate non-linear and viscous BCs at current level
81  // and put in m_pressureHBCs[0]
82  CalcNeumannPressureBCs(fields, N, kinvis);
83 
84  // Extrapolate to n+1
86 
87  // Add (phi,Du/Dt) term to m_presureHBC
88  AddDuDt();
89 
90  // Copy m_pressureHBCs to m_PbndExp
92  }
93 
94  CalcOutflowBCs(fields, kinvis);
95 }
96 
97 /**
98  *
99  */
101  const LibUtilities::TimeIntegrationSchemeSharedPtr &IntegrationScheme)
102 {
103  if (IntegrationScheme->GetName() == "IMEX" ||
104  IntegrationScheme->GetName() == "IMEXGear")
105  {
106  m_intSteps = IntegrationScheme->GetOrder();
107  }
108  else
109  {
111  "Integration method not suitable: "
112  "Options include IMEXGear or IMEXOrder{1,2,3,4}");
113  }
114 }
115 
116 /**
117  *
118  */
120  const Array<OneD, const Array<OneD, NekDouble>> &inarray, NekDouble Aii_DT,
121  NekDouble kinvis)
122 {
123  boost::ignore_unused(inarray, Aii_DT, kinvis);
124 }
125 
126 /**
127  *
128  */
130 {
131  boost::ignore_unused(nstep, time);
132 }
133 
134 /**
135  *
136  */
138 {
139  boost::ignore_unused(nstep);
140 }
141 
142 /**
143  *
144  */
148 {
149  Vmath::Svtvp(HBCdata, -kinvis, Q, 1, Advection, 1, Q, 1);
150 }
151 
152 /**
153  * At the start, the newest value is stored in array[nlevels-1]
154  * and the previous values in the first positions
155  * At the end, the acceleration from BDF is stored in array[nlevels-1]
156  * and the storage has been updated to included the new value
157  */
160 {
161  int nlevels = array.size();
162  int nPts = array[0].size();
163 
164  if (nPts)
165  {
166  // Update array
167  RollOver(array);
168 
169  // Calculate acceleration using Backward Differentiation Formula
170  Array<OneD, NekDouble> accelerationTerm(nPts, 0.0);
171  if (m_pressureCalls > 2)
172  {
173  int acc_order = std::min(m_pressureCalls - 2, m_intSteps);
174  Vmath::Smul(nPts, DuDt_Coeffs[acc_order - 1][0], array[0], 1,
175  accelerationTerm, 1);
176 
177  for (int i = 0; i < acc_order; i++)
178  {
179  Vmath::Svtvp(nPts, DuDt_Coeffs[acc_order - 1][i + 1],
180  array[i + 1], 1, accelerationTerm, 1,
181  accelerationTerm, 1);
182  }
183  }
184  array[nlevels - 1] = accelerationTerm;
185  }
186 }
187 } // namespace Nektar
#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: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
void RollOver(Array< OneD, Array< OneD, NekDouble >> &input)
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)
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
static std::string className
Name of class.
virtual void v_SubSteppingTimeIntegration(const LibUtilities::TimeIntegrationSchemeSharedPtr &IntegrationScheme) override
virtual void v_EvaluatePressureBCs(const Array< OneD, const Array< OneD, NekDouble >> &fields, const Array< OneD, const Array< OneD, NekDouble >> &N, NekDouble kinvis) 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.
virtual void v_AccelerationBDF(Array< OneD, Array< OneD, NekDouble >> &array) override
static NekDouble DuDt_Coeffs[3][4]
virtual void v_SubStepAdvance(int nstep, NekDouble time) override
virtual void v_SubStepSaveFields(int nstep) override
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_SubStepSetPressureBCs(const Array< OneD, const Array< OneD, NekDouble >> &inarray, NekDouble Aii_DT, NekDouble kinvis) override
virtual void v_MountHOPBCs(int HBCdata, NekDouble kinvis, Array< OneD, NekDouble > &Q, Array< OneD, const NekDouble > &Advection) override
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: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