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
36
37namespace Nektar
38{
40 {1.0, -1., 0.0, 0.0},
41 {2.5, -4.0, 1.5, 0.0},
42 {13. / 3., -9.5, 7.0, -11.0 / 6.0}};
43
44/**
45 * Registers the class with the Factory.
46 */
49 "Standard", StandardExtrapolate::create, "Standard");
50
55 const SolverUtils::AdvectionSharedPtr advObject)
56 : Extrapolate(pSession, pFields, pPressure, pVel, advObject)
57{
58}
59
61{
62}
63
64/**
65 * Function to extrapolate the new pressure boundary condition.
66 * Based on the velocity field and on the advection term.
67 * Acceleration term is also computed.
68 * This routine is a general one for 2d and 3D application and it can be called
69 * directly from velocity correction scheme. Specialisation on dimensionality is
70 * redirected to the CalcNeumannPressureBCs method.
71 */
73 const Array<OneD, const Array<OneD, NekDouble>> &fields,
74 const Array<OneD, const Array<OneD, NekDouble>> &N, NekDouble kinvis)
75{
77 if (m_HBCnumber > 0)
78 {
79 // Calculate non-linear and viscous BCs at current level
80 // and put in m_pressureHBCs[0]
81 CalcNeumannPressureBCs(fields, N, kinvis);
82
83 // Extrapolate to n+1
85
86 // Add (phi,Du/Dt) term to m_presureHBC
87 AddDuDt();
88
89 // Copy m_pressureHBCs to m_PbndExp
91 }
92
93 CalcOutflowBCs(fields, kinvis);
94}
95
96/**
97 *
98 */
100 const LibUtilities::TimeIntegrationSchemeSharedPtr &IntegrationScheme)
101{
102 if (IntegrationScheme->GetName() == "IMEX" ||
103 IntegrationScheme->GetName() == "IMEXGear")
104 {
105 m_intSteps = IntegrationScheme->GetOrder();
106 }
107 else
108 {
110 "Integration method not suitable: "
111 "Options include IMEXGear or IMEXOrder{1,2,3,4}");
112 }
113}
114
115/**
116 *
117 */
119 [[maybe_unused]] const Array<OneD, const Array<OneD, NekDouble>> &inarray,
120 [[maybe_unused]] NekDouble Aii_DT, [[maybe_unused]] NekDouble kinvis)
121{
122}
123
124/**
125 *
126 */
127void StandardExtrapolate::v_SubStepAdvance([[maybe_unused]] int nstep,
128 [[maybe_unused]] NekDouble time)
129{
130}
131
132/**
133 *
134 */
135void StandardExtrapolate::v_SubStepSaveFields([[maybe_unused]] int nstep)
136{
137}
138
139/**
140 *
141 */
145{
146 Vmath::Svtvp(HBCdata, -kinvis, Q, 1, Advection, 1, Q, 1);
147}
148
149/**
150 * At the start, the newest value is stored in array[nlevels-1]
151 * and the previous values in the first positions
152 * At the end, the acceleration from BDF is stored in array[nlevels-1]
153 * and the storage has been updated to included the new value
154 */
157{
158 int nlevels = array.size();
159 int nPts = array[0].size();
160
161 if (nPts)
162 {
163 // Update array
164 RollOver(array);
165
166 // Calculate acceleration using Backward Differentiation Formula
167 Array<OneD, NekDouble> accelerationTerm(nPts, 0.0);
168 if (m_pressureCalls > 2)
169 {
170 int acc_order = std::min(m_pressureCalls - 2, m_intSteps);
171 Vmath::Smul(nPts, DuDt_Coeffs[acc_order - 1][0], array[0], 1,
172 accelerationTerm, 1);
173
174 for (int i = 0; i < acc_order; i++)
175 {
176 Vmath::Svtvp(nPts, DuDt_Coeffs[acc_order - 1][i + 1],
177 array[i + 1], 1, accelerationTerm, 1,
178 accelerationTerm, 1);
179 }
180 }
181 array[nlevels - 1] = accelerationTerm;
182 }
183}
184} // 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:202
Array< OneD, Array< OneD, NekDouble > > m_pressureHBCs
Storage for current and previous levels of high order pressure boundary conditions.
Definition: Extrapolate.h:247
void CopyPressureHBCsToPbndExp(void)
int m_intSteps
Maximum points used in pressure BC evaluation.
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:172
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:232
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:197
An abstract base class encapsulating the concept of advection of a vector field.
Definition: Advection.h:81
void v_AccelerationBDF(Array< OneD, Array< OneD, NekDouble > > &array) override
static std::string className
Name of class.
void v_SubSteppingTimeIntegration(const LibUtilities::TimeIntegrationSchemeSharedPtr &IntegrationScheme) 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.
static NekDouble DuDt_Coeffs[3][4]
void v_EvaluatePressureBCs(const Array< OneD, const Array< OneD, NekDouble > > &fields, const Array< OneD, const Array< OneD, NekDouble > > &N, NekDouble kinvis) override
void v_SubStepAdvance(int nstep, NekDouble time) override
void v_SubStepSaveFields(int nstep) override
void v_SubStepSetPressureBCs(const Array< OneD, const Array< OneD, NekDouble > > &inarray, NekDouble Aii_DT, NekDouble kinvis) override
StandardExtrapolate(const LibUtilities::SessionReaderSharedPtr pSession, Array< OneD, MultiRegions::ExpListSharedPtr > pFields, MultiRegions::ExpListSharedPtr pPressure, const Array< OneD, int > pVel, const SolverUtils::AdvectionSharedPtr advObject)
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:54
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.hpp:396
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.hpp:100