SCIRun  5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
PrismElementWeights.h
Go to the documentation of this file.
1 //
2 // For more information, please see: http://software.sci.utah.edu
3 //
4 // The MIT License
5 //
6 // Copyright (c) 2009 Scientific Computing and Imaging Institute,
7 // University of Utah.
8 //
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining a
11 // copy of this software and associated documentation files (the "Software"),
12 // to deal in the Software without restriction, including without limitation
13 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 // and/or sell copies of the Software, and to permit persons to whom the
15 // Software is furnished to do so, subject to the following conditions:
16 //
17 // The above copyright notice and this permission notice shall be included
18 // in all copies or substantial portions of the Software.
19 //
20 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
21 // OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
23 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26 // DEALINGS IN THE SOFTWARE.
27 
28 
29 #ifndef CORE_BASIS_PRISMWEIGHTS_H
30 #define CORE_BASIS_PRISMWEIGHTS_H 1
31 
32 namespace SCIRun {
33 namespace Core {
34 namespace Basis {
35 
37 
38 public:
39  template <class VECTOR>
40  void get_linear_weights(const VECTOR& coords, double *w) const
41  {
42  const double x = static_cast<double>(coords[0]), y = static_cast<double>(coords[1]), z = static_cast<double>(coords[2]);
43  w[0] = (-1 + x + y) * (-1 + z);
44  w[1] = - (x * (-1 + z));
45  w[2] = - (y * (-1 + z));
46  w[3] = - ((-1 + x + y) * z);
47  w[4] = +x * z;
48  w[5] = +y * z;
49  }
50 
51  /// get derivative weight factors at parametric coordinate
52  template <class VECTOR>
53  void get_linear_derivate_weights(const VECTOR& coords, double *w) const
54  {
55  const double x = static_cast<double>(coords[0]), y = static_cast<double>(coords[1]), z = static_cast<double>(coords[2]);
56  w[0]= (-1 + z);
57  w[1]= (1 - z);
58  w[2]= 0;
59  w[3]= - z;
60  w[4]= +z;
61  w[5]= 0;
62  w[6]= (-1 + z);
63  w[7]= 0;
64  w[8]= (1 - z);
65  w[9]= - z;
66  w[10]= 0;
67  w[11]= z;
68  w[12]= (-1 + x + y);
69  w[13]= - x;
70  w[14]= - y;
71  w[15]= (1 - x - y);
72  w[16]= x;
73  w[17]= y;
74  }
75 
76  /// get weight factors at parametric coordinate
77  template< class VECTOR>
78  void get_quadratic_weights(const VECTOR& coords, double *w) const
79  {
80  const double x=static_cast<double>(coords[0]), y=static_cast<double>(coords[1]), z=static_cast<double>(coords[2]);
81  w[0] = -((-1 + x + y)*(-1 + z)*(-1 + 2*x + 2*y + 2*z));
82  w[1] = -(x*(-1 + 2*x -2*z)*(-1 + z));
83  w[2] = -(y*(-1 + 2*y - 2*z)*(-1 + z));
84  w[3] = (-1 + x + y)*(1 + 2*x + 2*y - 2*z)*z;
85  w[4] = +x*z*(-3 + 2*x + 2*z);
86  w[5] = y*z*(-3 + 2*y + 2*z);
87  w[6] = +4*x*(-1 + x + y)*(-1 + z);
88  w[7] = -4*x*y*(-1 + z);
89  w[8] = +4*y*(-1 + x + y)*(-1 + z);
90  w[9] = +4*(-1 + x + y)*(-1 + z)*z;
91  w[10] = -4*x*(-1 + z)*z;
92  w[11] = -4*y*(-1 + z)*z;
93  w[12] = -4*x*(-1 + x +y)*z;
94  w[13] = +4*x*y*z;
95  w[14] = -4*y*(-1 + x + y)*z;
96  }
97 
98  /// get weight factors of derivative at parametric coordinate
99  template< class VECTOR>
100  void get_quadratic_derivate_weights(const VECTOR& coords, double *w) const
101  {
102  const double x=static_cast<double>(coords[0]), y=static_cast<double>(coords[1]), z=static_cast<double>(coords[2]);
103  w[0]=-(-1 + z)*(-3 + 4*x + 4*y + 2*z);
104  w[1]=-(-1 + 4*x - 2*z)*(-1 + z);
105  w[2]=0;
106  w[3]=+(-1 + 4*x + 4*y - 2*z)*z;
107  w[4]=+z*(-3 + 4*x + 2*z);
108  w[5]=0;
109  w[6]=+4*(-1 + 2*x + y)*(-1 +z);
110  w[7]=-4*y*(-1 + z);
111  w[8]=+4*y*(-1 + z);
112  w[9]=+4*(-1 + z)*z;
113  w[10]=-4*(-1 + z)*z;
114  w[11]=0;
115  w[12]=-4*(-1 + 2*x + y)*z;
116  w[13]=+4*y*z;
117  w[14]=-4*y*z;
118  w[15]=-((-1 + z)*(-3 + 4*x + 4*y + 2*z));
119  w[16]=0;
120  w[17]=-((-1 + 4*y - 2*z)*(-1 + z));
121  w[18]=+(-1 + 4*x + 4*y - 2*z)*z;
122  w[19]=0;
123  w[20]=+z*(-3 + 4*y + 2*z);
124  w[21]=+4*x*(-1 + z);
125  w[22]=-4*x*(-1 + z);
126  w[23]=+4*(-1 + x + 2*y)*(-1 + z);
127  w[24]=4*(-1 + z)*z;
128  w[25]=0;
129  w[26]=-4*(-1 + z)*z;
130  w[27]=-4*x*z;
131  w[28]=+4*x*z;
132  w[29]=-4*(-1 + x + 2*y)*z;
133  w[30]=-((-1 + x + y)*(-3 + 2*x + 2*y + 4*z));
134  w[31]=+x*(-1 - 2*x + 4*z);
135  w[32]=+y*(-1 - 2*y + 4*z);
136  w[33]=+(-1 + x + y)*(1 + 2*x + 2*y - 4*z);
137  w[34]=+x*(-3 + 2*x + 4*z);
138  w[35]=+y*(-3 + 2*y + 4*z);
139  w[36]=+4*x*(-1 + x + y);
140  w[37]=-4*x*y;
141  w[38]=+4*y*(-1 + x + y);
142  w[39]=+4*(-1 + x + y)*(-1 + 2*z);
143  w[40]=+x*(4 - 8*z);
144  w[41]=+y*(4 - 8*z);
145  w[42]=-4*x*(-1 + x + y);
146  w[43]=+4*x*y;
147  w[44]=-4*y*(-1 + x + y);
148  }
149 
150 
151  template <class VECTOR>
152  void get_cubic_weights(const VECTOR &coords, double *w) const
153  {
154  const double x=static_cast<double>(coords[0]), y=static_cast<double>(coords[1]), z=static_cast<double>(coords[2]);
155  const double x2=x*x;
156  const double y2=y*y;
157  const double z2=z*z;
158  const double y12=(y-1)*(y-1);
159  const double z12=(z-1)*(z-1);
160 
161  w[0] = -((-1 + x + y)*(-1 + z)*(-1 + 2*x2 - y + 2*y2 - x*(1 + 2*y) - z + 2*z2));
162  w[1] = -(x*(1 - 2*x + x2 - y2)*(-1 + z));
163  w[2] = +(x2 - y12)*y*(-1 + z);
164  w[3] = -((-1 + x + y)*z12*z);
165  w[4] = +x*(-1 + z)*(-3*x + 2*x2 + z*(-1 + 2*z));
166  w[5] = +x2*(-1 + x + z - x*z);
167  w[6] = -(x2*y*(-1 + z));
168  w[7] = +x*z12*z;
169  w[8] = +y*(-1 + z)*(-3*y + 2*y2 + z*(-1 + 2*z));
170  w[9] = -(x*y2*(-1 + z));
171  w[10] = +y2*(-1 + y + z - y*z);
172  w[11] = +y*z12*z;
173  w[12] = +(-1 + x + y)*z*(2*x2 - y + 2*y2 - x*(1 + 2*y) + z*(-3 + 2*z));
174  w[13] = +x*(1 - 2*x + x2 - y2)*z;
175  w[14] = +(-x2 + y12)*y*z;
176  w[15] = -((-1 + x + y)*(-1 + z)*z2);
177  w[16] = +x*z*(-1 + 3*x - 2*x2 + 3*z - 2*z2);
178  w[17] = +(-1 + x)*x2*z;
179  w[18] = +x2*y*z;
180  w[19] = x*(-1 + z)*z2;
181  w[20] = +y*z*(-1 + 3*y - 2*y2 + 3*z - 2*z2);
182  w[21] = +x*y2*z;
183  w[22] = +(-1 + y)*y2*z;
184  w[23] = +y*(-1 + z)*z2;
185  }
186 
187  /// get derivative weight factors at parametric coordinate
188  template <class VECTOR>
189  void get_cubic_derivate_weights(const VECTOR &coords, double *w) const
190  {
191  const double x=static_cast<double>(coords[0]), y=static_cast<double>(coords[1]), z=static_cast<double>(coords[2]);
192  const double x2=x*x;
193  const double y2=y*y;
194  const double z2=z*z;
195  const double y12=(y-1)*(y-1);
196  const double z12=(z-1)*(z-1);
197  w[0]=-((-1 + z)*(-6*x + 6*x2 + z*(-1 + 2*z)));
198  w[1]=-((1 - 4*x + 3*x2 - y2)*(-1 + z));
199  w[2]=+2*x*y*(-1 + z);
200  w[3]=-(z12*z);
201  w[4]=+(-1 + z)*(-6*x + 6*x2 + z*(-1 + 2*z));
202  w[5]=-(x*(-2 + 3*x)*(-1 + z));
203  w[6]=-2*x*y*(-1 + z);
204  w[7]=+z12*z;
205  w[8]=0;
206  w[9]=-(y2*(-1 + z));
207  w[10]=0;
208  w[11]=0;
209  w[12]=z*(1- 6*x + 6*x2 - 3*z + 2*z2);
210  w[13]=+(1 - 4*x + 3*x2 - y2)*z;
211  w[14]=-2*x*y*z;
212  w[15]=-((-1 + z)*z2);
213  w[16]=+z*(-1 + 6*x - 6*x2 + 3*z - 2*z2);
214  w[17]=+x*(-2 + 3*x)*z;
215  w[18]=+2*x*y*z;
216  w[19]=+(-1 + z)*z2;
217  w[20]=0;
218  w[21]=+y2*z;
219  w[22]=0;
220  w[23]=0;
221  w[24]=-((-1 + z)*(-6*y + 6*y2 + z*(-1 + 2*z)));
222  w[25]=+2*x*y*(-1 + z);
223  w[26]=+(-1 + x2 + 4*y - 3*y2)*(-1 + z);
224  w[27]=-(z12*z);
225  w[28]=0;
226  w[29]=0;
227  w[30]=-(x2*(-1 + z));
228  w[31]=0;
229  w[32]=+(-1 + z)*(-6*y + 6*y2 + z*(-1 + 2*z));
230  w[33]=-2*x*y*(-1 + z);
231  w[34]=-(y*(-2 + 3*y)*(-1 + z));
232  w[35]=+z12*z;
233  w[36]=+z*(1 - 6*y + 6*y2 - 3*z + 2*z2);
234  w[37]=-2*x*y*z;
235  w[38]=-((-1 + x2 + 4*y - 3*y2)*z);
236  w[39]=-((-1 + z)*z2);
237  w[40]=0;
238  w[41]=0;
239  w[42]=+x2*z;
240  w[43]=0;
241  w[44]=z*(-1 + 6*y - 6*y2 + 3*z - 2*z2);
242  w[45]=2*x*y*z;
243  w[46]=y*(-2 + 3*y)*z;
244  w[47]=(-1 + z)*z2;
245  w[48]=-((-1 + x + y)*(2*x2 - y + 2*y2 - x*(1 + 2*y) + 6*(-1 + z)*z));
246  w[49]=x*(-1 + 2*x - x2 + y2);
247  w[50]=+(x2 - y12)*y;
248  w[51]=-((-1 + x + y)*(1 - 4*z + 3*z2));
249  w[52]=+x*(1 - 3*x + 2*x2 - 6*z + 6*z2);
250  w[53]=-((-1 + x)*x2);
251  w[54]=-(x2*y);
252  w[55]=+x*(1 - 4*z + 3*z2);
253  w[56]=+y*(1 - 3*y + 2*y2 - 6*z + 6*z2);
254  w[57]=-(x*y2);
255  w[58]=-((-1 + y)*y2);
256  w[59]=+y*(1 - 4*z + 3*z2);
257  w[60]=+(-1 + x + y)*(2*x2 - y + 2*y2 - x*(1 + 2*y) + 6*(-1 + z)*z);
258  w[61]=+x*(1 - 2*x + x2 - y2);
259  w[62]=+(-x2 + y12)*y;
260  w[63]=-((-1 + x + y)*z*(-2 + 3*z));
261  w[64]=+x*(-1 + 3*x - 2*x2 + 6*z - 6*z2);
262  w[65]=+(-1 + x)*x2;
263  w[66]=+x2*y;
264  w[67]=+x*z*(-2 + 3*z);
265  w[68]=+y*(-1 + 3*y - 2*y2 + 6*z - 6*z2);
266  w[69]=+x*y2;
267  w[70]=+(-1 + y)*y2;
268  w[71]=+y*z*(-2 + 3*z);
269  }
270 
271  inline int num_linear_weights() { return 6; }
272  inline int num_quadratic_weights() { return 15; }
273  inline int num_cubic_weights() { return 24; }
274 
275  inline int num_linear_derivate_weights() { return 18; }
276  inline int num_quadratic_derivate_weights() { return 45; }
277  inline int num_cubic_derivate_weights() { return 72; }
278 
279 
280  inline int num_derivs() { return 3; }
281  inline int num_hderivs() { return 3; }
282 };
283 
284 }}}
285 
286 #endif
287 
void get_quadratic_derivate_weights(const VECTOR &coords, double *w) const
get weight factors of derivative at parametric coordinate
Definition: PrismElementWeights.h:100
void get_linear_derivate_weights(const VECTOR &coords, double *w) const
get derivative weight factors at parametric coordinate
Definition: PrismElementWeights.h:53
int num_cubic_weights()
Definition: PrismElementWeights.h:273
void get_linear_weights(const VECTOR &coords, double *w) const
Definition: PrismElementWeights.h:40
void get_cubic_weights(const VECTOR &coords, double *w) const
Definition: PrismElementWeights.h:152
void get_quadratic_weights(const VECTOR &coords, double *w) const
get weight factors at parametric coordinate
Definition: PrismElementWeights.h:78
int num_linear_derivate_weights()
Definition: PrismElementWeights.h:275
int num_cubic_derivate_weights()
Definition: PrismElementWeights.h:277
int num_linear_weights()
Definition: PrismElementWeights.h:271
Definition: PrismElementWeights.h:36
int num_quadratic_weights()
Definition: PrismElementWeights.h:272
int num_hderivs()
Definition: PrismElementWeights.h:281
void get_cubic_derivate_weights(const VECTOR &coords, double *w) const
get derivative weight factors at parametric coordinate
Definition: PrismElementWeights.h:189
int num_quadratic_derivate_weights()
Definition: PrismElementWeights.h:276
int num_derivs()
Definition: PrismElementWeights.h:280