LifeV
/nonlinear_function.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 NLF_HPP
28 #define NLF_HPP
29 
30 #include <lifev/life/LifeV.hpp>
31 
32 // ===================================================
33 //! User functions
34 // ===================================================
35 
36 namespace LifeV
37 {
38 
39 double alpha = 1;
40 Real Pi2 = Pi* Pi;
41 
42 class AnalyticalSol
43 {
44 public:
45  inline Real operator() (Real t, Real x, Real y, Real z, UInt /*ic*/ = 0) const
46  {
47  return alpha * std::exp (-std::sin (Pi / 2 * t) ) * std::cos (Pi * x) * std::cos (Pi * y) * std::cos (Pi * z);
48  }
49  inline Real grad (UInt icoor, Real t, Real x, Real y, Real z, UInt /*ic*/ = 0) const
50  {
51  switch (icoor)
52  {
53  case 1: // der_x
54  return -alpha * Pi * std::exp (-std::sin (Pi / 2 * t) ) * std::sin (Pi * x) * std::cos (Pi * y) * std::cos (Pi * z);
55  case 2: // der_y
56  return -alpha * Pi * std::exp (-std::sin (Pi / 2 * t) ) * std::cos (Pi * x) * std::sin (Pi * y) * std::cos (Pi * z);
57  case 3: // der_z
58  return -alpha * Pi * std::exp (-std::sin (Pi / 2 * t) ) * std::cos (Pi * x) * std::cos (Pi * y) * std::sin (Pi * z);
59  default:
60  return 0;
61  }
62  }
63 };
64 
65 //solution on the boundary
66 Real uexact ( const Real& t ,
67  const Real& x,
68  const Real& y,
69  const Real& z,
70  const ID& icomp)
71 {
72  return alpha * std::exp (-std::sin (Pi / 2 * t) ) * std::cos (Pi * x) * std::cos (Pi * y) * std::cos (Pi * z);
73 }
74 
75 // u = alpha*exp(-sin(Pi/2*t))*cos(Pi*x)*cos(Pi*y)*cos(Pi*z
76 // v = -Pi/2*cos(Pi/2*t)*u;
77 // w = Pi2/4*sin(Pi/2*t)*u+Pi2/4cos(Pi/2*t)*u
78 
79 Real source_in ( const Real& t ,
80  const Real& x,
81  const Real& y,
82  const Real& z,
83  const ID& icomp)
84 {
85  return (3 + 1. / 4.* ( std::sin (Pi / 2 * t) + std::cos (Pi / 2 * t) * std::cos (Pi / 2 * t) ) )
86  * Pi2 * std::exp (-std::sin (Pi / 2 * t) ) * std::cos (Pi * x) * std::cos (Pi * y) * std::cos (Pi * z);
87 }
88 
89 Real d0 ( const Real& t ,
90  const Real& x,
91  const Real& y,
92  const Real& z,
93  const ID& icomp)
94 {
95  return alpha * std::cos (Pi * x) * std::cos (Pi * y) * std::cos (Pi * z);
96 }
97 
98 Real v0 ( const Real& t ,
99  const Real& x,
100  const Real& y,
101  const Real& z,
102  const ID& icomp)
103 {
104  return -alpha * Pi / 2std::*cos (Pi * x) * std::cos (Pi * y) * std::cos (Pi * z) * std::cos (Pi / 2 * t) * std::exp (-std::sin (Pi / 2 * t) );
105 }
106 
107 Real a0 ( const Real& t ,
108  const Real& x,
109  const Real& y,
110  const Real& z,
111  const ID& icomp)
112 {
113  return + 1. / 4.* ( std::sin (Pi / 2 * t) + std::cos (Pi / 2 * t) * std::cos (Pi / 2 * t) )
114  * Pi2 * std::exp (-std::sin (Pi / 2 * t) ) * std::cos (Pi * x) * std::cos (Pi * y) * std::cos (Pi * z);
115 }
116 
117 Real UZero ( const Real& /* t */,
118  const Real& ,
119  const Real& ,
120  const Real& ,
121  const ID& )
122 {
123  return 0.;
124 }
125 
126 
127 
128 }
129 #endif
void updateInverseJacobian(const UInt &iQuadPt)
Real operator()(Real t, Real x, Real y, Real z, UInt=0) const
Real grad(UInt icoor, Real t, Real x, Real y, Real z, UInt=0) const