SCIRun  5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QuadElementWeights.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_QUADWEIGHTS_H
30 #define CORE_BASIS_QUADWEIGHTS_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]);
43  w[0] = (-1 + x) * (-1 + y);
44  w[1] = -x * (-1 + y);
45  w[2] = x * y;
46  w[3] = -(-1 + x) * y;
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  const double x=static_cast<double>(coords[0]), y=static_cast<double>(coords[1]);
54  w[0] = (-1 + y);
55  w[1] = (1 - y);
56  w[2] = y;
57  w[3] = -y;
58  w[4] = (-1 + x);
59  w[5] = -x;
60  w[6] = x;
61  w[7] = (1 - x);
62  }
63 
64  /// get weight factors at parametric coordinate
65  template< class VECTOR>
66  void get_quadratic_weights(const VECTOR& coords, double *w) const
67  {
68  const double x=static_cast<double>(coords[0]), y=static_cast<double>(coords[1]);
69 
70  w[0] = -((-1 + x)*(-1 + y)*(-1 + 2*x + 2*y));
71  w[1] = -(x*(-1 + 2*x - 2*y)*(-1 +y));
72  w[2] = +x*y*(-3 + 2*x + 2*y);
73  w[3] = +(-1 + x)*(1 + 2*x - 2*y)*y;
74  w[4] = +4*(-1 + x)*x*(-1 + y);
75  w[5] = -4*x*(-1 + y)*y;
76  w[6] = -4*(-1 + x)*x*y;
77  w[7] = +4*(-1 + x)*(-1 + y)*y;
78  }
79 
80  /// get weight factors of derivative at parametric coordinate
81  template< class VECTOR>
82  void get_quadratic_derivate_weights(const VECTOR& coords, double *w) const
83  {
84  const double x=static_cast<double>(coords[0]), y=static_cast<double>(coords[1]);
85 
86  w[0]= -((-1 + y)*(-3 + 4*x + 2*y));
87  w[1]= -((-1 + 4*x - 2*y)*(-1 + y));
88  w[2]= +y*(-3+ 4*x + 2*y);
89  w[3]= +(-1 + 4*x - 2*y)*y;
90  w[4]= +4*(-1 + 2*x)*(-1 + y);
91  w[5]= -4*(-1 + y)*y;
92  w[6]= +(4 - 8*x)*y;
93  w[7]= +4*(-1 + y)*y;
94  w[8]= -((-1 + x)*(-3 + 2*x +4*y));
95  w[9]= +x*(-1 - 2*x + 4*y);
96  w[10]= +x*(-3 + 2*x + 4*y);
97  w[11]= +(-1 + x)*(1 + 2*x -4*y);
98  w[12]= +4*(-1 + x)*x;
99  w[13]= +x*(4 -8*y);
100  w[14]= -4*(-1 + x)*x;
101  w[15]= +4*(-1 + x)*(-1 +2*y);
102  }
103 
104 
105  template <class VECTOR>
106  void get_cubic_weights(const VECTOR &coords, double *w) const
107  {
108  const double x=static_cast<double>(coords[0]), y=static_cast<double>(coords[1]);
109  w[0] = -((-1 + x)*(-1 + y)*(-1 - x + 2*x*x - y + 2*y*y));
110  w[1] = -((x-1)*(x-1)*x*(-1 + y));
111  w[2] = -((-1 + x)*(y-1)*(y-1)*y);
112  w[3] = +x*(-1 + y)*(-3*x + 2*x*x + y*(-1 + 2*y));
113  w[4] = +x*x*(-1 + x + y - x*y);
114  w[5] = +x*(y-1)*(y-1)*y;
115  w[6] = +x*y*(-1 + 3*x - 2*x*x + 3*y - 2*y*y);
116  w[7] = +(-1 + x)*x*x*y;
117  w[8] = +x*(-1 + y)*y*y;
118  w[9] = +(-1 + x)*y*(-x + 2*x*x + y*(-3 + 2*y));
119  w[10] = +(x-1)*(x-1)*x*y;
120  w[11] = +y*y*(-1 + x + y - x*y);
121  }
122 
123  /// get derivative weight factors at parametric coordinate
124  template <class VECTOR>
125  void get_cubic_derivate_weights(const VECTOR &coords, double *w) const
126  {
127  const double x=static_cast<double>(coords[0]), y=static_cast<double>(coords[1]);
128  w[0]= -((-1 + y)*(-6*x + 6*x*x + y*(-1 + 2*y)));
129  w[1]= -((1 - 4*x + 3*x*x)*(-1 + y));
130  w[2]= -((y-1)*(y-1)*y);
131  w[3]= +(-1 + y)*(-6*x + 6*x*x + y*(-1 + 2*y));
132  w[4]= -(x*(-2 + 3*x)*(-1 + y));
133  w[5]= +(y-1)*(y-1)*y;
134  w[6]= +y*(-1 + 6*x - 6*x*x + 3*y - 2*y*y);
135  w[7]= +x*(-2 + 3*x)*y;
136  w[8]= +(-1 + y)*y*y;
137  w[9]= +y*(1 - 6*x + 6*x*x - 3*y + 2*y*y);
138  w[10]= +(1 - 4*x + 3*x*x)*y;
139  w[11]= -((-1 + y)*y*y);
140  w[12]= -((-1 + x)*(-x + 2*x*x + 6*(-1 + y)*y));
141  w[13]= -((x-1)*(x-1)*x);
142  w[14]= -((-1 + x)*(1 - 4*y + 3*y*y));
143  w[15]= +x*(1 - 3*x + 2*x*x - 6*y + 6*y*y);
144  w[16]= -((-1 + x)*x*x);
145  w[17]= +x*(1 - 4*y + 3*y*y);
146  w[18]= +x*(-1 + 3*x - 2*x*x + 6*y - 6*y*y);
147  w[19]= +(-1 + x)*x*x;
148  w[20]= +x*y*(-2 + 3*y);
149  w[21]= +(-1 + x)*(-x + 2*x*x + 6*(-1 + y)*y);
150  w[22]= +(x-1)*(x-1)*x;
151  w[23]= -((-1 + x)*y*(-2 + 3*y));
152  }
153 
154 
155  inline int num_linear_weights() { return 4; }
156  inline int num_quadratic_weights() { return 8; }
157  inline int num_cubic_weights() { return 12; }
158 
159  inline int num_linear_derivate_weights() { return 8; }
160  inline int num_quadratic_derivate_weights() { return 16; }
161  inline int num_cubic_derivate_weights() { return 24; }
162 
163  inline int num_derivs() { return 2; }
164  inline int num_hderivs() { return 2; }
165 };
166 
167 }}}
168 
169 #endif
int num_linear_weights()
Definition: QuadElementWeights.h:155
int num_cubic_derivate_weights()
Definition: QuadElementWeights.h:161
int num_quadratic_derivate_weights()
Definition: QuadElementWeights.h:160
int num_derivs()
Definition: QuadElementWeights.h:163
void get_quadratic_derivate_weights(const VECTOR &coords, double *w) const
get weight factors of derivative at parametric coordinate
Definition: QuadElementWeights.h:82
Definition: QuadElementWeights.h:36
void get_linear_derivate_weights(const VECTOR &coords, double *w) const
get derivative weight factors at parametric coordinate
Definition: QuadElementWeights.h:51
int num_linear_derivate_weights()
Definition: QuadElementWeights.h:159
void get_cubic_derivate_weights(const VECTOR &coords, double *w) const
get derivative weight factors at parametric coordinate
Definition: QuadElementWeights.h:125
void get_quadratic_weights(const VECTOR &coords, double *w) const
get weight factors at parametric coordinate
Definition: QuadElementWeights.h:66
int num_hderivs()
Definition: QuadElementWeights.h:164
int num_cubic_weights()
Definition: QuadElementWeights.h:157
int num_quadratic_weights()
Definition: QuadElementWeights.h:156
void get_linear_weights(const VECTOR &coords, double *w) const
Definition: QuadElementWeights.h:40
void get_cubic_weights(const VECTOR &coords, double *w) const
Definition: QuadElementWeights.h:106