fe_monomial_shape_1D.C
Go to the documentation of this file.
1 // The libMesh Finite Element Library.
2 // Copyright (C) 2002-2018 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 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 
67 
68 
69 template <>
71  const Order order,
72  const unsigned int i,
73  const Point & p)
74 {
75  libmesh_assert(elem);
76 
77  return FE<1,MONOMIAL>::shape(elem->type(), static_cast<Order>(order + elem->p_level()), i, p);
78 }
79 
80 
81 
82 template <>
84  const Order libmesh_dbg_var(order),
85  const unsigned int i,
86  const unsigned int libmesh_dbg_var(j),
87  const Point & p)
88 {
89  // only d()/dxi in 1D!
90 
91  libmesh_assert_equal_to (j, 0);
92 
93  const Real xi = p(0);
94 
95  libmesh_assert_less_equal (i, static_cast<unsigned int>(order));
96 
97  // monomials. since they are hierarchic we only need one case block.
98  switch (i)
99  {
100  case 0:
101  return 0.;
102 
103  case 1:
104  return 1.;
105 
106  case 2:
107  return 2.*xi;
108 
109  case 3:
110  return 3.*xi*xi;
111 
112  case 4:
113  return 4.*xi*xi*xi;
114 
115  default:
116  Real val = i;
117  for (unsigned int index = 1; index != i; ++index)
118  val *= xi;
119  return val;
120  }
121 }
122 
123 
124 
125 template <>
127  const Order order,
128  const unsigned int i,
129  const unsigned int j,
130  const Point & p)
131 {
132  libmesh_assert(elem);
133 
134  return FE<1,MONOMIAL>::shape_deriv(elem->type(),
135  static_cast<Order>(order + elem->p_level()), i, j, p);
136 }
137 
138 
139 
140 template <>
142  const Order libmesh_dbg_var(order),
143  const unsigned int i,
144  const unsigned int libmesh_dbg_var(j),
145  const Point & p)
146 {
147  // only d()/dxi in 1D!
148 
149  libmesh_assert_equal_to (j, 0);
150 
151  const Real xi = p(0);
152 
153  libmesh_assert_less_equal (i, static_cast<unsigned int>(order));
154 
155  switch (i)
156  {
157  case 0:
158  case 1:
159  return 0.;
160 
161  case 2:
162  return 2.;
163 
164  case 3:
165  return 6.*xi;
166 
167  case 4:
168  return 12.*xi*xi;
169 
170  default:
171  Real val = 2.;
172  for (unsigned int index = 2; index != i; ++index)
173  val *= (index+1) * xi;
174  return val;
175  }
176 }
177 
178 
179 
180 template <>
182  const Order order,
183  const unsigned int i,
184  const unsigned int j,
185  const Point & p)
186 {
187  libmesh_assert(elem);
188 
190  static_cast<Order>(order + elem->p_level()), i, j, p);
191 }
192 
193 } // namespace libMesh
static OutputShape shape(const ElemType t, const Order o, const unsigned int i, const Point &p)
The base class for all geometric element types.
Definition: elem.h:100
static OutputShape shape_deriv(const ElemType t, const Order o, const unsigned int i, const unsigned int j, const Point &p)
unsigned int p_level() const
Definition: elem.h:2555
DIE A HORRIBLE DEATH HERE typedef LIBMESH_DEFAULT_SCALAR_TYPE Real
virtual ElemType type() const =0
A geometric point in (x,y,z) space.
Definition: point.h:38
static OutputShape shape_second_deriv(const ElemType t, const Order o, const unsigned int i, const unsigned int j, const Point &p)