Line data Source code
1 : // The libMesh Finite Element Library.
2 : // Copyright (C) 2002-2026 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 : // C++ includes
20 :
21 : // Local includes
22 : #include "libmesh/fe.h"
23 : #include "libmesh/elem.h"
24 :
25 :
26 : namespace libMesh
27 : {
28 :
29 :
30 41616 : LIBMESH_DEFAULT_VECTORIZED_FE(1,MONOMIAL)
31 :
32 :
33 : template <>
34 33540 : Real FE<1,MONOMIAL>::shape(const ElemType,
35 : const Order libmesh_dbg_var(order),
36 : const unsigned int i,
37 : const Point & p)
38 : {
39 33540 : const Real xi = p(0);
40 :
41 2747 : libmesh_assert_less_equal (i, static_cast<unsigned int>(order));
42 :
43 : // monomials. since they are hierarchic we only need one case block.
44 33540 : switch (i)
45 : {
46 754 : case 0:
47 754 : return 1.;
48 :
49 7356 : case 1:
50 7356 : return xi;
51 :
52 6240 : case 2:
53 6240 : return xi*xi;
54 :
55 4968 : case 3:
56 4968 : return xi*xi*xi;
57 :
58 3504 : case 4:
59 3504 : return xi*xi*xi*xi;
60 :
61 154 : default:
62 154 : Real val = 1.;
63 11088 : for (unsigned int index = 0; index != i; ++index)
64 9548 : val *= xi;
65 154 : return val;
66 : }
67 : }
68 :
69 :
70 :
71 : template <>
72 33540 : Real FE<1,MONOMIAL>::shape(const Elem * elem,
73 : const Order order,
74 : const unsigned int i,
75 : const Point & p,
76 : const bool add_p_level)
77 : {
78 2747 : libmesh_assert(elem);
79 :
80 39034 : return FE<1,MONOMIAL>::shape(elem->type(), order + add_p_level*elem->p_level(), i, p);
81 : }
82 :
83 :
84 : template <>
85 0 : Real FE<1,MONOMIAL>::shape(const FEType fet,
86 : const Elem * elem,
87 : const unsigned int i,
88 : const Point & p,
89 : const bool add_p_level)
90 : {
91 0 : libmesh_assert(elem);
92 0 : return FE<1,MONOMIAL>::shape(elem->type(), fet.order + add_p_level*elem->p_level(), i, p);
93 : }
94 :
95 :
96 : template <>
97 17160 : Real FE<1,MONOMIAL>::shape_deriv(const ElemType,
98 : const Order libmesh_dbg_var(order),
99 : const unsigned int i,
100 : const unsigned int libmesh_dbg_var(j),
101 : const Point & p)
102 : {
103 : // only d()/dxi in 1D!
104 :
105 1430 : libmesh_assert_equal_to (j, 0);
106 :
107 17160 : const Real xi = p(0);
108 :
109 1430 : libmesh_assert_less_equal (i, static_cast<unsigned int>(order));
110 :
111 : // monomials. since they are hierarchic we only need one case block.
112 17160 : switch (i)
113 : {
114 350 : case 0:
115 350 : return 0.;
116 :
117 4200 : case 1:
118 4200 : return 1.;
119 :
120 3432 : case 2:
121 3432 : return 2.*xi;
122 :
123 2628 : case 3:
124 2628 : return 3.*xi*xi;
125 :
126 1788 : case 4:
127 1788 : return 4.*xi*xi*xi;
128 :
129 912 : default:
130 912 : Real val = i;
131 4560 : for (unsigned int index = 1; index != i; ++index)
132 3800 : val *= xi;
133 76 : return val;
134 : }
135 : }
136 :
137 :
138 :
139 : template <>
140 17160 : Real FE<1,MONOMIAL>::shape_deriv(const Elem * elem,
141 : const Order order,
142 : const unsigned int i,
143 : const unsigned int j,
144 : const Point & p,
145 : const bool add_p_level)
146 : {
147 1430 : libmesh_assert(elem);
148 :
149 18590 : return FE<1,MONOMIAL>::shape_deriv(elem->type(),
150 18590 : order + add_p_level*elem->p_level(), i, j, p);
151 : }
152 :
153 :
154 : template <>
155 0 : Real FE<1,MONOMIAL>::shape_deriv(const FEType fet,
156 : const Elem * elem,
157 : const unsigned int i,
158 : const unsigned int j,
159 : const Point & p,
160 : const bool add_p_level)
161 : {
162 0 : libmesh_assert(elem);
163 0 : return FE<1,MONOMIAL>::shape_deriv(elem->type(), fet.order + add_p_level*elem->p_level(), i, j, p);
164 :
165 :
166 : }
167 :
168 : #ifdef LIBMESH_ENABLE_SECOND_DERIVATIVES
169 :
170 : template <>
171 17160 : Real FE<1,MONOMIAL>::shape_second_deriv(const ElemType,
172 : const Order libmesh_dbg_var(order),
173 : const unsigned int i,
174 : const unsigned int libmesh_dbg_var(j),
175 : const Point & p)
176 : {
177 : // only d()/dxi in 1D!
178 :
179 1430 : libmesh_assert_equal_to (j, 0);
180 :
181 17160 : const Real xi = p(0);
182 :
183 1430 : libmesh_assert_less_equal (i, static_cast<unsigned int>(order));
184 :
185 17160 : switch (i)
186 : {
187 700 : case 0:
188 : case 1:
189 700 : return 0.;
190 :
191 3432 : case 2:
192 3432 : return 2.;
193 :
194 2628 : case 3:
195 2628 : return 6.*xi;
196 :
197 1788 : case 4:
198 1788 : return 12.*xi*xi;
199 :
200 76 : default:
201 76 : Real val = 2.;
202 3648 : for (unsigned int index = 2; index != i; ++index)
203 2888 : val *= (index+1) * xi;
204 76 : return val;
205 : }
206 : }
207 :
208 :
209 :
210 : template <>
211 17160 : Real FE<1,MONOMIAL>::shape_second_deriv(const Elem * elem,
212 : const Order order,
213 : const unsigned int i,
214 : const unsigned int j,
215 : const Point & p,
216 : const bool add_p_level)
217 : {
218 1430 : libmesh_assert(elem);
219 :
220 18590 : return FE<1,MONOMIAL>::shape_second_deriv(elem->type(),
221 18590 : order + add_p_level*elem->p_level(), i, j, p);
222 : }
223 :
224 : template <>
225 0 : Real FE<1,MONOMIAL>::shape_second_deriv(const FEType fet,
226 : const Elem * elem,
227 : const unsigned int i,
228 : const unsigned int j,
229 : const Point & p,
230 : const bool add_p_level)
231 : {
232 0 : libmesh_assert(elem);
233 0 : return FE<1,MONOMIAL>::shape_second_deriv(elem->type(), fet.order + add_p_level*elem->p_level(), i, j, p);
234 : }
235 :
236 : #endif
237 :
238 : } // namespace libMesh
|