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
38namespace Nektar
39{
40
42 "R-terminal", ROutflow::create, "Resistive outflow boundary condition");
43
47 : PulseWaveBoundary(pVessel, pSession, pressureArea)
48{
49}
50
52 const Array<OneD, const Array<OneD, NekDouble>> &inarray,
56 [[maybe_unused]] const NekDouble time, int omega, int offset, int n)
57{
58 NekDouble A_r = 0.0;
59 NekDouble u_r = 0.0;
60 NekDouble A_u = 0.0;
61 NekDouble u_u = 0.0;
62 NekDouble A_l = 0.0;
63 NekDouble u_l = 0.0;
64 NekDouble POut = m_pout;
65
67
68 // Pointers to the domains
69 vessel[0] = m_vessels[2 * omega];
70 vessel[1] = m_vessels[2 * omega + 1];
71
72 /* Find the terminal R boundary condition and
73 calculates the updated velocity and area as
74 well as the updated boundary conditions */
75
76 /* Load terminal resistance
77 and number of points from the input file */
78 NekDouble RT = ((vessel[0]->GetBndCondExpansions())[n])->GetCoeffs()[0];
79 int nq = vessel[0]->GetTotPoints();
80
81 // Get the values of all variables needed for the Riemann problem
82 A_l = inarray[0][offset + nq - 1];
83 u_l = inarray[1][offset + nq - 1];
84
85 // Call the R RiemannSolver
86 R_RiemannSolver(RT, A_l, u_l, A_0[omega][nq - 1], beta[omega][nq - 1],
87 alpha[omega][nq - 1], POut, A_u, u_u);
88
89 /* Fix the boundary conditions in the virtual region to ensure
90 upwind state matches the boundary condition at the next time step */
91 A_r = A_l;
92 u_r = 2 * u_u - u_l;
93
94 // Store the updated values
95 (vessel[0]->UpdateBndCondExpansion(n))->UpdatePhys()[0] = A_r;
96 (vessel[1]->UpdateBndCondExpansion(n))->UpdatePhys()[0] = u_r;
97}
98
100 NekDouble A_0, NekDouble beta, NekDouble alpha,
101 NekDouble POut, NekDouble &A_u, NekDouble &u_u)
102{
103 NekDouble W1 = 0.0;
104 NekDouble c = 0.0;
105 NekDouble cL = 0.0;
106 NekDouble I = 0.0;
107 NekDouble A_calc = 0.0;
108 NekDouble FA = 0.0;
109 NekDouble dFdA = 0.0;
110 NekDouble delta_A_calc = 0.0;
111 NekDouble P = 0.0;
112 NekDouble rho = m_rho;
113
114 int proceed = 1;
115 int iter = 0;
116 int MAX_ITER = 200;
117
118 // Tolerances for the algorithm
119 NekDouble Tol = 1.0E-10;
120
121 // Calculate the wave speed
122 m_pressureArea->GetC(cL, beta, A_l, A_0, alpha);
123
124 // Riemann invariant \f$W_1(Al,ul)\f$
125 m_pressureArea->GetW1(W1, u_l, beta, A_l, A_0, alpha);
126
127 // Newton Iteration (Area only)
128 A_calc = A_l;
129 while ((proceed) && (iter < MAX_ITER))
130 {
131 iter += 1;
132
133 m_pressureArea->GetPressure(P, beta, A_calc, A_0, 0, 0, alpha);
134 m_pressureArea->GetC(c, beta, A_calc, A_0, alpha);
135 m_pressureArea->GetCharIntegral(I, beta, A_calc, A_0, alpha);
136
137 FA = R * A_calc * (W1 - I) - P + POut;
138 dFdA = R * (W1 - I - c) - c * c * rho / A_calc;
139 delta_A_calc = FA / dFdA;
140 A_calc -= delta_A_calc;
141
142 if (sqrt(delta_A_calc * delta_A_calc) < Tol)
143 {
144 proceed = 0;
145 }
146 }
147
148 m_pressureArea->GetPressure(P, beta, A_calc, A_0, 0, 0, alpha);
149
150 // Obtain u_u and A_u
151 u_u = (P - POut) / (R * A_calc);
152 A_u = A_calc;
153}
154
155} // namespace Nektar
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Array< OneD, MultiRegions::ExpListSharedPtr > m_vessels
PulseWavePressureAreaSharedPtr m_pressureArea
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:51
static std::string className
Definition: ROutflow.h:68
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:99
ROutflow(Array< OneD, MultiRegions::ExpListSharedPtr > pVessel, const LibUtilities::SessionReaderSharedPtr pSession, PulseWavePressureAreaSharedPtr pressureArea)
Definition: ROutflow.cpp:44
static PulseWaveBoundarySharedPtr create(Array< OneD, MultiRegions::ExpListSharedPtr > &pVessel, const LibUtilities::SessionReaderSharedPtr &pSession, PulseWavePressureAreaSharedPtr &pressureArea)
Definition: ROutflow.h:58
std::shared_ptr< SessionReader > SessionReaderSharedPtr
@ beta
Gauss Radau pinned at x=-1,.
Definition: PointsType.h:59
@ P
Monomial polynomials .
Definition: BasisType.h:62
std::shared_ptr< PulseWavePressureArea > PulseWavePressureAreaSharedPtr
BoundaryFactory & GetBoundaryFactory()
double NekDouble
scalarT< T > sqrt(scalarT< T > in)
Definition: scalar.hpp:285