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