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