@@ -39,11 +39,9 @@ Real fe_lagrange_1D_linear_shape(const unsigned int i,
3939 case 0 :
4040 return .5 *(1 . - xi);
4141
42- case 1 :
43- return .5 *(1 . + xi);
44-
42+ // case 1
4543 default :
46- libmesh_error_msg ( " Invalid shape function index i = " << i );
44+ return . 5 *( 1 . + xi );
4745 }
4846}
4947
@@ -63,11 +61,9 @@ Real fe_lagrange_1D_quadratic_shape(const unsigned int i,
6361 case 1 :
6462 return .5 *xi*(xi + 1 );
6563
66- case 2 :
67- return (1 . - xi*xi);
68-
64+ // case 2
6965 default :
70- libmesh_error_msg ( " Invalid shape function index i = " << i );
66+ return ( 1 . - xi*xi );
7167 }
7268}
7369
@@ -90,11 +86,9 @@ Real fe_lagrange_1D_cubic_shape(const unsigned int i,
9086 case 2 :
9187 return 27 ./16 .*(1 .-xi*xi)*(1 ./3 .-xi);
9288
93- case 3 :
94- return 27 ./16 .*(1 .-xi*xi)*(1 ./3 .+xi);
95-
89+ // case 3
9690 default :
97- libmesh_error_msg ( " Invalid shape function index i = " << i );
91+ return 27 ./ 16 .*( 1 .-xi*xi)*( 1 ./ 3 .+xi );
9892 }
9993}
10094
@@ -105,6 +99,8 @@ Real fe_lagrange_1D_shape(const Order order,
10599 const unsigned int i,
106100 const Real xi)
107101{
102+ libmesh_assert_less_equal (order, THIRD);
103+
108104 switch (order)
109105 {
110106 // Lagrange linears
@@ -116,11 +112,9 @@ Real fe_lagrange_1D_shape(const Order order,
116112 return fe_lagrange_1D_quadratic_shape (i, xi);
117113
118114 // Lagrange cubics
119- case THIRD:
120- return fe_lagrange_1D_cubic_shape (i, xi);
121-
115+ // case THIRD
122116 default :
123- libmesh_error_msg ( " ERROR: Unsupported polynomial order = " << order );
117+ return fe_lagrange_1D_cubic_shape (i, xi );
124118 }
125119}
126120
@@ -141,11 +135,9 @@ Real fe_lagrange_1D_linear_shape_deriv(const unsigned int i,
141135 case 0 :
142136 return -.5 ;
143137
144- case 1 :
145- return .5 ;
146-
138+ // case 1
147139 default :
148- libmesh_error_msg ( " Invalid shape function index i = " << i) ;
140+ return . 5 ;
149141 }
150142}
151143
@@ -168,11 +160,9 @@ Real fe_lagrange_1D_quadratic_shape_deriv(const unsigned int i,
168160 case 1 :
169161 return xi+.5 ;
170162
171- case 2 :
172- return -2 .*xi;
173-
163+ // case 2
174164 default :
175- libmesh_error_msg ( " Invalid shape function index i = " << i) ;
165+ return - 2 .*xi ;
176166 }
177167}
178168
@@ -198,11 +188,9 @@ Real fe_lagrange_1D_cubic_shape_deriv(const unsigned int i,
198188 case 2 :
199189 return 27 ./16 .*(3 .*xi*xi-2 ./3 .*xi-1 .);
200190
201- case 3 :
202- return 27 ./16 .*(-3 .*xi*xi-2 ./3 .*xi+1 .);
203-
191+ // case 3
204192 default :
205- libmesh_error_msg ( " Invalid shape function index i = " << i );
193+ return 27 ./ 16 .*(- 3 .*xi*xi- 2 ./ 3 .*xi+ 1 . );
206194 }
207195}
208196
@@ -214,6 +202,8 @@ Real fe_lagrange_1D_shape_deriv(const Order order,
214202 const unsigned int j,
215203 const Real xi)
216204{
205+ libmesh_assert_less_equal (order, THIRD);
206+
217207 switch (order)
218208 {
219209 case FIRST:
@@ -222,11 +212,9 @@ Real fe_lagrange_1D_shape_deriv(const Order order,
222212 case SECOND:
223213 return fe_lagrange_1D_quadratic_shape_deriv (i, j, xi);
224214
225- case THIRD:
226- return fe_lagrange_1D_cubic_shape_deriv (i, j, xi);
227-
215+ // case THIRD
228216 default :
229- libmesh_error_msg ( " ERROR: Unsupported polynomial order = " << order );
217+ return fe_lagrange_1D_cubic_shape_deriv (i, j, xi );
230218 }
231219}
232220
@@ -244,6 +232,7 @@ Real fe_lagrange_1D_quadratic_shape_second_deriv(const unsigned int i,
244232 // Don't need to switch on j. 1D shape functions
245233 // depend on xi only!
246234 libmesh_assert_equal_to (j, 0 );
235+ libmesh_assert_less (i, 3 );
247236
248237 switch (i)
249238 {
@@ -253,11 +242,9 @@ Real fe_lagrange_1D_quadratic_shape_second_deriv(const unsigned int i,
253242 case 1 :
254243 return 1 .;
255244
256- case 2 :
257- return -2 .;
258-
245+ // case 2
259246 default :
260- libmesh_error_msg ( " Invalid shape function index i = " << i) ;
247+ return - 2 . ;
261248 }
262249}
263250
@@ -270,6 +257,7 @@ Real fe_lagrange_1D_cubic_shape_second_deriv(const unsigned int i,
270257 // Don't need to switch on j. 1D shape functions
271258 // depend on xi only!
272259 libmesh_assert_equal_to (j, 0 );
260+ libmesh_assert_less (i, 4 );
273261
274262 switch (i)
275263 {
@@ -282,11 +270,9 @@ Real fe_lagrange_1D_cubic_shape_second_deriv(const unsigned int i,
282270 case 2 :
283271 return 27 ./16 .*(6 *xi-2 ./3 .);
284272
285- case 3 :
286- return 27 ./16 .*(-6 *xi-2 ./3 .);
287-
273+ // case 2
288274 default :
289- libmesh_error_msg ( " Invalid shape function index i = " << i );
275+ return 27 ./ 16 .*(- 6 *xi- 2 ./ 3 . );
290276 }
291277}
292278
@@ -298,6 +284,8 @@ Real fe_lagrange_1D_shape_second_deriv(const Order order,
298284 const unsigned int j,
299285 const Real xi)
300286{
287+ libmesh_assert_less_equal (order, THIRD);
288+
301289 switch (order)
302290 {
303291 // All second derivatives of linears are zero....
@@ -307,11 +295,9 @@ Real fe_lagrange_1D_shape_second_deriv(const Order order,
307295 case SECOND:
308296 return fe_lagrange_1D_quadratic_shape_second_deriv (i, j, xi);
309297
310- case THIRD:
311- return fe_lagrange_1D_cubic_shape_second_deriv (i, j, xi);
312-
298+ // case THIRD
313299 default :
314- libmesh_error_msg ( " ERROR: Unsupported polynomial order = " << order );
300+ return fe_lagrange_1D_cubic_shape_second_deriv (i, j, xi );
315301 } // end switch (order)
316302}
317303
0 commit comments