LifeV
structure/examples/example_computePrincipalTensions/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 to be assigned as boundary conditions, in the file boundaryConditions.hpp . The functions
37  * can depend on time and space, while they can take in input an ID specifying one of the three principal axis
38  * if the functions to assign is vectorial and the boundary condition is of type \c Full \c.
39  */
40 
41 #include "ud_functions.hpp"
42 
43 #define PI 3.14159265359
44 
45 namespace LifeV
46 {
47 
48 Real f (const Real& /*t*/, const Real& /*x*/, const Real& /*y*/, const Real& /*z*/, const ID& i)
49 {
50  switch (i)
51  {
52  case 0:
53  return 0.0;
54  break;
55  case 1:
56  return 0.0;
57  break;
58  case 2:
59  return 0.0;
60  break;
61  default:
62  ERROR_MSG ("This entrie is not allowed: ud_functions.hpp");
63  return 0.;
64  break;
65  }
66 }
67 
68 
69 Real fzero_scalar (const Real& /*t*/, const Real& /*x*/, const Real& /*y*/, const Real& /*z*/, const ID& /*i*/)
70 {
71  return 0.0;
72 }
73 
74 Real InternalPressure (const Real& /*t*/, const Real& /*x*/, const Real& /*y*/, const Real& /*z*/, const ID& /*i*/)
75 {
76  return -1e+5;
77  //return -260000*sin(80*3.141592*t);
78 }
79 
80 // Initial displacement and velocity
81 Real d0 (const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
82 {
83 
84  switch (i)
85  {
86  case 0:
87  return 0.088002 * ( x + 0.5 );
88  break;
89  case 1:
90  return - ( 0.02068 * 2.0 ) * ( y );
91  break;
92  case 2:
93  return - ( 0.02068 * 2.0 ) * ( z );
94  break;
95  default:
96  ERROR_MSG ("This entry is not allowed: ud_functions.hpp");
97  return 0.;
98  break;
99  }
100 
101 }
102 
103 Real w0 (const Real& /*t*/, const Real& /*x*/, const Real& /*y*/, const Real& /*z*/, const ID& i)
104 {
105 
106  switch (i)
107  {
108  case 0:
109  return 0.0;
110  break;
111  case 1:
112  return 0.0;
113  break;
114  case 2:
115  return 0.0;
116  break;
117  default:
118  ERROR_MSG ("This entrie is not allowed: ud_functions.hpp");
119  return 0.;
120  break;
121  }
122 }
123 
124 Real a0 (const Real& /*t*/, const Real& /*x*/, const Real& /*y*/, const Real& /*z*/, const ID& i)
125 {
126 
127  switch (i)
128  {
129  case 0:
130  return 0.0;
131  break;
132  case 1:
133  return 0.0;
134  break;
135  case 2:
136  return 0.0;
137  break;
138  default:
139  ERROR_MSG ("This entrie is not allowed: ud_functions.hpp");
140  return 0.;
141  break;
142  }
143 }
144 
145 Real displacementVenantKirchhoffPenalized (const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
146 {
147  switch (i)
148  {
149  case 0:
150  return - 0.01649141 * ( x - 0.5 );
151  break;
152  case 1:
153  return 0.069238236 / 2.0 * ( y );
154  break;
155  case 2:
156  return - 0.01649141 * ( z + 0.5 );
157  break;
158  default:
159  ERROR_MSG ("This entry is not allowed: ud_functions.hpp");
160  return 0.;
161  break;
162  }
163 }
164 
165 
166 //----------------------------------------------Boundary Conditions--------------
167 Real bcZero (const Real& /*t*/, const Real& /*X*/, const Real& /*Y*/, const Real& /*Z*/, const ID& /*i*/)
168 {
169  return 0.;
170 }
171 
172 Real bcNonZero (const Real& t, const Real& X, const Real& Y, const Real& Z, const ID& i)
173 {
174  //Real pressure(200000);
175 
176  // Real top = 1000000;
177 
178  // return top * Y;
179 
180  return 10000;
181 
182  // Real highestPressure(6.666e+6);
183  // Real totalTime = 20.0;
184  // Real halfTime = totalTime / 2.0;
185 
186  // Real a = ( highestPressure / 2 ) * ( 1/ ((totalTime/2)*(totalTime/2)) );
187 
188  // if ( t <= halfTime )
189  // pressure = a * t*t;
190 
191  // if ( t > halfTime )
192  // pressure = - a * (t - totalTime)*(t - totalTime) + highestPressure;
193 
194  // switch (i)
195  // {
196  // case 0:
197  // return 0.0;
198  // break;
199  // case 1:
200  // return pressure;
201  // break;
202  // case 2:
203  // return 0.0;
204  // break;
205  // default:
206  // ERROR_MSG ("This entrie is not allowed: ud_functions.hpp");
207  // return 0.;
208  // break;
209  // }
210 }
211  Real smoothPressure(const Real& t, const Real& x, const Real& y, const Real& /*Z*/, const ID& i)
212  {
213  Real radius = std::sqrt( x*x + y*y);
214  Real pressure(0);
215 
216  Real highestPressure(200000);
217  Real totalTime = 4.5;
218  Real halfTime = totalTime / 2.0;
219 
220  Real a = ( highestPressure / 2 ) * ( 1/ ( halfTime*halfTime ) );
221 
222  if ( t <= halfTime )
223  pressure = a * t*t;
224 
225  if ( t > halfTime )
226  pressure = - a * (t - totalTime)*(t - totalTime) + highestPressure;
227 
228  switch (i)
229  {
230  case 0:
231  return pressure * ( x / radius ) ;
232  break;
233  case 1:
234  return pressure * ( y / radius ) ;
235  break;
236  case 2:
237  return 0.0;
238  break;
239 
240  }
241  return 0;
242 
243  }
244 
245 Real traction (const Real& /*t*/, const Real& /*X*/, const Real& /*Y*/, const Real& /*Z*/, const ID& /*i*/)
246 {
247  return 10000.;
248 }
249 
250 
251 //----------------------------------------------Fibers Directions--------------
252 Real Family1 ( const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
253 {
254  Real theta = PI/6.0; // value for anisotropic characterization taken from Robertson // ( PI / 6.0 );
255  //Real thetaChangeOfVariable = std::atan( y / x );
256 
257  // if( x < 0 )
258  // {
259  // // This is due to the periodicity of std::atan ( ref. official documentation )
260  // thetaChangeOfVariable += PI;
261  // }
262 
263  switch (i)
264  {
265  case 0:
266  // Tube
267  // return - std::sin( thetaChangeOfVariable ) * std::cos( theta );
268  // Cube
269  return std::sin( theta );
270  break;
271  case 1:
272  // Tube
273  //return std::cos( thetaChangeOfVariable ) * std::cos( theta );
274  // Cube
275  return std::cos( theta );
276  break;
277  case 2:
278  // Tube
279  //return std::sin( theta );
280  // Cube
281  return 0.0;
282  break;
283  default:
284  ERROR_MSG ("This entrie is not allowed: ud_functions.hpp");
285  return 0.;
286  break;
287  }
288 }
289 
290 Real Family2 ( const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
291 {
292  Real theta = ( - PI / 6.0 );
293  // Real thetaChangeOfVariable = std::atan( y / x );
294 
295  // if( x < 0 )
296  // {
297  // // This is due to the periodicity of std::atan ( ref. official documentation )
298  // thetaChangeOfVariable += PI;
299  // }
300 
301  switch (i)
302  {
303  case 0:
304  // Tube
305  // return - std::sin( thetaChangeOfVariable ) * std::cos( theta );
306  // Cube
307  return std::sin( theta );
308  break;
309  case 1:
310  // Tube
311  //return std::cos( thetaChangeOfVariable ) * std::cos( theta );
312  // Cube
313  return std::cos( theta );
314  break;
315  case 2:
316  // Tube
317  //return std::sin( theta );
318  // Cube
319  return 0.0;
320  break;
321  default:
322  ERROR_MSG ("This entrie is not allowed: ud_functions.hpp");
323  return 0.;
324  break;
325  }
326 }
327 
328 Real Family3 ( const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
329 {
330 
331  switch (i)
332  {
333  case 0:
334  return 0.0;
335  break;
336  case 1:
337  return 0.0;
338  break;
339  case 2:
340  return -1.0;
341  break;
342  default:
343  ERROR_MSG ("This entrie is not allowed: ud_functions.hpp");
344  return 0.;
345  break;
346  }
347 }
348 
349 
350 Real Family4 ( const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
351 {
352 
353  switch (i)
354  {
355  case 0:
356  return 0.0;
357  break;
358  case 1:
359  return 0.0;
360  break;
361  case 2:
362  return 0.0;
363  break;
364  default:
365  ERROR_MSG ("This entrie is not allowed: ud_functions.hpp");
366  return 0.;
367  break;
368  }
369 }
370 
371 
372 Real Family5 ( const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
373 {
374 
375  switch (i)
376  {
377  case 0:
378  return 0.0;
379  break;
380  case 1:
381  return 0.0;
382  break;
383  case 2:
384  return 0.0;
385  break;
386  default:
387  ERROR_MSG ("This entrie is not allowed: ud_functions.hpp");
388  return 0.;
389  break;
390  }
391 }
392 
393 Real Family6 ( const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
394 {
395 
396  switch (i)
397  {
398  case 0:
399  return 0.0;
400  break;
401  case 1:
402  return 0.0;
403  break;
404  case 2:
405  return 0.0;
406  break;
407  default:
408  ERROR_MSG ("This entrie is not allowed: ud_functions.hpp");
409  return 0.;
410  break;
411  }
412 }
413 
414 // Method for the definition of the fibers
415 fibersDirectionList::fibersDirectionList() :
416  M_mapNameDefinition( )
417 {}
418 
419 fibersDirectionList::~fibersDirectionList()
420 {}
421 
422 void fibersDirectionList::setupFiberDefinitions( const UInt nbFamilies )
423 {
424  // At the moment the creation of the table of fiber functions is done
425  // manually. There should be a way to make it automatically. Btw, only
426  // the first nbFamilies that are set in the data file are taken into account
427 
428  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." );
429 
430  // Creation of the database of functions
431  fiberFunctionPtr_Type pointerToFunction( new fiberFunction_Type( Family1 ) );
432  M_mapNameDefinition.insert( std::pair<std::string, fiberFunctionPtr_Type>
433  ( "Family1", pointerToFunction ) );
434 
435  pointerToFunction.reset( new fiberFunction_Type( Family2 ) );
436  M_mapNameDefinition.insert( std::pair<std::string, fiberFunctionPtr_Type>
437  ( "Family2", pointerToFunction ) );
438 
439  pointerToFunction.reset( new fiberFunction_Type( Family3 ) );
440  M_mapNameDefinition.insert( std::pair<std::string, fiberFunctionPtr_Type>
441  ( "Family3", pointerToFunction ) );
442 
443  pointerToFunction.reset( new fiberFunction_Type( Family4 ) );
444  M_mapNameDefinition.insert( std::pair<std::string, fiberFunctionPtr_Type>
445  ( "Family4", pointerToFunction ) );
446 
447  pointerToFunction.reset( new fiberFunction_Type( Family5 ) );
448  M_mapNameDefinition.insert( std::pair<std::string, fiberFunctionPtr_Type>
449  ( "Family5", pointerToFunction ) );
450 
451  pointerToFunction.reset( new fiberFunction_Type( Family6 ) );
452  M_mapNameDefinition.insert( std::pair<std::string, fiberFunctionPtr_Type>
453  ( "Family6", pointerToFunction ) );
454 
455 
456 }
457 
458 fibersDirectionList::fiberFunctionPtr_Type fibersDirectionList::fiberDefinition( const std::string nameFamily )
459 {
460 
461  mapNameDefinitionFiberFunction_Type::const_iterator IT;
462 
463  IT = M_mapNameDefinition.find ( nameFamily );
464 
465  if ( IT != M_mapNameDefinition.end() )
466  {
467  return IT->second;
468  }
469  else
470  {
471  std::cout << " Wrong identification of the fiber function! " << std::endl;
472  fiberFunctionPtr_Type pointerToFunction( new fiberFunction_Type() );
473 
474  return pointerToFunction;
475  }
476 }
477 
478 }
Real d0(const Real &t, const Real &x, const Real &y, const Real &z, const ID &i)
#define PI
void updateInverseJacobian(const UInt &iQuadPt)
Real w0(const Real &t, const Real &x, const Real &y, const Real &z, const ID &i)
#define ERROR_MSG(A)
Definition: LifeAssert.hpp:69
#define ASSERT(X, A)
Definition: LifeAssert.hpp:90
uint32_type ID
IDs.
Definition: LifeV.hpp:194
Real f(const Real &t, const Real &x, const Real &y, const Real &z, const ID &i)
double Real
Generic real data.
Definition: LifeV.hpp:175
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191