inf_fe_legendre_eval.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2018 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_error_msg("bad index i = " << i);
165  }
166 } // legendre_eval()
167 
168 
169 
170 
171 Real legendre_eval_deriv(Real v, unsigned i)
172 {
173  libmesh_assert (-1.-1.e-5 <= v && v < 1.);
174 
175  switch (i)
176  {
177  case 0:
178  return 0.;
179 
180  case 1:
181  return 1.;
182 
183  case 2:
184  return 3.*v;
185 
186  case 3:
187  return 7.5*v*v-1.5;
188 
189  case 4:
190  return (-7.5+17.5*v*v)*v;
191 
192  case 5:
193  return 1.875+(-26.25+39.375*v*v)*v*v;
194 
195  case 6:
196  return
197  (13.125+
198  (-78.75+86.625*v*v)*v*v)*v;
199 
200  case 7:
201  return -2.1875+
202  (59.0625+
203  (-216.5625+187.6875*v*v)*v*v)*v*v;
204 
205  case 8:
206  return
207  (-19.6875+
208  (216.5625+
209  (-563.0625+402.1875*v*v)*v*v)*v*v)*v;
210 
211  case 9:
212  return 2.4609375+
213  (-108.28125+
214  (703.828125+
215  (-1407.65625+854.6484375*v*v)*v*v)*v*v)*v*v;
216 
217  case 10:
218  return
219  (27.0703125+
220  (-469.21875+
221  (2111.484375+
222  (-3418.59375+1804.2578125*v*v)*v*v)*v*v)*v*v)*v;
223 
224  case 11:
225  return -2.70703125+
226  (175.95703125+
227  (-1759.5703125+
228  (5982.5390625+
229  (-8119.16015625+3788.94140625*v*v)*v*v)*v*v)*v*v)*v*v;
230 
231  case 12:
232  return
233  (-35.19140625+
234  (879.78515625+
235  (-5982.5390625+
236  (16238.3203125+
237  (-18944.70703125+7922.33203125*v*v)*v*v)*v*v)*v*v)*v*v)*v;
238 
239  case 13:
240  return 2.9326171875+
241  (-263.935546875+
242  (3739.0869140625+
243  (-18944.70703125+
244  (42625.5908203125+
245  (-43572.826171875+16504.8583984375*v*v)*v*v)*v*v)*v*v)*v*v)*v*v;
246 
247  case 14:
248  return
249  (43.9892578125+
250  (-1495.634765625+
251  (14208.5302734375+
252  (-56834.12109375+
253  (108932.0654296875+
254  (-99029.150390625+34279.3212890625*v*v)*v*v)*v*v)*v*v)*v*v)*v*v)*v;
255 
256  case 15:
257  return -3.14208984375+
258  (373.90869140625+
259  (-7104.26513671875+
260  (49729.85595703125+
261  (-163398.0981445313+
262  (272330.1635742188+
263  (-222815.5883789063+71007.16552734375*v*v)*v*v)*v*v)*v*v)*v*v)*v*v)*v*v;
264 
265  case 16:
266  return
267  (-53.41552734375+
268  (2368.08837890625+
269  (-29837.91357421875+
270  (163398.0981445313+
271  (-453883.6059570313+
272  (668446.7651367188+
273  (-497050.1586914063+146748.1420898438*v*v)*v*v)*v*v)*v*v)*v*v)*v*v)*v*v)*v;
274 
275  case 17:
276  return 3.338470458984375+
277  (-507.447509765625+
278  (12432.46398925781+
279  (-114378.6687011719+
280  (510619.0567016602+
281  (-1225485.736083984+
282  (1615413.01574707+
283  (-1100611.065673828+302668.0430603027*v*v)*v*v)*v*v)*v*v)*v*v)*v*v)*v*v)*v*v;
284 
285  case 18:
286  return
287  (63.43093872070313+
288  (-3552.132568359375+
289  (57189.33435058594+
290  (-408495.2453613281+
291  (1531857.17010498+
292  (-3230826.031494141+
293  (3852138.729858398+
294  (-2421344.344482422+623140.0886535645*v*v)*v*v)*v*v)*v*v)*v*v)*v*v)*v*v)*v*v)*v;
295 
296 
297  default:
298  libmesh_error_msg("bad index i = " << i);
299  }
300 } // legendre_eval_deriv()
301 
302 } // anonymous namespace
303 
304 
305 
306 
307 
308  // Specialize the eval() function for 1, 2, and 3 dimensions and the CARTESIAN mapping type
309  // to call the local helper function from the anonymous namespace.
310 template <> Real InfFE<1,LEGENDRE,CARTESIAN>::eval(Real v, Order, unsigned i) { return legendre_eval(v, i); }
311 template <> Real InfFE<2,LEGENDRE,CARTESIAN>::eval(Real v, Order, unsigned i) { return legendre_eval(v, i); }
312 template <> Real InfFE<3,LEGENDRE,CARTESIAN>::eval(Real v, Order, unsigned i) { return legendre_eval(v, i); }
313 
314 // Specialize the eval_deriv() function for 1, 2, and 3 dimensions and the CARTESIAN mapping type
315 // to call the local helper function from the anonymous namespace.
316 template <> Real InfFE<1,LEGENDRE,CARTESIAN>::eval_deriv(Real v, Order, unsigned i) { return legendre_eval_deriv(v, i); }
317 template <> Real InfFE<2,LEGENDRE,CARTESIAN>::eval_deriv(Real v, Order, unsigned i) { return legendre_eval_deriv(v, i); }
318 template <> Real InfFE<3,LEGENDRE,CARTESIAN>::eval_deriv(Real v, Order, unsigned i) { return legendre_eval_deriv(v, i); }
319 
320 } // namespace libMesh
321 
322 
323 #endif // LIBMESH_ENABLE_INFINITE_ELEMENTS
static Real eval_deriv(Real v, Order o_radial, unsigned int i)
static Real eval(Real v, Order o_radial, unsigned int i)
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real