LifeV
AnalyticalSolution.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 #ifndef ANALYTICALSOLUTION_H_
28 #define ANALYTICALSOLUTION_H_
29 
30 #include <lifev/core/LifeV.hpp>
31 
32 namespace LifeV
33 {
34 
36 {
37 public:
38  // Give to the class a "functor" interface
39  Real operator() (const Real& t, const Real& x, const Real& y, const Real& z, const UInt& ic) const
40  {
41  return u_ex ( t, x, y, z, ic );
42  }
43  // This method is required by the error calculation routines
44  Real grad (UInt icoor, const Real& t, const Real& x, const Real& y, const Real& z, const UInt& ic) const
45  {
46  return grad_ex ( icoor, t, x, y, z, ic );
47  }
48  // The exact solution to the problem
49  static Real u_ex (const Real& t, const Real& x, const Real& y, const Real& z, const UInt& i)
50  {
51  Real a = 1.57;
52 
53  Real d = 0.78;
54 
55  Real nu = 0.01;
56 
57  Real e = std::exp (-d*d*t*nu);
58 
59  switch (i)
60  {
61  case 0:
62  return -a * e * ( std::exp (a * x) * std::sin (a * y + d * z) + std::exp (a * z) * std::cos (a * x + d * y) );
63  case 1:
64  return -a * e * ( std::exp (a * y) * std::sin (a * z + d * x) + std::exp (a * x) * std::cos (a * y + d * z) );
65  case 2:
66  return -a * e * ( std::exp (a * z) * std::sin (a * x + d * y) + std::exp (a * y) * std::cos (a * z + d * x) );
67  default:
68  exit (1);
69  }
70  }
71  // The gradient of the exact solution
72  static Real grad_ex (const UInt& icoor, const Real& t, const Real& x, const Real& y, const Real& z, const UInt& i)
73  {
74  Real a = 1.57;
75 
76  Real d = 0.78;
77 
78  Real nu = 0.01;
79 
80  Real e = std::exp (-d* d* t * nu);
81 
82  switch (icoor)
83  {
84  case 0:
85  switch (i)
86  {
87  case 0:
88  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) );
89  case 1:
90  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) );
91  case 2:
92  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) );
93  default:
94  exit (1);
95  }
96  case 1: // u_y
97  switch (i)
98  {
99  case 0:
100  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) );
101  case 1:
102  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) );
103  case 2:
104  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) );
105  default:
106  exit (1);
107  }
108  case 2:
109  switch (i)
110  {
111  case 0:
112  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) );
113  case 1:
114  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) );
115  case 2:
116  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) );
117  default:
118  exit (1);
119  }
120  default:
121  exit (1);
122  }
123  return 1.;
124  }
125 
126 };
127 
128 } //namespace LifeV
129 
130 #endif
static Real u_ex(const Real &t, const Real &x, const Real &y, const Real &z, const UInt &i)
static Real grad_ex(const UInt &icoor, const Real &t, const Real &x, const Real &y, const Real &z, const UInt &i)
Real grad(UInt icoor, const Real &t, const Real &x, const Real &y, const Real &z, const UInt &ic) const
double Real
Generic real data.
Definition: LifeV.hpp:175
Real operator()(const Real &t, const Real &x, const Real &y, const Real &z, const UInt &ic) const
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191