Nektar++
ROutflow.cpp
Go to the documentation of this file.
1///////////////////////////////////////////////////////////////////////////////
2//
3// File: ROutflow.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// License for the specific language governing rights and limitations under
14// Permission is hereby granted, free of charge, to any person obtaining a
15// copy of this software and associated documentation files (the "Software"),
16// to deal in the Software without restriction, including without limitation
17// the rights to use, copy, modify, merge, publish, distribute, sublicense,
18// and/or sell copies of the Software, and to permit persons to whom the
19// Software is furnished to do so, subject to the following conditions:
20//
21// The above copyright notice and this permission notice shall be included
22// in all copies or substantial portions of the Software.
23//
24// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
25// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
27// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30// DEALINGS IN THE SOFTWARE.
31//
32// Description: ROuflow class
33//
34///////////////////////////////////////////////////////////////////////////////
35
37
38using namespace std;
39
40namespace Nektar
41{
42
44 "R-terminal", ROutflow::create, "Resistive outflow boundary condition");
45
49 : PulseWaveBoundary(pVessel, pSession, pressureArea)
50{
51}
52
54{
55}
56
58 const Array<OneD, const Array<OneD, NekDouble>> &inarray,
61 Array<OneD, Array<OneD, NekDouble>> &alpha, const NekDouble time, int omega,
62 int offset, int n)
63{
64 boost::ignore_unused(time);
65
66 NekDouble A_r = 0.0;
67 NekDouble u_r = 0.0;
68 NekDouble A_u = 0.0;
69 NekDouble u_u = 0.0;
70 NekDouble A_l = 0.0;
71 NekDouble u_l = 0.0;
72 NekDouble POut = m_pout;
73
75
76 // Pointers to the domains
77 vessel[0] = m_vessels[2 * omega];
78 vessel[1] = m_vessels[2 * omega + 1];
79
80 /* Find the terminal R boundary condition and
81 calculates the updated velocity and area as
82 well as the updated boundary conditions */
83
84 /* Load terminal resistance
85 and number of points from the input file */
86 NekDouble RT = ((vessel[0]->GetBndCondExpansions())[n])->GetCoeffs()[0];
87 int nq = vessel[0]->GetTotPoints();
88
89 // Get the values of all variables needed for the Riemann problem
90 A_l = inarray[0][offset + nq - 1];
91 u_l = inarray[1][offset + nq - 1];
92
93 // Call the R RiemannSolver
94 R_RiemannSolver(RT, A_l, u_l, A_0[omega][nq - 1], beta[omega][nq - 1],
95 alpha[omega][nq - 1], POut, A_u, u_u);
96
97 /* Fix the boundary conditions in the virtual region to ensure
98 upwind state matches the boundary condition at the next time step */
99 A_r = A_l;
100 u_r = 2 * u_u - u_l;
101
102 // Store the updated values
103 (vessel[0]->UpdateBndCondExpansion(n))->UpdatePhys()[0] = A_r;
104 (vessel[1]->UpdateBndCondExpansion(n))->UpdatePhys()[0] = u_r;
105}
106
108 NekDouble A_0, NekDouble beta, NekDouble alpha,
109 NekDouble POut, NekDouble &A_u, NekDouble &u_u)
110{
111 NekDouble W1 = 0.0;
112 NekDouble c = 0.0;
113 NekDouble cL = 0.0;
114 NekDouble I = 0.0;
115 NekDouble A_calc = 0.0;
116 NekDouble FA = 0.0;
117 NekDouble dFdA = 0.0;
118 NekDouble delta_A_calc = 0.0;
119 NekDouble P = 0.0;
120 NekDouble rho = m_rho;
121
122 int proceed = 1;
123 int iter = 0;
124 int MAX_ITER = 200;
125
126 // Tolerances for the algorithm
127 NekDouble Tol = 1.0E-10;
128
129 // Calculate the wave speed
130 m_pressureArea->GetC(cL, beta, A_l, A_0, alpha);
131
132 // Riemann invariant \f$W_1(Al,ul)\f$
133 m_pressureArea->GetW1(W1, u_l, beta, A_l, A_0, alpha);
134
135 // Newton Iteration (Area only)
136 A_calc = A_l;
137 while ((proceed) && (iter < MAX_ITER))
138 {
139 iter += 1;
140
141 m_pressureArea->GetPressure(P, beta, A_calc, A_0, 0, 0, alpha);
142 m_pressureArea->GetC(c, beta, A_calc, A_0, alpha);
143 m_pressureArea->GetCharIntegral(I, beta, A_calc, A_0, alpha);
144
145 FA = R * A_calc * (W1 - I) - P + POut;
146 dFdA = R * (W1 - I - c) - c * c * rho / A_calc;
147 delta_A_calc = FA / dFdA;
148 A_calc -= delta_A_calc;
149
150 if (sqrt(delta_A_calc * delta_A_calc) < Tol)
151 {
152 proceed = 0;
153 }
154 }
155
156 m_pressureArea->GetPressure(P, beta, A_calc, A_0, 0, 0, alpha);
157
158 // Obtain u_u and A_u
159 u_u = (P - POut) / (R * A_calc);
160 A_u = A_calc;
161}
162
163} // namespace Nektar
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:198
Array< OneD, MultiRegions::ExpListSharedPtr > m_vessels
PulseWavePressureAreaSharedPtr m_pressureArea
virtual void v_DoBoundary(const Array< OneD, const Array< OneD, NekDouble > > &inarray, Array< OneD, Array< OneD, NekDouble > > &A_0, Array< OneD, Array< OneD, NekDouble > > &beta, Array< OneD, Array< OneD, NekDouble > > &alpha, const NekDouble time, int omega, int offset, int n) override
Definition: ROutflow.cpp:57
static std::string className
Definition: ROutflow.h:66
void R_RiemannSolver(NekDouble R, NekDouble A_l, NekDouble u_l, NekDouble A_0, NekDouble beta, NekDouble alpha, NekDouble POut, NekDouble &A_u, NekDouble &u_u)
Definition: ROutflow.cpp:107
ROutflow(Array< OneD, MultiRegions::ExpListSharedPtr > pVessel, const LibUtilities::SessionReaderSharedPtr pSession, PulseWavePressureAreaSharedPtr pressureArea)
Definition: ROutflow.cpp:46
virtual ~ROutflow()
Definition: ROutflow.cpp:53
static PulseWaveBoundarySharedPtr create(Array< OneD, MultiRegions::ExpListSharedPtr > &pVessel, const LibUtilities::SessionReaderSharedPtr &pSession, PulseWavePressureAreaSharedPtr &pressureArea)
Definition: ROutflow.h:56
std::shared_ptr< SessionReader > SessionReaderSharedPtr
@ beta
Gauss Radau pinned at x=-1,.
Definition: PointsType.h:61
@ P
Monomial polynomials .
Definition: BasisType.h:64
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:2
std::shared_ptr< PulseWavePressureArea > PulseWavePressureAreaSharedPtr
BoundaryFactory & GetBoundaryFactory()
double NekDouble
scalarT< T > sqrt(scalarT< T > in)
Definition: scalar.hpp:294