00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef __itkFEMSolver_h
00019 #define __itkFEMSolver_h
00020
00021 #include "itkFEMElementBase.h"
00022 #include "itkFEMMaterialBase.h"
00023 #include "itkFEMLoadBase.h"
00024
00025 #include "itkFEMLinearSystemWrapper.h"
00026 #include "itkFEMLinearSystemWrapperVNL.h"
00027
00028 #include "itkImage.h"
00029
00030 namespace itk {
00031 namespace fem {
00032
00041 class Solver
00042 {
00043 public:
00044
00048 typedef Element::Float Float;
00049
00054 typedef Element::ArrayType ElementArray;
00055 ElementArray el;
00056
00060 typedef Node::ArrayType NodeArray;
00061 NodeArray node;
00062
00066 typedef Load::ArrayType LoadArray;
00067 LoadArray load;
00068
00072 typedef Material::ArrayType MaterialArray;
00073 MaterialArray mat;
00074
00078 typedef Element::VectorType VectorType;
00079
00090 itkStaticConstMacro(MaxGridDimensions, unsigned int, 3);
00091
00095 typedef itk::Image<Element::ConstPointer,MaxGridDimensions> InterpolationGridType;
00096
00111 void InitializeInterpolationGrid(const VectorType& size, const VectorType& bb1, const VectorType& bb2);
00112
00116 void InitializeInterpolationGrid(const VectorType& size)
00117 {
00118 InitializeInterpolationGrid(size, VectorType(size.size(),0.0), size-1.0);
00119 }
00121
00132 const InterpolationGridType * GetInterpolationGrid(void) const
00133 { return m_InterpolationGrid.GetPointer(); }
00134
00143 const Element * GetElementAtPoint(const VectorType& pt) const;
00144
00148 void Read( std::istream& f );
00149
00153 void Write( std::ostream& f );
00154
00158 virtual void Clear( void );
00159
00160
00169 void GenerateGFN( void );
00170
00174 void AssembleK( void );
00175
00182 virtual void InitializeMatrixForAssembly(unsigned int N);
00183
00189 virtual void FinalizeMatrixAfterAssembly( void )
00190 {
00191
00192 this->ApplyBC();
00193 };
00195
00202 virtual void AssembleElementMatrix(Element::Pointer e);
00203
00211 virtual void AssembleLandmarkContribution(Element::Pointer e, float);
00212
00226 void ApplyBC(int dim=0, unsigned int matrix=0);
00227
00235 void AssembleF(int dim=0);
00236
00240 void DecomposeK( void );
00241
00245 virtual void Solve( void );
00246
00251 void UpdateDisplacements( void );
00252
00253 Float GetSolution(unsigned int i,unsigned int which=0)
00254 {
00255 return m_ls->GetSolutionValue(i,which);
00256 }
00257
00258 unsigned int GetNumberOfDegreesOfFreedom( void )
00259 {
00260 return NGFN;
00261 }
00262
00264 Float GetDeformationEnergy(unsigned int SolutionIndex=0);
00265
00266 public:
00271 Solver();
00272
00276 virtual ~Solver() {}
00277
00292 void SetLinearSystemWrapper(LinearSystemWrapper::Pointer ls);
00293
00299 LinearSystemWrapper::Pointer GetLinearSystemWrapper() { return m_ls; }
00300
00305 virtual void InitializeLinearSystemWrapper(void);
00306
00310 virtual Float GetTimeStep( void ) const { return 0.0; }
00311
00317 virtual void SetTimeStep(Float) {}
00318
00319 protected:
00320
00324 unsigned int NGFN;
00325
00330 unsigned int NMFC;
00331
00333 LinearSystemWrapper::Pointer m_ls;
00334
00335 private:
00336
00340 LinearSystemWrapperVNL m_lsVNL;
00341
00347 InterpolationGridType::Pointer m_InterpolationGrid;
00348
00349 };
00350
00351
00352
00353
00354 }}
00355
00356 #endif // #ifndef __itkFEMSolver_h
00357