SCIRun  5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TetElementWeights.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_TETWEIGHTS_H
30 #define CORE_BASIS_TETWEIGHTS_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 - z);
44  w[1] = x;
45  w[2] = y;
46  w[3] = z;
47  }
48 
49  /// get derivative weight factors at parametric coordinate
50  template <class VECTOR>
51  void get_linear_derivate_weights(const VECTOR& /*coords*/, double *w) const
52  {
53  w[0] = -1;
54  w[1] = 1;
55  w[2] = 0;
56  w[3] = 0;
57  w[4] = -1;
58  w[5] = 0;
59  w[6] = 1;
60  w[7] = 0;
61  w[8] = -1;
62  w[9] = 0;
63  w[10] = 0;
64  w[11] = 1;
65  }
66 
67  /// get weight factors at parametric coordinate
68  template< class VECTOR>
69  void get_quadratic_weights(const VECTOR& coords, double *w) const
70  {
71  const double x=static_cast<double>(coords[0]), y=static_cast<double>(coords[1]), z=static_cast<double>(coords[2]);
72  w[0] = (1 + 2*x*x + 2*y*y - 3*z + 2*z*z + y*(-3 + 4*z) + x*(-3 + 4*y + 4*z));
73  w[1] = +x*(-1 + 2*x);
74  w[2] = +y*(-1 + 2*y);
75  w[3] = +z*(-1 + 2*z);
76  w[4] = -4*x*(-1 + x + y + z);
77  w[5] = +4*x*y;
78  w[6] = -4*y*(-1 + x + y + z);
79  w[7] = -4*z*(-1 + x + y + z);
80  w[8] = +4*x*z;
81  w[9] = +4*y*z;
82  }
83 
84  /// get weight factors of derivative at parametric coordinate
85  template< class VECTOR>
86  void get_quadratic_derivate_weights(const VECTOR& coords, double *w) const
87  {
88  const double x=static_cast<double>(coords[0]), y=static_cast<double>(coords[1]), z=static_cast<double>(coords[2]);
89  w[0] = (-3 + 4*x + 4*y + 4*z);
90  w[1] = +(-1 + 4*x);
91  w[2] = 0;
92  w[3] = 0;
93  w[4] = -4*(-1 + 2*x + y + z);
94  w[5] = 4*y;
95  w[6] = -4*y;
96  w[7] = -4*z;
97  w[8] = 4*z;
98  w[9] = 0;
99  w[10] = (-3 + 4*x + 4*y + 4*z);
100  w[11] = 0;
101  w[12] = (-1 + 4*y);
102  w[13] = 0;
103  w[14] = -4*x;
104  w[15] = +4*x;
105  w[16] = -4*(-1 + x + 2*y + z);
106  w[17] = -4*z;
107  w[18] = 0;
108  w[19] = +4*z;
109  w[20] = (-3 + 4*x + 4*y + 4*z);
110  w[21] = 0;
111  w[22] = 0;
112  w[23] = +(-1 + 4*z);
113  w[24] = -4*x;
114  w[25] = 0;
115  w[26] = -4*y;
116  w[27] = -4*(-1 + x + y + 2*z);
117  w[28] = +4*x;
118  w[29] = +4*y;
119  }
120 
121 
122  template <class VECTOR>
123  void get_cubic_weights(const VECTOR &coords, double *w) const
124  {
125  const double x=static_cast<double>(coords[0]), y=static_cast<double>(coords[1]), z=static_cast<double>(coords[2]);
126  w[0] = (-3*x*x + 2*x*x*x - 3*y*y + 2*y*y*y + (z-1)*(z-1)*(1 + 2*z));
127  w[1] = +x*(1 + x*x + x*(-2 + y) - y - z*z);
128  w[2] = +y*(-x*x + (-1 + y)*(-1 + y + z));
129  w[3] = +(-y*y + x*(-1 + z) + (z-1)*(z-1))*z;
130  w[4] = +(3 - 2*x)*x*x;
131  w[5] = +(-1 + x)*x*x;
132  w[6] = +x*x*y;
133  w[7] = -(x*(-1 + z)*z);
134  w[8] = +(3 - 2*y)*y*y;
135  w[9] = -((-1 + x)*x*y);
136  w[10] = +(-1 + y)*y*y;
137  w[11] = +y*y*z;
138  w[12] = +(3 - 2*z)*z*z;
139  w[13] = +x*z*z;
140  w[14] = -((-1 + y)*y*z);
141  w[15] = +(-1 + z)*z*z;
142  }
143 
144  /// get derivative weight factors at parametric coordinate
145  template <class VECTOR>
146  void get_cubic_derivate_weights(const VECTOR &coords, double *w) const
147  {
148  const double x=static_cast<double>(coords[0]), y=static_cast<double>(coords[1]), z=static_cast<double>(coords[2]);
149  w[0] = 6*(-1 + x)*x;
150  w[1] = +(1 + 3*x*x + 2*x*(-2 + y) - y - z*z);
151  w[2] = -2*x*y;
152  w[3] = +(-1 + z)*z;
153  w[4] = -6*(-1 + x)*x;
154  w[5] = +x*(-2 + 3*x);
155  w[6] = +2*x*y;
156  w[7] = -((-1 + z)*z);
157  w[8] = (y - 2*x*y);
158  w[9] = 0;
159  w[10] = 0;
160  w[11] = 0;
161  w[12] = z*z;
162  w[13] = 0;
163  w[14] = 0;
164  w[15] = 0;
165  w[16] = 6*(-1 + y)*y;
166  w[17] = (-1 + x)*x;
167  w[18] = (1 - x*x + 3*y*y + 2*y*(-2 + z) - z);
168  w[19] = -2*y*z;
169  w[20] = 0;
170  w[21] = 0;
171  w[22] = x*x;
172  w[23] = 0;
173  w[24] = -6*(-1 + y)*y;
174  w[25] = -((-1 + x)*x);
175  w[26] = +y*(-2 + 3*y);
176  w[27] = +2*y*z;
177  w[28] = 0;
178  w[29] = 0;
179  w[30] = (z - 2*y*z);
180  w[31] = 0;
181  w[32] = 6*(-1 + z)*z;
182  w[33] = -2*x*z;
183  w[34] = (-1 + y)*y;
184  w[35] = (1 - x - y*y - 4*z + 2*x*z + 3*z*z);
185  w[36] = 0;
186  w[37] = 0;
187  w[38] = 0;
188  w[39] = (x - 2*x*z);
189  w[40] = 0;
190  w[41] = 0;
191  w[42] = 0;
192  w[43] = y*y;
193  w[44] = -6*(-1 + z)*z;
194  w[45] = 2*x*z;
195  w[46] = -((-1 + y)*y);
196  w[47] = z*(-2 + 3*z);
197  }
198 
199  inline int num_linear_weights() { return 4; }
200  inline int num_quadratic_weights() { return 10; }
201  inline int num_cubic_weights() { return 16; }
202 
203  inline int num_linear_derivate_weights() { return 12; }
204  inline int num_quadratic_derivate_weights() { return 30; }
205  inline int num_cubic_derivate_weights() { return 48; }
206 
207  inline int num_derivs() { return 3; }
208  inline int num_hderivs() { return 3; }
209 };
210 
211 }}}
212 
213 #endif
214 
int num_quadratic_derivate_weights()
Definition: TetElementWeights.h:204
void get_quadratic_weights(const VECTOR &coords, double *w) const
get weight factors at parametric coordinate
Definition: TetElementWeights.h:69
int num_linear_weights()
Definition: TetElementWeights.h:199
Definition: TetElementWeights.h:36
void get_linear_weights(const VECTOR &coords, double *w) const
Definition: TetElementWeights.h:40
int num_derivs()
Definition: TetElementWeights.h:207
void get_linear_derivate_weights(const VECTOR &, double *w) const
get derivative weight factors at parametric coordinate
Definition: TetElementWeights.h:51
int num_hderivs()
Definition: TetElementWeights.h:208
void get_cubic_derivate_weights(const VECTOR &coords, double *w) const
get derivative weight factors at parametric coordinate
Definition: TetElementWeights.h:146
int num_cubic_derivate_weights()
Definition: TetElementWeights.h:205
void get_cubic_weights(const VECTOR &coords, double *w) const
Definition: TetElementWeights.h:123
int num_linear_derivate_weights()
Definition: TetElementWeights.h:203
int num_quadratic_weights()
Definition: TetElementWeights.h:200
void get_quadratic_derivate_weights(const VECTOR &coords, double *w) const
get weight factors of derivative at parametric coordinate
Definition: TetElementWeights.h:86
int num_cubic_weights()
Definition: TetElementWeights.h:201