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