fe_monomial_shape_1D.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2014 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++ inlcludes
20 
21 // Local includes
22 #include "libmesh/fe.h"
23 #include "libmesh/elem.h"
24 
25 namespace libMesh
26 {
27 
28 
29 
30 
31 template <>
33  const Order libmesh_dbg_var(order),
34  const unsigned int i,
35  const Point& p)
36 {
37  const Real xi = p(0);
38 
39  libmesh_assert_less_equal (i, static_cast<unsigned int>(order));
40 
41  // monomials. since they are hierarchic we only need one case block.
42  switch (i)
43  {
44  case 0:
45  return 1.;
46 
47  case 1:
48  return xi;
49 
50  case 2:
51  return xi*xi;
52 
53  case 3:
54  return xi*xi*xi;
55 
56  case 4:
57  return xi*xi*xi*xi;
58 
59  default:
60  Real val = 1.;
61  for (unsigned int index = 0; index != i; ++index)
62  val *= xi;
63  return val;
64  }
65 
66  libmesh_error();
67  return 0.;
68 }
69 
70 
71 
72 template <>
74  const Order order,
75  const unsigned int i,
76  const Point& p)
77 {
78  libmesh_assert(elem);
79 
80  return FE<1,MONOMIAL>::shape(elem->type(), static_cast<Order>(order + elem->p_level()), i, p);
81 }
82 
83 
84 
85 template <>
87  const Order libmesh_dbg_var(order),
88  const unsigned int i,
89  const unsigned int libmesh_dbg_var(j),
90  const Point& p)
91 {
92  // only d()/dxi in 1D!
93 
94  libmesh_assert_equal_to (j, 0);
95 
96  const Real xi = p(0);
97 
98  libmesh_assert_less_equal (i, static_cast<unsigned int>(order));
99 
100  // monomials. since they are hierarchic we only need one case block.
101  switch (i)
102  {
103  case 0:
104  return 0.;
105 
106  case 1:
107  return 1.;
108 
109  case 2:
110  return 2.*xi;
111 
112  case 3:
113  return 3.*xi*xi;
114 
115  case 4:
116  return 4.*xi*xi*xi;
117 
118  default:
119  Real val = i;
120  for (unsigned int index = 1; index != i; ++index)
121  val *= xi;
122  return val;
123  }
124 
125  libmesh_error();
126  return 0.;
127 }
128 
129 
130 
131 template <>
133  const Order order,
134  const unsigned int i,
135  const unsigned int j,
136  const Point& p)
137 {
138  libmesh_assert(elem);
139 
140  return FE<1,MONOMIAL>::shape_deriv(elem->type(),
141  static_cast<Order>(order + elem->p_level()), i, j, p);
142 }
143 
144 
145 
146 template <>
148  const Order libmesh_dbg_var(order),
149  const unsigned int i,
150  const unsigned int libmesh_dbg_var(j),
151  const Point& p)
152 {
153  // only d()/dxi in 1D!
154 
155  libmesh_assert_equal_to (j, 0);
156 
157  const Real xi = p(0);
158 
159  libmesh_assert_less_equal (i, static_cast<unsigned int>(order));
160 
161  switch (i)
162  {
163  case 0:
164  case 1:
165  return 0.;
166 
167  case 2:
168  return 2.;
169 
170  case 3:
171  return 6.*xi;
172 
173  case 4:
174  return 12.*xi*xi;
175 
176  default:
177  Real val = 2.;
178  for (unsigned int index = 2; index != i; ++index)
179  val *= (index+1) * xi;
180  return val;
181  }
182 
183  libmesh_error();
184  return 0.;
185 }
186 
187 
188 
189 template <>
191  const Order order,
192  const unsigned int i,
193  const unsigned int j,
194  const Point& p)
195 {
196  libmesh_assert(elem);
197 
199  static_cast<Order>(order + elem->p_level()), i, j, p);
200 }
201 
202 } // namespace libMesh

Site Created By: libMesh Developers
Last modified: February 07 2014 16:57:05 UTC

Hosted By:
SourceForge.net Logo