SCIRun  5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CrvCubicHmt.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 CrvCubicHmt.h
29 /// @author Martin Cole, Frank B. Sachse
30 /// @date Dec 04 2004
31 
32 #ifndef CORE_BASIS_CRVCUBICHMT_H
33 #define CORE_BASIS_CRVCUBICHMT_H 1
34 
36 
37 namespace SCIRun {
38 namespace Core {
39 namespace Basis {
40 
41 /// Class for describing unit geometry of CrvCubicHmt
43 public:
46 
47  static int dofs() { return 4; } ///< return degrees of freedom
48 };
49 
50 
51 /// Class for handling of element of type curve with
52 /// cubic hermitian interpolation
53 template <class T>
54 class CrvCubicHmt : public BasisAddDerivatives<T>,
55  public CrvApprox,
56  public CrvGaussian3<double>,
57  public CrvSamplingSchemes,
59  public CrvElementWeights
60 {
61 public:
62  typedef T value_type;
63 
64  static int GaussianNum;
65  static double GaussianPoints[3][1];
66  static double GaussianWeights[3];
67 
69  virtual ~CrvCubicHmt() {}
70 
71 
72  static int polynomial_order() { return 3; }
73 
74  template<class VECTOR>
75  inline void get_weights(const VECTOR& coords, double *w) const
76  { get_cubic_weights(coords,w); }
77 
78  template<class VECTOR>
79  inline void get_derivate_weights(const VECTOR& coords, double *w) const
80  { get_cubic_derivate_weights(coords,w); }
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[4];
87  get_cubic_weights(coords,w);
88  return T(
89  w[0] * cd.node0() +
90  w[1] * this->derivs_[cd.node0_index()][0] +
91  w[2] * cd.node1() +
92  w[3] * this->derivs_[cd.node1_index()][0]);
93  }
94 
95  /// get first derivative at parametric coordinate
96  template <class ElemData, class VECTOR1, class VECTOR2>
97  void derivate(const VECTOR1 &coords, const ElemData &cd,
98  VECTOR2 &derivs) const
99  {
100  double w[4];
101  get_cubic_derivate_weights(coords,w);
102 
103  derivs.resize(1);
104  derivs[0] = static_cast<typename VECTOR2::value_type>(
105  w[0] * cd.node0() +
106  w[1] * this->derivs_[cd.node0_index()][0] +
107  w[2] * cd.node1() +
108  w[3] * this->derivs_[cd.node1_index()][0]);
109  }
110 
111  /// get parametric coordinate for value within the element
112  template <class ElemData, class VECTOR>
113  bool get_coords(VECTOR &coords, const T& value,
114  const ElemData &cd) const
115  {
117  return CL.get_coords(this, coords, value, cd);
118  }
119 
120  /// get arc length for edge
121  template <class ElemData>
122  double get_arc_length(const unsigned edge, const ElemData &cd) const
123  {
124  return get_arc1d_length<CrvGaussian3<double> >(this, edge, cd);
125  }
126 
127  /// get area
128  template <class ElemData>
129  double get_area(const unsigned /* face */, const ElemData & /* cd */) const
130  {
131  return 0.;
132  }
133 
134  /// get volume
135  template <class ElemData>
136  double get_volume(const ElemData & /* cd */) const
137  {
138  return 0.;
139  }
140 
141  static const std::string type_name(int n = -1);
142 
143  virtual void io (Piostream& str);
144 
145 };
146 
147 template <class T>
148 const std::string
150 {
151  ASSERT((n >= -1) && n <= 1);
152  if (n == -1)
153  {
154  static const std::string name = TypeNameGenerator::make_template_id(type_name(0), type_name(1));
155  return name;
156  }
157  else if (n == 0)
158  {
159  static const std::string nm("CrvCubicHmt");
160  return nm;
161  } else {
162  return find_type_name((T *)0);
163  }
164 }
165 
166 
167 
168 
169 }}
170 
171 template <class T>
173 {
174  static TypeDescription* td = 0;
175  if(!td){
176  const TypeDescription *sub = get_type_description((T*)0);
178  (*subs)[0] = sub;
179  td = new TypeDescription("CrvCubicHmt", subs,
180  std::string(__FILE__),
181  "SCIRun",
183  }
184  return td;
185 }
186 
188 template <class T>
189 void
191 {
192  stream.begin_class(get_type_description(this)->get_name(),
194  Pio(stream, this->derivs_);
195  stream.end_class();
196 }
197 
198 }
199 
200 #endif
Definition: CrvSamplingSchemes.h:43
Definition: CrvElementWeights.h:38
T interpolate(const VECTOR &coords, const ElemData &cd) const
get value at parametric coordinate
Definition: CrvCubicHmt.h:84
static int GaussianNum
Definition: CrvCubicHmt.h:64
Definition: Persistent.h:89
CrvCubicHmtUnitElement()
Definition: CrvCubicHmt.h:44
Definition: TypeDescription.h:45
std::vector< const TypeDescription * > td_vec
Definition: TypeDescription.h:56
static double GaussianWeights[3]
Definition: CrvCubicHmt.h:66
#define ASSERT(condition)
Definition: Assert.h:110
virtual ~CrvCubicHmt()
Definition: CrvCubicHmt.h:69
Class for describing unit geometry of CrvLinearLgn.
Definition: CrvLinearLgn.h:50
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 get_cubic_weights(const VECTOR &coords, double *w) const
Definition: CrvElementWeights.h:78
Definition: CrvLinearLgn.h:139
Class for creating geometrical approximations of Crv meshes.
Definition: CrvLinearLgn.h:99
const char * name[]
Definition: BoostGraphExampleTests.cc:87
void derivate(const VECTOR1 &coords, const ElemData &cd, VECTOR2 &derivs) const
get first derivative at parametric coordinate
Definition: CrvCubicHmt.h:97
double get_arc_length(const unsigned edge, const ElemData &cd) const
get arc length for edge
Definition: CrvCubicHmt.h:122
T value_type
Definition: CrvCubicHmt.h:62
virtual ~CrvCubicHmtUnitElement()
Definition: CrvCubicHmt.h:45
bool get_coords(const ElemBasis *pEB, VECTOR &coords, const T &value, const ElemData &cd) const
find coordinate in interpolation for given value
Definition: CrvLinearLgn.h:148
virtual void io(Piostream &str)
Definition: CrvCubicHmt.h:190
static const std::string make_template_id(const std::string &templateName, const std::string &templateParam)
Definition: TypeName.h:62
static const std::string type_name(int n=-1)
Definition: CrvCubicHmt.h:149
CrvCubicHmt()
Definition: CrvCubicHmt.h:68
void Pio(Piostream &stream, Array1< T > &array)
Definition: Array1.h:65
static int dofs()
return degrees of freedom
Definition: CrvCubicHmt.h:47
std::vector< std::vector< T > > derivs_
Definition: Basis.h:160
virtual void end_class()
Definition: Persistent.cc:178
void get_weights(const VECTOR &coords, double *w) const
Definition: CrvCubicHmt.h:75
void get_derivate_weights(const VECTOR &coords, double *w) const
Definition: CrvCubicHmt.h:79
static int polynomial_order()
Definition: CrvCubicHmt.h:72
Definition: CrvCubicHmt.h:54
int n
Definition: eab.py:9
double get_volume(const ElemData &) const
get volume
Definition: CrvCubicHmt.h:136
bool get_coords(VECTOR &coords, const T &value, const ElemData &cd) const
get parametric coordinate for value within the element
Definition: CrvCubicHmt.h:113
const int CRVCUBICHMT_BASIS_VERSION
Definition: CrvCubicHmt.h:187
Class for describing unit geometry of CrvCubicHmt.
Definition: CrvCubicHmt.h:42
Class with weights and coordinates for 3rd order Gaussian integration.
Definition: CrvLinearLgn.h:237
double get_area(const unsigned, const ElemData &) const
get area
Definition: CrvCubicHmt.h:129
void get_cubic_derivate_weights(const VECTOR &coords, double *w) const
get derivative weight factors at parametric coordinate
Definition: CrvElementWeights.h:89
Definition: TypeDescription.h:49
const TypeDescription * get_type_description(Core::Basis::ConstantBasis< T > *)
Definition: Constant.h:209
static double GaussianPoints[3][1]
Definition: CrvCubicHmt.h:65