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