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