LifeV
structure/testsuite/evaluateNodalETA/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 
146 //----------------------------------------------Boundary Conditions--------------
147 Real bcZero (const Real& /*t*/, const Real& /*X*/, const Real& /*Y*/, const Real& /*Z*/, const ID& /*i*/)
148 {
149  return 0.;
150 }
151 
152 Real bcNonZero (const Real& t, const Real& X, const Real& Y, const Real& Z, const ID& i)
153 {
154  //Real pressure(200000);
155 
156  // Real top = 1000000;
157 
158  // return top * Y;
159 
160  return 700000;
161 
162  // Real highestPressure(6.666e+6);
163  // Real totalTime = 20.0;
164  // Real halfTime = totalTime / 2.0;
165 
166  // Real a = ( highestPressure / 2 ) * ( 1/ ((totalTime/2)*(totalTime/2)) );
167 
168  // if ( t <= halfTime )
169  // pressure = a * t*t;
170 
171  // if ( t > halfTime )
172  // pressure = - a * (t - totalTime)*(t - totalTime) + highestPressure;
173 
174  // switch (i)
175  // {
176  // case 0:
177  // return 0.0;
178  // break;
179  // case 1:
180  // return pressure;
181  // break;
182  // case 2:
183  // return 0.0;
184  // break;
185  // default:
186  // ERROR_MSG ("This entrie is not allowed: ud_functions.hpp");
187  // return 0.;
188  // break;
189  // }
190 }
191  Real smoothPressure(const Real& t, const Real& x, const Real& y, const Real& /*Z*/, const ID& i)
192  {
193  Real radius = std::sqrt( x*x + y*y);
194  Real pressure(0);
195 
196  Real highestPressure(200000);
197  Real totalTime = 4.5;
198  Real halfTime = totalTime / 2.0;
199 
200  Real a = ( highestPressure / 2 ) * ( 1/ ( halfTime*halfTime ) );
201 
202  if ( t <= halfTime )
203  pressure = a * t*t;
204 
205  if ( t > halfTime )
206  pressure = - a * (t - totalTime)*(t - totalTime) + highestPressure;
207 
208  switch (i)
209  {
210  case 0:
211  return pressure * ( x / radius ) ;
212  break;
213  case 1:
214  return pressure * ( y / radius ) ;
215  break;
216  case 2:
217  return 0.0;
218  break;
219 
220  }
221  return 0;
222 
223  }
224 
225 Real traction (const Real& /*t*/, const Real& /*X*/, const Real& /*Y*/, const Real& /*Z*/, const ID& /*i*/)
226 {
227  return 10000.;
228 }
229 
230 
231 //----------------------------------------------Fibers Directions--------------
232 Real Family1 ( const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
233 {
234  Real theta = PI / 6.0; // value for anisotropic characterization taken from Robertson // ( PI / 6.0 );
235  //Real thetaChangeOfVariable = std::atan( y / x );
236 
237  // if( x < 0 )
238  // {
239  // // This is due to the periodicity of std::atan ( ref. official documentation )
240  // thetaChangeOfVariable += PI;
241  // }
242 
243  switch (i)
244  {
245  case 0:
246  // Tube
247  // return - std::sin( thetaChangeOfVariable ) * std::cos( theta );
248  // Cube
249  return std::sin( theta );
250  break;
251  case 1:
252  // Tube
253  //return std::cos( thetaChangeOfVariable ) * std::cos( theta );
254  // Cube
255  return std::cos( theta );
256  break;
257  case 2:
258  // Tube
259  //return std::sin( theta );
260  // Cube
261  return 0.0;
262  break;
263  default:
264  ERROR_MSG ("This entrie is not allowed: ud_functions.hpp");
265  return 0.;
266  break;
267  }
268 }
269 
270 Real Family2 ( const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
271 {
272  Real theta = ( - PI / 6.0 );
273 // Real thetaChangeOfVariable = std::atan( y / x );
274 
275  // if( x < 0 )
276  // {
277  // // This is due to the periodicity of std::atan ( ref. official documentation )
278  // thetaChangeOfVariable += PI;
279  // }
280 
281  switch (i)
282  {
283  case 0:
284  // Tube
285  //return - std::sin( thetaChangeOfVariable ) * std::cos( theta );
286  // Cube
287  return std::sin( theta );
288  break;
289  case 1:
290  // Tube
291  //return std::cos( thetaChangeOfVariable ) * std::cos( theta );
292  // Cube
293  return std::cos( theta );
294  break;
295  case 2:
296  // Tube
297  //return std::sin( theta );
298  // Cube
299  return 0.0;
300  break;
301  default:
302  ERROR_MSG ("This entrie is not allowed: ud_functions.hpp");
303  return 0.;
304  break;
305  }
306 }
307 
308 Real Family3 ( const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
309 {
310 
311  switch (i)
312  {
313  case 0:
314  return 0.0;
315  break;
316  case 1:
317  return 0.0;
318  break;
319  case 2:
320  return -1.0;
321  break;
322  default:
323  ERROR_MSG ("This entrie is not allowed: ud_functions.hpp");
324  return 0.;
325  break;
326  }
327 }
328 
329 
330 Real Family4 ( const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
331 {
332 
333  switch (i)
334  {
335  case 0:
336  return 0.0;
337  break;
338  case 1:
339  return 0.0;
340  break;
341  case 2:
342  return 0.0;
343  break;
344  default:
345  ERROR_MSG ("This entrie is not allowed: ud_functions.hpp");
346  return 0.;
347  break;
348  }
349 }
350 
351 
352 Real Family5 ( const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
353 {
354 
355  switch (i)
356  {
357  case 0:
358  return 0.0;
359  break;
360  case 1:
361  return 0.0;
362  break;
363  case 2:
364  return 0.0;
365  break;
366  default:
367  ERROR_MSG ("This entrie is not allowed: ud_functions.hpp");
368  return 0.;
369  break;
370  }
371 }
372 
373 Real Family6 ( const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
374 {
375 
376  switch (i)
377  {
378  case 0:
379  return 0.0;
380  break;
381  case 1:
382  return 0.0;
383  break;
384  case 2:
385  return 0.0;
386  break;
387  default:
388  ERROR_MSG ("This entrie is not allowed: ud_functions.hpp");
389  return 0.;
390  break;
391  }
392 }
393 
394 // Method for the definition of the fibers
395 fibersDirectionList::fibersDirectionList() :
396  M_mapNameDefinition( )
397 {}
398 
399 fibersDirectionList::~fibersDirectionList()
400 {}
401 
402 void fibersDirectionList::setupFiberDefinitions( const UInt nbFamilies )
403 {
404  // At the moment the creation of the table of fiber functions is done
405  // manually. There should be a way to make it automatically. Btw, only
406  // the first nbFamilies that are set in the data file are taken into account
407 
408  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." );
409 
410  // Creation of the database of functions
411  fiberFunctionPtr_Type pointerToFunction( new fiberFunction_Type( Family1 ) );
412  M_mapNameDefinition.insert( std::pair<std::string, fiberFunctionPtr_Type>
413  ( "Family1", pointerToFunction ) );
414 
415  pointerToFunction.reset( new fiberFunction_Type( Family2 ) );
416  M_mapNameDefinition.insert( std::pair<std::string, fiberFunctionPtr_Type>
417  ( "Family2", pointerToFunction ) );
418 
419  pointerToFunction.reset( new fiberFunction_Type( Family3 ) );
420  M_mapNameDefinition.insert( std::pair<std::string, fiberFunctionPtr_Type>
421  ( "Family3", pointerToFunction ) );
422 
423  pointerToFunction.reset( new fiberFunction_Type( Family4 ) );
424  M_mapNameDefinition.insert( std::pair<std::string, fiberFunctionPtr_Type>
425  ( "Family4", pointerToFunction ) );
426 
427  pointerToFunction.reset( new fiberFunction_Type( Family5 ) );
428  M_mapNameDefinition.insert( std::pair<std::string, fiberFunctionPtr_Type>
429  ( "Family5", pointerToFunction ) );
430 
431  pointerToFunction.reset( new fiberFunction_Type( Family6 ) );
432  M_mapNameDefinition.insert( std::pair<std::string, fiberFunctionPtr_Type>
433  ( "Family6", pointerToFunction ) );
434 
435 
436 }
437 
438 fibersDirectionList::fiberFunctionPtr_Type fibersDirectionList::fiberDefinition( const std::string nameFamily )
439 {
440 
441  mapNameDefinitionFiberFunction_Type::const_iterator IT;
442 
443  IT = M_mapNameDefinition.find ( nameFamily );
444 
445  if ( IT != M_mapNameDefinition.end() )
446  {
447  return IT->second;
448  }
449  else
450  {
451  std::cout << " Wrong identification of the fiber function! " << std::endl;
452  fiberFunctionPtr_Type pointerToFunction( new fiberFunction_Type() );
453 
454  return pointerToFunction;
455  }
456 }
457 
458 }
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