LifeV
functions.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 File containing the boundary conditions for the Monolithic Test
30  *
31  * @date 2009-04-09
32  * @author Paolo Crosetto <crosetto@iacspc70.epfl.ch>
33  *
34  * @contributor Cristiano Malossi <cristiano.malossi@epfl.ch>
35  * @maintainer Paolo Crosetto <crosetto@iacspc70.epfl.ch>
36  *
37  * Contains the functions to be assigned as boundary conditions, in the file boundaryConditions.hpp . The functions
38  * can depend on time and space, while they can take in input an ID specifying one of the three principal axis
39  * if the functions to assign is vectorial and the boundary condition is of type \c Full \c.
40  */
41 
42 #ifndef FRES_HPP
43 #define FRES_HPP
44 
45 // LifeV includes
46 #include <lifev/core/LifeV.hpp>
47 
48 namespace LifeV
49 {
50 
51  Real exactVelocity (const Real& t, const Real& x, const Real& y, const Real& z, const ID& i){
52 
53  Real a = 1.57;
54 
55  Real d = 0.78;
56 
57  Real nu = 0.01;
58 
59  Real e = std::exp (-d*d*t*nu);
60 
61  switch (i)
62  {
63  case 0:
64  return -a * e * ( std::exp (a * x) * std::sin (a * y + d * z) + std::exp (a * z) * std::cos (a * x + d * y) );
65  case 1:
66  return -a * e * ( std::exp (a * y) * std::sin (a * z + d * x) + std::exp (a * x) * std::cos (a * y + d * z) );
67  case 2:
68  return -a * e * ( std::exp (a * z) * std::sin (a * x + d * y) + std::exp (a * y) * std::cos (a * z + d * x) );
69  default:
70  exit (1);
71  }
72 
73  }
74 
75  Real gradientVelocity ( const UInt& icoor, const Real& t, const Real& x, const Real& y, const Real& z, const ID& i){
76 
77  Real a = 1.57;
78 
79  Real d = 0.78;
80 
81  Real nu = 0.01;
82 
83  Real e = std::exp (-d* d* t * nu);
84 
85  switch (icoor)
86  {
87  case 0:
88  switch (i)
89  {
90  case 0:
91  return -a* e * ( a* std::exp (a* x) * std::sin (a* y + d* z) - a* std::exp (a* z) * std::sin (a* x + d* y) );
92  case 1:
93  return -a* e * ( d* std::exp (a* y) * std::cos (a* z + d* x) + a* std::exp (a* x) * std::cos (a* y + d* z) );
94  case 2:
95  return -a* e * ( a* std::exp (a* z) * std::cos (a* x + d* y) - d* std::exp (a* y) * std::sin (a* z + d* x) );
96  default:
97  exit (1);
98  }
99  case 1: // u_y
100  switch (i)
101  {
102  case 0:
103  return -a* e * ( a* std::exp (a* x) * std::cos (a* y + d* z) - d* std::exp (a* z) * std::sin (a* x + d* y) );
104  case 1:
105  return -a* e * ( a* std::exp (a* y) * std::sin (a* z + d* x) - a* std::exp (a* x) * std::sin (a* y + d* z) );
106  case 2:
107  return -a* e * ( d* std::exp (a* z) * std::cos (a* x + d* y) + a* std::exp (a* y) * std::cos (a* z + d* x) );
108  default:
109  exit (1);
110  }
111  case 2:
112  switch (i)
113  {
114  case 0:
115  return -a* e * ( d* std::exp (a* x) * std::cos (a* y + d* z) + a* std::exp (a* z) * std::cos (a* x + d* y) );
116  case 1:
117  return -a* e * ( a* std::exp (a* y) * std::cos (a* z + d* x) - d* std::exp (a* x) * std::sin (a* y + d* z) );
118  case 2:
119  return -a* e * ( a* std::exp (a* z) * std::sin (a* x + d* y) - a* std::exp (a* y) * std::sin (a* z + d* x) );
120  default:
121  exit (1);
122  }
123  default:
124  exit (1);
125  }
126  return 1.;
127 
128 
129  }
130 
131  Real exactPressure (const Real& t, const Real& x, const Real& y, const Real& z, const ID& i){
132 
133  Real a = 1.58;
134 
135  Real d = 0.78;
136 
137  Real nu = 0.01;
138 
139  return - a*a/2.0*std::exp(-2.0*d*d*nu*t)*(std::exp (2.0*a*x)+std::exp(2.0*a*y)+std::exp(2.0*a*z) +
140  2.0*std::sin(a*x+d*y)*std::cos(a*z+d*x)*std::exp(a*(y+z)) +
141  2.0*std::sin(a*y+d*z)*std::cos(a*x+d*y)*std::exp(a*(z+x)) +
142  2.0*std::sin(a*z+d*x)*std::cos(a*y+d*z)*std::exp(a*(x+y)) );
143 
144  }
145 
146  Real normalStress (const Real& t, const Real& x, const Real& y, const Real& z, const ID& i){
147 
148  Real dinamic_viscosity = 0.01;
149 
150  // Caution: accordingly to what is done in the driver navier_stokes.hpp, here I assume that the normal of the Neumann face
151  // is the one whose outward normal unit vector is n = [ 0; 0; 1 ].
152 
153  Real n[3] = {0.0, 0.0, -1.0};
154 
155  Real out = 0.0;
156 
157  for (UInt k = 0; k < 3; k++){
158 
159  out += dinamic_viscosity * gradientVelocity (k, t, x, y, z, i) * n[k];
160 
161  }
162 
163  for (UInt k = 0; k < 3; k++){
164 
165  out += dinamic_viscosity * gradientVelocity (i, t, x, y, z, k) * n[k];
166 
167  }
168 
169  out -= exactPressure (t, x, y, z, i) * n[i];
170 
171  return out;
172 
173  }
174 
175 } // end Namespace LifeV
176 
177 #endif // end of define FRES_HPP
Real exactPressure(const Real &t, const Real &x, const Real &y, const Real &z, const ID &i)
Definition: functions.hpp:131
uint32_type ID
IDs.
Definition: LifeV.hpp:194
Real exactVelocity(const Real &t, const Real &x, const Real &y, const Real &z, const ID &i)
Definition: functions.hpp:51
double Real
Generic real data.
Definition: LifeV.hpp:175
Real normalStress(const Real &t, const Real &x, const Real &y, const Real &z, const ID &i)
Definition: functions.hpp:146
Real gradientVelocity(const UInt &icoor, const Real &t, const Real &x, const Real &y, const Real &z, const ID &i)
Definition: functions.hpp:75
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191