LifeV
core/testsuite/filter/importExport/RossEthierSteinmanDec.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 Ross-Ethier Steinmann Analytical Solution
29  @brief A short description of the test content
30 
31  @author Christoph Winkelmann <christoph.winkelmann@epfl.ch>
32  @contributor Mauro Perego <mauro@mathcs.emory.edu>
33  @contributor Umberto Villa <uvilla@emory.edu>
34  @maintainer Umberto Villa <uvilla@emory.edu>
35 
36  @date 2004-11-12
37 
38  Implementation.
39 */
40 
41 #include <lifev/core/LifeV.hpp>
42 
43 #include <lifev/navier_stokes/function/RossEthierSteinmanDec.hpp>
44 
45 namespace LifeV
46 {
47 
48 
49 Real RossEthierSteinmanUnsteadyDec::uexact ( const Real& t,
50  const Real& x,
51  const Real& y,
52  const Real& z,
53  const ID& i)
54 {
55  Real e = std::exp (-S_d * S_d * S_nu * t);
56 
57  switch (i)
58  {
59  case 0:
60  return -S_a * e * ( std::exp (S_a * x) * std::sin (S_a * y + S_d * z) + std::exp (S_a * z) * std::cos (S_a * x + S_d * y) );
61  case 1:
62  return -S_a * e * ( std::exp (S_a * y) * std::sin (S_a * z + S_d * x) + std::exp (S_a * x) * std::cos (S_a * y + S_d * z) );
63  case 2:
64  return -S_a * e * ( std::exp (S_a * z) * std::sin (S_a * x + S_d * y) + std::exp (S_a * y) * std::cos (S_a * z + S_d * x) );
65  default:
66  exit (1);
67  }
68  return 1.;
69 }
70 
71 Real RossEthierSteinmanUnsteadyDec::uderexact ( const Real& t,
72  const Real& x,
73  const Real& y,
74  const Real& z,
75  const ID& i)
76 {
77 
78  if (i < 3)
79  {
80  return -S_d * S_d * S_nu * xexact (t, x, y, z, i);
81  }
82  else
83  {
84  return 0.;
85  }
86 }
87 
88 Real RossEthierSteinmanUnsteadyDec::pexact ( const Real& t,
89  const Real& x,
90  const Real& y,
91  const Real& z,
92  const ID& /* i */ )
93 {
94  return - S_rho * S_a * S_a / 2. * std::exp (-2.*S_d * S_d * S_nu * t) *
95  ( std::exp (2.*S_a * x) + std::exp (2.*S_a * y) + std::exp (2.*S_a * z) +
96  2. * std::sin (S_a * x + S_d * y) * std::cos (S_a * z + S_d * x) * std::exp (S_a * (y + z) ) +
97  2. * std::sin (S_a * y + S_d * z) * std::cos (S_a * x + S_d * y) * std::exp (S_a * (z + x) ) +
98  2. * std::sin (S_a * z + S_d * x) * std::cos (S_a * y + S_d * z) * std::exp (S_a * (x + y) ) );
99 }
100 
101 Real RossEthierSteinmanUnsteadyDec::grad_u ( const UInt& icoor, const Real& t, const Real& x, const Real& y, const Real& z, const ID& i )
102 {
103  Real e = std::exp (-S_d * S_d * S_nu * t);
104  switch (icoor)
105  {
106  case 0: // u_x
107  switch (i)
108  {
109  case 0:
110  return -S_a * e * ( S_a * std::exp (S_a * x) * std::sin (S_a * y + S_d * z) - S_a * std::exp (S_a * z) * std::sin (S_a * x + S_d * y) );
111  case 1:
112  return -S_a * e * ( S_d * std::exp (S_a * y) * std::cos (S_a * z + S_d * x) + S_a * std::exp (S_a * x) * std::cos (S_a * y + S_d * z) );
113  case 2:
114  return -S_a * e * ( S_a * std::exp (S_a * z) * std::cos (S_a * x + S_d * y) - S_d * std::exp (S_a * y) * std::sin (S_a * z + S_d * x) );
115  default:
116  exit (1);
117  }
118  case 1: // u_y
119  switch (i)
120  {
121  case 0:
122  return -S_a * e * ( S_a * std::exp (S_a * x) * std::cos (S_a * y + S_d * z) - S_d * std::exp (S_a * z) * std::sin (S_a * x + S_d * y) );
123  case 1:
124  return -S_a * e * ( S_a * std::exp (S_a * y) * std::sin (S_a * z + S_d * x) - S_a * std::exp (S_a * x) * std::sin (S_a * y + S_d * z) );
125  case 2:
126  return -S_a * e * ( S_d * std::exp (S_a * z) * std::cos (S_a * x + S_d * y) + S_a * std::exp (S_a * y) * std::cos (S_a * z + S_d * x) );
127  default:
128  exit (1);
129  }
130  case 2:
131  switch (i)
132  {
133  case 0:
134  return -S_a * e * ( S_d * std::exp (S_a * x) * std::cos (S_a * y + S_d * z) + S_a * std::exp (S_a * z) * std::cos (S_a * x + S_d * y) );
135  case 1:
136  return -S_a * e * ( S_a * std::exp (S_a * y) * std::cos (S_a * z + S_d * x) - S_d * std::exp (S_a * x) * std::sin (S_a * y + S_d * z) );
137  case 2:
138  return -S_a * e * ( S_a * std::exp (S_a * z) * std::sin (S_a * x + S_d * y) - S_a * std::exp (S_a * y) * std::sin (S_a * z + S_d * x) );
139  default:
140  exit (1);
141  }
142  default:
143  exit (1);
144  }
145  return 1.;
146 }
147 
148 Real RossEthierSteinmanUnsteadyDec::f ( const Real& /* t */,
149  const Real& /* x */,
150  const Real& /* y */,
151  const Real& /* z */,
152  const ID& /* i */ )
153 {
154  return 0.;
155 }
156 
157 Real RossEthierSteinmanUnsteadyDec::xexact ( const Real& t,
158  const Real& x,
159  const Real& y,
160  const Real& z,
161  const ID& i )
162 {
163  switch (i)
164  {
165  case 0:
166  case 1:
167  case 2:
168  return uexact (t, x, y, z, i);
169  case 3:
170  return pexact (t, x, y, z, 1);
171  default:
172  exit (1);
173  }
174  return 1.;
175 }
176 
177 
178 
179 // Initial velocity
180 Real RossEthierSteinmanUnsteadyDec::x0 ( const Real& t, const Real& x, const Real& y,
181  const Real& z, const ID& i )
182 {
183  return xexact (t, x, y, z, i);
184 }
185 
186 
187 
188 //we suppose that the problem geometry is the cube [-1,1]x[-1,1]x[-1,1].
189 Real RossEthierSteinmanUnsteadyDec::fNeumann ( const Real& t,
190  const Real& x,
191  const Real& y,
192  const Real& z,
193  const ID& i )
194 {
195  Real n[3] = {0., 0., 0.};
196  Real out = 0.;
197  if ( x == -1. )
198  {
199  n[0] = -1.;
200  }
201  else if ( x == 1. )
202  {
203  n[0] = 1.;
204  }
205  else if ( y == -1. )
206  {
207  n[1] = -1.;
208  }
209  else if ( y == 1. )
210  {
211  n[1] = 1.;
212  }
213  else if ( z == -1. )
214  {
215  n[2] = -1.;
216  }
217  else if ( z == 1. )
218  {
219  n[2] = 1.;
220  }
221  else
222  {
223  std::cout << "strange point: x=" << x << " y=" << y << " z=" << z
224  << std::endl;
225  }
226 
227  for (UInt k = 0; k < 3; k++) //mu grad_u n
228  {
229  out += S_mu * grad_u (k, t, x, y, z, i) * n[k];
230  }
231 
232  if (S_flagStrain)
233  for (UInt k = 0; k < 3; k++) //mu grad_u^T n
234  {
235  out += S_mu * grad_u (i, t, x, y, z, k) * n[k];
236  }
237 
238  out -= pexact (t, x, y, z, i) * n[i]; //grad_p n
239  return out;
240 }
241 
242 
243 //we suppose that the problem geometry is the cube [-1,1]x[-1,1]x[-1,1].
244 Real RossEthierSteinmanUnsteadyDec::normalVector ( const Real& /*t*/,
245  const Real& x,
246  const Real& y,
247  const Real& z,
248  const ID& i )
249 {
250  Real n[3] = {0., 0., 0.};
251  if ( x == -1. )
252  {
253  n[0] = -1.;
254  }
255  else if ( x == 1. )
256  {
257  n[0] = 1.;
258  }
259  else if ( y == -1. )
260  {
261  n[1] = -1.;
262  }
263  else if ( y == 1. )
264  {
265  n[1] = 1.;
266  }
267  else if ( z == -1. )
268  {
269  n[2] = -1.;
270  }
271  else if ( z == 1. )
272  {
273  n[2] = 1.;
274  }
275  else
276  {
277  std::cout << "strange point: x=" << x << " y=" << y << " z=" << z
278  << std::endl;
279  }
280  return n[i];
281 
282 }
283 
284 
285 //we suppose that the problem geometry is the cylinder having axis x, origin (0,0,0), diameter D and height L
286 Real RossEthierSteinmanUnsteadyDec::fShearStress ( const Real& t, const Real& x, const Real& y, const Real& z, const ID& i )
287 {
288  Real out = 0.;
289 
290  for (UInt k = 0; k < nDimensions; k++) //mu gradu n
291  {
292  out += S_mu * grad_u (k, t, x, y, z, i) * normalVector ( t, x, y, z, k );
293  }
294 
295  if (S_flagStrain)
296  for (UInt k = 0; k < nDimensions; k++) //mu gradu^T n
297  {
298  out += S_mu * grad_u (i, t, x, y, z, k) * normalVector ( t, x, y, z, k );
299  }
300 
301  return out;
302 }
303 
304 //we suppose that the problem geometry is the cylinder having axis x, origin (0,0,0), diameter D and height L
305 Real RossEthierSteinmanUnsteadyDec::fWallShearStress ( const Real& t, const Real& x, const Real& y, const Real& z, const ID& i )
306 {
307  // wss = s_n - ( s_n \cdot n ) n
308  Real wss = 0.;
309  Real s_n_n (0.);
310  // this is the i-component of the normal stress
311  wss = fShearStress (t, x, y, z, i);
312 
313  for (UInt k = 0; k < nDimensions; k++) // ( s_n \cdot n )
314  {
315  s_n_n += fShearStress (t, x, y, z, k) * normalVector ( t, x, y, z, k );
316  }
317 
318  wss -= s_n_n * normalVector ( t, x, y, z, i );
319 
320  return wss;
321 }
322 
323 void RossEthierSteinmanUnsteadyDec::setParamsFromGetPot ( const GetPot& dataFile )
324 {
325  S_a = dataFile ( "fluid/problem/a", 1. ) ;
326  S_d = dataFile ( "fluid/problem/d", 1. ) ;
327  S_mu = dataFile ( "fluid/physics/viscosity", 1. );
328  S_rho = dataFile ( "fluid/physics/density", 1. );
329  S_nu = S_mu / S_rho;
330  S_flagStrain = dataFile ( "fluid/physics/flag_strain", 0 );
331 }
332 void RossEthierSteinmanUnsteadyDec::setA (const Real& aValue)
333 {
334  S_a = aValue;
335 }
336 void RossEthierSteinmanUnsteadyDec::setD (const Real& dValue)
337 {
338  S_d = dValue;
339 }
340 void RossEthierSteinmanUnsteadyDec::setViscosity (const Real& mu)
341 {
342  S_mu = mu;
343  S_nu = S_mu / S_rho;
344 }
345 void RossEthierSteinmanUnsteadyDec::setDensity (const Real& rho)
346 {
347  S_rho = rho;
348  S_nu = S_mu / S_rho;
349 }
350 void RossEthierSteinmanUnsteadyDec::setFlagStrain (const Int& flagValue)
351 {
352  S_flagStrain = flagValue;
353 }
354 
355 Real RossEthierSteinmanUnsteadyDec::S_a;
356 Real RossEthierSteinmanUnsteadyDec::S_d;
357 Real RossEthierSteinmanUnsteadyDec::S_mu;
358 Real RossEthierSteinmanUnsteadyDec::S_rho;
359 Real RossEthierSteinmanUnsteadyDec::S_nu;
360 int RossEthierSteinmanUnsteadyDec::S_flagStrain;
361 
362 } // namespace LifeV
static Real x0(const Real &t, const Real &x, const Real &y, const Real &z, const ID &i)
double operator()(const char *VarName, const double &Default) const
Definition: GetPot.hpp:2033
static Real pexact(const Real &t, const Real &x, const Real &y, const Real &z, const ID &i)
static Real uexact(const Real &t, const Real &x, const Real &y, const Real &z, const ID &i)
static void setParamsFromGetPot(const GetPot &dataFile)
int32_type Int
Generic integer data.
Definition: LifeV.hpp:188
static Real uderexact(const Real &t, const Real &x, const Real &y, const Real &z, const ID &i)
static void setDensity(const Real &rho)
static Real fWallShearStress(const Real &t, const Real &x, const Real &y, const Real &z, const ID &i)
void updateInverseJacobian(const UInt &iQuadPt)
static Real fShearStress(const Real &t, const Real &x, const Real &y, const Real &z, const ID &i)
static Real fNeumann(const Real &t, const Real &x, const Real &y, const Real &z, const ID &i)
static void setFlagStrain(const Int &flagValue)
static void setA(const Real &aValue)
static Real xexact(const Real &t, const Real &x, const Real &y, const Real &z, const ID &i)
uint32_type ID
IDs.
Definition: LifeV.hpp:194
static void setViscosity(const Real &mu)
static Real grad_u(const UInt &icoor, const Real &t, const Real &x, const Real &y, const Real &z, const ID &i)
static void setD(const Real &dValue)
static Real normalVector(const Real &t, const Real &x, const Real &y, const Real &z, const ID &i)
double Real
Generic real data.
Definition: LifeV.hpp:175
int operator()(const char *VarName, int Default) const
Definition: GetPot.hpp:2021
const UInt nDimensions(NDIM)
static Real f(const Real &t, const Real &x, const Real &y, const Real &z, const ID &i)
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191