LifeV
HeartStiffnessFibers.hpp
Go to the documentation of this file.
1 //@HEADER
2 /*
3 *******************************************************************************
4 
5  Copyright (C) 2004, 2005, 2007 EPFL, Politecnico di Milano, INRIA
6  Copyright (C) 2010 EPFL, Politecnico di Milano, Emory University
7 
8  This file is part of LifeV.
9 
10  LifeV is free software; you can redistribute it and/or modify
11  it under the terms of the GNU Lesser General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  (at your option) any later version.
14 
15  LifeV is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public License
21  along with LifeV. If not, see <http://www.gnu.org/licenses/>.
22 
23 *******************************************************************************
24 */
25 //@HEADER
26 
27 /*!
28  @file
29  @brief Contains an extension to the elemOper for including
30  @a the fibers in the stiffness term for the Bidomain, Monodomain, and
31  @ Electromechanical problems
32 
33  @date 12-2009
34  @author Ricardo Ruiz-Baier <ricardo.ruiz@epfl.ch>
35 
36  @contributors Simone Rossi <simone.rossi@epfl.ch>
37  @mantainer Simone Rossi <simone.rossi@epfl.ch>, Ricardo Ruiz-Baier <ricardo.ruiz@epfl.ch>
38 
39  */
40 
41 
42 
43 
44 namespace LifeV
45 {
46 
47 template <class vector_type>
48 void stiff (const Real sigma_l, const Real sigma_t, const vector_type& cos, MatrixElemental& elmat, const CurrentFE& fe, const DOF& dof, UInt iblock, UInt jblock);
49 
50 template <class reduced_sigma, class vector_type>
51 void stiff ( const reduced_sigma& red_sigma, const Real sigma_l, const Real sigma_t, const vector_type& cos, MatrixElemental& elmat, const CurrentFE& fe, const DOF& dof, UInt iblock, UInt jblock, ID id = 0);
52 
53 template <class reduced_sigma>
54 void stiff ( reduced_sigma red_sigma, const Real D, MatrixElemental& elmat, const CurrentFE& fe, const DOF& dof, UInt iblock, UInt jblock, ID id = 0);
55 
56 template <class vector_type>
57 void stiffNL (vector_type& U, Real coef, MatrixElemental& elmat, const CurrentFE& fe,
58  const DOF& dof, UInt iblock, UInt jblock, const Real beta);
59 
60 //template <class vector_type>
61 //void stiffNL(vector_type& U, Real coef, MatrixElemental& elmat, const CurrentFE& fe,
62 // const DOF& dof, UInt iblock, UInt jblock, UInt nb, const Real beta);
63 
64 template <class vector_type>
65 void stiffNL (const vector_type& U, const Real sigma_l, const Real sigma_t,
66  const vector_type& cos, MatrixElemental& elmat, const CurrentFE& fe,
67  const DOF& dof, UInt iblock, UInt jblock, const Real beta);
68 
69 template <class vector_type>
70 void stiff ( const Real sigma_l, const Real sigma_t, const vector_type& cos, MatrixElemental& elmat, const CurrentFE& fe, const DOF& dof, UInt iblock, UInt jblock)
71 {
72  //! Assembling the righthand side
73  //ASSERT_PRE( fe.hasFirstDeriv(),
74  // "Stiffness matrix needs at least the first derivatives" );
75  MatrixElemental::matrix_view mat = elmat.block ( iblock, jblock );
76  Int iloc, jloc;
77  UInt i, icoor, jcoor, ig;
78  Real s;
79  ID eleId = fe.currentLocalId();
80  UInt dim = dof.numTotalDof();
81 
82  Vector a_l (fe.nbLocalCoor() );
83  Vector u_x (fe.nbQuadPt() );
84  Vector u_y (fe.nbQuadPt() );
85  Vector u_z (fe.nbQuadPt() );
86 
87  for ( ig = 0; ig < fe.nbQuadPt(); ig++ )
88  {
89  u_x[ig] = u_y[ig] = u_z[ig] = 0;
90  for (i = 0; i < fe.nbFEDof(); i++)
91  {
92  u_x[ig] += cos[dof.localToGlobalMap (eleId, i)] * fe.phi (i, ig); //(one component)
93  u_y[ig] += cos[dof.localToGlobalMap (eleId, i) + dim] * fe.phi (i, ig);
94  u_z[ig] += cos[dof.localToGlobalMap (eleId, i) + 2 * dim] * fe.phi (i, ig);
95  }
96  }
97  //
98  // diagonal
99  //
100 
101  for ( i = 0; i < fe.nbDiag(); i++ )
102  {
103  iloc = fe.patternFirst ( i );
104  s = 0;
105  for ( ig = 0; ig < fe.nbQuadPt(); ig++ )
106  {
107  a_l[0] = u_x[ig];
108  a_l[1] = u_y[ig];
109  a_l[2] = u_z[ig];
110  Real norm = std::sqrt (a_l[0] * a_l[0] + a_l[1] * a_l[1] + a_l[2] * a_l[2]);
111  a_l[0] = a_l[0] / norm;
112  a_l[1] = a_l[1] / norm;
113  a_l[2] = a_l[2] / norm;
114 
115  // std::cout<< a_l[0] << a_l[1] << a_l[2] << " "; // D = sigma_t * I + (sigma_l-sigma_t) * a_l * a_l^T
116  for ( icoor = 0; icoor < fe.nbLocalCoor(); icoor++ )
117  {
118  s += fe.phiDer ( iloc, icoor, ig ) * fe.phiDer ( iloc, icoor, ig ) *
119  fe.weightDet ( ig ) * sigma_t;
120  for ( jcoor = 0; jcoor < fe.nbLocalCoor(); jcoor++ )
121  s += fe.phiDer ( iloc, icoor, ig ) * fe.phiDer ( iloc, jcoor, ig ) *
122  fe.weightDet ( ig ) * (sigma_l - sigma_t) * a_l[icoor] * a_l[jcoor];
123  }
124 
125  }
126  mat ( iloc, iloc ) += s;
127  }
128 
129 
130 
131  //
132  // extra diagonal
133  //
134  for ( i = fe.nbDiag(); i < fe.nbDiag() + fe.nbUpper(); i++ )
135  {
136  s = 0;
137  iloc = fe.patternFirst ( i );
138  jloc = fe.patternSecond ( i );
139  for ( ig = 0; ig < fe.nbQuadPt(); ig++ )
140  {
141  a_l[0] = u_x[ig];
142  a_l[1] = u_y[ig];
143  a_l[2] = u_z[ig];
144  Real norm = std::sqrt (a_l[0] * a_l[0] + a_l[1] * a_l[1] + a_l[2] * a_l[2]);
145  a_l[0] = a_l[0] / norm;
146  a_l[1] = a_l[1] / norm;
147  a_l[2] = a_l[2] / norm;
148  // D = sigma_t * I + (sigma_l-sigma_t) * a_l * a_l^T
149  for ( icoor = 0; icoor < fe.nbLocalCoor(); icoor++ )
150  {
151  s += fe.phiDer ( iloc, icoor, ig ) * fe.phiDer ( jloc, icoor, ig ) *
152  fe.weightDet ( ig ) * sigma_t; //diagonal
153  for ( jcoor = 0; jcoor < fe.nbLocalCoor(); jcoor++ )
154  s += fe.phiDer ( iloc, icoor, ig ) * fe.phiDer ( jloc, jcoor, ig ) *
155  fe.weightDet ( ig ) * (sigma_l - sigma_t) * a_l[icoor] * a_l[jcoor];
156  }
157  }
158 
159  mat ( iloc, jloc ) += s;
160  mat ( jloc, iloc ) += s;
161  }
162 }
163 
164 
165 template <class reduced_sigma, class vector_type>
166 void stiff ( const reduced_sigma& red_sigma, const Real sigma_l, const Real sigma_t, const vector_type& cos, MatrixElemental& elmat, const CurrentFE& fe, const DOF& dof, UInt iblock, UInt jblock, ID id)
167 {
168  // ASSERT_PRE( fe.hasFirstDeriv(),
169  // "Stiffness matrix needs at least the first derivatives" );
170  MatrixElemental::matrix_view mat = elmat.block ( iblock, jblock );
171  Int iloc, jloc;
172  UInt i, icoor, jcoor, ig;
173  Real s;
174  ID eleId = fe.currentLocalId();
175  Real x, y, z;
176 
177 
178  Vector a_l (fe.nbLocalCoor() );
179  UInt dim = dof.numTotalDof();
180  Vector u_x (fe.nbQuadPt() );
181  Vector u_y (fe.nbQuadPt() );
182  Vector u_z (fe.nbQuadPt() );
183 
184  for ( ig = 0; ig < fe.nbQuadPt(); ig++ )
185  {
186  u_x[ig] = u_y[ig] = u_z[ig] = 0;
187  for (i = 0; i < fe.nbFEDof(); i++)
188  {
189  u_x[ig] += cos[dof.localToGlobalMap (eleId, i)] * fe.phi (i, ig); //(one component)
190  u_y[ig] += cos[dim + dof.localToGlobalMap (eleId, i)] * fe.phi (i, ig);
191  u_z[ig] += cos[2 * dim + dof.localToGlobalMap (eleId, i)] * fe.phi (i, ig);
192  }
193  }
194 
195  //
196  // diagonal
197  //
198  for ( i = 0; i < fe.nbDiag(); i++ )
199  {
200  iloc = fe.patternFirst ( i );
201  s = 0;
202  for ( ig = 0; ig < fe.nbQuadPt(); ig++ )
203  {
204  a_l[0] = u_x[ig];
205  a_l[1] = u_y[ig];
206  a_l[2] = u_z[ig];
207  Real norm = std::sqrt (a_l[0] * a_l[0] + a_l[1] * a_l[1] + a_l[2] * a_l[2]);
208  a_l[0] = a_l[0] / norm;
209  a_l[1] = a_l[1] / norm;
210  a_l[2] = a_l[2] / norm;
211 
212  fe.coorQuadPt (x, y, z, ig);
213  // D = sigma_t * I + (sigma_l-sigma_t) * a_l * a_l^T
214  for ( icoor = 0; icoor < fe.nbLocalCoor(); icoor++ )
215  {
216  s += fe.phiDer ( iloc, icoor, ig ) * fe.phiDer ( iloc, icoor, ig ) *
217  fe.weightDet ( ig ) * red_sigma (x, y, z, 0, id, sigma_t);
218  for ( jcoor = 0; jcoor < fe.nbLocalCoor(); jcoor++ )
219  s += fe.phiDer ( iloc, icoor, ig ) * fe.phiDer ( iloc, jcoor, ig ) *
220  fe.weightDet ( ig ) * (red_sigma (x, y, z, 0, id, sigma_l) - red_sigma (x, y, z, 0, id, sigma_t) ) * a_l[icoor] * a_l[jcoor];
221  }
222 
223  }
224  mat ( iloc, iloc ) += s;
225  }
226  //
227  // extra diagonal
228  //
229  for ( i = fe.nbDiag(); i < fe.nbDiag() + fe.nbUpper(); i++ )
230  {
231  s = 0;
232  iloc = fe.patternFirst ( i );
233  jloc = fe.patternSecond ( i );
234  for ( ig = 0; ig < fe.nbQuadPt(); ig++ )
235  {
236  a_l[0] = u_x[ig];
237  a_l[1] = u_y[ig];
238  a_l[2] = u_z[ig];
239 
240  Real norm = std::sqrt (a_l[0] * a_l[0] + a_l[1] * a_l[1] + a_l[2] * a_l[2]);
241  a_l[0] = a_l[0] / norm;
242  a_l[1] = a_l[1] / norm;
243  a_l[2] = a_l[2] / norm;
244 
245  // D = sigma_t * I + (sigma_l-sigma_t) * a_l * a_l^T
246  for ( icoor = 0; icoor < fe.nbLocalCoor(); icoor++ )
247  {
248  s += fe.phiDer ( iloc, icoor, ig ) * fe.phiDer ( jloc, icoor, ig ) *
249  fe.weightDet ( ig ) * red_sigma (x, y, z, 0, id, sigma_t); //diagonal
250  for ( jcoor = 0; jcoor < fe.nbLocalCoor(); jcoor++ )
251  s += fe.phiDer ( iloc, icoor, ig ) * fe.phiDer ( jloc, jcoor, ig ) *
252  fe.weightDet ( ig ) * (red_sigma (x, y, z, 0, id, sigma_l) - red_sigma (x, y, z, 0, id, sigma_t) ) * a_l[icoor] * a_l[jcoor];
253  }
254  }
255 
256  mat ( iloc, jloc ) += s;
257  mat ( jloc, iloc ) += s;
258  }
259 }
260 
261 
262 template <class reduced_sigma>
263 void stiff ( reduced_sigma red_sigma, const Real D, MatrixElemental& elmat, const CurrentFE& fe, const DOF& /*dof*/, UInt iblock, UInt jblock, ID id)
264 {
265 
266  // ASSERT_PRE( fe.hasFirstDeriv(),
267  // "Stiffness matrix needs at least the first derivatives" );
268  MatrixElemental::matrix_view mat = elmat.block ( iblock, jblock );
269  Int iloc, jloc;
270  UInt i, icoor, ig;
271  Real s;
272 
273  Real x, y, z;
274  for ( i = 0; i < fe.nbDiag(); i++ )
275  {
276  iloc = fe.patternFirst ( i );
277  s = 0;
278  for ( ig = 0; ig < fe.nbQuadPt(); ig++ )
279  {
280  fe.coorQuadPt (x, y, z, ig);
281  for ( icoor = 0; icoor < fe.nbLocalCoor(); icoor++ )
282  s += fe.phiDer ( iloc, icoor, ig ) * fe.phiDer ( iloc, icoor, ig )
283  * fe.weightDet ( ig ) * red_sigma (x, y, z, 0, id, D);
284  }
285  mat ( iloc, iloc ) += s;
286  }
287 
288 
289  //
290  // extra diagonal
291  //
292 
293 
294  for ( i = fe.nbDiag(); i < fe.nbDiag() + fe.nbUpper(); i++ )
295  {
296  iloc = fe.patternFirst ( i );
297  jloc = fe.patternSecond ( i );
298  s = 0;
299  for ( ig = 0; ig < fe.nbQuadPt(); ig++ )
300  {
301  fe.coorQuadPt (x, y, z, ig);
302  for ( icoor = 0; icoor < fe.nbLocalCoor(); icoor++ )
303  s += fe.phiDer ( iloc, icoor, ig ) * fe.phiDer ( jloc, icoor, ig ) *
304  fe.weightDet ( ig ) * red_sigma (x, y, z, 0, id, D);
305  }
306  mat ( iloc, jloc ) += s;
307  mat ( jloc, iloc ) += s;
308  }
309 }
310 
311 //Without fibers
312 template <class vector_type>
313 void stiffNL (vector_type& U, Real coef, MatrixElemental& elmat, const CurrentFE& fe,
314  const DOF& dof, UInt iblock, UInt jblock, const Real beta)
315 {
316  MatrixElemental::matrix_view mat = elmat.block ( iblock, jblock );
317  Int iloc, jloc, i, icoor, jcoor, ig;
318  Real s, coef_s;
319  ID eleId = fe.currentLocalId();
320  UInt dim = dof.numTotalDof();
321  Int iu;
322  std::vector<Real> locU (fe.nbFEDof() );
323  std::vector<Real> MM_l (fe.nbLocalCoor() );
324  Real bPt;
325 
326  for (i = 0; i < fe.nbFEDof(); i++)
327  {
328  locU[i] = U[dof.localToGlobalMap (eleId, i)]; //(one component)
329  }
330 
331  //
332  // diagonal
333  //
334  for ( i = 0; i < fe.nbDiag(); i++ )
335  {
336  iloc = fe.patternFirst ( i );
337  s = 0;
338  for ( ig = 0; ig < fe.nbQuadPt(); ig++ )
339  {
340  bPt = 0.0;
341  for (iu = 0; iu < fe.nbFEDof(); iu++)
342  {
343  bPt += locU[iu] * fe.phi (iu, ig);
344  }
345  MM_l[0] = 1.0 / (1.0 + beta * (bPt + 84.0) / (184.0 + bPt) + 0.001 * bPt);
346  MM_l[1] = 1.0 + beta * (bPt + 84.0) / (184.0 + bPt) + 0.001 * bPt;
347  MM_l[2] = 1.0 + beta * (bPt + 84.0) / (184.0 + bPt) + 0.001 * bPt;
348 
349  for ( icoor = 0; icoor < fe.nbLocalCoor(); icoor++ )
350  {
351  s += fe.phiDer ( iloc, icoor, ig ) * fe.phiDer ( iloc, icoor, ig ) *
352  fe.weightDet ( ig ) * MM_l[icoor];
353  }
354  }
355  mat ( iloc, iloc ) += coef * s;
356  }
357  //
358  // extra diagonal
359  //
360 
361  for ( i = fe.nbDiag(); i < fe.nbDiag() + fe.nbUpper(); i++ )
362  {
363  s = 0;
364  iloc = fe.patternFirst ( i );
365  jloc = fe.patternSecond ( i );
366  for ( ig = 0; ig < fe.nbQuadPt(); ig++ )
367  {
368  bPt = 0.0;
369  for (iu = 0; iu < fe.nbFEDof(); iu++)
370  {
371  bPt += locU[iu] * fe.phi (iu, ig);
372  }
373  MM_l[0] = 1.0 / (1.0 + beta * (bPt + 84.0) / (184.0 + bPt) + 0.001 * bPt);
374  MM_l[1] = 1.0 + beta * (bPt + 84.0) / (184.0 + bPt) + 0.001 * bPt;
375  MM_l[2] = 1.0 + beta * (bPt + 84.0) / (184.0 + bPt) + 0.001 * bPt;
376 
377  for ( icoor = 0; icoor < fe.nbLocalCoor(); icoor++ )
378  {
379  s += fe.phiDer ( iloc, icoor, ig ) * fe.phiDer ( jloc, icoor, ig ) *
380  fe.weightDet ( ig ) * MM_l[icoor];
381  }
382  }
383  coef_s = coef * s;
384  mat ( iloc, jloc ) += coef_s;
385  mat ( jloc, iloc ) += coef_s;
386  }
387 }
388 
389 
390 //----------------------------------------------------------------------------
391 
392 /* This one is for the vectorial case, only 'UInt nb' has been added to the argument
393 template <class vector_type>
394 void stiffNL(vector_type& U, Real coef, MatrixElemental& elmat, const CurrentFE& fe,
395  const DOF& dof, UInt iblock, UInt jblock, UInt nb, const Real beta)
396 {
397  Tab2d mat_tmp( fe.nbFEDof(), fe.nbFEDof() );
398  mat_tmp = ZeroMatrix( fe.nbFEDof(), fe.nbFEDof() );
399 
400  Int iloc, jloc, i, icoor, jcoor, ig;
401  Real s, coef_s;
402 
403  ID eleId=fe.currentLocalId();
404  UInt dim = dof.numTotalDof();
405  Int iu;
406  std::vector<Real> locU(fe.nbFEDof());
407  std::vector<Real> MM_l(fe.nbLocalCoor());
408  Real bPt;
409 
410  for (i=0;i<fe.nbFEDof();i++){
411  locU[i]=U[dof.localToGlobalMap(eleId,i)]; //(one component)
412  }
413 
414  //
415  // diagonal
416  //
417  for ( i = 0;i < fe.nbDiag();i++ )
418  {
419  iloc = fe.patternFirst( i );
420  s = 0;
421  for ( ig = 0;ig < fe.nbQuadPt();ig++ )
422  {
423  bPt = 0.0;
424  for(iu=0;iu<fe.nbFEDof();iu++){
425  bPt+=locU[iu]*fe.phi(iu,ig);
426  }
427  MM_l[0] = 1.0/(1.0+beta*(bPt+84.0)/(184.0+bPt)+0.001*bPt);
428  MM_l[1]=1.0+beta*(bPt+84.0)/(184.0+bPt)+0.001*bPt;
429  MM_l[2]=1.0+beta*(bPt+84.0)/(184.0+bPt)+0.001*bPt;
430 
431  for ( icoor = 0;icoor < fe.nbLocalCoor();icoor++ ){
432  s += fe.phiDer( iloc, icoor, ig ) * fe.phiDer( iloc, icoor, ig ) *
433  fe.weightDet( ig )*MM_l[icoor];
434  }
435  }
436  mat_tmp( iloc, iloc ) += coef * s;
437  }
438  //
439  // extra diagonal
440  //
441 
442  for ( i = fe.nbDiag();i < fe.nbDiag() + fe.nbUpper();i++ )
443  {
444  s = 0;
445  iloc = fe.patternFirst( i );
446  jloc = fe.patternSecond( i );
447  for ( ig = 0;ig < fe.nbQuadPt();ig++ ){
448  bPt = 0.0;
449  for(iu=0;iu<fe.nbFEDof();iu++){
450  bPt+=locU[iu]*fe.phi(iu,ig);
451  }
452  MM_l[0] = 1.0/(1.0+beta*(bPt+84.0)/(184.0+bPt)+0.001*bPt);
453  MM_l[1]=1.0+beta*(bPt+84.0)/(184.0+bPt)+0.001*bPt;
454  MM_l[2]=1.0+beta*(bPt+84.0)/(184.0+bPt)+0.001*bPt;
455 
456  for ( icoor = 0;icoor < fe.nbLocalCoor();icoor++ ){
457  s += fe.phiDer( iloc, icoor, ig ) * fe.phiDer( jloc, icoor, ig ) *
458  fe.weightDet( ig )*MM_l[icoor];
459  }
460  }
461  coef_s= coef * s;
462  mat_tmp( iloc, jloc ) += coef_s;
463  mat_tmp( jloc, iloc ) += coef_s;
464  }
465  // copy on the components
466  for ( Int icomp = 0;icomp < nb;icomp++ )
467  {MatrixElemental::matrix_view mat_icomp = elmat.block( iblock + icomp, jblock + icomp );
468  for ( i = 0;i < fe.nbDiag();i++ )
469  {
470  iloc = fe.patternFirst( i );
471  mat_icomp( iloc, iloc ) += mat_tmp( iloc, iloc );
472  }
473  for ( i = fe.nbDiag();i < fe.nbDiag() + fe.nbUpper();i++ )
474  {
475  iloc = fe.patternFirst( i );
476  jloc = fe.patternSecond( i );
477  mat_icomp( iloc, jloc ) += mat_tmp( iloc, jloc );
478  mat_icomp( jloc, iloc ) += mat_tmp( jloc, iloc );
479  }
480  }
481 }
482 
483 */
484 
485 //----------------------------------------------------------------------------
486 
487 
488 
489 //with the fibers
490 template <class vector_type>
491 void stiffNL (const vector_type& U, const Real sigma_l, const Real sigma_t,
492  const vector_type& cos, MatrixElemental& elmat, const CurrentFE& fe,
493  const DOF& dof, UInt iblock, UInt jblock, const Real beta)
494 {
495  MatrixElemental::matrix_view mat = elmat.block ( iblock, jblock );
496  Int iloc, jloc;
497  UInt i, icoor, jcoor, ig;
498  Real s;
499  ID eleId = fe.currentLocalId();
500  UInt dim = dof.numTotalDof();
501  Int iu;
502  Vector locU (fe.nbFEDof() );
503  Vector MM_l (fe.nbLocalCoor() );
504  Real bPt;
505  Vector a_l (fe.nbLocalCoor() );
506  Vector u_x (fe.nbQuadPt() );
507  Vector u_y (fe.nbQuadPt() );
508  Vector u_z (fe.nbQuadPt() );
509 
510  for ( ig = 0; ig < fe.nbQuadPt(); ig++ )
511  {
512  u_x[ig] = u_y[ig] = u_z[ig] = 0;
513  for (i = 0; i < fe.nbFEDof(); i++)
514  {
515  locU[i] = U[dof.localToGlobalMap (eleId, i)]; // ojo!!! quizas es -1
516  u_x[ig] += cos[dof.localToGlobalMap (eleId, i)] * fe.phi (i, ig); //(one component)
517  u_y[ig] += cos[dof.localToGlobalMap (eleId, i) + dim] * fe.phi (i, ig);
518  u_z[ig] += cos[dof.localToGlobalMap (eleId, i) + 2 * dim] * fe.phi (i, ig);
519  }
520  }
521  //
522  // diagonal
523  //
524 
525  for ( i = 0; i < fe.nbDiag(); i++ )
526  {
527  iloc = fe.patternFirst ( i );
528  s = 0;
529  for ( ig = 0; ig < fe.nbQuadPt(); ig++ )
530  {
531  bPt = 0.0;
532  for (iu = 0; iu < fe.nbFEDof(); iu++)
533  {
534  bPt += locU[iu] * fe.phi (iu, ig);
535  }
536  MM_l[0] = 1.0 / (1.0 + beta * (bPt + 84.0) / (184.0 + bPt) + 0.001 * bPt);
537  MM_l[1] = 1.0 + beta * (bPt + 84.0) / (184.0 + bPt) + 0.001 * bPt;
538  MM_l[2] = 1.0 + beta * (bPt + 84.0) / (184.0 + bPt) + 0.001 * bPt;
539  a_l[0] = u_x[ig];
540  a_l[1] = u_y[ig];
541  a_l[2] = u_z[ig];
542  Real norm = std::sqrt (a_l[0] * a_l[0] + a_l[1] * a_l[1] + a_l[2] * a_l[2]);
543  a_l[0] = a_l[0] / norm;
544  a_l[1] = a_l[1] / norm;
545  a_l[2] = a_l[2] / norm;
546 
547  // D = sigma_t * I + (sigma_l-sigma_t) * a_l * a_l^T
548  for ( icoor = 0; icoor < fe.nbLocalCoor(); icoor++ )
549  {
550  s += fe.phiDer ( iloc, icoor, ig ) * fe.phiDer ( iloc, icoor, ig ) *
551  fe.weightDet ( ig ) * sigma_t * MM_l[icoor];
552  for ( jcoor = 0; jcoor < fe.nbLocalCoor(); jcoor++ )
553  s += fe.phiDer ( iloc, icoor, ig ) * fe.phiDer ( iloc, jcoor, ig ) *
554  fe.weightDet ( ig ) * (sigma_l - sigma_t) * a_l[icoor] * a_l[jcoor];
555  }
556 
557  }
558  mat ( iloc, iloc ) += s;
559  }
560 
561 
562 
563  //
564  // extra diagonal
565  //
566  for ( i = fe.nbDiag(); i < fe.nbDiag() + fe.nbUpper(); i++ )
567  {
568  s = 0;
569  iloc = fe.patternFirst ( i );
570  jloc = fe.patternSecond ( i );
571  for ( ig = 0; ig < fe.nbQuadPt(); ig++ )
572  {
573  bPt = 0.0;
574  for (iu = 0; iu < fe.nbFEDof(); iu++)
575  {
576  bPt += locU[iu] * fe.phi (iu, ig);
577  }
578  MM_l[0] = 1.0 / (1.0 + beta * (bPt + 84.0) / (184.0 + bPt) + 0.001 * bPt);
579  MM_l[1] = 1.0 + beta * (bPt + 84.0) / (184.0 + bPt) + 0.001 * bPt;
580  MM_l[2] = 1.0 + beta * (bPt + 84.0) / (184.0 + bPt) + 0.001 * bPt;
581  a_l[0] = u_x[ig];
582  a_l[1] = u_y[ig];
583  a_l[2] = u_z[ig];
584  Real norm = std::sqrt (a_l[0] * a_l[0] + a_l[1] * a_l[1] + a_l[2] * a_l[2]);
585  a_l[0] = a_l[0] / norm;
586  a_l[1] = a_l[1] / norm;
587  a_l[2] = a_l[2] / norm;
588  // D = sigma_t * I + (sigma_l-sigma_t) * a_l * a_l^T
589  for ( icoor = 0; icoor < fe.nbLocalCoor(); icoor++ )
590  {
591  s += fe.phiDer ( iloc, icoor, ig ) * fe.phiDer ( jloc, icoor, ig ) *
592  fe.weightDet ( ig ) * sigma_t * MM_l[icoor]; //diagonal
593  for ( jcoor = 0; jcoor < fe.nbLocalCoor(); jcoor++ )
594  s += fe.phiDer ( iloc, icoor, ig ) * fe.phiDer ( jloc, jcoor, ig ) *
595  fe.weightDet ( ig ) * (sigma_l - sigma_t) * a_l[icoor] * a_l[jcoor];
596  }
597  }
598 
599  mat ( iloc, jloc ) += s;
600  mat ( jloc, iloc ) += s;
601  }
602 }
603 
604 
605 /*-------------------------------------------------------------------------------*/
606 
607 
608 
609 }
int patternFirst(int i) const
patternFirst(i): row index in the element matrix of the i-th term of the pattern
Definition: CurrentFE.hpp:716
void stiffNL(vector_type &U, Real coef, MatrixElemental &elmat, const CurrentFE &fe, const DOF &dof, UInt iblock, UInt jblock, const Real beta)
void stiff(const reduced_sigma &red_sigma, const Real sigma_l, const Real sigma_t, const vector_type &cos, MatrixElemental &elmat, const CurrentFE &fe, const DOF &dof, UInt iblock, UInt jblock, ID id=0)
int32_type Int
Generic integer data.
Definition: LifeV.hpp:188
UInt nbUpper() const
Getter for the number of entries in the pattern.
Definition: CurrentFE.hpp:413
UInt nbDiag() const
Getter for the diagonal entries in the pattern.
Definition: CurrentFE.hpp:407
UInt nbLocalCoor() const
Getter for the number of local coordinates.
Definition: CurrentFE.hpp:425
void stiff(reduced_sigma red_sigma, const Real D, MatrixElemental &elmat, const CurrentFE &fe, const DOF &dof, UInt iblock, UInt jblock, ID id=0)
Real phiDer(UInt node, UInt derivative, UInt quadNode) const
Old accessor, use dphi instead.
Definition: CurrentFE.hpp:548
void stiff(const Real sigma_l, const Real sigma_t, const vector_type &cos, MatrixElemental &elmat, const CurrentFE &fe, const DOF &dof, UInt iblock, UInt jblock)
uint32_type ID
IDs.
Definition: LifeV.hpp:194
void coorQuadPt(Real &x, Real &y, Real &z, int ig) const
Definition: CurrentFE.hpp:710
void stiffNL(const vector_type &U, const Real sigma_l, const Real sigma_t, const vector_type &cos, MatrixElemental &elmat, const CurrentFE &fe, const DOF &dof, UInt iblock, UInt jblock, const Real beta)
double Real
Generic real data.
Definition: LifeV.hpp:175
CurrentFE - A primordial class for the assembly of the local matrices/vectors retaining the values on...
Definition: CurrentFE.hpp:243
UInt nbFEDof() const
Getter for the number of nodes.
Definition: CurrentFE.hpp:377
int patternSecond(int i) const
patternSecond(i): column index in the element matrix of the i-th term of the pattern ...
Definition: CurrentFE.hpp:721
UInt currentLocalId() const
Getter for the local ID of the current cell.
Definition: CurrentFE.hpp:359
Real weightDet(UInt quadNode) const
Old accessor, use wDetJacobian instead.
Definition: CurrentFE.hpp:527
UInt nbQuadPt() const
Getter for the number of quadrature nodes.
Definition: CurrentFE.hpp:365
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191