Nektar++
RCROutflow.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File RCROutflow.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:
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
37 
38 using namespace std;
39 
40 namespace Nektar
41 {
42 
43  std::string RCROutflow::className
45  "RCR-terminal",
46  RCROutflow::create,
47  "RCR outflow boundary condition");
48 
49  /**
50  *
51  */
52  RCROutflow::RCROutflow(Array<OneD, MultiRegions::ExpListSharedPtr> pVessel,
54  PulseWavePressureAreaSharedPtr pressureArea)
55  : PulseWaveBoundary(pVessel,pSession,pressureArea)
56  {
57  m_session->LoadParameter("TimeStep", m_timestep);
58  }
59 
60  /**
61  *
62  */
64  {
65 
66  }
67 
69  const Array<OneD,const Array<OneD, NekDouble> > &inarray,
72  const NekDouble time,
73  int omega,int offset,int n)
74  {
75  NekDouble A_r, u_r;
76  NekDouble A_u, u_u;
77  NekDouble A_l, u_l, c_0;
78 
80 
81  vessel[0] = m_vessels[2*omega];
82  vessel[1] = m_vessels[2*omega+1];
83 
84  /* Find the terminal RCR boundary condition and calculates
85  the updated velocity and area as well as the updated
86  boundary conditions */
87 
88  NekDouble RT=((vessel[0]->GetBndCondExpansions())[n])->GetCoeffs()[0];
89  NekDouble C=((vessel[1]->GetBndCondExpansions())[n])->GetCoeffs()[0];
90 
91  m_session->LoadParameter("pout", m_pout);
92 
93  NekDouble R1;
94  NekDouble R2;
95  NekDouble pout = m_pout;
96 
97  NekDouble rho = m_rho;
98  int nq = vessel[0]->GetTotPoints();
99 
100  A_l = inarray[0][offset+nq-1];
101  u_l = inarray[1][offset+nq-1];
102 
103  // Goes through the first resistance Calculate c_0
104  c_0 = sqrt(beta[omega][nq-1]/(2*m_rho))*sqrt(sqrt(A_0[omega][nq-1]));
105 
106  // Calculate R1 and R2, R1 being calculated so as
107  // to eliminate reflections in the vessel
108  R1 = rho*c_0/A_0[omega][nq-1];
109  R2 = RT-R1;
110 
111  // Call the R RiemannSolver
112  R_RiemannSolver(R1,A_l,u_l,A_0[omega][nq-1],beta[omega][nq-1],m_pc,A_u,u_u);
113  A_r = A_l;
114  u_r = 2*u_u-u_l;
115 
116  // Goes through the CR system, it consists in
117  // updating the pressure pc
118  m_pc = m_pc + m_timestep/C*(A_u*u_u-(m_pc-pout)/R2);
119 
120  // Store the updated values in the boundary condition
121  (vessel[0]->UpdateBndCondExpansion(n))->UpdatePhys()[0] = A_r;
122  (vessel[1]->UpdateBndCondExpansion(n))->UpdatePhys()[0] = u_r;
123  }
124 
126  NekDouble beta, NekDouble pout,
127  NekDouble &A_u,NekDouble &u_u)
128  {
129  NekDouble W1 = 0.0;
130  NekDouble c_l = 0.0;
131  NekDouble pext = m_pext;
132  NekDouble A_calc = 0.0;
133  NekDouble fa = 0.0;
134  NekDouble dfa = 0.0;
135  NekDouble delta_A_calc = 0.0;
136  NekDouble rho = m_rho;
137 
138  int proceed = 1;
139  int iter = 0;
140  int MAX_ITER = 200;
141 
142  // Tolerances for the algorithm
143  NekDouble Tol = 1.0e-10;
144 
145  // Calculate the wave speed
146  c_l = sqrt(beta/(2*rho))*sqrt(sqrt(A_l));
147 
148  // Riemann invariant \f$W_1(Al,ul)\f$
149  W1 = u_l + 4*c_l;
150 
151  // Newton Iteration (Area only)
152  A_calc = A_l;
153  while ((proceed) && (iter < MAX_ITER))
154  {
155  iter =iter+1;
156 
157  fa = R*W1*A_calc-4*R*sqrt(beta/(2*rho))*A_calc*sqrt(sqrt(A_calc))-pext-beta*(sqrt(A_calc)-sqrt(A_0))+pout;
158  dfa = R*W1-5*R*sqrt(beta/(2*rho))*sqrt(sqrt(A_calc))-beta/(2*sqrt(A_calc));
159  delta_A_calc = fa/dfa;
160  A_calc = A_calc - delta_A_calc;
161 
162  if (sqrt(delta_A_calc*delta_A_calc) < Tol)
163  proceed = 0;
164  }
165 
166  // Obtain u_u and A_u
167  //u_u = W1 - 4*sqrt(beta/(2*rho))*(sqrt(sqrt(A_calc)));
168  u_u=(pext+beta*(sqrt(A_calc)-sqrt(A_0))-pout)/(R*A_calc);
169  A_u = A_calc;
170  }
171 
172 
173 
174 
175 }
NekDouble m_timestep
Definition: RCROutflow.h:80
LibUtilities::SessionReaderSharedPtr m_session
STL namespace.
Array< OneD, MultiRegions::ExpListSharedPtr > m_vessels
BoundaryFactory & GetBoundaryFactory()
NekDouble m_pc
Definition: RCROutflow.h:82
double NekDouble
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, const NekDouble time, int omega, int offset, int n)
Definition: RCROutflow.cpp:68
std::shared_ptr< PulseWavePressureArea > PulseWavePressureAreaSharedPtr
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:199
void R_RiemannSolver(NekDouble R, NekDouble A_l, NekDouble u_l, NekDouble A_0, NekDouble beta, NekDouble pout, NekDouble &A_u, NekDouble &u_u)
Definition: RCROutflow.cpp:125
std::shared_ptr< SessionReader > SessionReaderSharedPtr
virtual ~RCROutflow()
Definition: RCROutflow.cpp:63