inf_fe_legendre_eval.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2014 Benjamin S. Kirk, John W. Peterson, Roy H. Stogner
3 
4 // This library is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU Lesser General Public
6 // License as published by the Free Software Foundation; either
7 // version 2.1 of the License, or (at your option) any later version.
8 
9 // This library is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // Lesser General Public License for more details.
13 
14 // You should have received a copy of the GNU Lesser General Public
15 // License along with this library; if not, write to the Free Software
16 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 
18 
19 // Local Includes
20 #include "libmesh/libmesh_config.h"
21 #ifdef LIBMESH_ENABLE_INFINITE_ELEMENTS
22 #include "libmesh/inf_fe.h"
23 #include "libmesh/inf_fe_macro.h"
24 
25 namespace libMesh
26 {
27 
28  // Anonymous namespace for local helper functions
29  namespace {
30 
31  Real legendre_eval(Real v, unsigned i)
32  {
33  libmesh_assert (-1.-1.e-5 <= v && v < 1.);
34 
35  switch (i)
36  {
37  case 0:
38  return 1.;
39 
40  case 1:
41  return v+1.;
42 
43  case 2:
44  return 1.5*v*v-1.5;
45 
46  case 3:
47  return 1.+(-1.5+2.5*v*v)*v;
48 
49  case 4:
50  return -.625+(-3.75+4.375*v*v)*v*v;
51 
52  case 5:
53  return 1.+(1.875+(-8.75+7.875*v*v)*v*v)*v;
54 
55  case 6:
56  return -1.3125+
57  (6.5625+
58  (-19.6875+14.4375*v*v)*v*v)*v*v;
59 
60  case 7:
61  return 1.+
62  (-2.1875+
63  (19.6875+
64  (-43.3125+26.8125*v*v)*v*v)*v*v)*v;
65 
66  case 8:
67  return -.7265625+
68  (-9.84375+
69  (54.140625+
70  (-93.84375+50.2734375*v*v)*v*v)*v*v)*v*v;
71 
72  case 9:
73  return 1.+
74  (2.4609375+
75  (-36.09375+
76  (140.765625+
77  (-201.09375+94.9609375*v*v)*v*v)*v*v)*v*v)*v;
78 
79  case 10:
80  return -1.24609375+
81  (13.53515625+
82  (-117.3046875+
83  (351.9140625+
84  (-427.32421875+180.42578125*v*v)*v*v)*v*v)*v*v)*v*v;
85 
86  case 11:
87  return 1.+
88  (-2.70703125+
89  (58.65234375+
90  (-351.9140625+
91  (854.6484375+
92  (-902.12890625+344.44921875*v*v)*v*v)*v*v)*v*v)*v*v)*v;
93 
94  case 12:
95  return -.7744140625+
96  (-17.595703125+
97  (219.9462890625+
98  (-997.08984375+
99  (2029.7900390625+
100  (-1894.470703125+660.1943359375*v*v)*v*v)*v*v)*v*v)*v*v)*v*v;
101 
102  case 13:
103  return 1.+
104  (2.9326171875+
105  (-87.978515625+
106  (747.8173828125+
107  (-2706.38671875+
108  (4736.1767578125+
109  (-3961.166015625+1269.6044921875*v*v)*v*v)*v*v)*v*v)*v*v)*v*v)*v;
110 
111  case 14:
112  return -1.20947265625+
113  (21.99462890625+
114  (-373.90869140625+
115  (2368.08837890625+
116  (-7104.26513671875+
117  (10893.20654296875+
118  (-8252.42919921875+2448.52294921875*v*v)*v*v)*v*v)*v*v)*v*v)*v*v)*v*v;
119 
120  case 15:
121  return 1.+
122  (-3.14208984375+
123  (124.63623046875+
124  (-1420.85302734375+
125  (7104.26513671875+
126  (-18155.34423828125+
127  (24757.28759765625+
128  (-17139.66064453125+4733.81103515625*v*v)*v*v)*v*v)*v*v)*v*v)*v*v)*v*v)*v;
129 
130  case 16:
131  return -.803619384765625+
132  (-26.707763671875+
133  (592.0220947265625+
134  (-4972.985595703125+
135  (20424.76226806641+
136  (-45388.36059570313+
137  (55703.89709472656+
138  (-35503.58276367188+9171.758880615234*v*v)*v*v)*v*v)*v*v)*v*v)*v*v)*v*v)*v*v;
139 
140  case 17:
141  return 1.+
142  (3.338470458984375+
143  (-169.149169921875+
144  (2486.492797851563+
145  (-16339.80981445313+
146  (56735.45074462891+
147  (-111407.7941894531+
148  (124262.5396728516+
149  (-73374.07104492188+17804.00253295898*v*v)*v*v)*v*v)*v*v)*v*v)*v*v)*v*v)*v*v)*v;
150 
151  case 18:
152  return -1.185470581054688+
153  (31.71546936035156+
154  (-888.0331420898438+
155  (9531.555725097656+
156  (-51061.90567016602+
157  (153185.717010498+
158  (-269235.5026245117+
159  (275152.766418457+
160  (-151334.0215301514+34618.89381408691*v*v)*v*v)*v*v)*v*v)*v*v)*v*v)*v*v)*v*v)*v*v;
161 
162 
163  default:
164  libMesh::err << "bad index i = " << i << std::endl;
165  libmesh_error();
166 
167  }
168 
169  // we never end up here.
170  libmesh_error();
171  return 0.;
172  } // legendre_eval()
173 
174 
175 
176 
177  Real legendre_eval_deriv(Real v, unsigned i)
178  {
179  libmesh_assert (-1.-1.e-5 <= v && v < 1.);
180 
181  switch (i)
182  {
183  case 0:
184  return 0.;
185 
186  case 1:
187  return 1.;
188 
189  case 2:
190  return 3.*v;
191 
192  case 3:
193  return 7.5*v*v-1.5;
194 
195  case 4:
196  return (-7.5+17.5*v*v)*v;
197 
198  case 5:
199  return 1.875+(-26.25+39.375*v*v)*v*v;
200 
201  case 6:
202  return
203  (13.125+
204  (-78.75+86.625*v*v)*v*v)*v;
205 
206  case 7:
207  return -2.1875+
208  (59.0625+
209  (-216.5625+187.6875*v*v)*v*v)*v*v;
210 
211  case 8:
212  return
213  (-19.6875+
214  (216.5625+
215  (-563.0625+402.1875*v*v)*v*v)*v*v)*v;
216 
217  case 9:
218  return 2.4609375+
219  (-108.28125+
220  (703.828125+
221  (-1407.65625+854.6484375*v*v)*v*v)*v*v)*v*v;
222 
223  case 10:
224  return
225  (27.0703125+
226  (-469.21875+
227  (2111.484375+
228  (-3418.59375+1804.2578125*v*v)*v*v)*v*v)*v*v)*v;
229 
230  case 11:
231  return -2.70703125+
232  (175.95703125+
233  (-1759.5703125+
234  (5982.5390625+
235  (-8119.16015625+3788.94140625*v*v)*v*v)*v*v)*v*v)*v*v;
236 
237  case 12:
238  return
239  (-35.19140625+
240  (879.78515625+
241  (-5982.5390625+
242  (16238.3203125+
243  (-18944.70703125+7922.33203125*v*v)*v*v)*v*v)*v*v)*v*v)*v;
244 
245  case 13:
246  return 2.9326171875+
247  (-263.935546875+
248  (3739.0869140625+
249  (-18944.70703125+
250  (42625.5908203125+
251  (-43572.826171875+16504.8583984375*v*v)*v*v)*v*v)*v*v)*v*v)*v*v;
252 
253  case 14:
254  return
255  (43.9892578125+
256  (-1495.634765625+
257  (14208.5302734375+
258  (-56834.12109375+
259  (108932.0654296875+
260  (-99029.150390625+34279.3212890625*v*v)*v*v)*v*v)*v*v)*v*v)*v*v)*v;
261 
262  case 15:
263  return -3.14208984375+
264  (373.90869140625+
265  (-7104.26513671875+
266  (49729.85595703125+
267  (-163398.0981445313+
268  (272330.1635742188+
269  (-222815.5883789063+71007.16552734375*v*v)*v*v)*v*v)*v*v)*v*v)*v*v)*v*v;
270 
271  case 16:
272  return
273  (-53.41552734375+
274  (2368.08837890625+
275  (-29837.91357421875+
276  (163398.0981445313+
277  (-453883.6059570313+
278  (668446.7651367188+
279  (-497050.1586914063+146748.1420898438*v*v)*v*v)*v*v)*v*v)*v*v)*v*v)*v*v)*v;
280 
281  case 17:
282  return 3.338470458984375+
283  (-507.447509765625+
284  (12432.46398925781+
285  (-114378.6687011719+
286  (510619.0567016602+
287  (-1225485.736083984+
288  (1615413.01574707+
289  (-1100611.065673828+302668.0430603027*v*v)*v*v)*v*v)*v*v)*v*v)*v*v)*v*v)*v*v;
290 
291  case 18:
292  return
293  (63.43093872070313+
294  (-3552.132568359375+
295  (57189.33435058594+
296  (-408495.2453613281+
297  (1531857.17010498+
298  (-3230826.031494141+
299  (3852138.729858398+
300  (-2421344.344482422+623140.0886535645*v*v)*v*v)*v*v)*v*v)*v*v)*v*v)*v*v)*v*v)*v;
301 
302 
303  default:
304  libMesh::err << "bad index i = " << i << std::endl;
305  libmesh_error();
306 
307  }
308 
309  // we never end up here.
310  libmesh_error();
311  return 0.;
312  } // legendre_eval_deriv()
313 
314  } // anonymous namespace
315 
316 
317 
318 
319 
320  // Specialize the eval() function for 1, 2, and 3 dimensions and the CARTESIAN mapping type
321  // to call the local helper function from the anonymous namespace.
322  template <> Real InfFE<1,LEGENDRE,CARTESIAN>::eval(Real v, Order, unsigned i) { return legendre_eval(v, i); }
323  template <> Real InfFE<2,LEGENDRE,CARTESIAN>::eval(Real v, Order, unsigned i) { return legendre_eval(v, i); }
324  template <> Real InfFE<3,LEGENDRE,CARTESIAN>::eval(Real v, Order, unsigned i) { return legendre_eval(v, i); }
325 
326  // Specialize the eval_deriv() function for 1, 2, and 3 dimensions and the CARTESIAN mapping type
327  // to call the local helper function from the anonymous namespace.
328  template <> Real InfFE<1,LEGENDRE,CARTESIAN>::eval_deriv(Real v, Order, unsigned i) { return legendre_eval_deriv(v, i); }
329  template <> Real InfFE<2,LEGENDRE,CARTESIAN>::eval_deriv(Real v, Order, unsigned i) { return legendre_eval_deriv(v, i); }
330  template <> Real InfFE<3,LEGENDRE,CARTESIAN>::eval_deriv(Real v, Order, unsigned i) { return legendre_eval_deriv(v, i); }
331 
332 } // namespace libMesh
333 
334 
335 #endif // LIBMESH_ENABLE_INFINITE_ELEMENTS

Site Created By: libMesh Developers
Last modified: February 07 2014 16:57:05 UTC

Hosted By:
SourceForge.net Logo