SCIRun  5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TriQuadraticLgn.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 TriQuadraticLgn.h
29 /// @author Martin Cole, Frank Sachse
30 /// @date Dec 04 2004
31 
32 #ifndef CORE_BASIS_TRIQUADRATICLGN_H
33 #define CORE_BASIS_TRIQUADRATICLGN_H 1
34 
37 
38 namespace SCIRun {
39 namespace Core {
40 namespace Basis {
41 
42 /// Class for describing unit geometry of TriQuadraticLgn
44 public:
45  static SCISHARE double unit_vertices[6][2]; ///< Parametric coordinates of vertices of unit edge
46 
49 
50  static int number_of_vertices() { return 6; } ///< return number of vertices
51  static int dofs() { return 6; } ///< return degrees of freedom
52 };
53 
54 
55 /// Class for handling of element of type triangle with
56 /// linear quadratic interpolation
57 template <class T>
58 class TriQuadraticLgn : public BasisAddNodes<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 ~TriQuadraticLgn() {}
70 
71  static int polynomial_order() { return 2; }
72 
73  template<class VECTOR>
74  inline void get_weights(const VECTOR& coords, double *w) const
75  { get_quadratic_weights(coords,w); }
76 
77  template<class VECTOR>
78  inline void get_derivate_weights(const VECTOR& coords, double *w) const
79  { get_quadratic_derivate_weights(coords,w); }
80 
81 
82  /// get value at parametric coordinate
83  template <class ElemData, class VECTOR>
84  T interpolate(const VECTOR &coords, const ElemData &cd) const
85  {
86  double w[6];
87  get_quadratic_weights(coords, w);
88 
89  return (T)(
90  w[0] * cd.node0() +
91  w[1] * cd.node1() +
92  w[2] * cd.node2() +
93  w[3] * this->nodes_[cd.edge0_index()] +
94  w[4] * this->nodes_[cd.edge1_index()] +
95  w[5] * this->nodes_[cd.edge2_index()]);
96  }
97 
98  /// get first derivative at parametric coordinate
99  template <class ElemData, class VECTOR1, class VECTOR2>
100  void derivate(const VECTOR1 &coords, const ElemData &cd,
101  VECTOR2 &derivs) const
102  {
103  double w[12];
105 
106  derivs.resize(2);
107 
108  derivs[0]=static_cast<typename VECTOR2::value_type>(
109  w[0]*cd.node0()
110  + w[1]*cd.node1()
111  + w[2]*cd.node2()
112  + w[3]*this->nodes_[cd.edge0_index()]
113  + w[4]*this->nodes_[cd.edge1_index()]
114  + w[5]*this->nodes_[cd.edge2_index()]);
115 
116  derivs[1]=static_cast<typename VECTOR2::value_type>(
117  w[6]*cd.node0()
118  + w[7]*cd.node1()
119  + w[8]*cd.node2()
120  + w[9]*this->nodes_[cd.edge0_index()]
121  + w[10]*this->nodes_[cd.edge1_index()]
122  + w[11] *this->nodes_[cd.edge2_index()]);
123  }
124 
125  /// get the parametric coordinate for value within the element
126  template <class ElemData, class VECTOR>
127  bool get_coords(VECTOR &coords, const T& value,
128  const ElemData &cd) const
129  {
131  return CL.get_coords(this, coords, value, cd);
132  }
133 
134  /// get arc length for edge
135  template <class ElemData>
136  double get_arc_length(const unsigned edge, const ElemData &cd) const
137  {
138  return get_arc2d_length<CrvGaussian2<double> >(this, edge, cd);
139  }
140 
141  /// get area
142  template <class ElemData>
143  double get_area(const unsigned face, const ElemData &cd) const
144  {
145  return get_area2<TriGaussian3<double> >(this, face, cd);
146  }
147 
148  /// get volume
149  template <class ElemData>
150  double get_volume(const ElemData & /* cd */) const
151  {
152  return 0.;
153  }
154 
155 
156  static const std::string type_name(int n = -1);
157 
158 
159  virtual void io (Piostream& str);
160 
161 };
162 
163 
164 
165 
166 
167 template <class T>
168 const std::string
170 {
171  ASSERT((n >= -1) && n <= 1);
172  if (n == -1)
173  {
174  static const std::string name = TypeNameGenerator::make_template_id(type_name(0), type_name(1));
175  return name;
176  }
177  else if (n == 0)
178  {
179  static const std::string nm("TriQuadraticLgn");
180  return nm;
181  } else {
182  return find_type_name((T *)0);
183  }
184 }
185 
186 }}
187 
188 template <class T>
190 {
191  static TypeDescription* td = 0;
192  if(!td){
193  const TypeDescription *sub = get_type_description((T*)0);
195  (*subs)[0] = sub;
196  td = new TypeDescription("TriQuadraticLgn", subs,
197  std::string(__FILE__),
198  "SCIRun",
200  }
201  return td;
202 }
203 
204  const int TRIQUADRATICLGN_VERSION = 1;
205  template <class T>
206  void
208  {
209  stream.begin_class(get_type_description(this)->get_name(),
211  Pio(stream, this->nodes_);
212  stream.end_class();
213  }
214 }
215 
216 #endif
T interpolate(const VECTOR &coords, const ElemData &cd) const
get value at parametric coordinate
Definition: TriQuadraticLgn.h:84
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
void get_quadratic_derivate_weights(const VECTOR &coords, double *w) const
get weight factors of derivative at parametric coordinate
Definition: TriElementWeights.h:76
Definition: Persistent.h:89
TriQuadraticLgnUnitElement()
Definition: TriQuadraticLgn.h:47
Class for creating geometrical approximations of Tri meshes.
Definition: TriLinearLgn.h:109
virtual ~TriQuadraticLgnUnitElement()
Definition: TriQuadraticLgn.h:48
void get_weights(const VECTOR &coords, double *w) const
Definition: TriQuadraticLgn.h:74
Definition: TypeDescription.h:45
#define SCISHARE
Definition: share.h:39
std::vector< const TypeDescription * > td_vec
Definition: TypeDescription.h:56
virtual void io(Piostream &str)
Definition: TriQuadraticLgn.h:207
std::vector< T > nodes_
Definition: Basis.h:159
double get_area(const unsigned face, const ElemData &cd) const
get area
Definition: TriQuadraticLgn.h:143
#define ASSERT(condition)
Definition: Assert.h:110
virtual int begin_class(const std::string &name, int current_version)
Definition: Persistent.cc:143
static const std::string type_name(int n=-1)
Definition: TriQuadraticLgn.h:169
const string find_type_name(float *)
Definition: TypeName.cc:63
virtual ~TriQuadraticLgn()
Definition: TriQuadraticLgn.h:69
void derivate(const VECTOR1 &coords, const ElemData &cd, VECTOR2 &derivs) const
get first derivative at parametric coordinate
Definition: TriQuadraticLgn.h:100
void get_quadratic_weights(const VECTOR &coords, double *w) const
get weight factors at parametric coordinate
Definition: TriElementWeights.h:63
const char * name[]
Definition: BoostGraphExampleTests.cc:87
static int dofs()
return degrees of freedom
Definition: TriQuadraticLgn.h:51
Persistent i/o for STL containers.
Definition: TriQuadraticLgn.h:58
static int number_of_vertices()
return number of vertices
Definition: TriQuadraticLgn.h:50
TriQuadraticLgn()
Definition: TriQuadraticLgn.h:68
Class for describing unit geometry of TriQuadraticLgn.
Definition: TriQuadraticLgn.h:43
void get_derivate_weights(const VECTOR &coords, double *w) const
Definition: TriQuadraticLgn.h:78
Class for describing interfaces to basis elements with additional nodes.
Definition: Basis.h:169
double get_arc_length(const unsigned edge, const ElemData &cd) const
get arc length for edge
Definition: TriQuadraticLgn.h:136
static const std::string make_template_id(const std::string &templateName, const std::string &templateParam)
Definition: TypeName.h:62
T value_type
Definition: TriQuadraticLgn.h:66
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
virtual void end_class()
Definition: Persistent.cc:178
static SCISHARE double unit_vertices[6][2]
Parametric coordinates of vertices of unit edge.
Definition: TriQuadraticLgn.h:45
Definition: TriSamplingSchemes.h:43
int n
Definition: eab.py:9
Class with weights and coordinates for 3rd order Gaussian integration.
Definition: TriLinearLgn.h:292
Definition: TriLinearLgn.h:185
static int polynomial_order()
Definition: TriQuadraticLgn.h:71
double get_volume(const ElemData &) const
get volume
Definition: TriQuadraticLgn.h:150
const int TRIQUADRATICLGN_VERSION
Definition: TriQuadraticLgn.h:204
bool get_coords(VECTOR &coords, const T &value, const ElemData &cd) const
get the parametric coordinate for value within the element
Definition: TriQuadraticLgn.h:127
Definition: TypeDescription.h:49
const TypeDescription * get_type_description(Core::Basis::ConstantBasis< T > *)
Definition: Constant.h:209