LifeV
SetOfFun.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 Quadrature Rule test
30 
31  @author Samuel Quinodoz <samuel.quinodoz@epfl.ch>
32  @author Umberto Villa <uvilla@emory.edu>
33  @contributor
34  @maintainer Umberto Villa <uvilla@emory.edu>
35 
36  @date 02-03-2010
37 
38 Definition of all the polynomials we need to integrate to check the degree of exactness.
39 The last function is an exponential function to check the convergence rate
40 
41 
42 */
43 
44 #include "SetOfFun.hpp"
45 
46 // IMPLEMENTATION
47 namespace LifeV
48 {
50  _i (31),
51  _integral (_i + 1),
52  _name (_i + 1),
53  _degree (_i + 1)
54 {
55  _integral[0] = 1.;
56  _name[0] = "p(x) = 1 ";
57  _degree[0] = 0;
58  _integral[1] = .5;
59  _name[1] = "p(x) = x ";
60  _degree[1] = 1;
61  _integral[2] = 1. / 3.;
62  _name[2] = "p(x) = x^2 ";
63  _degree[2] = 2;
64  _integral[3] = .25;
65  _name[3] = "p(x) = x*y ";
66  _degree[3] = 2;
67  _integral[4] = .25;
68  _name[4] = "p(x) = x^3 ";
69  _degree[4] = 3;
70  _integral[5] = 1. / 6.;
71  _name[5] = "p(x) = x^2*y ";
72  _degree[5] = 3;
73  _integral[6] = .125;
74  _name[6] = "p(x) = x*y*z ";
75  _degree[6] = 3;
76  _integral[7] = 0.2;
77  _name[7] = "p(x) = x^4 ";
78  _degree[7] = 4;
79  _integral[8] = 1. / 8.;
80  _name[8] = "p(x) = x^3*y ";
81  _degree[8] = 4;
82  _integral[9] = 1. / 9.;
83  _name[9] = "p(x) = x^2*y^2 ";
84  _degree[9] = 4;
85  _integral[10] = 1. / 12.;
86  _name[10] = "p(x) = x^2*y*z ";
87  _degree[10] = 4;
88  _integral[11] = 1. / 6.;
89  _name[11] = "p(x) = x^5 ";
90  _degree[11] = 5;
91  _integral[12] = 1. / 10.;
92  _name[12] = "p(x) = x^4*y ";
93  _degree[12] = 5;
94  _integral[13] = 1. / 12.;
95  _name[13] = "p(x) = x^3*y^2 ";
96  _degree[13] = 5;
97  _integral[14] = 1. / 16.;
98  _name[14] = "p(x) = x^3*y*z ";
99  _degree[14] = 5;
100  _integral[15] = 1. / 18.;
101  _name[15] = "p(x) = x^2*y^2*z ";
102  _degree[15] = 5;
103  _integral[16] = 1. / 7.;
104  _name[16] = "p(x) = x^6 ";
105  _degree[16] = 6;
106  _integral[17] = 1. / 12.;
107  _name[17] = "p(x) = x^5*y ";
108  _degree[17] = 6;
109  _integral[18] = 1. / 15.;
110  _name[18] = "p(x) = x^4*y^2 ";
111  _degree[18] = 6;
112  _integral[19] = 1. / 16.;
113  _name[19] = "p(x) = x^3*y^3 ";
114  _degree[19] = 6;
115  _integral[20] = 1. / 20.;
116  _name[20] = "p(x) = x^4*y*z ";
117  _degree[20] = 6;
118  _integral[21] = 1. / 24.;
119  _name[21] = "p(x) = x^3*y^2*z ";
120  _degree[21] = 6;
121  _integral[22] = 1. / 27.;
122  _name[22] = "p(x) = x^2*y^2*z^2";
123  _degree[22] = 6;
124  _integral[23] = 1. / 8.;
125  _name[23] = "p(x) = x^7 ";
126  _degree[23] = 7;
127  _integral[24] = 1. / 14.;
128  _name[24] = "p(x) = x^6*y ";
129  _degree[24] = 7;
130  _integral[25] = 1. / 18.;
131  _name[25] = "p(x) = x^5*y^2 ";
132  _degree[25] = 7;
133  _integral[26] = 1. / 20.;
134  _name[26] = "p(x) = x^4*y^3 ";
135  _degree[26] = 7;
136  _integral[27] = 1. / 24.;
137  _name[27] = "p(x) = x^5*y*z ";
138  _degree[27] = 7;
139  _integral[28] = 1. / 30.;
140  _name[28] = "p(x) = x^4*y^2*z ";
141  _degree[28] = 7;
142  _integral[29] = 1. / 32.;
143  _name[29] = "p(x) = x^3*y^3*z ";
144  _degree[29] = 7;
145  _integral[30] = 1. / 36.;
146  _name[30] = "p(x) = x^3*y^2*z^2";
147  _degree[30] = 7;
148  _integral[31] = 3.12912420246652;
149  _name[31] = "f(x) = exp(x^2+y^2+z^2)";
150  _degree[31] = 100;
151 }
152 
153 Real SetofFun::val (int fun, Real& x, Real& y, Real& z)
154 {
155  switch (fun)
156  {
157  case 0:
158  return 1.;
159  case 1:
160  return x;
161  case 2:
162  return x * x;
163  case 3:
164  return x * y;
165  case 4:
166  return x * x * x;
167  case 5:
168  return x * x * y;
169  case 6:
170  return x * y * z;
171  case 7:
172  return x * x * x * x;
173  case 8:
174  return x * x * x * y;
175  case 9:
176  return x * x * y * y;
177  case 10:
178  return x * x * y * z;
179  case 11:
180  return x * x * x * x * x;
181  case 12:
182  return x * x * x * x * y;
183  case 13:
184  return x * x * x * y * y;
185  case 14:
186  return x * x * x * y * z;
187  case 15:
188  return x * x * y * y * z;
189  case 16:
190  return x * x * x * x * x * x;
191  case 17:
192  return x * x * x * x * x * y;
193  case 18:
194  return x * x * x * x * y * y;
195  case 19:
196  return x * x * x * y * y * y;
197  case 20:
198  return x * x * x * x * y * z;
199  case 21:
200  return x * x * x * y * y * z;
201  case 22:
202  return x * x * y * y * z * z;
203  case 23:
204  return x * x * x * x * x * x * x;
205  case 24:
206  return x * x * x * x * x * x * y;
207  case 25:
208  return x * x * x * x * x * y * y;
209  case 26:
210  return x * x * x * x * y * y * y;
211  case 27:
212  return x * x * x * x * x * y * z;
213  case 28:
214  return x * x * x * x * y * y * z;
215  case 29:
216  return x * x * x * y * y * y * z;
217  case 30:
218  return x * x * x * y * y * z * z;
219  case 31:
220  return exp (x * x + y * y + z * z);
221  default:
222  return 0.;
223  }
224 }
225 
226 std::string SetofFun::name (UInt fun)
227 {
228  return _name[fun];
229 }
230 
232 {
233  return _degree[fun];
234 }
235 
237 {
238  return _integral[fun];
239 }
240 
242 {
243  return _i;
244 }
245 
246 } /*end namespace */
Real ex_int(UInt fun)
Definition: SetOfFun.cpp:236
void updateInverseJacobian(const UInt &iQuadPt)
std::string name(UInt fun)
Definition: SetOfFun.cpp:226
double Real
Generic real data.
Definition: LifeV.hpp:175
UInt degree(UInt fun)
Definition: SetOfFun.cpp:231
Real val(int fun, Real &x, Real &y, Real &z)
Definition: SetOfFun.cpp:153
uint32_type UInt
generic unsigned integer (used mainly for addressing)
Definition: LifeV.hpp:191