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