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,
61  const NekDouble &dAUdx,
62  const NekDouble &gamma,
63  const NekDouble &alpha)
64 {
65  P = m_PExt + beta * (sqrt(A) - sqrt(A0)) -
66  gamma * dAUdx / sqrt(A); // Viscoelasticity
67 }
68 
70  const NekDouble &A, const NekDouble &A0,
71  const NekDouble &alpha)
72 {
73  c = sqrt(beta / (2 * m_rho)) * sqrt(sqrt(A)); // Elastic
74 }
75 
77  const NekDouble &beta, const NekDouble &A,
78  const NekDouble &A0, const NekDouble &alpha)
79 {
80  NekDouble I = 0.0;
81  GetCharIntegral(I, beta, A, A0);
82 
83  W1 = u + I; // Elastic and assumes u0 = 0
84 }
85 
87  const NekDouble &beta, const NekDouble &A,
88  const NekDouble &A0, const NekDouble &alpha)
89 {
90  NekDouble I = 0.0;
91  GetCharIntegral(I, beta, A, A0);
92 
93  W2 = u - I; // Elastic and assumes u0 = 0
94 }
95 
97  const NekDouble &W2,
98  const NekDouble &beta,
99  const NekDouble &A0,
100  const NekDouble &alpha)
101 {
102  A = pow((W1 - W2) * sqrt(2 * m_rho / beta) / 8 + sqrt(sqrt(A0)), 4);
103 }
104 
106  const NekDouble &W2)
107 {
108  u = (W1 + W2) / 2; // Necessarily the case for all tube laws
109 }
110 
112  const NekDouble &A,
113  const NekDouble &A0,
114  const NekDouble &alpha)
115 {
116  NekDouble c = 0.0;
117  NekDouble c0 = 0.0;
118 
119  GetC(c, beta, A, A0);
120  GetC(c0, beta, A0, A0);
121 
122  I = 4 * (c - c0);
123 }
124 
126  const Array<OneD, NekDouble> &Au,
127  const Array<OneD, NekDouble> &uu,
129  const Array<OneD, NekDouble> &A0,
130  const Array<OneD, NekDouble> &alpha,
131  const std::string &type)
132 {
133  /*
134  In the interest of speed, the inverse of the Jacobians for bifurcations,
135  merges and junctions for the beta law have been calculated analytically.
136  This can be done for other laws too, or the general formulation can be used
137  instead.
138  */
139 
140  NekDouble k = 0.0;
141 
142  if (type == "Bifurcation")
143  {
144  NekMatrix<NekDouble> J(6, 6);
147 
148  for (int i = 0; i < 3; ++i)
149  {
150  GetC(c[i], beta[i], Au[i], A0[i], alpha[i]);
151  }
152 
153  k = c[0] * Au[1] * c[2] + Au[0] * c[2] * c[1] + Au[2] * c[0] * c[1];
154  K[0] = (c[0] - uu[0]) * k;
155  K[1] = (c[1] + uu[1]) * k;
156  K[2] = (c[2] + uu[2]) * k;
157 
158  invJ.SetValue(0, 0,
159  (-c[1] * uu[0] * c[2] * Au[0] +
160  Au[2] * c[1] * c[0] * c[0] +
161  Au[1] * c[0] * c[0] * c[2]) /
162  K[0]);
163  invJ.SetValue(0, 1, Au[1] * (c[1] - uu[1]) * c[0] * c[2] / K[0]);
164  invJ.SetValue(0, 2, Au[2] * (c[2] - uu[2]) * c[0] * c[1] / K[0]);
165  invJ.SetValue(0, 3, c[0] * c[1] * c[2] / K[0]);
166  invJ.SetValue(0, 4, -0.5 * c[0] * Au[1] * c[2] / K[0]);
167  invJ.SetValue(0, 5, -0.5 * Au[2] * c[0] * c[1] / K[0]);
168 
169  invJ.SetValue(1, 0, Au[0] * (c[0] + uu[0]) * c[1] * c[2] / K[1]);
170  invJ.SetValue(1, 1,
171  (c[0] * uu[1] * c[2] * Au[1] +
172  Au[2] * c[0] * c[1] * c[1] +
173  c[2] * c[1] * c[1] * Au[0]) /
174  K[1]);
175  invJ.SetValue(1, 2, -Au[2] * (c[2] - uu[2]) * c[0] * c[1] / K[1]);
176  invJ.SetValue(1, 3, -c[0] * c[1] * c[2] / K[1]);
177  invJ.SetValue(1, 4, -0.5 * (c[0] * Au[2] + Au[0] * c[2]) * c[1] / K[1]);
178  invJ.SetValue(1, 5, 0.5 * Au[2] * c[0] * c[1] / K[1]);
179 
180  invJ.SetValue(2, 0, Au[0] * (c[0] + uu[0]) * c[1] * c[2] / K[2]);
181  invJ.SetValue(2, 1, -Au[1] * (c[1] - uu[1]) * c[0] * c[2] / K[2]);
182  invJ.SetValue(2, 2,
183  (c[0] * c[1] * uu[2] * Au[2] +
184  c[0] * Au[1] * c[2] * c[2] +
185  c[1] * c[2] * c[2] * Au[0]) /
186  K[2]);
187  invJ.SetValue(2, 3, -c[0] * c[1] * c[2] / K[2]);
188  invJ.SetValue(2, 4, 0.5 * c[0] * Au[1] * c[2] / K[2]);
189  invJ.SetValue(2, 5, -0.5 * (Au[1] * c[0] + c[1] * Au[0]) * c[2] / K[2]);
190 
191  invJ.SetValue(3, 0,
192  Au[0] *
193  (Au[0] * c[2] * c[1] - uu[0] * c[2] * Au[1] -
194  uu[0] * c[1] * Au[2]) /
195  K[0]);
196  invJ.SetValue(3, 1, -Au[0] * Au[1] * (c[1] - uu[1]) * c[2] / K[0]);
197  invJ.SetValue(3, 2, -Au[0] * Au[2] * (c[2] - uu[2]) * c[1] / K[0]);
198  invJ.SetValue(3, 3, -Au[0] * c[2] * c[1] / K[0]);
199  invJ.SetValue(3, 4, 0.5 * Au[0] * Au[1] * c[2] / K[0]);
200  invJ.SetValue(3, 5, 0.5 * Au[0] * c[1] * Au[2] / K[0]);
201 
202  invJ.SetValue(4, 0, Au[0] * Au[1] * (c[0] + uu[0]) * c[2] / K[1]);
203  invJ.SetValue(4, 1,
204  -Au[1] *
205  (c[0] * Au[1] * c[2] + c[0] * uu[1] * Au[2] +
206  c[2] * uu[1] * Au[0]) /
207  K[1]);
208  invJ.SetValue(4, 2, -Au[2] * Au[1] * (c[2] - uu[2]) * c[0] / K[1]);
209  invJ.SetValue(4, 3, -c[0] * Au[1] * c[2] / K[1]);
210  invJ.SetValue(4, 4,
211  -0.5 * Au[1] * (c[0] * Au[2] + Au[0] * c[2]) / K[1]);
212  invJ.SetValue(4, 5, 0.5 * Au[2] * Au[1] * c[0] / K[1]);
213 
214  invJ.SetValue(5, 0, Au[0] * Au[2] * (c[0] + uu[0]) * c[1] / K[2]);
215  invJ.SetValue(5, 1, -Au[2] * Au[1] * (c[1] - uu[1]) * c[0] / K[2]);
216  invJ.SetValue(5, 2,
217  -Au[2] *
218  (Au[2] * c[0] * c[1] + c[0] * uu[2] * Au[1] +
219  c[1] * uu[2] * Au[0]) /
220  K[2]);
221  invJ.SetValue(5, 3, -Au[2] * c[0] * c[1] / K[2]);
222  invJ.SetValue(5, 4, 0.5 * Au[2] * Au[1] * c[0] / K[2]);
223  invJ.SetValue(5, 5,
224  -0.5 * Au[2] * (Au[1] * c[0] + c[1] * Au[0]) / K[2]);
225  }
226  else if (type == "Merge")
227  {
228  NekMatrix<NekDouble> J(6, 6);
231 
232  for (int i = 0; i < 3; ++i)
233  {
234  GetC(c[i], beta[i], Au[i], A0[i], alpha[i]);
235  }
236 
237  k = c[0] * Au[1] * c[2] + Au[0] * c[2] * c[1] + Au[2] * c[0] * c[1];
238  K[0] = (c[0] - uu[0]) * k;
239  K[1] = (c[1] + uu[1]) * k;
240  K[2] = (c[2] + uu[2]) * k;
241 
242  invJ.SetValue(0, 0,
243  (-c[1] * uu[0] * c[2] * Au[0] +
244  Au[2] * c[1] * c[0] * c[0] +
245  Au[1] * c[0] * c[0] * c[2]) /
246  K[0]);
247  invJ.SetValue(0, 1, Au[1] * (c[1] - uu[1]) * c[0] * c[2] / K[0]);
248  invJ.SetValue(0, 2, Au[2] * (c[2] - uu[2]) * c[0] * c[1] / K[0]);
249  invJ.SetValue(0, 3, c[0] * c[1] * c[2] / K[0]);
250  invJ.SetValue(0, 4, -0.5 * c[0] * Au[1] * c[2] / K[0]);
251  invJ.SetValue(0, 5, -0.5 * Au[2] * c[0] * c[1] / K[0]);
252 
253  invJ.SetValue(1, 0, Au[0] * (c[0] + uu[0]) * c[1] * c[2] / K[1]);
254  invJ.SetValue(1, 1,
255  (c[0] * uu[1] * c[2] * Au[1] +
256  Au[2] * c[0] * c[1] * c[1] +
257  c[2] * c[1] * c[1] * Au[0]) /
258  K[1]);
259  invJ.SetValue(1, 2, -Au[2] * (c[2] - uu[2]) * c[0] * c[1] / K[1]);
260  invJ.SetValue(1, 3, -c[0] * c[1] * c[2] / K[1]);
261  invJ.SetValue(1, 4, -0.5 * (c[0] * Au[2] + Au[0] * c[2]) * c[1] / K[1]);
262  invJ.SetValue(1, 5, 0.5 * Au[2] * c[0] * c[1] / K[1]);
263 
264  invJ.SetValue(2, 0, Au[0] * (c[0] - uu[0]) * c[1] * c[2] / K[2]);
265  invJ.SetValue(2, 1, -Au[1] * (c[1] + uu[1]) * c[0] * c[2] / K[2]);
266  invJ.SetValue(2, 2,
267  -(c[0] * uu[2] * c[1] * Au[2] -
268  Au[1] * c[0] * c[2] * c[2] -
269  c[1] * c[2] * c[2] * Au[0]) /
270  K[2]);
271  invJ.SetValue(2, 3, -c[0] * c[1] * c[2] / K[2]);
272  invJ.SetValue(2, 4, -0.5 * Au[1] * c[0] * c[2] / K[2]);
273  invJ.SetValue(2, 5, 0.5 * (Au[1] * c[0] + Au[0] * c[1]) * c[2] / K[2]);
274 
275  invJ.SetValue(3, 0,
276  -Au[0] *
277  (Au[0] * c[2] * c[1] + uu[0] * c[2] * Au[1] +
278  uu[0] * c[1] * Au[2]) /
279  K[0]);
280  invJ.SetValue(3, 1, Au[0] * Au[1] * (c[1] + uu[1]) * c[2] / K[0]);
281 
282  invJ.SetValue(3, 2, -Au[0] * Au[2] * (c[2] - uu[2]) * c[1] / K[0]);
283  invJ.SetValue(3, 3, -Au[0] * c[2] * c[1] / K[0]);
284  invJ.SetValue(3, 4, 0.5 * Au[0] * Au[1] * c[2] / K[0]);
285  invJ.SetValue(3, 5, 0.5 * Au[0] * c[1] * Au[2] / K[0]);
286 
287  invJ.SetValue(4, 0, Au[0] * Au[1] * (c[0] + uu[0]) * c[2] / K[1]);
288  invJ.SetValue(4, 1,
289  -Au[1] *
290  (c[0] * Au[1] * c[2] + c[0] * uu[1] * Au[2] +
291  c[2] * uu[1] * Au[0]) /
292  K[1]);
293  invJ.SetValue(4, 2, -Au[2] * Au[1] * (c[2] - uu[2]) * c[0] / K[1]);
294  invJ.SetValue(4, 3, -c[0] * Au[1] * c[2] / K[1]);
295  invJ.SetValue(4, 4,
296  -0.5 * Au[1] * (c[0] * Au[2] + Au[0] * c[2]) / K[1]);
297  invJ.SetValue(4, 5, 0.5 * Au[2] * Au[1] * c[0] / K[1]);
298 
299  invJ.SetValue(5, 0, Au[0] * Au[2] * (c[0] + uu[0]) * c[1] / K[2]);
300  invJ.SetValue(5, 1, -Au[2] * Au[1] * (c[1] - uu[1]) * c[0] / K[2]);
301  invJ.SetValue(5, 2,
302  -Au[2] *
303  (Au[2] * c[0] * c[1] + c[0] * uu[2] * Au[1] +
304  c[1] * uu[2] * Au[0]) /
305  K[2]);
306  invJ.SetValue(5, 3, -Au[2] * c[0] * c[1] / K[2]);
307  invJ.SetValue(5, 4, 0.5 * Au[2] * Au[1] * c[0] / K[2]);
308  invJ.SetValue(5, 5,
309  -0.5 * Au[2] * (Au[1] * c[0] + c[1] * Au[0]) / K[2]);
310  }
311  else if (type == "Interface")
312  {
313  NekMatrix<NekDouble> J(4, 4);
316 
317  for (int i = 0; i < 2; ++i)
318  {
319  GetC(c[i], beta[i], Au[i], A0[i], alpha[i]);
320  }
321 
322  k = (c[0] * Au[1] + Au[0] * c[1]);
323  K[0] = (c[0] + uu[0]) * k;
324  K[1] = (c[1] + uu[1]) * k;
325 
326  invJ.SetValue(0, 0,
327  (Au[1] * c[0] * c[0] - c[1] * uu[0] * Au[0]) / K[0]);
328  invJ.SetValue(0, 1, Au[1] * (c[1] - uu[1]) * c[0] / K[0]);
329  invJ.SetValue(0, 2, c[0] * c[1] / K[0]);
330  invJ.SetValue(0, 3, -0.5 * c[0] * Au[1] / K[0]);
331 
332  invJ.SetValue(1, 0, Au[0] * (c[0] + uu[0]) * c[1] / K[1]);
333  invJ.SetValue(1, 1,
334  (c[0] * uu[1] * Au[1] + c[1] * c[1] * Au[0]) / K[1]);
335  invJ.SetValue(1, 2, -c[0] * c[1] / K[1]);
336  invJ.SetValue(1, 3, -0.5 * Au[0] * c[1] / K[1]);
337 
338  invJ.SetValue(2, 0, Au[0] * (Au[0] * c[1] - uu[0] * Au[1]) / K[0]);
339  invJ.SetValue(2, 1, -Au[0] * Au[1] * (c[1] - uu[1]) / K[0]);
340  invJ.SetValue(2, 2, -Au[0] * c[1] / K[0]);
341  invJ.SetValue(2, 3, 0.5 * Au[1] * Au[0] / K[0]);
342 
343  invJ.SetValue(3, 0, Au[0] * Au[1] * (c[0] + uu[0]) / K[1]);
344  invJ.SetValue(3, 1, -Au[1] * (c[0] * Au[1] + uu[1] * Au[0]) / K[1]);
345  invJ.SetValue(3, 2, -c[0] * Au[1] / K[1]);
346  invJ.SetValue(3, 3, -0.5 * Au[1] * Au[0] / K[1]);
347  }
348 }
349 
350 } // 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:198
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
@ beta
Gauss Radau pinned at x=-1,.
Definition: PointsType.h:61
The above copyright notice and this permission notice shall be included.
Definition: CoupledSolver.h:1
PressureAreaFactory & GetPressureAreaFactory()
double NekDouble
scalarT< T > sqrt(scalarT< T > in)
Definition: scalar.hpp:291