SCIRun  5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
CrvQuadraticLgn.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 CrvQuadraticLgn.h
29 /// @author Marty Cole, Frank B. Sachse
30 /// @date Nov 30 2004
31 
32 #ifndef CORE_BASIS_CRVQUADRATICLGN_H
33 #define CORE_BASIS_CRVQUADRATICLGN_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 CrvLinearLgn
44 public:
45  static double unit_vertices[3][1]; ///< Parametric coordinates of vertices of unit edge
46 
49 
50  static int number_of_vertices() { return 3; } ///< return number of vertices
51  static int dofs() { return 3; } ///< return degrees of freedom
52 };
53 
54 
55 
56 /// Class for handling of element of type curve with
57 /// quadratic lagrangian interpolation
58 template <class T>
59  class CrvQuadraticLgn : public BasisAddNodes<T>,
60  public CrvApprox,
61  public CrvGaussian2<double>,
62  public CrvSamplingSchemes,
64  public CrvElementWeights
65 {
66 public:
67  typedef T value_type;
68 
70  virtual ~CrvQuadraticLgn() {}
71 
72  static int polynomial_order() { return 2; }
73 
74  template<class VECTOR>
75  inline void get_weights(const VECTOR& coords, double *w) const
76  { get_quadratic_weights(coords,w); }
77 
78  template<class VECTOR>
79  inline void get_derivate_weights(const VECTOR& coords, double *w) const
80  { get_quadratic_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[3];
87  get_quadratic_weights(coords, w);
88 
89  return T(
90  w[0] * cd.node0() +
91  w[1] * cd.node1() +
92  w[2] * this->nodes_[cd.edge0_index()]);
93  }
94 
95  /// get derivative weight factors at parametric coordinate
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[3];
105 
106  derivs.resize(1);
107  derivs[0] = static_cast<typename VECTOR2::value_type>(
108  w[0] * cd.node0()
109  + w[1] * cd.node1()
110  + w[2] * this->nodes_[cd.edge0_index()]);
111  }
112 
113  /// get parametric coordinate for value within the element
114  template <class ElemData, class VECTOR>
115  bool get_coords(VECTOR &coords, const T& value,
116  const ElemData &cd) const
117  {
119  return CL.get_coords(this, coords, value, cd);
120  }
121 
122  /// get arc length for edge
123  template <class ElemData>
124  double get_arc_length(const unsigned edge, const ElemData &cd) const
125  {
126  return get_arc1d_length<CrvGaussian2<double> >(this, edge, cd);
127  }
128 
129  /// get area
130  template <class ElemData>
131  double get_area(const unsigned /* face */, const ElemData & /* cd */) const
132  {
133  return 0.;
134  }
135 
136  /// get volume
137  template <class ElemData>
138  double get_volume(const ElemData & /* cd */) const
139  {
140  return 0.;
141  }
142 
143 
144  static const std::string type_name(int n = -1);
145 
146  virtual void io (Piostream& str);
147 
148 };
149 
150 
151 template <class T>
152 const std::string
154 {
155  ASSERT((n >= -1) && n <= 1);
156  if (n == -1)
157  {
158  static const std::string name = TypeNameGenerator::make_template_id(type_name(0), type_name(1));
159  return name;
160  }
161  else if (n == 0)
162  {
163  static const std::string nm("CrvQuadraticLgn");
164  return nm;
165  } else {
166  return find_type_name((T *)0);
167  }
168 }
169 
170 
171 
172 
173 
174 }}
175 template <class T>
177 {
178  static TypeDescription* td = 0;
179  if(!td){
180  const TypeDescription *sub = get_type_description((T*)0);
182  (*subs)[0] = sub;
183  td = new TypeDescription("CrvQuadraticLgn", subs,
184  std::string(__FILE__),
185  "SCIRun",
187  }
188  return td;
189 }
190 
192 template <class T>
193 void
195 {
196  stream.begin_class(get_type_description(this)->get_name(),
198  Pio(stream, this->nodes_);
199  stream.end_class();
200 }
201 }
202 
203 #endif
virtual ~CrvQuadraticLgnUnitElement()
Definition: CrvQuadraticLgn.h:48
double get_area(const unsigned, const ElemData &) const
get area
Definition: CrvQuadraticLgn.h:131
CrvQuadraticLgnUnitElement()
Definition: CrvQuadraticLgn.h:47
Definition: CrvSamplingSchemes.h:43
Definition: CrvElementWeights.h:38
Definition: CrvQuadraticLgn.h:59
T interpolate(const VECTOR &coords, const ElemData &cd) const
get value at parametric coordinate
Definition: CrvQuadraticLgn.h:84
Definition: Persistent.h:89
Definition: TypeDescription.h:45
#define SCISHARE
Definition: share.h:39
std::vector< const TypeDescription * > td_vec
Definition: TypeDescription.h:56
static const std::string type_name(int n=-1)
Definition: CrvQuadraticLgn.h:153
std::vector< T > nodes_
Definition: Basis.h:159
#define ASSERT(condition)
Definition: Assert.h:110
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
bool get_coords(VECTOR &coords, const T &value, const ElemData &cd) const
get parametric coordinate for value within the element
Definition: CrvQuadraticLgn.h:115
static int dofs()
return degrees of freedom
Definition: CrvQuadraticLgn.h:51
const string find_type_name(float *)
Definition: TypeName.cc:63
static int number_of_vertices()
return number of vertices
Definition: CrvQuadraticLgn.h:50
static int polynomial_order()
Definition: CrvQuadraticLgn.h:72
void get_quadratic_derivate_weights(const VECTOR &coords, double *w) const
get weight factors of derivative at parametric coordinate
Definition: CrvElementWeights.h:69
Definition: CrvLinearLgn.h:139
Class for creating geometrical approximations of Crv meshes.
Definition: CrvLinearLgn.h:99
const char * name[]
Definition: BoostGraphExampleTests.cc:87
T value_type
Definition: CrvQuadraticLgn.h:67
void get_weights(const VECTOR &coords, double *w) const
Definition: CrvQuadraticLgn.h:75
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
Class for describing interfaces to basis elements with additional nodes.
Definition: Basis.h:169
Class with weights and coordinates for 2nd order Gaussian integration.
Definition: CrvLinearLgn.h:218
static const std::string make_template_id(const std::string &templateName, const std::string &templateParam)
Definition: TypeName.h:62
void get_quadratic_weights(const VECTOR &coords, double *w) const
get weight factors at parametric coordinate
Definition: CrvElementWeights.h:59
CrvQuadraticLgn()
Definition: CrvQuadraticLgn.h:69
void Pio(Piostream &stream, Array1< T > &array)
Definition: Array1.h:65
const int CRVQUADRATICLGN_VERSION
Definition: CrvQuadraticLgn.h:191
virtual void end_class()
Definition: Persistent.cc:178
virtual ~CrvQuadraticLgn()
Definition: CrvQuadraticLgn.h:70
void derivate(const VECTOR1 &coords, const ElemData &cd, VECTOR2 &derivs) const
get derivative weight factors at parametric coordinate
Definition: CrvQuadraticLgn.h:100
virtual void io(Piostream &str)
Definition: CrvQuadraticLgn.h:194
int n
Definition: eab.py:9
double get_arc_length(const unsigned edge, const ElemData &cd) const
get arc length for edge
Definition: CrvQuadraticLgn.h:124
double get_volume(const ElemData &) const
get volume
Definition: CrvQuadraticLgn.h:138
void get_derivate_weights(const VECTOR &coords, double *w) const
Definition: CrvQuadraticLgn.h:79
Class for describing unit geometry of CrvLinearLgn.
Definition: CrvQuadraticLgn.h:43
Definition: TypeDescription.h:49
const TypeDescription * get_type_description(Core::Basis::ConstantBasis< T > *)
Definition: Constant.h:209