SCIRun  5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
QuadBicubicHmt.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 /// @file QuadBicubicHmt.h
29 /// @author Martin Cole, Frank B. Sachse
30 /// @date Dec 04 2004
31 
32 #ifndef CORE_BASIS_QUADBICUBICHMT_H
33 #define CORE_BASIS_QUADBICUBICHMT_H 1
34 
36 
37 namespace SCIRun {
38 namespace Core {
39 namespace Basis {
40 
41 /// Class for describing unit geometry of QuadBicubicHmt
43 public:
46 
47  static int dofs() { return 12; } ///< return degrees of freedom
48 };
49 
50 
51 /// Class for handling of element of type quad with
52 /// bicubic hermitian interpolation
53 template <class T>
55  public QuadApprox,
56  public QuadGaussian3<double>,
57  public QuadSamplingSchemes,
59  public QuadElementWeights
60 {
61 public:
62  typedef T value_type;
63 
65  virtual ~QuadBicubicHmt() {}
66 
67  static int polynomial_order() { return 3; }
68 
69  template<class VECTOR>
70  inline void get_weights(const VECTOR& coords, double *w) const
71  { get_cubic_weights(coords,w); }
72 
73  template<class VECTOR>
74  inline void get_derivate_weights(const VECTOR& coords, double *w) const
75  { get_cubic_derivate_weights(coords,w); }
76 
77  /// get value at parametric coordinate
78  template <class ElemData, class VECTOR>
79  T interpolate(const VECTOR &coords, const ElemData &cd) const
80  {
81  double w[12];
82  get_cubic_weights(coords, w);
83  return (T)(w[0] * cd.node0() +
84  w[1] * this->derivs_[cd.node0_index()][0] +
85  w[2] * this->derivs_[cd.node0_index()][1] +
86  w[3] * cd.node1() +
87  w[4] * this->derivs_[cd.node1_index()][0] +
88  w[5] * this->derivs_[cd.node1_index()][1] +
89  w[6] * cd.node2() +
90  w[7] * this->derivs_[cd.node2_index()][0] +
91  w[8] * this->derivs_[cd.node2_index()][1] +
92  w[9] * cd.node3() +
93  w[10] * this->derivs_[cd.node3_index()][0] +
94  w[11] * this->derivs_[cd.node3_index()][1]);
95  }
96 
97  /// get first derivative at parametric coordinate
98  template <class ElemData, class VECTOR1, class VECTOR2>
99  void derivate(const VECTOR1 &coords, const ElemData &cd,
100  VECTOR2 &derivs) const
101  {
102  double w[24];
103  get_cubic_derivate_weights(coords,w);
104 
105  derivs.resize(2);
106  derivs[0] = static_cast<typename VECTOR2::value_type>(
107  w[0]*cd.node0() +
108  w[1]*this->derivs_[cd.node0_index()][0] +
109  w[2]*this->derivs_[cd.node0_index()][1] +
110  w[3]*cd.node1() +
111  w[4]*this->derivs_[cd.node1_index()][0] +
112  w[5]*this->derivs_[cd.node1_index()][1] +
113  w[6]*cd.node2() +
114  w[7]*this->derivs_[cd.node2_index()][0] +
115  w[8]*this->derivs_[cd.node2_index()][1] +
116  w[9]*cd.node3() +
117  w[10]*this->derivs_[cd.node3_index()][0] +
118  w[11]*this->derivs_[cd.node3_index()][1]);
119 
120  derivs[1] = static_cast<typename VECTOR2::value_type>(
121  w[12]*cd.node0() +
122  w[13]*this->derivs_[cd.node0_index()][0] +
123  w[14]*this->derivs_[cd.node0_index()][1] +
124  w[15]*cd.node1() +
125  w[16]*this->derivs_[cd.node1_index()][0] +
126  w[17]*this->derivs_[cd.node1_index()][1] +
127  w[18]*cd.node2() +
128  w[19]*this->derivs_[cd.node2_index()][0] +
129  w[20]*this->derivs_[cd.node2_index()][1] +
130  w[21]*cd.node3() +
131  w[22]*this->derivs_[cd.node3_index()][0] +
132  w[23]*this->derivs_[cd.node3_index()][1]);
133  }
134 
135  /// get parametric coordinate for value within the element
136  template <class ElemData, class VECTOR>
137  bool get_coords(VECTOR &coords, const T& value,
138  const ElemData &cd) const
139  {
141  return CL.get_coords(this, coords, value, cd);
142  }
143 
144  /// get arc length for edge
145  template <class ElemData>
146  double get_arc_length(const unsigned edge, const ElemData &cd) const
147  {
148  return get_arc2d_length<CrvGaussian2<double> >(this, edge, cd);
149  }
150 
151  /// get area
152  template <class ElemData>
153  double get_area(const unsigned face, const ElemData &cd) const
154  {
155  return get_area2<QuadGaussian3<double> >(this, face, cd);
156  }
157 
158  /// get volume
159  template <class ElemData>
160  double get_volume(const ElemData & /* cd */) const
161  {
162  return 0.;
163  }
164 
165  static const std::string type_name(int n = -1);
166 
167  virtual void io (Piostream& str);
168 
169 };
170 
171 
172 
173 
174 template <class T>
175 const std::string
177 {
178  ASSERT((n >= -1) && n <= 1);
179  if (n == -1)
180  {
181  static const std::string name = TypeNameGenerator::make_template_id(type_name(0), type_name(1));
182  return name;
183  }
184  else if (n == 0)
185  {
186  static const std::string nm("QuadBicubicHmt");
187  return nm;
188  } else {
189  return find_type_name((T *)0);
190  }
191 }
192 
193 
194 
195 
196 
197 }}
198 
199 template <class T>
201 {
202  static TypeDescription* td = 0;
203  if(!td){
204  const TypeDescription *sub = get_type_description((T*)0);
206  (*subs)[0] = sub;
207  td = new TypeDescription("QuadBicubicHmt", subs,
208  std::string(__FILE__),
209  "SCIRun",
211  }
212  return td;
213 }
214 
216 template <class T>
217 void
219 {
220  stream.begin_class(get_type_description(this)->get_name(),
222  Pio(stream, this->derivs_);
223  stream.end_class();
224 }
225 }
226 
227 #endif
virtual void io(Piostream &str)
Definition: QuadBicubicHmt.h:218
Definition: Persistent.h:89
static int dofs()
return degrees of freedom
Definition: QuadBicubicHmt.h:47
void derivate(const VECTOR1 &coords, const ElemData &cd, VECTOR2 &derivs) const
get first derivative at parametric coordinate
Definition: QuadBicubicHmt.h:99
Class for describing unit geometry of QuadBicubicHmt.
Definition: QuadBicubicHmt.h:42
Definition: TypeDescription.h:45
std::vector< const TypeDescription * > td_vec
Definition: TypeDescription.h:56
void get_derivate_weights(const VECTOR &coords, double *w) const
Definition: QuadBicubicHmt.h:74
void get_weights(const VECTOR &coords, double *w) const
Definition: QuadBicubicHmt.h:70
#define ASSERT(condition)
Definition: Assert.h:110
Definition: QuadElementWeights.h:36
virtual int begin_class(const std::string &name, int current_version)
Definition: Persistent.cc:143
static int polynomial_order()
Definition: QuadBicubicHmt.h:67
const int QUADBICUBICHMT_VERSION
Definition: QuadBicubicHmt.h:215
const string find_type_name(float *)
Definition: TypeName.cc:63
Definition: QuadSamplingSchemes.h:42
const char * name[]
Definition: BoostGraphExampleTests.cc:87
T interpolate(const VECTOR &coords, const ElemData &cd) const
get value at parametric coordinate
Definition: QuadBicubicHmt.h:79
virtual ~QuadBicubicHmt()
Definition: QuadBicubicHmt.h:65
QuadBicubicHmt()
Definition: QuadBicubicHmt.h:64
QuadBicubicHmtUnitElement()
Definition: QuadBicubicHmt.h:44
Definition: QuadBilinearLgn.h:175
void get_cubic_derivate_weights(const VECTOR &coords, double *w) const
get derivative weight factors at parametric coordinate
Definition: QuadElementWeights.h:125
Class for describing unit geometry of QuadBilinearLgn.
Definition: QuadBilinearLgn.h:46
bool get_coords(const ElemBasis *pEB, VECTOR &coords, const T &value, const ElemData &cd) const
find value in interpolation for given value
Definition: QuadBilinearLgn.h:184
static const std::string make_template_id(const std::string &templateName, const std::string &templateParam)
Definition: TypeName.h:62
void Pio(Piostream &stream, Array1< T > &array)
Definition: Array1.h:65
static const std::string type_name(int n=-1)
Definition: QuadBicubicHmt.h:176
double get_arc_length(const unsigned edge, const ElemData &cd) const
get arc length for edge
Definition: QuadBicubicHmt.h:146
std::vector< std::vector< T > > derivs_
Definition: Basis.h:160
virtual void end_class()
Definition: Persistent.cc:178
Definition: QuadBicubicHmt.h:54
bool get_coords(VECTOR &coords, const T &value, const ElemData &cd) const
get parametric coordinate for value within the element
Definition: QuadBicubicHmt.h:137
Class for creating geometrical approximations of Quad meshes.
Definition: QuadBilinearLgn.h:108
double get_area(const unsigned face, const ElemData &cd) const
get area
Definition: QuadBicubicHmt.h:153
T value_type
Definition: QuadBicubicHmt.h:62
int n
Definition: eab.py:9
virtual ~QuadBicubicHmtUnitElement()
Definition: QuadBicubicHmt.h:45
double get_volume(const ElemData &) const
get volume
Definition: QuadBicubicHmt.h:160
void get_cubic_weights(const VECTOR &coords, double *w) const
Definition: QuadElementWeights.h:106
Class with weights and coordinates for 3rd order Gaussian integration.
Definition: QuadBilinearLgn.h:287
Definition: TypeDescription.h:49
const TypeDescription * get_type_description(Core::Basis::ConstantBasis< T > *)
Definition: Constant.h:209