SCIRun  5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TetQuadraticLgn.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 TetQuadraticLgn.h
29 /// @author Martin Cole, Frank B. Sachse
30 /// @date Dec 04 2004
31 
32 #ifndef CORE_BASIS_TETQUADRATICLGN_H
33 #define CORE_BASIS_TETQUADRATICLGN_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 TetQuadraticLgn
44  public:
45  static double unit_vertices[10][3]; ///< Parametric coordinates of vertices of unit edge
46 
49 
50  /// return number of vertices
51  static int number_of_vertices()
52  { return 10; }
53 
54  ///< return degrees of freedom
55  static int dofs()
56  { return 10; }
57 };
58 
59 
60 /// Class for handling of element of type tetrahedron with
61 /// quadratic lagrangian interpolation
62 template <class T>
63 class TetQuadraticLgn : public BasisAddNodes<T>,
64  public TetApprox,
65  public TetGaussian3<double>,
66  public TetSamplingSchemes,
68  public TetElementWeights
69 {
70 public:
71  typedef T value_type;
72 
74  virtual ~TetQuadraticLgn() {}
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[10];
91  get_quadratic_weights(coords, w);
92 
93  return (T)(w[0] * cd.node0() +
94  w[1] * cd.node1() +
95  w[2] * cd.node2() +
96  w[3] * cd.node3() +
97  w[4] * this->nodes_[cd.edge0_index()] +
98  w[5] * this->nodes_[cd.edge1_index()] +
99  w[6] * this->nodes_[cd.edge2_index()] +
100  w[7] * this->nodes_[cd.edge3_index()] +
101  w[8] * this->nodes_[cd.edge4_index()] +
102  w[9] * this->nodes_[cd.edge5_index()]);
103  }
104 
105  /// get first derivative at parametric coordinate
106  template <class ElemData, class VECTOR1, class VECTOR2>
107  void derivate(const VECTOR1 &coords, const ElemData &cd,
108  VECTOR2 &derivs) const
109  {
110  double w[30];
112 
113  derivs.resize(3);
114 
115  derivs[0]=static_cast<typename VECTOR2::value_type>(
116  w[0]*cd.node0() +
117  w[1]*cd.node1() +
118  w[4]*this->nodes_[cd.edge0_index()] +
119  w[5]*this->nodes_[cd.edge1_index()] +
120  w[6]*this->nodes_[cd.edge2_index()] +
121  w[7]*this->nodes_[cd.edge3_index()] +
122  w[8]*this->nodes_[cd.edge4_index()]);
123 
124  derivs[1]=static_cast<typename VECTOR2::value_type>(
125  w[10]*cd.node0() +
126  w[12]*cd.node2() +
127  w[14]*this->nodes_[cd.edge0_index()] +
128  w[15]*this->nodes_[cd.edge1_index()] +
129  w[16]*this->nodes_[cd.edge2_index()] +
130  w[17]*this->nodes_[cd.edge3_index()] +
131  w[19]*this->nodes_[cd.edge5_index()]);
132 
133  derivs[2]=static_cast<typename VECTOR2::value_type>(
134  w[20]*cd.node0() +
135  w[23]*cd.node3() +
136  w[24]*this->nodes_[cd.edge0_index()] +
137  w[26]*this->nodes_[cd.edge2_index()] +
138  w[27]*this->nodes_[cd.edge3_index()] +
139  w[28]*this->nodes_[cd.edge4_index()] +
140  w[29]*this->nodes_[cd.edge5_index()]);
141  }
142 
143  /// get parametric coordinate for value within the element
144  template <class ElemData, class VECTOR>
145  bool get_coords(VECTOR &coords, const T& value,
146  const ElemData &cd) const
147  {
149  return CL.get_coords(this, coords, value, cd);
150  }
151 
152  /// get arc length for edge
153  template <class ElemData>
154  double get_arc_length(const unsigned edge, const ElemData &cd) const
155  {
156  return get_arc3d_length<CrvGaussian2<double> >(this, edge, cd);
157  }
158 
159  /// get area
160  template <class ElemData>
161  double get_area(const unsigned face, const ElemData &cd) const
162  {
163  return get_area3<TriGaussian3<double> >(this, face, cd);
164  }
165 
166  /// get volume
167  template <class ElemData>
168  double get_volume(const ElemData & cd) const
169  {
170  return get_volume3(this, cd);
171  }
172 
173 
174  static const std::string type_name(int n = -1);
175 
176  virtual void io (Piostream& str);
177 
178 };
179 
180 
181 template <class T>
182 const std::string
184 {
185  ASSERT((n >= -1) && n <= 1);
186  if (n == -1)
187  {
188  static const std::string name = TypeNameGenerator::make_template_id(type_name(0), type_name(1));
189  return name;
190  }
191  else if (n == 0)
192  {
193  static const std::string nm("TetQuadraticLgn");
194  return nm;
195  } else {
196  return find_type_name((T *)0);
197  }
198 }
199 
200 
201 
202 
203 }}
204 template <class T>
206 {
207  static TypeDescription* td = 0;
208  if(!td){
209  const TypeDescription *sub = get_type_description((T*)0);
211  (*subs)[0] = sub;
212  td = new TypeDescription("TetQuadraticLgn", subs,
213  std::string(__FILE__),
214  "SCIRun",
216  }
217  return td;
218 }
219 
221 template <class T>
222 void
224 {
225  stream.begin_class(get_type_description(this)->get_name(),
227  Pio(stream, this->nodes_);
228  stream.end_class();
229 }
230 
231 }
232 
233 #endif
Class with weights and coordinates for 3rd order Gaussian integration.
Definition: TetLinearLgn.h:341
void get_weights(const VECTOR &coords, double *w) const
Definition: TetQuadraticLgn.h:79
T value_type
Definition: TetQuadraticLgn.h:71
Class for describing unit geometry of TetLinearLgn.
Definition: TetLinearLgn.h:47
Definition: Persistent.h:89
void get_quadratic_weights(const VECTOR &coords, double *w) const
get weight factors at parametric coordinate
Definition: TetElementWeights.h:69
Definition: TypeDescription.h:45
#define SCISHARE
Definition: share.h:39
std::vector< const TypeDescription * > td_vec
Definition: TypeDescription.h:56
Definition: TetElementWeights.h:36
std::vector< T > nodes_
Definition: Basis.h:159
#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
const string find_type_name(float *)
Definition: TypeName.cc:63
void derivate(const VECTOR1 &coords, const ElemData &cd, VECTOR2 &derivs) const
get first derivative at parametric coordinate
Definition: TetQuadraticLgn.h:107
virtual void io(Piostream &str)
Definition: TetQuadraticLgn.h:223
const char * name[]
Definition: BoostGraphExampleTests.cc:87
Class for describing unit geometry of TetQuadraticLgn.
Definition: TetQuadraticLgn.h:43
double get_arc_length(const unsigned edge, const ElemData &cd) const
get arc length for edge
Definition: TetQuadraticLgn.h:154
void get_derivate_weights(const VECTOR &coords, double *w) const
Definition: TetQuadraticLgn.h:83
Class for creating geometrical approximations of Tet meshes.
Definition: TetLinearLgn.h:112
Class for describing interfaces to basis elements with additional nodes.
Definition: Basis.h:169
static const std::string make_template_id(const std::string &templateName, const std::string &templateParam)
Definition: TypeName.h:62
static int dofs()
Definition: TetQuadraticLgn.h:55
T interpolate(const VECTOR &coords, const ElemData &cd) const
get value at parametric coordinate
Definition: TetQuadraticLgn.h:88
void Pio(Piostream &stream, Array1< T > &array)
Definition: Array1.h:65
Definition: TetSamplingSchemes.h:42
double get_volume(const ElemData &cd) const
get volume
Definition: TetQuadraticLgn.h:168
static int number_of_vertices()
return number of vertices
Definition: TetQuadraticLgn.h:51
virtual void end_class()
Definition: Persistent.cc:178
virtual ~TetQuadraticLgn()
Definition: TetQuadraticLgn.h:74
TetQuadraticLgn()
Definition: TetQuadraticLgn.h:73
bool get_coords(VECTOR &coords, const T &value, const ElemData &cd) const
get parametric coordinate for value within the element
Definition: TetQuadraticLgn.h:145
static const std::string type_name(int n=-1)
Definition: TetQuadraticLgn.h:183
Definition: TetQuadraticLgn.h:63
int n
Definition: eab.py:9
virtual ~TetQuadraticLgnUnitElement()
Definition: TetQuadraticLgn.h:48
static int polynomial_order()
Definition: TetQuadraticLgn.h:76
double get_area(const unsigned face, const ElemData &cd) const
get area
Definition: TetQuadraticLgn.h:161
const int TETQUADRATICLGN_VERSION
Definition: TetQuadraticLgn.h:220
TetQuadraticLgnUnitElement()
Definition: TetQuadraticLgn.h:47
double get_volume3(const ElemBasis *pEB, const ElemData &cd)
Definition: Locate.h:179
void get_quadratic_derivate_weights(const VECTOR &coords, double *w) const
get weight factors of derivative at parametric coordinate
Definition: TetElementWeights.h:86
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