20 #include "libmesh/fe.h"
21 #include "libmesh/elem.h"
22 #include "libmesh/fe_lagrange_shape_1D.h"
42 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
44 Real fe_lagrange_2D_shape_second_deriv(
const ElemType type,
50 #endif // LIBMESH_ENABLE_SECOND_DERIVATIVES
65 return fe_lagrange_2D_shape(type, order, i, p);
76 return fe_lagrange_2D_shape(type, order, i, p);
85 const bool add_p_level)
90 return fe_lagrange_2D_shape(elem->
type(), static_cast<Order>(order + add_p_level * elem->
p_level()), i, p);
100 const bool add_p_level)
105 return fe_lagrange_2D_shape(elem->
type(), static_cast<Order>(order + add_p_level * elem->
p_level()), i, p);
113 const unsigned int i,
114 const unsigned int j,
117 return fe_lagrange_2D_shape_deriv(type, order, i, j, p);
125 const unsigned int i,
126 const unsigned int j,
129 return fe_lagrange_2D_shape_deriv(type, order, i, j, p);
137 const unsigned int i,
138 const unsigned int j,
140 const bool add_p_level)
145 return fe_lagrange_2D_shape_deriv(elem->
type(), static_cast<Order>(order + add_p_level * elem->
p_level()), i, j, p);
153 const unsigned int i,
154 const unsigned int j,
156 const bool add_p_level)
162 return fe_lagrange_2D_shape_deriv(elem->
type(), static_cast<Order>(order + add_p_level * elem->
p_level()), i, j, p);
167 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
172 const unsigned int i,
173 const unsigned int j,
176 return fe_lagrange_2D_shape_second_deriv(type, order, i, j, p);
184 const unsigned int i,
185 const unsigned int j,
188 return fe_lagrange_2D_shape_second_deriv(type, order, i, j, p);
196 const unsigned int i,
197 const unsigned int j,
199 const bool add_p_level)
204 return fe_lagrange_2D_shape_second_deriv(elem->
type(), static_cast<Order>(order + add_p_level * elem->
p_level()), i, j, p);
212 const unsigned int i,
213 const unsigned int j,
215 const bool add_p_level)
220 return fe_lagrange_2D_shape_second_deriv(elem->
type(), static_cast<Order>(order + add_p_level * elem->
p_level()), i, j, p);
223 #endif // LIBMESH_ENABLE_SECOND_DERIVATIVES
236 const unsigned int i,
255 const Real xi = p(0);
256 const Real eta = p(1);
258 libmesh_assert_less (i, 4);
261 static const unsigned int i0[] = {0, 1, 1, 0};
262 static const unsigned int i1[] = {0, 0, 1, 1};
272 const Real zeta1 = p(0);
273 const Real zeta2 = p(1);
274 const Real zeta0 = 1. - zeta1 - zeta2;
276 libmesh_assert_less (i, 3);
290 libmesh_error_msg(
"Invalid shape function index i = " << i);
295 libmesh_error_msg(
"ERROR: Unsupported 2D element type: " << type);
308 const Real xi = p(0);
309 const Real eta = p(1);
311 libmesh_assert_less (i, 8);
316 return .25*(1. - xi)*(1. - eta)*(-1. - xi - eta);
319 return .25*(1. + xi)*(1. - eta)*(-1. + xi - eta);
322 return .25*(1. + xi)*(1. + eta)*(-1. + xi + eta);
325 return .25*(1. - xi)*(1. + eta)*(-1. - xi + eta);
328 return .5*(1. - xi*xi)*(1. - eta);
331 return .5*(1. + xi)*(1. - eta*eta);
334 return .5*(1. - xi*xi)*(1. + eta);
337 return .5*(1. - xi)*(1. - eta*eta);
340 libmesh_error_msg(
"Invalid shape function index i = " << i);
347 const Real xi = p(0);
348 const Real eta = p(1);
350 libmesh_assert_less (i, 9);
353 static const unsigned int i0[] = {0, 1, 1, 0, 2, 1, 2, 0, 2};
354 static const unsigned int i1[] = {0, 0, 1, 1, 0, 2, 1, 2, 2};
362 const Real zeta1 = p(0);
363 const Real zeta2 = p(1);
364 const Real zeta0 = 1. - zeta1 - zeta2;
366 libmesh_assert_less (i, 6);
371 return 2.*zeta0*(zeta0-0.5);
374 return 2.*zeta1*(zeta1-0.5);
377 return 2.*zeta2*(zeta2-0.5);
380 return 4.*zeta0*zeta1;
383 return 4.*zeta1*zeta2;
386 return 4.*zeta2*zeta0;
389 libmesh_error_msg(
"Invalid shape function index i = " << i);
394 libmesh_error_msg(
"ERROR: Unsupported 2D element type: " << type);
402 libmesh_error_msg(
"ERROR: Unsupported 2D FE order: " << order);
404 #else // LIBMESH_DIM > 1
406 libmesh_not_implemented();
414 const unsigned int i,
415 const unsigned int j,
420 libmesh_assert_less (j, 2);
436 const Real xi = p(0);
437 const Real eta = p(1);
439 libmesh_assert_less (i, 4);
442 static const unsigned int i0[] = {0, 1, 1, 0};
443 static const unsigned int i1[] = {0, 0, 1, 1};
458 libmesh_error_msg(
"ERROR: Invalid derivative index j = " << j);
466 libmesh_assert_less (i, 3);
468 const Real dzeta0dxi = -1.;
469 const Real dzeta1dxi = 1.;
470 const Real dzeta2dxi = 0.;
472 const Real dzeta0deta = -1.;
473 const Real dzeta1deta = 0.;
474 const Real dzeta2deta = 1.;
493 libmesh_error_msg(
"Invalid shape function index i = " << i);
511 libmesh_error_msg(
"Invalid shape function index i = " << i);
515 libmesh_error_msg(
"ERROR: Invalid derivative index j = " << j);
520 libmesh_error_msg(
"ERROR: Unsupported 2D element type: " << type);
533 const Real xi = p(0);
534 const Real eta = p(1);
536 libmesh_assert_less (i, 8);
545 return .25*(1. - eta)*((1. - xi)*(-1.) +
546 (-1.)*(-1. - xi - eta));
549 return .25*(1. - eta)*((1. + xi)*(1.) +
550 (1.)*(-1. + xi - eta));
553 return .25*(1. + eta)*((1. + xi)*(1.) +
554 (1.)*(-1. + xi + eta));
557 return .25*(1. + eta)*((1. - xi)*(-1.) +
558 (-1.)*(-1. - xi + eta));
561 return .5*(-2.*xi)*(1. - eta);
564 return .5*(1.)*(1. - eta*eta);
567 return .5*(-2.*xi)*(1. + eta);
570 return .5*(-1.)*(1. - eta*eta);
573 libmesh_error_msg(
"Invalid shape function index i = " << i);
581 return .25*(1. - xi)*((1. - eta)*(-1.) +
582 (-1.)*(-1. - xi - eta));
585 return .25*(1. + xi)*((1. - eta)*(-1.) +
586 (-1.)*(-1. + xi - eta));
589 return .25*(1. + xi)*((1. + eta)*(1.) +
590 (1.)*(-1. + xi + eta));
593 return .25*(1. - xi)*((1. + eta)*(1.) +
594 (1.)*(-1. - xi + eta));
597 return .5*(1. - xi*xi)*(-1.);
600 return .5*(1. + xi)*(-2.*eta);
603 return .5*(1. - xi*xi)*(1.);
606 return .5*(1. - xi)*(-2.*eta);
609 libmesh_error_msg(
"Invalid shape function index i = " << i);
613 libmesh_error_msg(
"ERROR: Invalid derivative index j = " << j);
620 const Real xi = p(0);
621 const Real eta = p(1);
623 libmesh_assert_less (i, 9);
626 static const unsigned int i0[] = {0, 1, 1, 0, 2, 1, 2, 0, 2};
627 static const unsigned int i1[] = {0, 0, 1, 1, 0, 2, 1, 2, 2};
642 libmesh_error_msg(
"ERROR: Invalid derivative index j = " << j);
648 libmesh_assert_less (i, 6);
650 const Real zeta1 = p(0);
651 const Real zeta2 = p(1);
652 const Real zeta0 = 1. - zeta1 - zeta2;
654 const Real dzeta0dxi = -1.;
655 const Real dzeta1dxi = 1.;
656 const Real dzeta2dxi = 0.;
658 const Real dzeta0deta = -1.;
659 const Real dzeta1deta = 0.;
660 const Real dzeta2deta = 1.;
669 return (4.*zeta0-1.)*dzeta0dxi;
672 return (4.*zeta1-1.)*dzeta1dxi;
675 return (4.*zeta2-1.)*dzeta2dxi;
678 return 4.*zeta1*dzeta0dxi + 4.*zeta0*dzeta1dxi;
681 return 4.*zeta2*dzeta1dxi + 4.*zeta1*dzeta2dxi;
684 return 4.*zeta2*dzeta0dxi + 4*zeta0*dzeta2dxi;
687 libmesh_error_msg(
"Invalid shape function index i = " << i);
696 return (4.*zeta0-1.)*dzeta0deta;
699 return (4.*zeta1-1.)*dzeta1deta;
702 return (4.*zeta2-1.)*dzeta2deta;
705 return 4.*zeta1*dzeta0deta + 4.*zeta0*dzeta1deta;
708 return 4.*zeta2*dzeta1deta + 4.*zeta1*dzeta2deta;
711 return 4.*zeta2*dzeta0deta + 4*zeta0*dzeta2deta;
714 libmesh_error_msg(
"Invalid shape function index i = " << i);
718 libmesh_error_msg(
"ERROR: Invalid derivative index j = " << j);
723 libmesh_error_msg(
"ERROR: Unsupported 2D element type: " << type);
729 libmesh_error_msg(
"ERROR: Unsupported 2D FE order: " << order);
731 #else // LIBMESH_DIM > 1
733 libmesh_not_implemented();
739 #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
741 Real fe_lagrange_2D_shape_second_deriv(
const ElemType type,
743 const unsigned int i,
744 const unsigned int j,
752 libmesh_assert_less (j, 3);
768 const Real xi = p(0);
769 const Real eta = p(1);
771 libmesh_assert_less (i, 4);
774 static const unsigned int i0[] = {0, 1, 1, 0};
775 static const unsigned int i1[] = {0, 0, 1, 1};
793 libmesh_error_msg(
"ERROR: Invalid derivative index j = " << j);
806 libmesh_error_msg(
"ERROR: Unsupported 2D element type: " << type);
820 const Real xi = p(0);
821 const Real eta = p(1);
823 libmesh_assert_less (j, 3);
851 libmesh_error_msg(
"Invalid shape function index i = " << i);
861 return 0.25*( 1. - 2.*xi - 2.*eta);
864 return 0.25*(-1. - 2.*xi + 2.*eta);
867 return 0.25*( 1. + 2.*xi + 2.*eta);
870 return 0.25*(-1. + 2.*xi - 2.*eta);
885 libmesh_error_msg(
"Invalid shape function index i = " << i);
913 libmesh_error_msg(
"Invalid shape function index i = " << i);
918 libmesh_error_msg(
"ERROR: Invalid derivative index j = " << j);
925 const Real xi = p(0);
926 const Real eta = p(1);
928 libmesh_assert_less (i, 9);
931 static const unsigned int i0[] = {0, 1, 1, 0, 2, 1, 2, 0, 2};
932 static const unsigned int i1[] = {0, 0, 1, 1, 0, 2, 1, 2, 2};
952 libmesh_error_msg(
"ERROR: Invalid derivative index j = " << j);
958 const Real dzeta0dxi = -1.;
959 const Real dzeta1dxi = 1.;
960 const Real dzeta2dxi = 0.;
962 const Real dzeta0deta = -1.;
963 const Real dzeta1deta = 0.;
964 const Real dzeta2deta = 1.;
966 libmesh_assert_less (j, 3);
976 return 4.*dzeta0dxi*dzeta0dxi;
979 return 4.*dzeta1dxi*dzeta1dxi;
982 return 4.*dzeta2dxi*dzeta2dxi;
985 return 8.*dzeta0dxi*dzeta1dxi;
988 return 8.*dzeta1dxi*dzeta2dxi;
991 return 8.*dzeta0dxi*dzeta2dxi;
994 libmesh_error_msg(
"Invalid shape function index i = " << i);
1004 return 4.*dzeta0dxi*dzeta0deta;
1007 return 4.*dzeta1dxi*dzeta1deta;
1010 return 4.*dzeta2dxi*dzeta2deta;
1013 return 4.*dzeta1deta*dzeta0dxi + 4.*dzeta0deta*dzeta1dxi;
1016 return 4.*dzeta2deta*dzeta1dxi + 4.*dzeta1deta*dzeta2dxi;
1019 return 4.*dzeta2deta*dzeta0dxi + 4.*dzeta0deta*dzeta2dxi;
1022 libmesh_error_msg(
"Invalid shape function index i = " << i);
1032 return 4.*dzeta0deta*dzeta0deta;
1035 return 4.*dzeta1deta*dzeta1deta;
1038 return 4.*dzeta2deta*dzeta2deta;
1041 return 8.*dzeta0deta*dzeta1deta;
1044 return 8.*dzeta1deta*dzeta2deta;
1047 return 8.*dzeta0deta*dzeta2deta;
1050 libmesh_error_msg(
"Invalid shape function index i = " << i);
1055 libmesh_error_msg(
"ERROR: Invalid derivative index j = " << j);
1060 libmesh_error_msg(
"ERROR: Unsupported 2D element type: " << type);
1068 libmesh_error_msg(
"ERROR: Unsupported 2D FE order: " << order);
1072 #else // LIBMESH_DIM > 1
1074 libmesh_not_implemented();
1078 #endif // LIBMESH_ENABLE_SECOND_DERIVATIVES