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