Nektar++
Extrapolate.h
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File: Extrapolate.h
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 Extrapolate.
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
35 #ifndef NEKTAR_SOLVERS_EXTRAPOLATE_H
36 #define NEKTAR_SOLVERS_EXTRAPOLATE_H
37 
41 #include <MultiRegions/ExpList.h>
45 
46 
47 namespace Nektar
48 {
49 
50  enum HBCType
51  {
53  eHBCNeumann, // Standard High Order BC
54  eOBC, // High Order outflow BC (Neumann-Dirichlet) from Dong et al JCP 2014
55  eConvectiveOBC // Convective High Order (Robin type) BC from Dong JCP 2015
56  };
57 
58  // Forward declaration
59  class Extrapolate;
60  typedef std::shared_ptr<Extrapolate> ExtrapolateSharedPtr;
61  typedef LibUtilities::NekFactory< std::string, Extrapolate,
65  const Array<OneD, int>& ,
67 
69  typedef std::shared_ptr<HighOrderOutflow> HighOrderOutflowSharedPtr;
70 
71 
72  ExtrapolateFactory& GetExtrapolateFactory();
73 
74  class Extrapolate
75  {
76  public:
77  Extrapolate(
78  const LibUtilities::SessionReaderSharedPtr pSession,
79  Array<OneD, MultiRegions::ExpListSharedPtr> pFields,
80  MultiRegions::ExpListSharedPtr pPressure,
81  const Array<OneD, int> pVel,
82  const SolverUtils::AdvectionSharedPtr advObject);
83 
84  virtual ~Extrapolate();
85 
86  void GenerateHOPBCMap(const LibUtilities::SessionReaderSharedPtr& pSsession);
87 
88  void UpdateRobinPrimCoeff(void);
89 
90  inline void SubSteppingTimeIntegration(
91  const int intMethod,
92  const LibUtilities::TimeIntegrationWrapperSharedPtr &IntegrationScheme);
93 
94  inline void SubStepSaveFields(
95  const int nstep);
96 
97  inline void SubStepSetPressureBCs(
98  const Array<OneD, const Array<OneD, NekDouble> > &inarray,
99  const NekDouble Aii_DT,
100  NekDouble kinvis);
101 
102  inline void SubStepAdvance(
103  const LibUtilities::TimeIntegrationSolutionSharedPtr &integrationSoln,
104  const int nstep,
105  NekDouble time);
106 
107  inline void MountHOPBCs(
108  int HBCdata,
109  NekDouble kinvis,
112 
113  inline void EvaluatePressureBCs(
114  const Array<OneD, const Array<OneD, NekDouble> > &fields,
115  const Array<OneD, const Array<OneD, NekDouble> > &N,
116  NekDouble kinvis);
117 
118 
119  void AddDuDt(void);
120 
121  void AddVelBC(void);
122 
123  void ExtrapolatePressureHBCs(void);
124  void CopyPressureHBCsToPbndExp(void);
125 
127  const Array<OneD, Array<OneD,NekDouble> > inarray);
128 
129 
131 
133  Array<OneD, NekDouble> &IprodVn);
134 
136 
138 
140 
142 
144 
145  void ExtrapolateArray(
146  Array<OneD, Array<OneD, NekDouble> > &oldarrays,
147  Array<OneD, NekDouble> &newarray,
148  Array<OneD, NekDouble> &outarray);
149 
150  void AddNormVelOnOBC(const int nbcoeffs, const int nreg,
152 
153  void AddPressureToOutflowBCs(NekDouble kinvis);
154 
155  protected:
156  virtual void v_EvaluatePressureBCs(
157  const Array<OneD, const Array<OneD, NekDouble> > &inarray,
158  const Array<OneD, const Array<OneD, NekDouble> > &N,
159  NekDouble kinvis)=0;
160 
161  virtual void v_SubSteppingTimeIntegration(
162  int intMethod,
163  const LibUtilities::TimeIntegrationWrapperSharedPtr &IntegrationScheme)=0;
164 
165  virtual void v_SubStepSaveFields(
166  int nstep)=0;
167 
168  virtual void v_SubStepSetPressureBCs(
169  const Array<OneD, const Array<OneD, NekDouble> > &inarray,
170  NekDouble Aii_DT,
171  NekDouble kinvis)=0;
172 
173  virtual void v_SubStepAdvance(
174  const LibUtilities::TimeIntegrationSolutionSharedPtr &integrationSoln,
175  int nstep,
176  NekDouble time)=0;
177 
178  virtual void v_MountHOPBCs(
179  int HBCdata,
180  NekDouble kinvis,
182  Array<OneD, const NekDouble> &Advection)=0;
183 
186 
188  const Array<OneD, const Array<OneD, NekDouble> > &fields,
189  const Array<OneD, const Array<OneD, NekDouble> > &N,
190  NekDouble kinvis)
191  {
192  v_CalcNeumannPressureBCs( fields, N, kinvis);
193  }
194 
195  virtual void v_CalcNeumannPressureBCs(
196  const Array<OneD, const Array<OneD, NekDouble> > &fields,
197  const Array<OneD, const Array<OneD, NekDouble> > &N,
198  NekDouble kinvis);
199 
200  virtual void v_CorrectPressureBCs( const Array<OneD, NekDouble> &pressure);
201 
202  virtual void v_AddNormVelOnOBC(const int nbcoeffs, const int nreg,
204  void CalcOutflowBCs(
205  const Array<OneD, const Array<OneD, NekDouble> > &fields,
206  NekDouble kinvis);
207 
208  void RollOver(Array<OneD, Array<OneD, NekDouble> > &input);
209 
210  LibUtilities::SessionReaderSharedPtr m_session;
211 
213 
214  /// Array of type of high order BCs for splitting shemes
216 
217  /// Velocity fields
218  Array<OneD, MultiRegions::ExpListSharedPtr> m_fields;
219 
220  /// Pointer to field holding pressure field
221  MultiRegions::ExpListSharedPtr m_pressure;
222 
223  /// int which identifies which components of m_fields contains the
224  /// velocity (u,v,w);
225  Array<OneD, int> m_velocity;
226 
228 
230 
231  /// Curl-curl dimensionality
233 
234  /// bounday dimensionality
236 
237  /// pressure boundary conditions container
239 
240  /// pressure boundary conditions expansion container
241  Array<OneD, MultiRegions::ExpListSharedPtr> m_PBndExp;
242 
243  /// number of times the high-order pressure BCs have been called
245 
246  // Number of degrees of freedom (coefficients) for HOPbc
248 
249  // Number of HOPbcs
251 
252  /// Maximum points used in pressure BC evaluation
254 
256 
257  /// Storage for current and previous levels of high order pressure boundary conditions.
259 
260  /// Storage for current and previous levels of the inner product of normal velocity
262 
264 
265  // Velocity correction scheme coefficient required for extrapolation.
269 
270  // data related to high order outflow.
271  HighOrderOutflowSharedPtr m_houtflow;
272 
273  private:
274  static std::string def;
275  };
276 
277 
279  {
280  HighOrderOutflow(const int numHOpts, const int outHBCnumber,const int curldim, const LibUtilities::SessionReaderSharedPtr &pSession):
281  m_numOutHBCPts(numHOpts),
282  m_outHBCnumber(outHBCnumber)
283  {
284  m_outflowVel = Array<OneD,
285  Array<OneD, Array<OneD,
286  Array<OneD, NekDouble> > > > (outHBCnumber);
287 
288  m_outflowVelBnd = Array<OneD,
289  Array<OneD, Array<OneD,
290  Array<OneD, NekDouble> > > > (outHBCnumber);
291 
292  m_UBndExp = Array<OneD,
293  Array<OneD, MultiRegions::ExpListSharedPtr> >(curldim);
294 
295  pSession->LoadParameter("OutflowBC_theta", m_obcTheta, 1.0);
296  pSession->LoadParameter("OutflowBC_alpha1", m_obcAlpha1, 0.0);
297  pSession->LoadParameter("OutflowBC_alpha2", m_obcAlpha2, 0.0);
298 
299  pSession->LoadParameter("U0_HighOrderBC", m_U0,1.0);
300  pSession->LoadParameter("Delta_HighOrderBC", m_delta,1/20.0);
301  }
302 
304  {};
305 
306  /// Number of quadrature points for Outflow HOBC
307  int m_numOutHBCPts;
308 
309  /// Number of Outflow HOBCs
311 
312  /// Parameters for outflow boundary condition
318  std::string m_defVelPrimCoeff[3];
319 
320  /// Storage for current and previous velocity fields along the outflow
322 
323  /// Storage for current and previous velocities along the outflow boundary
325 
326  /// Velocity boundary condition expansions on high order boundaries.
328 
329  /// primitive coefficient for pressure when using convetive like OBCs
331 
332  /// primitive coefficient for velocities when using convetive like OBCs
334  };
335 
336  /**
337  * Evaluate Pressure Boundary Conditions for Standard Extrapolation
338  */
340  const Array<OneD, const Array<OneD, NekDouble> > &inarray,
341  const Array<OneD, const Array<OneD, NekDouble> > &N,
342  NekDouble kinvis)
343  {
344  v_EvaluatePressureBCs(inarray,N,kinvis);
345  }
346 
347  /**
348  *
349  */
351  int intMethod,
352  const LibUtilities::TimeIntegrationWrapperSharedPtr &IntegrationScheme)
353  {
354  v_SubSteppingTimeIntegration(intMethod, IntegrationScheme);
355  }
356 
357  /**
358  *
359  */
361  int nstep)
362  {
363  v_SubStepSaveFields(nstep);
364  }
365 
366  /**
367  *
368  */
370  const Array<OneD, const Array<OneD, NekDouble> > &inarray,
371  NekDouble Aii_DT,
372  NekDouble kinvis)
373  {
374  v_SubStepSetPressureBCs(inarray,Aii_DT,kinvis);
375  }
376 
377  /**
378  *
379  */
381  const LibUtilities::TimeIntegrationSolutionSharedPtr &integrationSoln,
382  int nstep,
383  NekDouble time)
384  {
385  v_SubStepAdvance(integrationSoln,nstep, time);
386  }
387 
388  /**
389  *
390  */
392  int HBCdata,
393  NekDouble kinvis,
396  {
397  v_MountHOPBCs(HBCdata,kinvis,Q,Advection);
398  }
399 
400  /**
401  *
402  */
405  {
407  }
408 
409  /**
410  *
411  */
414  {
415  v_CorrectPressureBCs(pressure);
416  }
417 
418 
419  /**
420  *
421  */
422  inline void Extrapolate::AddNormVelOnOBC(const int nbcoeffs, const int nreg,
424  {
425  v_AddNormVelOnOBC(nbcoeffs,nreg,u);
426  }
427 
428 }
429 
430 #endif
431 
void UpdateRobinPrimCoeff(void)
MultiRegions::ExpListSharedPtr m_pressure
Pointer to field holding pressure field.
Definition: Extrapolate.h:221
void IProductNormVelocityOnHBC(const Array< OneD, const Array< OneD, NekDouble > > &Vel, Array< OneD, NekDouble > &IprodVn)
LibUtilities::SessionReaderSharedPtr m_session
Definition: Extrapolate.h:210
void ExtrapolateArray(Array< OneD, Array< OneD, NekDouble > > &array)
virtual void v_SubSteppingTimeIntegration(int intMethod, const LibUtilities::TimeIntegrationWrapperSharedPtr &IntegrationScheme)=0
virtual void v_AddNormVelOnOBC(const int nbcoeffs, const int nreg, Array< OneD, Array< OneD, NekDouble > > &u)
Array< OneD, int > m_velocity
int which identifies which components of m_fields contains the velocity (u,v,w);
Definition: Extrapolate.h:225
NekDouble m_obcTheta
Parameters for outflow boundary condition.
Definition: Extrapolate.h:313
void SubStepAdvance(const LibUtilities::TimeIntegrationSolutionSharedPtr &integrationSoln, const int nstep, NekDouble time)
Definition: Extrapolate.h:380
Array< OneD, MultiRegions::ExpListSharedPtr > m_PBndExp
pressure boundary conditions expansion container
Definition: Extrapolate.h:241
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
Array< OneD, Array< OneD, Array< OneD, Array< OneD, NekDouble > > > > m_outflowVelBnd
Storage for current and previous velocities along the outflow boundary.
Definition: Extrapolate.h:324
void SubSteppingTimeIntegration(const int intMethod, const LibUtilities::TimeIntegrationWrapperSharedPtr &IntegrationScheme)
Definition: Extrapolate.h:350
void SubStepSetPressureBCs(const Array< OneD, const Array< OneD, NekDouble > > &inarray, const NekDouble Aii_DT, NekDouble kinvis)
Definition: Extrapolate.h:369
ExtrapolateFactory & GetExtrapolateFactory()
Definition: Extrapolate.cpp:49
std::shared_ptr< Advection > AdvectionSharedPtr
A shared pointer to an Advection object.
Definition: Advection.h:170
std::shared_ptr< Extrapolate > ExtrapolateSharedPtr
Definition: Extrapolate.h:59
void AccelerationBDF(Array< OneD, Array< OneD, NekDouble > > &array)
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object.
Definition: Comm.h:53
Array< OneD, Array< OneD, Array< OneD, Array< OneD, NekDouble > > > > m_outflowVel
Storage for current and previous velocity fields along the outflow.
Definition: Extrapolate.h:321
void RollOver(Array< OneD, Array< OneD, NekDouble > > &input)
HighOrderOutflow(const int numHOpts, const int outHBCnumber, const int curldim, const LibUtilities::SessionReaderSharedPtr &pSession)
Definition: Extrapolate.h:280
HighOrderOutflowSharedPtr m_houtflow
Definition: Extrapolate.h:271
void CopyPressureHBCsToPbndExp(void)
virtual void v_SubStepAdvance(const LibUtilities::TimeIntegrationSolutionSharedPtr &integrationSoln, int nstep, NekDouble time)=0
void ExtrapolatePressureHBCs(void)
LibUtilities::CommSharedPtr m_comm
Definition: Extrapolate.h:212
void AddPressureToOutflowBCs(NekDouble kinvis)
Array< OneD, MultiRegions::ExpListSharedPtr > m_fields
Velocity fields.
Definition: Extrapolate.h:218
static NekDouble StifflyStable_Gamma0_Coeffs[3]
Definition: Extrapolate.h:268
void EvaluateBDFArray(Array< OneD, Array< OneD, NekDouble > > &array)
virtual void v_EvaluatePressureBCs(const Array< OneD, const Array< OneD, NekDouble > > &inarray, const Array< OneD, const Array< OneD, NekDouble > > &N, NekDouble kinvis)=0
Array< OneD, Array< OneD, NekDouble > > m_velocityPrimCoeff
primitive coefficient for velocities when using convetive like OBCs
Definition: Extrapolate.h:333
static std::string def
Definition: Extrapolate.h:274
Extrapolate(const LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields, MultiRegions::ExpListSharedPtr pPressure, const Array< OneD, int > pVel, const SolverUtils::AdvectionSharedPtr advObject)
Definition: Extrapolate.cpp:55
int m_bnd_dim
bounday dimensionality
Definition: Extrapolate.h:235
std::shared_ptr< TimeIntegrationWrapper > TimeIntegrationWrapperSharedPtr
void MountHOPBCs(int HBCdata, NekDouble kinvis, Array< OneD, NekDouble > &Q, Array< OneD, const NekDouble > &Advection)
Definition: Extrapolate.h:391
void GenerateHOPBCMap(const LibUtilities::SessionReaderSharedPtr &pSsession)
Array< OneD, NekDouble > GetMaxStdVelocity(const Array< OneD, Array< OneD, NekDouble > > inarray)
Array< OneD, HBCType > m_hbcType
Array of type of high order BCs for splitting shemes.
Definition: Extrapolate.h:215
virtual LibUtilities::TimeIntegrationMethod v_GetSubStepIntegrationMethod(void)
int m_intSteps
Maximum points used in pressure BC evaluation.
Definition: Extrapolate.h:253
LibUtilities::NekFactory< std::string, Extrapolate, const LibUtilities::SessionReaderSharedPtr &, Array< OneD, MultiRegions::ExpListSharedPtr > &, MultiRegions::ExpListSharedPtr &, const Array< OneD, int > &, const SolverUtils::AdvectionSharedPtr &> ExtrapolateFactory
Definition: Extrapolate.h:66
double NekDouble
Array< OneD, NekDouble > m_pressurePrimCoeff
primitive coefficient for pressure when using convetive like OBCs
Definition: Extrapolate.h:330
int m_pressureCalls
number of times the high-order pressure BCs have been called
Definition: Extrapolate.h:244
virtual void v_CalcNeumannPressureBCs(const Array< OneD, const Array< OneD, NekDouble > > &fields, const Array< OneD, const Array< OneD, NekDouble > > &N, NekDouble kinvis)
virtual void v_MountHOPBCs(int HBCdata, NekDouble kinvis, Array< OneD, NekDouble > &Q, Array< OneD, const NekDouble > &Advection)=0
Array< OneD, Array< OneD, MultiRegions::ExpListSharedPtr > > m_UBndExp
Velocity boundary condition expansions on high order boundaries.
Definition: Extrapolate.h:327
void IProductNormVelocityBCOnHBC(Array< OneD, NekDouble > &IprodVn)
virtual void v_SubStepSetPressureBCs(const Array< OneD, const Array< OneD, NekDouble > > &inarray, NekDouble Aii_DT, NekDouble kinvis)=0
void CorrectPressureBCs(const Array< OneD, NekDouble > &pressure)
Definition: Extrapolate.h:412
LibUtilities::TimeIntegrationMethod GetSubStepIntegrationMethod(void)
Definition: Extrapolate.h:404
virtual void v_SubStepSaveFields(int nstep)=0
virtual void v_CorrectPressureBCs(const Array< OneD, NekDouble > &pressure)
Array< OneD, Array< OneD, NekDouble > > m_previousVelFields
Definition: Extrapolate.h:229
Array< OneD, Array< OneD, NekDouble > > m_pressureHBCs
Storage for current and previous levels of high order pressure boundary conditions.
Definition: Extrapolate.h:258
static NekDouble StifflyStable_Alpha_Coeffs[3][3]
Definition: Extrapolate.h:267
SolverUtils::AdvectionSharedPtr m_advObject
Definition: Extrapolate.h:227
Array< OneD, Array< OneD, NekDouble > > m_traceNormals
Definition: Extrapolate.h:263
int m_numOutHBCPts
Number of quadrature points for Outflow HOBC.
Definition: Extrapolate.h:304
int m_curl_dim
Curl-curl dimensionality.
Definition: Extrapolate.h:232
void EvaluatePressureBCs(const Array< OneD, const Array< OneD, NekDouble > > &fields, const Array< OneD, const Array< OneD, NekDouble > > &N, NekDouble kinvis)
Definition: Extrapolate.h:339
void CalcOutflowBCs(const Array< OneD, const Array< OneD, NekDouble > > &fields, NekDouble kinvis)
std::shared_ptr< HighOrderOutflow > HighOrderOutflowSharedPtr
Definition: Extrapolate.h:68
std::shared_ptr< TimeIntegrationSolution > TimeIntegrationSolutionSharedPtr
Array< OneD, Array< OneD, NekDouble > > m_iprodnormvel
Storage for current and previous levels of the inner product of normal velocity.
Definition: Extrapolate.h:261
Array< OneD, const SpatialDomains::BoundaryConditionShPtr > m_PBndConds
pressure boundary conditions container
Definition: Extrapolate.h:238
void SubStepSaveFields(const int nstep)
Definition: Extrapolate.h:360
NekDouble m_timestep
Definition: Extrapolate.h:255
std::shared_ptr< SessionReader > SessionReaderSharedPtr
virtual ~Extrapolate()
Definition: Extrapolate.cpp:71
int m_outHBCnumber
Number of Outflow HOBCs.
Definition: Extrapolate.h:310
An abstract base class encapsulating the concept of advection of a vector field.
Definition: Advection.h:69
static NekDouble StifflyStable_Betaq_Coeffs[3][3]
Definition: Extrapolate.h:266
Provides a generic Factory class.
Definition: NekFactory.hpp:103
void AddNormVelOnOBC(const int nbcoeffs, const int nreg, Array< OneD, Array< OneD, NekDouble > > &u)
Definition: Extrapolate.h:422
void CalcNeumannPressureBCs(const Array< OneD, const Array< OneD, NekDouble > > &fields, const Array< OneD, const Array< OneD, NekDouble > > &N, NekDouble kinvis)
Definition: Extrapolate.h:187