Skip to content

Commit cb466d4

Browse files
committed
Address review:
- add some asserts in every routine changed - add comments that default is used as a regular case
1 parent 44983e2 commit cb466d4

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

include/fe/fe_lagrange_shape_1D.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Real fe_lagrange_1D_linear_shape(const unsigned int i,
3939
case 0:
4040
return .5*(1. - xi);
4141

42+
// case 1
4243
default:
4344
return .5*(1. + xi);
4445
}
@@ -60,6 +61,7 @@ Real fe_lagrange_1D_quadratic_shape(const unsigned int i,
6061
case 1:
6162
return .5*xi*(xi + 1);
6263

64+
// case 2
6365
default:
6466
return (1. - xi*xi);
6567
}
@@ -84,6 +86,7 @@ Real fe_lagrange_1D_cubic_shape(const unsigned int i,
8486
case 2:
8587
return 27./16.*(1.-xi*xi)*(1./3.-xi);
8688

89+
// case 3
8790
default:
8891
return 27./16.*(1.-xi*xi)*(1./3.+xi);
8992
}
@@ -96,6 +99,8 @@ Real fe_lagrange_1D_shape(const Order order,
9699
const unsigned int i,
97100
const Real xi)
98101
{
102+
libmesh_assert_less_equal(order, THIRD);
103+
99104
switch (order)
100105
{
101106
// Lagrange linears
@@ -107,6 +112,7 @@ Real fe_lagrange_1D_shape(const Order order,
107112
return fe_lagrange_1D_quadratic_shape(i, xi);
108113

109114
// Lagrange cubics
115+
// case THIRD
110116
default:
111117
return fe_lagrange_1D_cubic_shape(i, xi);
112118
}
@@ -129,6 +135,7 @@ Real fe_lagrange_1D_linear_shape_deriv(const unsigned int i,
129135
case 0:
130136
return -.5;
131137

138+
// case 1
132139
default:
133140
return .5;
134141
}
@@ -153,6 +160,7 @@ Real fe_lagrange_1D_quadratic_shape_deriv(const unsigned int i,
153160
case 1:
154161
return xi+.5;
155162

163+
// case 2
156164
default:
157165
return -2.*xi;
158166
}
@@ -180,6 +188,7 @@ Real fe_lagrange_1D_cubic_shape_deriv(const unsigned int i,
180188
case 2:
181189
return 27./16.*(3.*xi*xi-2./3.*xi-1.);
182190

191+
// case 3
183192
default:
184193
return 27./16.*(-3.*xi*xi-2./3.*xi+1.);
185194
}
@@ -193,6 +202,8 @@ Real fe_lagrange_1D_shape_deriv(const Order order,
193202
const unsigned int j,
194203
const Real xi)
195204
{
205+
libmesh_assert_less_equal(order, THIRD);
206+
196207
switch (order)
197208
{
198209
case FIRST:
@@ -201,6 +212,7 @@ Real fe_lagrange_1D_shape_deriv(const Order order,
201212
case SECOND:
202213
return fe_lagrange_1D_quadratic_shape_deriv(i, j, xi);
203214

215+
// case THIRD
204216
default:
205217
return fe_lagrange_1D_cubic_shape_deriv(i, j, xi);
206218
}
@@ -220,6 +232,7 @@ Real fe_lagrange_1D_quadratic_shape_second_deriv(const unsigned int i,
220232
// Don't need to switch on j. 1D shape functions
221233
// depend on xi only!
222234
libmesh_assert_equal_to (j, 0);
235+
libmesh_assert_less(i, 3);
223236

224237
switch (i)
225238
{
@@ -229,6 +242,7 @@ Real fe_lagrange_1D_quadratic_shape_second_deriv(const unsigned int i,
229242
case 1:
230243
return 1.;
231244

245+
// case 2
232246
default:
233247
return -2.;
234248
}
@@ -243,6 +257,7 @@ Real fe_lagrange_1D_cubic_shape_second_deriv(const unsigned int i,
243257
// Don't need to switch on j. 1D shape functions
244258
// depend on xi only!
245259
libmesh_assert_equal_to (j, 0);
260+
libmesh_assert_less(i, 4);
246261

247262
switch (i)
248263
{
@@ -255,6 +270,7 @@ Real fe_lagrange_1D_cubic_shape_second_deriv(const unsigned int i,
255270
case 2:
256271
return 27./16.*(6*xi-2./3.);
257272

273+
// case 2
258274
default:
259275
return 27./16.*(-6*xi-2./3.);
260276
}
@@ -268,6 +284,8 @@ Real fe_lagrange_1D_shape_second_deriv(const Order order,
268284
const unsigned int j,
269285
const Real xi)
270286
{
287+
libmesh_assert_less_equal(order, THIRD);
288+
271289
switch (order)
272290
{
273291
// All second derivatives of linears are zero....
@@ -277,6 +295,7 @@ Real fe_lagrange_1D_shape_second_deriv(const Order order,
277295
case SECOND:
278296
return fe_lagrange_1D_quadratic_shape_second_deriv(i, j, xi);
279297

298+
// case THIRD
280299
default:
281300
return fe_lagrange_1D_cubic_shape_second_deriv(i, j, xi);
282301
} // end switch (order)

0 commit comments

Comments
 (0)