Nektar++
QInflow.cpp
Go to the documentation of this file.
1 ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File QInflow.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: QInflow class
32 //
33 ///////////////////////////////////////////////////////////////////////////////
34 
36 
37 using namespace std;
38 
39 namespace Nektar
40 {
41 
42  std::string QInflow::className
44  "Q-inflow",
45  QInflow::create,
46  "Inflow boundary condition");
47 
48  /**
49  *
50  */
53  PulseWavePressureAreaSharedPtr pressureArea)
54  : PulseWaveBoundary(pVessel,pSession,pressureArea)
55  {
56  }
57 
58  /**
59  *
60  */
62  {
63 
64  }
65 
67  const Array<OneD,const Array<OneD, NekDouble> > &inarray,
70  const NekDouble time,
71  int omega,
72  int offset,
73  int n)
74  {
75  NekDouble Q, A_u, u_u;
76  NekDouble A_r, u_r, A_l, u_l;
78 
79  vessel[0] = m_vessels[2*omega];
80  vessel[1] = m_vessels[2*omega+1];
81 
82  vessel[0]->EvaluateBoundaryConditions(time);
83 
84  // Note: The Q value is contained in A in the
85  // inputfile, the value in u has to be 1.0
86  //ASSERTL0((vessel[1]->UpdateBndCondExpansion(n))->UpdatePhys()[0] == 1.0, "For the Q-inflow BC the value in u must be 1.0");
87 
88  // Get the values of all variables needed for the Riemann problem
89  Q = (vessel[0]->UpdateBndCondExpansion(n))->GetCoeffs()[0];
90 
91  A_r = inarray[0][offset];
92  u_r = inarray[1][offset];
93 
94  // Call the Q-inflow Riemann solver
95  Q_RiemannSolver(Q,A_r,u_r,A_0[omega][0],beta[omega][0],A_u,u_u);
96 
97  // Set the boundary conditions to prescribe
98  A_l=A_r;
99  u_l=2*u_u-u_r;
100 
101  // Store the updated values in the boundary condition
102  (vessel[0]->UpdateBndCondExpansion(n))->UpdatePhys()[0] = A_l;
103  (vessel[1]->UpdateBndCondExpansion(n))->UpdatePhys()[0] = u_l;
104  }
105 
106  /**
107  * Q-inflow Riemann solver for pulse wave propagation. This Riemann solver is called
108  * by DoOdeProjection in case of a Q-inflow boundary condition. It is based on the
109  * conservation of mass and total pressure and on the characteristic information. For
110  * further details see "Pulse wave propagation in the human vascular system", section 3.4.1
111  * Returns the upwinded quantities \f$(A_u,u_u)\f$ and stores them into the boundary values
112  */
114  NekDouble &Au,NekDouble &uu)
115  {
116  NekDouble W2 = 0.0;
117  NekDouble A_calc = 0.0;
118  NekDouble fa = 0.0;
119  NekDouble dfa = 0.0;
120  NekDouble delta_A_calc = 0.0;
121  NekDouble rho = m_rho;
122 
123  int proceed = 1;
124  int iter = 0;
125  int MAX_ITER = 200;
126 
127  // Tolerances for the algorithm
128  NekDouble Tol = 1.0e-10;
129 
130  // Riemann invariant \f$W_2(Ar,ur)\f$
131  W2 = u_r - 4*sqrt(beta/(2*rho))*sqrt(sqrt(A_r));
132 
133  // Newton Iteration (Area only)
134  A_calc = A_r;
135  while ((proceed) && (iter < MAX_ITER))
136  {
137  iter =iter+1;
138 
139  fa = Q - W2*A_calc - A_calc*4*sqrt(beta/(2*rho))*sqrt(sqrt(A_calc));
140  dfa = -W2 - 5*sqrt(beta/(2*rho))*sqrt(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  uu = W2+4*sqrt(beta/(2*rho))*sqrt(sqrt(A_calc));
150  Au = A_calc;
151  }
152 
153 }
void Q_RiemannSolver(NekDouble Q, NekDouble A_r, NekDouble u_r, NekDouble A_0, NekDouble beta, NekDouble &Au, NekDouble &uu)
Definition: QInflow.cpp:113
STL namespace.
Array< OneD, MultiRegions::ExpListSharedPtr > m_vessels
BoundaryFactory & GetBoundaryFactory()
virtual ~QInflow()
Definition: QInflow.cpp:61
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: QInflow.cpp:66
double NekDouble
std::shared_ptr< PulseWavePressureArea > PulseWavePressureAreaSharedPtr
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:199
std::shared_ptr< SessionReader > SessionReaderSharedPtr