Nektar++
BetaPressureArea.cpp
Go to the documentation of this file.
1  ///////////////////////////////////////////////////////////////////////////////
2 //
3 // File BetaPressureArea.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: BetaPressureArea class
33 //
34 ///////////////////////////////////////////////////////////////////////////////
35 
37 
38 using namespace std;
39 
40 namespace Nektar
41 {
42 
43 std::string BetaPressureArea::className =
45  "Beta", BetaPressureArea::create,
46  "Beta law pressure area relationship for the arterial system");
47 
48 BetaPressureArea::BetaPressureArea(
51  : PulseWavePressureArea(pVessel, pSession)
52 {
53 }
54 
56 {
57 }
58 
60  const NekDouble &A, const NekDouble &A0, const NekDouble &dAUdx,
61  const NekDouble &gamma, const NekDouble &alpha)
62 {
63  P = m_PExt + beta * (sqrt(A) - sqrt(A0)) - gamma * dAUdx / sqrt(A); // Viscoelasticity
64 }
65 
67  const NekDouble &A, const NekDouble &A0, const NekDouble &alpha)
68 {
69  c = sqrt(beta / (2 * m_rho)) * sqrt(sqrt(A)); // Elastic
70 }
71 
73  const NekDouble &beta, const NekDouble &A, const NekDouble &A0,
74  const NekDouble &alpha)
75 {
76  NekDouble I = 0.0;
77  GetCharIntegral(I, beta, A, A0);
78 
79  W1 = u + I; // Elastic and assumes u0 = 0
80 }
81 
83  const NekDouble &beta, const NekDouble &A, const NekDouble &A0,
84  const NekDouble &alpha)
85 {
86  NekDouble I = 0.0;
87  GetCharIntegral(I, beta, A, A0);
88 
89  W2 = u - I; // Elastic and assumes u0 = 0
90 }
91 
93  const NekDouble &W2, const NekDouble &beta, const NekDouble &A0,
94  const NekDouble &alpha)
95 {
96  A = pow((W1 - W2) * sqrt(2 * m_rho / beta) / 8 + sqrt(sqrt(A0)), 4);
97 }
98 
100  const NekDouble &W2)
101 {
102  u = (W1 + W2) / 2; // Necessarily the case for all tube laws
103 }
104 
106  const NekDouble &A, const NekDouble &A0, const NekDouble &alpha)
107 {
108  NekDouble c = 0.0;
109  NekDouble c0 = 0.0;
110 
111  GetC(c, beta, A, A0);
112  GetC(c0, beta, A0, A0);
113 
114  I = 4 * (c - c0);
115 }
116 
118  const Array<OneD, NekDouble> &Au, const Array<OneD, NekDouble> &uu,
119  const Array<OneD, NekDouble> &beta, const Array<OneD, NekDouble> &A0,
120  const Array<OneD, NekDouble> &alpha, const std::string &type)
121 {
122  /*
123  In the interest of speed, the inverse of the Jacobians for bifurcations,
124  merges and junctions for the beta law have been calculated analytically.
125  This can be done for other laws too, or the general formulation can be used
126  instead.
127  */
128 
129  NekDouble k = 0.0;
130 
131  if (type == "Bifurcation")
132  {
133  NekMatrix<NekDouble> J(6, 6);
136 
137  for (int i = 0; i < 3; ++i)
138  {
139  GetC(c[i], beta[i], Au[i], A0[i], alpha[i]);
140  }
141 
142  k = c[0] * Au[1] * c[2] + Au[0] * c[2] * c[1] + Au[2] * c[0] * c[1];
143  K[0] = (c[0] - uu[0]) * k;
144  K[1] = (c[1] + uu[1]) * k;
145  K[2] = (c[2] + uu[2]) * k;
146 
147  invJ.SetValue(0, 0, (-c[1] * uu[0] * c[2] * Au[0] + Au[2] * c[1] * c[0]
148  * c[0] + Au[1] * c[0] * c[0] * c[2]) / K[0]);
149  invJ.SetValue(0, 1, Au[1] * (c[1] - uu[1]) * c[0] * c[2] / K[0]);
150  invJ.SetValue(0, 2, Au[2] * (c[2] - uu[2]) * c[0] * c[1] / K[0]);
151  invJ.SetValue(0, 3, c[0] * c[1] * c[2] / K[0]);
152  invJ.SetValue(0, 4, -0.5 * c[0] * Au[1] * c[2] / K[0]);
153  invJ.SetValue(0, 5, -0.5 * Au[2] * c[0] * c[1] / K[0]);
154 
155  invJ.SetValue(1, 0, Au[0] * (c[0] + uu[0]) * c[1] * c[2] / K[1]);
156  invJ.SetValue(1, 1, (c[0] * uu[1] * c[2] * Au[1] + Au[2] * c[0] * c[1]
157  * c[1] + c[2] * c[1] * c[1] * Au[0]) / K[1]);
158  invJ.SetValue(1, 2, -Au[2] * (c[2] - uu[2]) * c[0] * c[1] / K[1]);
159  invJ.SetValue(1, 3, -c[0] * c[1] * c[2] / K[1]);
160  invJ.SetValue(1, 4, -0.5 * (c[0] * Au[2] + Au[0] * c[2]) * c[1] / K[1]);
161  invJ.SetValue(1, 5, 0.5 * Au[2] * c[0] * c[1] / K[1]);
162 
163  invJ.SetValue(2, 0, Au[0] * (c[0] + uu[0]) * c[1] * c[2] / K[2]);
164  invJ.SetValue(2, 1, -Au[1] * (c[1] - uu[1]) * c[0] * c[2] / K[2]);
165  invJ.SetValue(2, 2, (c[0] * c[1] * uu[2] * Au[2] + c[0] * Au[1] * c[2]
166  * c[2] + c[1] * c[2] * c[2] * Au[0]) / K[2]);
167  invJ.SetValue(2, 3, -c[0] * c[1] * c[2] / K[2]);
168  invJ.SetValue(2, 4, 0.5 * c[0] * Au[1] * c[2] / K[2]);
169  invJ.SetValue(2, 5, -0.5 * (Au[1] * c[0] + c[1] * Au[0]) * c[2] / K[2]);
170 
171  invJ.SetValue(3, 0, Au[0] * (Au[0] * c[2] * c[1] - uu[0] * c[2] * Au[1]
172  - uu[0] * c[1] * Au[2]) / K[0]);
173  invJ.SetValue(3, 1, -Au[0] * Au[1] * (c[1] - uu[1]) * c[2] / K[0]);
174  invJ.SetValue(3, 2, -Au[0] * Au[2] * (c[2] - uu[2]) * c[1] / K[0]);
175  invJ.SetValue(3, 3, -Au[0] * c[2] * c[1] / K[0]);
176  invJ.SetValue(3, 4, 0.5 * Au[0] * Au[1] * c[2] / K[0]);
177  invJ.SetValue(3, 5, 0.5 * Au[0] * c[1] * Au[2] / K[0]);
178 
179  invJ.SetValue(4, 0, Au[0] * Au[1] * (c[0] + uu[0]) * c[2] / K[1]);
180  invJ.SetValue(4, 1, -Au[1] * (c[0] * Au[1] * c[2] + c[0] * uu[1] * Au[2]
181  + c[2] * uu[1] * Au[0]) / K[1]);
182  invJ.SetValue(4, 2, -Au[2] * Au[1] * (c[2] - uu[2]) * c[0] / K[1]);
183  invJ.SetValue(4, 3, -c[0] * Au[1] * c[2] / K[1]);
184  invJ.SetValue(4, 4, -0.5 * Au[1] * (c[0] * Au[2] + Au[0] * c[2]) / K[1]);
185  invJ.SetValue(4, 5, 0.5 * Au[2] * Au[1] * c[0] / K[1]);
186 
187  invJ.SetValue(5, 0, Au[0] * Au[2] * (c[0] + uu[0]) * c[1] / K[2]);
188  invJ.SetValue(5, 1, -Au[2] * Au[1] * (c[1] - uu[1]) * c[0] / K[2]);
189  invJ.SetValue(5, 2, -Au[2] * (Au[2] * c[0] * c[1] + c[0] * uu[2] * Au[1]
190  + c[1] * uu[2] * Au[0]) / K[2]);
191  invJ.SetValue(5, 3, -Au[2] * c[0] * c[1] / K[2]);
192  invJ.SetValue(5, 4, 0.5 * Au[2] * Au[1] * c[0] / K[2]);
193  invJ.SetValue(5, 5, -0.5 * Au[2] * (Au[1] * c[0] + c[1] * Au[0]) / K[2]);
194  }
195  else if (type == "Merge")
196  {
197  NekMatrix<NekDouble> J(6, 6);
200 
201  for (int i = 0; i < 3; ++i)
202  {
203  GetC(c[i], beta[i], Au[i], A0[i], alpha[i]);
204  }
205 
206  k = c[0] * Au[1] * c[2] + Au[0] * c[2] * c[1] + Au[2] * c[0] * c[1];
207  K[0] = (c[0] - uu[0]) * k;
208  K[1] = (c[1] + uu[1]) * k;
209  K[2] = (c[2] + uu[2]) * k;
210 
211  invJ.SetValue(0, 0, (-c[1] * uu[0] * c[2] * Au[0] + Au[2] * c[1] * c[0]
212  * c[0] + Au[1] * c[0] * c[0] * c[2]) / K[0]);
213  invJ.SetValue(0, 1, Au[1] * (c[1] - uu[1]) * c[0] * c[2] / K[0]);
214  invJ.SetValue(0, 2, Au[2] * (c[2] - uu[2]) * c[0] * c[1] / K[0]);
215  invJ.SetValue(0, 3, c[0] * c[1] * c[2] / K[0]);
216  invJ.SetValue(0, 4, -0.5 * c[0] * Au[1] * c[2] / K[0]);
217  invJ.SetValue(0, 5, -0.5 * Au[2] * c[0] * c[1] / K[0]);
218 
219  invJ.SetValue(1, 0, Au[0] * (c[0] + uu[0]) * c[1] * c[2] / K[1]);
220  invJ.SetValue(1, 1, (c[0] * uu[1] * c[2] * Au[1] + Au[2] * c[0] * c[1]
221  * c[1] + c[2] * c[1] * c[1] * Au[0]) / K[1]);
222  invJ.SetValue(1, 2, -Au[2] * (c[2] - uu[2]) * c[0] * c[1] / K[1]);
223  invJ.SetValue(1, 3, -c[0] * c[1] * c[2] / K[1]);
224  invJ.SetValue(1, 4, -0.5 * (c[0] * Au[2] + Au[0] * c[2]) * c[1] / K[1]);
225  invJ.SetValue(1, 5, 0.5 * Au[2] * c[0] * c[1] / K[1]);
226 
227  invJ.SetValue(2, 0, Au[0] * (c[0] - uu[0]) * c[1] * c[2] / K[2]);
228  invJ.SetValue(2, 1, -Au[1] * (c[1] + uu[1]) * c[0] * c[2] / K[2]);
229  invJ.SetValue(2, 2, -(c[0] * uu[2] * c[1] * Au[2] - Au[1] * c[0] *
230  c[2] * c[2] - c[1] * c[2] * c[2] * Au[0]) / K[2]);
231  invJ.SetValue(2, 3, -c[0] * c[1] * c[2] / K[2]);
232  invJ.SetValue(2, 4, -0.5 * Au[1] * c[0] * c[2] / K[2]);
233  invJ.SetValue(2, 5, 0.5 * (Au[1] * c[0] + Au[0] * c[1]) * c[2] / K[2]);
234 
235  invJ.SetValue(3, 0, -Au[0] * (Au[0] * c[2] * c[1] + uu[0] * c[2] *
236  Au[1] + uu[0] * c[1] * Au[2]) / K[0]);
237  invJ.SetValue(3, 1, Au[0] * Au[1] * (c[1] + uu[1]) * c[2] / K[0]);
238 
239  invJ.SetValue(3, 2, -Au[0] * Au[2] * (c[2] - uu[2]) * c[1] / K[0]);
240  invJ.SetValue(3, 3, -Au[0] * c[2] * c[1] / K[0]);
241  invJ.SetValue(3, 4, 0.5 * Au[0] * Au[1] * c[2] / K[0]);
242  invJ.SetValue(3, 5, 0.5 * Au[0] * c[1] * Au[2] / K[0]);
243 
244  invJ.SetValue(4, 0, Au[0] * Au[1] * (c[0] + uu[0]) * c[2] / K[1]);
245  invJ.SetValue(4, 1, -Au[1] * (c[0] * Au[1] * c[2] + c[0] * uu[1] * Au[2]
246  + c[2] * uu[1] * Au[0]) / K[1]);
247  invJ.SetValue(4, 2, -Au[2] * Au[1] * (c[2] - uu[2]) * c[0] / K[1]);
248  invJ.SetValue(4, 3, -c[0] * Au[1] * c[2] / K[1]);
249  invJ.SetValue(4, 4, -0.5 * Au[1] * (c[0] * Au[2] + Au[0] * c[2]) / K[1]);
250  invJ.SetValue(4, 5, 0.5 * Au[2] * Au[1] * c[0] / K[1]);
251 
252  invJ.SetValue(5, 0, Au[0] * Au[2] * (c[0] + uu[0]) * c[1] / K[2]);
253  invJ.SetValue(5, 1, -Au[2] * Au[1] * (c[1] - uu[1]) * c[0] / K[2]);
254  invJ.SetValue(5, 2, -Au[2] * (Au[2] * c[0] * c[1] + c[0] * uu[2] * Au[1]
255  + c[1] * uu[2] * Au[0]) / K[2]);
256  invJ.SetValue(5, 3, -Au[2] * c[0] * c[1] / K[2]);
257  invJ.SetValue(5, 4, 0.5 * Au[2] * Au[1] * c[0] / K[2]);
258  invJ.SetValue(5, 5, -0.5 * Au[2] * (Au[1] * c[0] + c[1] * Au[0]) / K[2]);
259  }
260  else if (type == "Junction")
261  {
262  NekMatrix<NekDouble> J(4, 4);
265 
266  for (int i = 0; i < 2; ++i)
267  {
268  GetC(c[i], beta[i], Au[i], A0[i], alpha[i]);
269  }
270 
271  k = (c[0] * Au[1] + Au[0] * c[1]);
272  K[0] = (c[0] + uu[0]) * k;
273  K[1] = (c[1] + uu[1]) * k;
274 
275  invJ.SetValue(0, 0, (Au[1] * c[0] * c[0] - c[1] * uu[0] * Au[0]) / K[0]);
276  invJ.SetValue(0, 1, Au[1] * (c[1] - uu[1]) * c[0] / K[0]);
277  invJ.SetValue(0, 2, c[0] * c[1] / K[0]);
278  invJ.SetValue(0, 3, -0.5 * c[0] * Au[1] / K[0]);
279 
280  invJ.SetValue(1, 0, Au[0] * (c[0] + uu[0]) * c[1] / K[1]);
281  invJ.SetValue(1, 1, (c[0] * uu[1] * Au[1] + c[1] * c[1] * Au[0]) / K[1]);
282  invJ.SetValue(1, 2, -c[0] * c[1] / K[1]);
283  invJ.SetValue(1, 3, -0.5 * Au[0] * c[1] / K[1]);
284 
285  invJ.SetValue(2, 0, Au[0] * (Au[0] * c[1] - uu[0] * Au[1]) / K[0]);
286  invJ.SetValue(2, 1, -Au[0] * Au[1] * (c[1] - uu[1]) / K[0]);
287  invJ.SetValue(2, 2, -Au[0] * c[1] / K[0]);
288  invJ.SetValue(2, 3, 0.5 * Au[1] * Au[0] / K[0]);
289 
290  invJ.SetValue(3, 0, Au[0] * Au[1] * (c[0] + uu[0]) / K[1]);
291  invJ.SetValue(3, 1, -Au[1] * (c[0] * Au[1] + uu[1] * Au[0]) / K[1]);
292  invJ.SetValue(3, 2, -c[0] * Au[1] / K[1]);
293  invJ.SetValue(3, 3, -0.5 * Au[1] * Au[0] / K[1]);
294  }
295 }
296 
297 } // namespace Nektar
virtual void v_GetW1(NekDouble &W1, const NekDouble &u, const NekDouble &beta, const NekDouble &A, const NekDouble &A0, const NekDouble &alpha=0.5)
virtual void v_GetC(NekDouble &c, const NekDouble &beta, const NekDouble &A, const NekDouble &A0, const NekDouble &alpha=0.5)
virtual void v_GetW2(NekDouble &W2, const NekDouble &u, const NekDouble &beta, const NekDouble &A, const NekDouble &A0, const NekDouble &alpha=0.5)
virtual void v_GetCharIntegral(NekDouble &I, const NekDouble &beta, const NekDouble &A, const NekDouble &A0, const NekDouble &alpha=0.5)
virtual void v_GetUFromChars(NekDouble &u, const NekDouble &W1, const NekDouble &W2)
virtual void v_GetAFromChars(NekDouble &A, const NekDouble &W1, const NekDouble &W2, const NekDouble &beta, const NekDouble &A0, const NekDouble &alpha=0.5)
virtual void v_GetJacobianInverse(NekMatrix< NekDouble > &invJ, const Array< OneD, NekDouble > &Au, const Array< OneD, NekDouble > &uu, const Array< OneD, NekDouble > &beta, const Array< OneD, NekDouble > &A0, const Array< OneD, NekDouble > &alpha, const std::string &type)
virtual void v_GetPressure(NekDouble &P, const NekDouble &beta, const NekDouble &A, const NekDouble &A0, const NekDouble &dAUdx, const NekDouble &gamma=0, const NekDouble &alpha=0.5)
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
Definition: NekFactory.hpp:200
void GetCharIntegral(NekDouble &I, const NekDouble &beta, const NekDouble &A, const NekDouble &A0, const NekDouble &alpha=0.5)
void GetC(NekDouble &c, const NekDouble &beta, const NekDouble &A, const NekDouble &A0, const NekDouble &alpha=0.5)
std::shared_ptr< SessionReader > SessionReaderSharedPtr
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:1
PressureAreaFactory & GetPressureAreaFactory()
double NekDouble
P
Definition: main.py:133
scalarT< T > sqrt(scalarT< T > in)
Definition: scalar.hpp:267