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