LifeV
structure/examples/example_bodyForces/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 VectorSmall<3> f (const Real& t, const Real& x, const Real& y, const Real& z)
49 {
50  VectorSmall<3> evaluationOfF;
51 
52  evaluationOfF[ 0 ] = 1.0;
53  evaluationOfF[ 1 ] = 1.0;
54  evaluationOfF[ 2 ] = 1.0;
55 
56  return evaluationOfF;
57 
58 }
59 
60 
61 Real fzero_scalar (const Real& /*t*/, const Real& /*x*/, const Real& /*y*/, const Real& /*z*/, const ID& /*i*/)
62 {
63  return 0.0;
64 }
65 
66 Real InternalPressure (const Real& /*t*/, const Real& /*x*/, const Real& /*y*/, const Real& /*z*/, const ID& /*i*/)
67 {
68  return -1e+5;
69  //return -260000*sin(80*3.141592*t);
70 }
71 
72 // Initial displacement and velocity
73 Real d0 (const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
74 {
75 
76  switch (i)
77  {
78  case 0:
79  return 0.088002 * ( x + 0.5 );
80  break;
81  case 1:
82  return - ( 0.02068 * 2.0 ) * ( y );
83  break;
84  case 2:
85  return - ( 0.02068 * 2.0 ) * ( z );
86  break;
87  default:
88  ERROR_MSG ("This entry is not allowed: ud_functions.hpp");
89  return 0.;
90  break;
91  }
92 
93 }
94 
95 Real w0 (const Real& /*t*/, const Real& /*x*/, const Real& /*y*/, const Real& /*z*/, const ID& i)
96 {
97 
98  switch (i)
99  {
100  case 0:
101  return 0.0;
102  break;
103  case 1:
104  return 0.0;
105  break;
106  case 2:
107  return 0.0;
108  break;
109  default:
110  ERROR_MSG ("This entrie is not allowed: ud_functions.hpp");
111  return 0.;
112  break;
113  }
114 }
115 
116 Real a0 (const Real& /*t*/, const Real& /*x*/, const Real& /*y*/, const Real& /*z*/, const ID& i)
117 {
118 
119  switch (i)
120  {
121  case 0:
122  return 0.0;
123  break;
124  case 1:
125  return 0.0;
126  break;
127  case 2:
128  return 0.0;
129  break;
130  default:
131  ERROR_MSG ("This entrie is not allowed: ud_functions.hpp");
132  return 0.;
133  break;
134  }
135 }
136 
137 
138 //----------------------------------------------Boundary Conditions--------------
139 Real bcZero (const Real& /*t*/, const Real& /*X*/, const Real& /*Y*/, const Real& /*Z*/, const ID& /*i*/)
140 {
141  return 0.;
142 }
143 
144 Real bcNonZero (const Real& t, const Real& X, const Real& Y, const Real& Z, const ID& i)
145 {
146  return 5.313710193277322e+03;
147 
148  // Real pressure(0);
149 
150  // Real highestPressure(6.666e+6);
151  // Real totalTime = 20.0;
152  // Real halfTime = totalTime / 2.0;
153 
154  // Real a = ( highestPressure / 2 ) * ( 1/ ((totalTime/2)*(totalTime/2)) );
155 
156  // if ( t <= halfTime )
157  // pressure = a * t*t;
158 
159  // if ( t > halfTime )
160  // pressure = - a * (t - totalTime)*(t - totalTime) + highestPressure;
161 
162  // switch (i)
163  // {
164  // case 0:
165  // return 0.0;
166  // break;
167  // case 1:
168  // return pressure;
169  // break;
170  // case 2:
171  // return 0.0;
172  // break;
173  // default:
174  // ERROR_MSG ("This entrie is not allowed: ud_functions.hpp");
175  // return 0.;
176  // break;
177  // }
178 }
179 
180 Real analyticalDisplacement (const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
181 {
182 
183  switch (i)
184  {
185  case 0:
186  return -0.046537410754408 * ( x + 0.5 );
187  break;
188  case 1:
189  return 0.1 * y;
190  break;
191  case 2:
192  return -0.046537410754408 * ( z + 0.5 );
193  break;
194  default:
195  ERROR_MSG ("This entrie is not allowed: ud_functions.hpp");
196  return 0.;
197  break;
198  }
199 
200  return 0.0;
201 }
202 
203 
204 Real bcNonZeroSecondOrderExponential (const Real& /*t*/, const Real& /*X*/, const Real& /*Y*/, const Real& /*Z*/, const ID& /*i*/)
205 {
206  return 19180.;
207 }
208 
209 
210 //----------------------------------------------Fibers Directions--------------
211 Real Family1 ( const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
212 {
213  switch (i)
214  {
215  case 0:
216  return std::sin( 0.8723155 );
217  break;
218  case 1:
219  return std::cos( 0.8723155 );
220  break;
221  case 2:
222  return 0.0;
223  break;
224  default:
225  ERROR_MSG ("This entrie is not allowed: ud_functions.hpp");
226  return 0.;
227  break;
228  }
229 }
230 
231 Real Family2 ( const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
232 {
233 
234  switch (i)
235  {
236  case 0:
237  return std::sin( - 0.8723155 );
238  break;
239  case 1:
240  return std::cos( - 0.8723155 );
241  break;
242  case 2:
243  return 0.0;
244  break;
245  default:
246  ERROR_MSG ("This entrie is not allowed: ud_functions.hpp");
247  return 0.;
248  break;
249  }
250 }
251 
252 Real Family3 ( const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
253 {
254 
255  switch (i)
256  {
257  case 0:
258  return 0.0;
259  break;
260  case 1:
261  return 0.0;
262  break;
263  case 2:
264  return -1.0;
265  break;
266  default:
267  ERROR_MSG ("This entrie is not allowed: ud_functions.hpp");
268  return 0.;
269  break;
270  }
271 }
272 
273 
274 Real Family4 ( const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
275 {
276 
277  switch (i)
278  {
279  case 0:
280  return 0.0;
281  break;
282  case 1:
283  return 0.0;
284  break;
285  case 2:
286  return 0.0;
287  break;
288  default:
289  ERROR_MSG ("This entrie is not allowed: ud_functions.hpp");
290  return 0.;
291  break;
292  }
293 }
294 
295 
296 Real Family5 ( const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
297 {
298 
299  switch (i)
300  {
301  case 0:
302  return 0.0;
303  break;
304  case 1:
305  return 0.0;
306  break;
307  case 2:
308  return 0.0;
309  break;
310  default:
311  ERROR_MSG ("This entrie is not allowed: ud_functions.hpp");
312  return 0.;
313  break;
314  }
315 }
316 
317 Real Family6 ( const Real& /*t*/, const Real& x, const Real& y, const Real& z, const ID& i)
318 {
319 
320  switch (i)
321  {
322  case 0:
323  return 0.0;
324  break;
325  case 1:
326  return 0.0;
327  break;
328  case 2:
329  return 0.0;
330  break;
331  default:
332  ERROR_MSG ("This entrie is not allowed: ud_functions.hpp");
333  return 0.;
334  break;
335  }
336 }
337 
338 // Method for the definition of the fibers
339 fibersDirectionList::fibersDirectionList() :
340  M_mapNameDefinition( )
341 {}
342 
343 fibersDirectionList::~fibersDirectionList()
344 {}
345 
346 void fibersDirectionList::setupFiberDefinitions( const UInt nbFamilies )
347 {
348  // At the moment the creation of the table of fiber functions is done
349  // manually. There should be a way to make it automatically. Btw, only
350  // the first nbFamilies that are set in the data file are taken into account
351 
352  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." );
353 
354  // Creation of the database of functions
355  fiberFunctionPtr_Type pointerToFunction( new fiberFunction_Type( Family1 ) );
356  M_mapNameDefinition.insert( std::pair<std::string, fiberFunctionPtr_Type>
357  ( "Family1", pointerToFunction ) );
358 
359  pointerToFunction.reset( new fiberFunction_Type( Family2 ) );
360  M_mapNameDefinition.insert( std::pair<std::string, fiberFunctionPtr_Type>
361  ( "Family2", pointerToFunction ) );
362 
363  pointerToFunction.reset( new fiberFunction_Type( Family3 ) );
364  M_mapNameDefinition.insert( std::pair<std::string, fiberFunctionPtr_Type>
365  ( "Family3", pointerToFunction ) );
366 
367  pointerToFunction.reset( new fiberFunction_Type( Family4 ) );
368  M_mapNameDefinition.insert( std::pair<std::string, fiberFunctionPtr_Type>
369  ( "Family4", pointerToFunction ) );
370 
371  pointerToFunction.reset( new fiberFunction_Type( Family5 ) );
372  M_mapNameDefinition.insert( std::pair<std::string, fiberFunctionPtr_Type>
373  ( "Family5", pointerToFunction ) );
374 
375  pointerToFunction.reset( new fiberFunction_Type( Family6 ) );
376  M_mapNameDefinition.insert( std::pair<std::string, fiberFunctionPtr_Type>
377  ( "Family6", pointerToFunction ) );
378 
379 
380 }
381 
382 fibersDirectionList::fiberFunctionPtr_Type fibersDirectionList::fiberDefinition( const std::string nameFamily )
383 {
384 
385  mapNameDefinitionFiberFunction_Type::const_iterator IT;
386 
387  IT = M_mapNameDefinition.find ( nameFamily );
388 
389  if ( IT != M_mapNameDefinition.end() )
390  {
391  return IT->second;
392  }
393  else
394  {
395  std::cout << " Wrong identification of the fiber function! " << std::endl;
396  fiberFunctionPtr_Type pointerToFunction( new fiberFunction_Type() );
397 
398  return pointerToFunction;
399  }
400 }
401 
402 }
Real d0(const Real &t, const Real &x, const Real &y, const Real &z, const ID &i)
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
Real & operator[](UInt const &i)
Operator [].
#define ASSERT(X, A)
Definition: LifeAssert.hpp:90
uint32_type ID
IDs.
Definition: LifeV.hpp:194
double Real
Generic real data.
Definition: LifeV.hpp:175
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191