Orfeo Toolbox  3.16
itkFEMElementBase.h
Go to the documentation of this file.
1 /*=========================================================================
2 
3  Program: Insight Segmentation & Registration Toolkit
4  Module: $RCSfile: itkFEMElementBase.h,v $
5  Language: C++
6  Date: $Date: 2009-01-29 21:28:16 $
7  Version: $Revision: 1.43 $
8 
9  Copyright (c) Insight Software Consortium. All rights reserved.
10  See ITKCopyright.txt or http://www.itk.org/HTML/Copyright.htm for details.
11 
12  This software is distributed WITHOUT ANY WARRANTY; without even
13  the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the above copyright notices for more information.
15 
16 =========================================================================*/
17 
18 #ifndef __itkFEMElementBase_h
19 #define __itkFEMElementBase_h
20 
21 #include "itkFEMLightObject.h"
22 #include "itkFEMPArray.h"
23 #include "itkFEMMaterialBase.h"
24 #include "itkFEMSolution.h"
25 #include "itkVisitorDispatcher.h"
26 #include "vnl/vnl_matrix.h"
27 #include "vnl/vnl_vector.h"
28 #include <set>
29 #include <vector>
30 
31 namespace itk {
32 namespace fem {
33 
34 // FIXME: Write better documentation
67 #define HANDLE_ELEMENT_LOADS() \
68  \
69  typedef void (*LoadImplementationFunctionPointer)(ConstPointer,Element::LoadPointer, Element::VectorType& ); \
70  virtual void GetLoadVector( Element::LoadPointer l, Element::VectorType& Fe ) const \
71  { VisitorDispatcher<Self,Element::LoadType, LoadImplementationFunctionPointer>::Visit(l)(this,l,Fe); }
72 
73 class Element : public FEMLightObject
74 {
76 public:
77 
81  typedef double Float;
82 
87 
91  typedef vnl_matrix<Float> MatrixType;
92 
96  typedef vnl_vector<Float> VectorType;
97 
110  typedef LoadType::Pointer LoadPointer;
111 
115  typedef unsigned int DegreeOfFreedomIDType;
116 
122  enum{ InvalidDegreeOfFreedomID = 0xffffffff };
123 
132  class Node : public FEMLightObject
133  {
135  public:
136 
140  typedef double Float;
141 
146 
147 
148  /* Windows visualization */
149  #ifdef FEM_BUILD_VISUALIZATION
150 
151  void Draw(CDC* pDC, Solution::ConstPointer sol) const;
153  static double& DC_Scale;
154  #endif
155 
159  Node() {}
160 
164  Node(Float x, Float y) : m_coordinates(VectorType(2))
165  { m_coordinates[0]=x; m_coordinates[1]=y; }
166 
170  Node(Float x, Float y, Float z) : m_coordinates(VectorType(3))
171  { m_coordinates[0]=x; m_coordinates[1]=y; m_coordinates[2]=z;}
176  const VectorType& GetCoordinates( void ) const
177  { return m_coordinates; }
178 
182  void SetCoordinates( const VectorType& coords )
183  { m_coordinates=coords; }
184 
189  {
190  if( i>=m_dof.size() ) { return InvalidDegreeOfFreedomID; }
191  return m_dof[i];
192  }
193 
197  void SetDegreeOfFreedom(unsigned int i, DegreeOfFreedomIDType dof) const
198  {
199  if( i>=m_dof.size() ) { m_dof.resize(i+1, InvalidDegreeOfFreedomID); }
200  m_dof[i]=dof;
201  }
202 
203  virtual void ClearDegreesOfFreedom( void ) const
204  {
205  m_dof.clear();
206  }
207 
208  virtual void Read( std::istream& f, void* info );
209  virtual void Write( std::ostream& f ) const;
210 
211  public:
216  typedef std::set<Element*> SetOfElements;
218 
219  private:
224 
229  mutable std::vector<DegreeOfFreedomIDType> m_dof;
230 
231  }; // end class Node
232 
234  /*
235  * Methods related to the physics of the problem.
236  */
237 
238  virtual VectorType GetStrainsAtPoint(const VectorType& pt, const Solution& sol, unsigned int index) const;
239 
240  virtual VectorType GetStressesAtPoint(const VectorType& pt, const VectorType& e, const Solution& sol, unsigned int index) const;
241 
262  virtual void GetStiffnessMatrix( MatrixType& Ke ) const;
263 
273  virtual Float GetElementDeformationEnergy( MatrixType& LocalSolution ) const;
274 
286  virtual void GetMassMatrix( MatrixType& Me ) const;
287 
299  virtual void GetLandmarkContributionMatrix(float eta, MatrixType& Le) const;
300 
330  virtual void GetLoadVector( LoadPointer l, VectorType& Fe ) const = 0;
331 
339  virtual void GetStrainDisplacementMatrix( MatrixType& B, const MatrixType& shapeDgl ) const = 0;
340 
346  virtual void GetMaterialMatrix( MatrixType& D ) const = 0;
347 
359  virtual VectorType InterpolateSolution( const VectorType& pt, const Solution& sol , unsigned int solutionIndex=0 ) const;
360 
374  virtual Float InterpolateSolutionN( const VectorType& pt, const Solution& sol, unsigned int f , unsigned int solutionIndex=0 ) const;
375 
382  DegreeOfFreedomIDType GetDegreeOfFreedom( unsigned int local_dof ) const
383  {
384  if(local_dof>this->GetNumberOfDegreesOfFreedom()) { return InvalidDegreeOfFreedomID; }
385  return this->GetNode(local_dof/this->GetNumberOfDegreesOfFreedomPerNode())->GetDegreeOfFreedom(local_dof%this->GetNumberOfDegreesOfFreedomPerNode());
386  }
387 
404  virtual Material::ConstPointer GetMaterial(void) const { return 0; }
405 
414  virtual void SetMaterial(Material::ConstPointer) {} // FIXME: maybe we should throw an exception instead
415 
417 
443  virtual void GetIntegrationPointAndWeight( unsigned int i, VectorType& pt, Float& w, unsigned int order=0 ) const = 0;
444 
455  virtual unsigned int GetNumberOfIntegrationPoints( unsigned int order=0 ) const = 0;
456 
465  enum { gaussMaxOrder=10 };
466 
479 
486 
487 
489  /*
490  * Methods related to the geometry of an element
491  */
492 
498 
502  virtual unsigned int GetNumberOfNodes( void ) const = 0;
503 
507  virtual NodeIDType GetNode(unsigned int n) const = 0;
508 
512  virtual void SetNode(unsigned int n, NodeIDType node) = 0;
513 
519  virtual const VectorType& GetNodeCoordinates( unsigned int n ) const = 0;
520 
526  virtual VectorType GetGlobalFromLocalCoordinates( const VectorType& pt ) const;
527 
534  virtual bool GetLocalFromGlobalCoordinates( const VectorType& globalPt , VectorType& localPt ) const = 0;
535 
541  virtual unsigned int GetNumberOfSpatialDimensions() const = 0;
542 
550  virtual VectorType ShapeFunctions( const VectorType& pt ) const = 0;
551 
567  virtual void ShapeFunctionDerivatives( const VectorType& pt, MatrixType& shapeD ) const = 0;
568 
588  virtual void ShapeFunctionGlobalDerivatives( const VectorType& pt, MatrixType& shapeDgl, const MatrixType* pJ=0, const MatrixType* pshapeD=0 ) const;
589 
611  virtual void Jacobian( const VectorType& pt, MatrixType& J, const MatrixType* pshapeD = 0 ) const;
612 
622  virtual Float JacobianDeterminant( const VectorType& pt, const MatrixType* pJ = 0 ) const;
623 
635  virtual void JacobianInverse( const VectorType& pt, MatrixType& invJ, const MatrixType* pJ = 0 ) const;
636 
642  virtual unsigned int GetNumberOfDegreesOfFreedom( void ) const
643  {
644  return this->GetNumberOfNodes() * this->GetNumberOfDegreesOfFreedomPerNode();
645  }
646 
654  virtual unsigned int GetNumberOfDegreesOfFreedomPerNode( void ) const = 0;
655 
657 
661 #ifdef FEM_BUILD_VISUALIZATION
662 
665  virtual void Draw(CDC* pDC, Solution::ConstPointer sol) const {}
667  static double DC_Scale;
668 #endif
669 
670 };
671 
672 // Make sure that Element::Node class is registered with the object factory.
673 static INITClass Initializer_ElementNode(Element::Node::CLID());
674 
675 // Alias for Element::Node class
677 
690 {
691 public:
692 
696 
699 
702 
705 
708  m_node(node_), m_el(el_), m_mat(mat_) {}
709 };
710 
711 }} // end namespace itk::fem
712 
713 #endif // #ifndef __itkFEMElementBase_h

Generated at Sat Feb 2 2013 23:36:42 for Orfeo Toolbox with doxygen 1.8.1.1