Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ROutflow.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File CommMpi.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 
38 namespace Nektar
39 {
40 
41  std::string ROutflow::className
43  "Rterminal",
45  "Resistive outflow boundary condition");
46 
47  /**
48  *
49  */
52  PulseWavePressureAreaSharedPtr pressureArea)
53  : PulseWaveBoundary(pVessel,pSession,pressureArea)
54  {
55  }
56 
57  /**
58  *
59  */
61  {
62 
63  }
64 
66  const Array<OneD,const Array<OneD, NekDouble> > &inarray,
69  const NekDouble time,
70  int omega,int offset,int n)
71  {
72  NekDouble A_r, u_r;
73  NekDouble A_u, u_u;
74  NekDouble A_l, u_l;
75 
77 
78  vessel[0] = m_vessels[2*omega];
79  vessel[1] = m_vessels[2*omega+1];
80 
81  /* Find the terminal R boundary condition and
82  calculates the updated velocity and area as
83  well as the updated boundary conditions */
84 
85  NekDouble RT=((vessel[0]->GetBndCondExpansions())[n])->GetCoeffs()[0];
86  NekDouble pout = m_pout;
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],
95  beta[omega][nq-1],pout,A_u,u_u);
96 
97  // Calculates the new boundary conditions
98  A_r=A_l;
99  u_r=2*u_u-u_l;
100 
101  // Store the updated values in the boundary condition
102 
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 pout,
109  NekDouble &A_u,NekDouble &u_u)
110  {
111  NekDouble W1 = 0.0;
112  NekDouble c_l = 0.0;
113  NekDouble pext = m_pext;
114  NekDouble A_calc = 0.0;
115  NekDouble fa = 0.0;
116  NekDouble dfa = 0.0;
117  NekDouble delta_A_calc = 0.0;
118  NekDouble rho = m_rho;
119 
120  int proceed = 1;
121  int iter = 0;
122  int MAX_ITER = 200;
123 
124  // Tolerances for the algorithm
125  NekDouble Tol = 1.0e-10;
126 
127  // Calculate the wave speed
128  c_l = sqrt(beta/(2*rho))*sqrt(sqrt(A_l));
129 
130  // Riemann invariant \f$W_1(Al,ul)\f$
131  W1 = u_l + 4*c_l;
132 
133  // Newton Iteration (Area only)
134  A_calc = A_l;
135  while ((proceed) && (iter < MAX_ITER))
136  {
137  iter =iter+1;
138 
139  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;
140  dfa = R*W1-5*R*sqrt(beta/(2*rho))*sqrt(sqrt(A_calc))-beta/(2*sqrt(A_calc));
141  delta_A_calc = fa/dfa;
142  A_calc = A_calc - delta_A_calc;
143 
144  if (sqrt(delta_A_calc*delta_A_calc) < Tol)
145  proceed = 0;
146  }
147 
148  // Obtain u_u and A_u
149  u_u=(pext+beta*(sqrt(A_calc)-sqrt(A_0))-pout)/(R*A_calc);
150  A_u = A_calc;
151  }
152 
153 
154 }
static std::string className
Name of class.
Definition: ROutflow.h:63
ROutflow(Array< OneD, MultiRegions::ExpListSharedPtr > pVessel, const LibUtilities::SessionReaderSharedPtr pSession, PulseWavePressureAreaSharedPtr pressureArea)
Definition: ROutflow.cpp:50
Array< OneD, MultiRegions::ExpListSharedPtr > m_vessels
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: ROutflow.cpp:107
boost::shared_ptr< SessionReader > SessionReaderSharedPtr
Definition: MeshPartition.h:51
BoundaryFactory & GetBoundaryFactory()
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: ROutflow.cpp:65
virtual ~ROutflow()
Definition: ROutflow.cpp:60
double NekDouble
boost::shared_ptr< PulseWavePressureArea > PulseWavePressureAreaSharedPtr
static PulseWaveBoundarySharedPtr create(Array< OneD, MultiRegions::ExpListSharedPtr > &pVessel, const LibUtilities::SessionReaderSharedPtr &pSession, PulseWavePressureAreaSharedPtr &pressureArea)
Creates an instance of this class.
Definition: ROutflow.h:55
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:215