LifeV
structure/examples/example_checkingFibersDirection/ud_functions.cpp
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 File containing the boundary conditions for the Monolithic Test
30  *
31  * @date 2009-04-09
32  * @author Paolo Tricerri <paolo.tricerri@epfl.ch>
33  *
34  * @maintainer Paolo Tricerri <paolo.tricerri@epfl.ch>
35  *
36  * Contains the functions for the fiber families
37  */
38 
39 #include "ud_functions.hpp"
40 #include<lifev/core/array/VectorSmall.hpp>
41 #include<lifev/core/array/MatrixSmall.hpp>
42 
43 #define PI 3.14159265359
44 
45 namespace LifeV
46 {
47 
48 
49 Real thetaFunction ( const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
50 {
51 
52  // Half thorus
53  Real thetaFiber ( 0.0 );
54  Real xT (0.138);
55  Real rT ( xT );
56  Real thetaFree(0);
57  Real thetaRotation(0);
58  Real thetaPosition(0);
59  thetaFree = std::atan( z / ( x - xT ) );
60  thetaPosition = thetaFree;
61  if ( x < xT )
62  {
63  thetaPosition = thetaFree + PI;
64  thetaRotation = PI/2.0 - std::fabs( thetaFree );
65  }
66  else
67  {
68  thetaRotation = thetaFree - PI/2.0;
69  }
70 
71  return thetaPosition;
72 }
73 
74 Real thetaRotationFunction ( const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
75 {
76  // Half thorus
77  Real thetaFiber ( 0.0 );
78  Real xT (0.138);
79  Real rT ( xT );
80  Real thetaFree(0);
81  Real thetaRotation(0);
82  Real thetaPosition(0);
83  thetaFree = std::atan( z / ( x - xT ) );
84  thetaPosition = thetaFree;
85  if ( x < xT )
86  {
87  thetaPosition = thetaFree + PI;
88  thetaRotation = PI/2.0 - std::fabs( thetaFree );
89  }
90  else
91  {
92  thetaRotation = thetaFree - PI/2.0;
93  }
94 
95  return thetaRotation;
96 }
97 
98 
99 //----------------------------------------------Fibers Directions--------------
100 Real Family1 ( const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
101 {
102 
103  // Tube
104  Real theta = 0.8426; // value for anisotropic characterization taken from Robertson // ( PI / 6.0 );
105  // Real thetaChangeOfVariable = std::atan( y / x );
106 
107  // if( x < 0 )
108  // {
109  // // This is due to the periodicity of std::atan ( ref. official documentation )
110  // thetaChangeOfVariable += PI;
111  // }
112 
113  // Half thorus
114  Real thetaFiber ( theta );
115  Real xT (0.138);
116  Real rT ( xT );
117  Real thetaFree(0);
118  Real thetaRotation(0);
119  Real thetaPosition(0);
120  thetaFree = std::atan( z / ( x - xT ) );
121  thetaPosition = thetaFree;
122  if ( x < xT )
123  {
124  thetaPosition = thetaFree + PI;
125  thetaRotation = PI/2.0 - std::fabs( thetaFree );
126  }
127  else
128  {
129  thetaRotation = thetaFree - PI/2.0;
130  }
131 
132  Real xCenter;
133  Real zCenter;
134  xCenter = rT * std::cos( thetaPosition ) + xT;
135  zCenter = rT * std::sin( thetaPosition );
136 
137  VectorSmall<3> positionCenter;
138  positionCenter[0] = xCenter;
139  positionCenter[1] = 0;
140  positionCenter[2] = zCenter;
141 
142  VectorSmall<3> position;
143  position[0] = x;
144  position[1] = y;
145  position[2] = z;
146 
147  MatrixSmall<3,3> changeOfVariable;
148  changeOfVariable(0,0) = std::cos( thetaRotation ); changeOfVariable(0,1) = 0.0; changeOfVariable(0,2) = std::sin( thetaRotation );
149  changeOfVariable(1,0) = 0.0; changeOfVariable(1,1) = 1.0; changeOfVariable(1,2) = 0.0;
150  changeOfVariable(2,0) = -std::sin( thetaRotation ); changeOfVariable(2,1) = 0.0; changeOfVariable(2,2) = std::cos( thetaRotation );
151 
152  VectorSmall<3> localPosition;
153  localPosition = changeOfVariable * ( position - positionCenter );
154 
155  Real thetaPositionOnSection(0);
156  thetaPositionOnSection = std::atan( localPosition[2] / localPosition[1] );
157 
158  if ( localPosition[1] < 0 )
159  thetaPositionOnSection += PI;
160 
161  VectorSmall<3> localFibers;
162  localFibers[0] = std::sin( thetaFiber );
163  localFibers[1] = std::cos( thetaFiber ) * std::sin( thetaPositionOnSection );
164  localFibers[2] = - std::cos( thetaFiber ) * std::cos( thetaPositionOnSection );
165 
166  VectorSmall<3> originFibers;
167  originFibers = changeOfVariable.transpose() * localFibers + positionCenter;
168 
169  originFibers.normalize();
170 
171  switch (i)
172  {
173  case 0:
174  // Tube
175  // return - std::sin( thetaChangeOfVariable ) * std::cos( theta );
176 
177  // half thorus
178  return originFibers[0];
179 
180  // Cube
181  //return std::sin( theta );
182  break;
183  case 1:
184  // Tube
185  // return std::cos( thetaChangeOfVariable ) * std::cos( theta );
186 
187  // half thorus
188  return originFibers[1];
189 
190  // Cube
191  //return std::cos( theta );
192  break;
193  case 2:
194  // Tube
195  //return std::sin( theta );
196 
197  // half thorus
198  return originFibers[2];
199 
200  // Cube
201  //return 0.0;
202  break;
203  default:
204  ERROR_MSG ("This entrie is not allowed: ud_functions.hpp");
205  return 0.;
206  break;
207  }
208 
209 }
210 
211 Real Family1Spherical ( const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
212 {
213  // Half thorus
214  Real thetaFiber ( PI / 2.0 );
215  Real xT (0.138);
216  Real rT ( xT );
217  Real thetaFree(0);
218  Real thetaRotation(0);
219  Real thetaPosition(0);
220  thetaFree = std::atan( z / ( x - xT ) );
221  thetaPosition = thetaFree;
222  if ( x < xT )
223  {
224  thetaPosition = thetaFree + PI;
225  thetaRotation = PI/2.0 - std::fabs( thetaFree );
226  }
227  else
228  {
229  thetaRotation = thetaFree - PI/2.0;
230  }
231 
232  VectorSmall<3> position;
233  position[0] = x;
234  position[1] = y;
235  position[2] = z;
236 
237  VectorSmall<3> centerSphere;
238  centerSphere[0] = 0.138;
239  centerSphere[1] = 0.0;
240  centerSphere[2] = 0.185;
241 
242  VectorSmall<3> centerOnTorusAxis;
243  centerOnTorusAxis[0] = rT * std::cos( thetaPosition ) + xT;
244  centerOnTorusAxis[1] = 0.0;
245  centerOnTorusAxis[2] = rT * std::sin( thetaPosition );
246 
247  Real xCenter;
248  Real yCenter;
249  Real zCenter;
250 
251  if( ( ( position - centerSphere ).norm() ) <= 0.05 ) // inside the dome
252  {
253  VectorSmall<3> tangentVectorToAxisTorus;
254  tangentVectorToAxisTorus[0] = std::sin( thetaPosition ) ;
255  tangentVectorToAxisTorus[1] = 0.0;
256  tangentVectorToAxisTorus[2] = -std::cos( thetaPosition );
257 
258  VectorSmall<3> centerSphereOnSection;
259  centerSphereOnSection = centerSphere - ( ( centerSphere - centerOnTorusAxis ).dot( tangentVectorToAxisTorus ) ) * tangentVectorToAxisTorus;
260 
261  xCenter = centerSphereOnSection[0];
262  yCenter = centerSphereOnSection[1];
263  zCenter = centerSphereOnSection[2];
264  }
265  else
266  {
267  xCenter = centerOnTorusAxis[0];
268  yCenter = centerOnTorusAxis[1];
269  zCenter = centerOnTorusAxis[2];
270  }
271 
272  // Changing reference system
273  MatrixSmall<3,3> changeOfVariable;
274  changeOfVariable(0,0) = std::cos( thetaRotation ); changeOfVariable(0,1) = 0.0; changeOfVariable(0,2) = std::sin( thetaRotation );
275  changeOfVariable(1,0) = 0.0; changeOfVariable(1,1) = 1.0; changeOfVariable(1,2) = 0.0;
276  changeOfVariable(2,0) = -std::sin( thetaRotation ); changeOfVariable(2,1) = 0.0; changeOfVariable(2,2) = std::cos( thetaRotation );
277 
278  VectorSmall<3> positionCenter;
279  positionCenter[0] = xCenter;
280  positionCenter[1] = yCenter;
281  positionCenter[2] = zCenter;
282 
283  VectorSmall<3> localPosition;
284  localPosition = changeOfVariable * ( position - positionCenter );
285 
286  Real thetaPositionOnSection(0);
287  thetaPositionOnSection = std::atan( localPosition[2] / localPosition[1] );
288 
289  if ( localPosition[1] < 0 )
290  thetaPositionOnSection += PI;
291 
292  VectorSmall<3> localFibers;
293  localFibers[0] = std::sin( thetaFiber );
294  localFibers[1] = std::cos( thetaFiber ) * std::sin( thetaPositionOnSection );
295  localFibers[2] = - std::cos( thetaFiber ) * std::cos( thetaPositionOnSection );
296 
297  VectorSmall<3> originFibers;
298  originFibers = changeOfVariable.transpose() * localFibers + positionCenter;
299 
300  originFibers.normalize();
301 
302  switch (i)
303  {
304  case 0:
305  // Tube
306  // return - std::sin( thetaChangeOfVariable ) * std::cos( theta );
307 
308  // half thorus
309  return originFibers[0];
310 
311  // Cube
312  //return std::sin( theta );
313  break;
314  case 1:
315  // Tube
316  // return std::cos( thetaChangeOfVariable ) * std::cos( theta );
317 
318  // half thorus
319  return originFibers[1];
320 
321  // Cube
322  //return std::cos( theta );
323  break;
324  case 2:
325  // Tube
326  //return std::sin( theta );
327 
328  // half thorus
329  return originFibers[2];
330 
331  // Cube
332  //return 0.0;
333  break;
334  default:
335  ERROR_MSG ("This entrie is not allowed: ud_functions.hpp");
336  return 0.;
337  break;
338  }
339 
340 }
341 
342 Real positionCenter ( const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
343 {
344  // Half thorus
345  Real thetaFiber ( 0.0 );
346  Real xT (0.138);
347  Real rT ( xT );
348  Real thetaFree(0);
349  Real thetaRotation(0);
350  Real thetaPosition(0);
351  thetaFree = std::atan( z / ( x - xT ) );
352  thetaPosition = thetaFree;
353  if ( x < xT )
354  {
355  thetaPosition = thetaFree + PI;
356  thetaRotation = PI/2.0 - std::fabs( thetaFree );
357  }
358  else
359  {
360  thetaRotation = thetaFree - PI/2.0;
361  }
362 
363  Real xCenter;
364  Real zCenter;
365  xCenter = rT * std::cos( thetaPosition ) + xT;
366  zCenter = rT * std::sin( thetaPosition );
367 
368  switch (i)
369  {
370  case 0:
371  // Tube
372  return xCenter;
373  // Cube
374  //return std::sin( theta );
375  break;
376  case 1:
377  // Tube
378  return 0.0;
379  // Cube
380  //return std::cos( theta );
381  break;
382  case 2:
383  // Tube
384  return zCenter;
385  // Cube
386  //return 0.0;
387  break;
388  default:
389  ERROR_MSG ("This entrie is not allowed: ud_functions.hpp");
390  return 0.;
391  break;
392  }
393 
394 
395 }
396 
397 Real localPositionSpherical ( const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
398 {
399 
400  // Half thorus
401  Real thetaFiber ( 0.0 );
402  Real xT (0.138);
403  Real rT ( xT );
404  Real thetaFree(0);
405  Real thetaRotation(0);
406  Real thetaPosition(0);
407  thetaFree = std::atan( z / ( x - xT ) );
408  thetaPosition = thetaFree;
409  if ( x < xT )
410  {
411  thetaPosition = thetaFree + PI;
412  thetaRotation = PI/2.0 - std::fabs( thetaFree );
413  }
414  else
415  {
416  thetaRotation = thetaFree - PI/2.0;
417  }
418 
419  VectorSmall<3> position;
420  position[0] = x;
421  position[1] = y;
422  position[2] = z;
423 
424  VectorSmall<3> centerSphere;
425  centerSphere[0] = 0.138;
426  centerSphere[1] = 0.0;
427  centerSphere[2] = 0.185;
428 
429  VectorSmall<3> centerOnTorusAxis;
430  centerOnTorusAxis[0] = rT * std::cos( thetaPosition ) + xT;
431  centerOnTorusAxis[1] = 0.0;
432  centerOnTorusAxis[2] = rT * std::sin( thetaPosition );
433 
434  Real xCenter;
435  Real yCenter;
436  Real zCenter;
437 
438  if( ( ( position - centerSphere ).norm() ) <= 0.05 ) // inside the dome
439  {
440  VectorSmall<3> tangentVectorToAxisTorus;
441  tangentVectorToAxisTorus[0] = std::sin( thetaPosition ) ;
442  tangentVectorToAxisTorus[1] = 0.0;
443  tangentVectorToAxisTorus[2] = -std::cos( thetaPosition );
444 
445  VectorSmall<3> centerSphereOnSection;
446  centerSphereOnSection = centerSphere - ( ( centerSphere - centerOnTorusAxis ).dot( tangentVectorToAxisTorus ) ) * tangentVectorToAxisTorus;
447 
448  xCenter = centerSphereOnSection[0];
449  yCenter = centerSphereOnSection[1];
450  zCenter = centerSphereOnSection[2];
451  }
452  else
453  {
454  xCenter = centerOnTorusAxis[0];
455  yCenter = centerOnTorusAxis[1];
456  zCenter = centerOnTorusAxis[2];
457  }
458 
459  // Changing reference system
460  MatrixSmall<3,3> changeOfVariable;
461  changeOfVariable(0,0) = std::cos( thetaRotation ); changeOfVariable(0,1) = 0.0; changeOfVariable(0,2) = std::sin( thetaRotation );
462  changeOfVariable(1,0) = 0.0; changeOfVariable(1,1) = 1.0; changeOfVariable(1,2) = 0.0;
463  changeOfVariable(2,0) = -std::sin( thetaRotation ); changeOfVariable(2,1) = 0.0; changeOfVariable(2,2) = std::cos( thetaRotation );
464 
465  VectorSmall<3> positionCenter;
466  positionCenter[0] = xCenter;
467  positionCenter[1] = yCenter;
468  positionCenter[2] = zCenter;
469 
470  VectorSmall<3> localPosition;
471  localPosition = changeOfVariable * ( position - positionCenter );
472 
473 
474  // returning local positions
475  switch (i)
476  {
477  case 0:
478  // Tube
479  return localPosition[0];
480  // Cube
481  //return std::sin( theta );
482  break;
483  case 1:
484  // Tube
485  return localPosition[1];
486  // Cube
487  //return std::cos( theta );
488  break;
489  case 2:
490  // Tube
491  return localPosition[2];
492  // Cube
493  //return 0.0;
494  break;
495  default:
496  ERROR_MSG ("This entrie is not allowed: ud_functions.hpp");
497  return 0.;
498  break;
499  }
500 
501 }
502 
503 Real localPosition ( const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
504 {
505  // Half thorus
506  Real thetaFiber ( 0.0 );
507  Real xT (0.138);
508  Real rT ( xT );
509  Real thetaFree(0);
510  Real thetaRotation(0);
511  Real thetaPosition(0);
512  thetaFree = std::atan( z / ( x - xT ) );
513  thetaPosition = thetaFree;
514  if ( x < xT )
515  {
516  thetaPosition = thetaFree + PI;
517  thetaRotation = PI/2.0 - std::fabs( thetaFree );
518  }
519  else
520  {
521  thetaRotation = thetaFree - PI/2.0;
522  }
523 
524  Real xCenter;
525  Real zCenter;
526  xCenter = rT * std::cos( thetaPosition ) + xT;
527  zCenter = rT * std::sin( thetaPosition );
528 
529  VectorSmall<3> positionCenter;
530  positionCenter[0] = xCenter;
531  positionCenter[1] = 0;
532  positionCenter[2] = zCenter;
533 
534  VectorSmall<3> position;
535  position[0] = x;
536  position[1] = y;
537  position[2] = z;
538 
539  MatrixSmall<3,3> changeOfVariable;
540  changeOfVariable(0,0) = std::cos( thetaRotation ); changeOfVariable(0,1) = 0.0; changeOfVariable(0,2) = std::sin( thetaRotation );
541  changeOfVariable(1,0) = 0.0; changeOfVariable(1,1) = 1.0; changeOfVariable(1,2) = 0.0;
542  changeOfVariable(2,0) = -std::sin( thetaRotation ); changeOfVariable(2,1) = 0.0; changeOfVariable(2,2) = std::cos( thetaRotation );
543 
544  VectorSmall<3> localPosition;
545  localPosition = changeOfVariable * ( position - positionCenter );
546 
547  switch (i)
548  {
549  case 0:
550  // Tube
551  return localPosition[0];
552  // Cube
553  //return std::sin( theta );
554  break;
555  case 1:
556  // Tube
557  return localPosition[1];
558  // Cube
559  //return std::cos( theta );
560  break;
561  case 2:
562  // Tube
563  return localPosition[2];
564  // Cube
565  //return 0.0;
566  break;
567  default:
568  ERROR_MSG ("This entrie is not allowed: ud_functions.hpp");
569  return 0.;
570  break;
571  }
572 
573 
574 }
575 
576 Real sphereIndicatorFunction ( const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
577 {
578  // Half thorus
579  VectorSmall<3> position;
580  position[0] = x;
581  position[1] = y;
582  position[2] = z;
583 
584  VectorSmall<3> centerSphere;
585  centerSphere[0] = 0.138;
586  centerSphere[1] = 0.0;
587  centerSphere[2] = 0.185;
588 
589  if( ( ( position - centerSphere ).norm() ) <= ( 0.05 ) ) // inside the dome
590  {
591  return 1.0;
592  }
593  else
594  {
595  return 0.0;
596  }
597  return 100000.0;
598 }
599 
600 
601 Real positionCenterSpherical ( const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
602 {
603  // Half thorus
604  Real thetaFiber ( 0.0 );
605  Real xT (0.138);
606  Real rT ( xT );
607  Real thetaFree(0);
608  Real thetaRotation(0);
609  Real thetaPosition(0);
610  thetaFree = std::atan( z / ( x - xT ) );
611  thetaPosition = thetaFree;
612  if ( x < xT )
613  {
614  thetaPosition = thetaFree + PI;
615  thetaRotation = PI/2.0 - std::fabs( thetaFree );
616  }
617  else
618  {
619  thetaRotation = thetaFree - PI/2.0;
620  }
621 
622  VectorSmall<3> position;
623  position[0] = x;
624  position[1] = y;
625  position[2] = z;
626 
627  VectorSmall<3> centerSphere;
628  centerSphere[0] = 0.138;
629  centerSphere[1] = 0.0;
630  centerSphere[2] = 0.185;
631 
632  VectorSmall<3> centerOnTorusAxis;
633  centerOnTorusAxis[0] = rT * std::cos( thetaPosition ) + xT;
634  centerOnTorusAxis[1] = 0.0;
635  centerOnTorusAxis[2] = rT * std::sin( thetaPosition );
636 
637  Real xCenter;
638  Real yCenter;
639  Real zCenter;
640 
641  if( ( ( position - centerSphere ).norm() ) <= 0.05 ) // inside the dome
642  {
643  VectorSmall<3> tangentVectorToAxisTorus;
644  tangentVectorToAxisTorus[0] = std::sin( thetaPosition ) ;
645  tangentVectorToAxisTorus[1] = 0.0;
646  tangentVectorToAxisTorus[2] = -std::cos( thetaPosition );
647 
648  VectorSmall<3> centerSphereOnSection;
649  centerSphereOnSection = centerSphere - ( ( centerSphere - centerOnTorusAxis ).dot( tangentVectorToAxisTorus ) ) * tangentVectorToAxisTorus;
650 
651  xCenter = centerSphereOnSection[0];
652  yCenter = centerSphereOnSection[1];
653  zCenter = centerSphereOnSection[2];
654  }
655  else
656  {
657  xCenter = centerOnTorusAxis[0];
658  yCenter = centerOnTorusAxis[1];
659  zCenter = centerOnTorusAxis[2];
660  }
661 
662  switch (i)
663  {
664  case 0:
665  // Tube
666  return xCenter;
667  // Cube
668  //return std::sin( theta );
669  break;
670  case 1:
671  // Tube
672  return 0.0;
673  // Cube
674  //return std::cos( theta );
675  break;
676  case 2:
677  // Tube
678  return zCenter;
679  // Cube
680  //return 0.0;
681  break;
682  default:
683  ERROR_MSG ("This entrie is not allowed: ud_functions.hpp");
684  return 0.;
685  break;
686  }
687 
688 }
689 
690 Real Family2 ( const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
691 {
692  // Tube
693  // Real theta = 0.8426; // value for anisotropic characterization taken from Robertson // ( PI / 6.0 );
694  // Real thetaChangeOfVariable = std::atan( y / x );
695 
696  // if( x < 0 )
697  // {
698  // // This is due to the periodicity of std::atan ( ref. official documentation )
699  // thetaChangeOfVariable += PI;
700  // }
701 
702  // Half thorus
703  Real thetaFiber ( - PI / 2.0 );
704  Real xT (0.138);
705  Real rT ( xT );
706  Real thetaFree(0);
707  Real thetaRotation(0);
708  Real thetaPosition(0);
709  thetaFree = std::atan( z / ( x - xT ) );
710  thetaPosition = thetaFree;
711  if ( x < xT )
712  {
713  thetaPosition = thetaFree + PI;
714  thetaRotation = PI/2.0 - std::fabs( thetaFree );
715  }
716  else
717  {
718  thetaRotation = thetaFree - PI/2.0;
719  }
720 
721  Real xCenter;
722  Real zCenter;
723  xCenter = rT * std::cos( thetaPosition ) + xT;
724  zCenter = rT * std::sin( thetaPosition );
725 
726  VectorSmall<3> positionCenter;
727  positionCenter[0] = xCenter;
728  positionCenter[1] = 0;
729  positionCenter[2] = zCenter;
730 
731  VectorSmall<3> position;
732  position[0] = x;
733  position[1] = y;
734  position[2] = z;
735 
736  MatrixSmall<3,3> changeOfVariable;
737  changeOfVariable(0,0) = std::cos( thetaRotation ); changeOfVariable(0,1) = 0.0; changeOfVariable(0,2) = std::sin( thetaRotation );
738  changeOfVariable(1,0) = 0.0; changeOfVariable(1,1) = 1.0; changeOfVariable(1,2) = 0.0;
739  changeOfVariable(2,0) = -std::sin( thetaRotation ); changeOfVariable(2,1) = 0.0; changeOfVariable(2,2) = std::cos( thetaRotation );
740 
741  VectorSmall<3> localPosition;
742  localPosition = changeOfVariable * ( position - positionCenter );
743 
744  Real thetaPositionOnSection(0);
745  thetaPositionOnSection = std::atan( localPosition[2] / localPosition[1] );
746 
747  if ( localPosition[1] < 0 )
748  thetaPositionOnSection += PI;
749 
750  VectorSmall<3> localFibers;
751  localFibers[0] = std::sin( thetaFiber );
752  localFibers[1] = std::cos( thetaFiber ) * std::sin( thetaPositionOnSection );
753  localFibers[2] = - std::cos( thetaFiber ) * std::cos( thetaPositionOnSection );
754 
755  VectorSmall<3> originFibers;
756  originFibers = changeOfVariable.transpose() * localFibers + positionCenter;
757 
758  originFibers.normalize();
759 
760  switch (i)
761  {
762  case 0:
763  // Tube
764  // return - std::sin( thetaChangeOfVariable ) * std::cos( theta );
765 
766  // half thorus
767  return originFibers[0];
768 
769  // Cube
770  //return std::sin( theta );
771  break;
772  case 1:
773  // Tube
774  // return std::cos( thetaChangeOfVariable ) * std::cos( theta );
775 
776  // half thorus
777  return originFibers[1];
778 
779  // Cube
780  //return std::cos( theta );
781  break;
782  case 2:
783  // Tube
784  //return std::sin( theta );
785 
786  // half thorus
787  return originFibers[2];
788 
789  // Cube
790  //return 0.0;
791  break;
792  default:
793  ERROR_MSG ("This entrie is not allowed: ud_functions.hpp");
794  return 0.;
795  break;
796  }
797 }
798 
799 Real Family3 ( const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
800 {
801 
802  Real theta = - 0.8426;
803  Real thetaChangeOfVariable = std::atan( y / x );
804 
805  if( x < 0 )
806  {
807  // This is due to the periodicity of std::atan ( ref. official documentation )
808  thetaChangeOfVariable += PI;
809  }
810 
811  switch (i)
812  {
813  case 0:
814  // Tube
815  return - std::sin( thetaChangeOfVariable ) * std::cos( theta );
816  // Cube
817  //return std::sin( theta );
818  break;
819  case 1:
820  // Tube
821  return std::cos( thetaChangeOfVariable ) * std::cos( theta );
822  // Cube
823  //return std::cos( theta );
824  break;
825  case 2:
826  // Tube
827  return std::sin( theta );
828  // Cube
829  //return 0.0;
830  break;
831  default:
832  ERROR_MSG ("This entrie is not allowed: ud_functions.hpp");
833  return 0.;
834  break;
835  }
836 }
837 
838 
839 Real Family4 ( const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
840 {
841 
842  switch (i)
843  {
844  case 0:
845  return 0.0;
846  break;
847  case 1:
848  return 0.0;
849  break;
850  case 2:
851  return 0.0;
852  break;
853  default:
854  ERROR_MSG ("This entrie is not allowed: ud_functions.hpp");
855  return 0.;
856  break;
857  }
858 }
859 
860 
861 Real Family5 ( const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
862 {
863 
864  switch (i)
865  {
866  case 0:
867  return 0.0;
868  break;
869  case 1:
870  return 0.0;
871  break;
872  case 2:
873  return 0.0;
874  break;
875  default:
876  ERROR_MSG ("This entrie is not allowed: ud_functions.hpp");
877  return 0.;
878  break;
879  }
880 }
881 
882 Real Family6 ( const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
883 {
884 
885  switch (i)
886  {
887  case 0:
888  return 0.0;
889  break;
890  case 1:
891  return 0.0;
892  break;
893  case 2:
894  return 0.0;
895  break;
896  default:
897  ERROR_MSG ("This entrie is not allowed: ud_functions.hpp");
898  return 0.;
899  break;
900  }
901 }
902 
903 // Method for the definition of the fibers
904 fibersDirectionList::fibersDirectionList() :
905  M_mapNameDefinition( )
906 {}
907 
908 fibersDirectionList::~fibersDirectionList()
909 {}
910 
911 void fibersDirectionList::setupFiberDefinitions( const UInt nbFamilies )
912 {
913  // At the moment the creation of the table of fiber functions is done
914  // manually. There should be a way to make it automatically. Btw, only
915  // the first nbFamilies that are set in the data file are taken into account
916 
917  ASSERT( nbFamilies < 6, "At the moment, a maximum number = 6 of families can be used! If you want more \n modifiy the file ud_functions.hpp in the application folder." );
918 
919  // Creation of the database of functions
920  fiberFunctionPtr_Type pointerToFunction( new fiberFunction_Type( Family1Spherical ) );
921  M_mapNameDefinition.insert( std::pair<std::string, fiberFunctionPtr_Type>
922  ( "Family1", pointerToFunction ) );
923 
924  pointerToFunction.reset( new fiberFunction_Type( Family2 ) );
925  M_mapNameDefinition.insert( std::pair<std::string, fiberFunctionPtr_Type>
926  ( "Family2", pointerToFunction ) );
927 
928  pointerToFunction.reset( new fiberFunction_Type( Family3 ) );
929  M_mapNameDefinition.insert( std::pair<std::string, fiberFunctionPtr_Type>
930  ( "Family3", pointerToFunction ) );
931 
932  pointerToFunction.reset( new fiberFunction_Type( Family4 ) );
933  M_mapNameDefinition.insert( std::pair<std::string, fiberFunctionPtr_Type>
934  ( "Family4", pointerToFunction ) );
935 
936  pointerToFunction.reset( new fiberFunction_Type( Family5 ) );
937  M_mapNameDefinition.insert( std::pair<std::string, fiberFunctionPtr_Type>
938  ( "Family5", pointerToFunction ) );
939 
940  pointerToFunction.reset( new fiberFunction_Type( Family6 ) );
941  M_mapNameDefinition.insert( std::pair<std::string, fiberFunctionPtr_Type>
942  ( "Family6", pointerToFunction ) );
943 
944 
945 }
946 
947 fibersDirectionList::fiberFunctionPtr_Type fibersDirectionList::fiberDefinition( const std::string nameFamily )
948 {
949 
950  mapNameDefinitionFiberFunction_Type::const_iterator IT;
951 
952  IT = M_mapNameDefinition.find ( nameFamily );
953 
954  if ( IT != M_mapNameDefinition.end() )
955  {
956  return IT->second;
957  }
958  else
959  {
960  std::cout << " Wrong identification of the fiber function! " << std::endl;
961  fiberFunctionPtr_Type pointerToFunction( new fiberFunction_Type() );
962 
963  return pointerToFunction;
964  }
965 }
966 
967 }
VectorSmall< 3 > operator-(VectorSmall< 3 > const &vector) const
Operator -.
#define PI
Real dot(VectorSmall< 3 > const &vector) const
Scalar product.
VectorSmall< 3 > & operator=(VectorSmall< 3 > const &vector)
Assignment operator.
void updateInverseJacobian(const UInt &iQuadPt)
void normalize()
Normalize vector.
#define ERROR_MSG(A)
Definition: LifeAssert.hpp:69
Real & operator[](UInt const &i)
Operator [].
#define ASSERT(X, A)
Definition: LifeAssert.hpp:90
uint32_type ID
IDs.
Definition: LifeV.hpp:194
Real norm() const
norm
double Real
Generic real data.
Definition: LifeV.hpp:175
VectorSmall< 3 > operator*(Real const &factor, VectorSmall< 3 > const &vector)
Operator * (multiplication by scalar on the left)
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191