19 #ifndef itkFEMSolverCrankNicolson_h
20 #define itkFEMSolverCrankNicolson_h
28 #include "vnl/vnl_sparse_matrix.h"
29 #include "vnl/vnl_matrix.h"
30 #include "vnl/vnl_vector.h"
31 #include "vnl/algo/vnl_svd.h"
32 #include "vnl/algo/vnl_cholesky.h"
33 #include <vnl/vnl_sparse_matrix_linear_system.h>
71 template <
unsigned int TDimension = 3>
89 itkSetMacro(UseMassMatrix,
bool);
90 itkGetMacro(UseMassMatrix,
bool);
94 itkGetConstMacro(Iterations,
unsigned int);
111 void AddToDisplacements(Float optimum = 1.0);
113 void AverageLastTwoDisplacements(Float t = 0.5);
115 void ZeroVector(
int which = 0);
117 void PrintDisplacements();
122 itkGetMacro(TotalSolutionIndex,
unsigned int);
125 itkGetMacro(SolutionTMinus1Index,
unsigned int);
128 itkSetMacro(Alpha, Float);
129 itkGetMacro(Alpha, Float);
133 itkSetMacro(Rho, Float);
134 itkGetMacro(Rho, Float);
156 void RecomputeForceVector(
unsigned int index);
160 void FindBracketingTriplet(Float *a, Float *b, Float *c);
165 Float GoldenSection(Float tol = 0.01,
unsigned int MaxIters = 25);
168 Float BrentsMethod(Float tol = 0.01,
unsigned int MaxIters = 25);
170 Float EvaluateResidual(Float t = 1.0);
172 Float GetDeformationEnergy(Float t = 1.0);
176 return b > 0.0 ? std::fabs(a) : -1. * std::fabs(a);
180 return a > b ? a : b;
183 void SetEnergyToMin(Float xmin);
187 return this->m_LinearSystem;
192 return m_CurrentMaxSolution;
197 void PrintMinMaxOfSolution();
210 void GenerateData() ITK_OVERRIDE;
215 virtual
void RunSolver(
void) ITK_OVERRIDE;
220 void InitializeForSolution();
227 void AssembleKandM();
236 void AssembleFforTimeStep(
int dim = 0);
243 bool m_UseMassMatrix;
244 unsigned int m_Iterations;
246 unsigned int m_ForceTIndex;
247 unsigned int m_ForceTotalIndex;
248 unsigned int m_ForceTMinus1Index;
249 unsigned int m_SolutionTIndex;
250 unsigned int m_SolutionTMinus1Index;
251 unsigned int m_SolutionVectorTMinus1Index;
252 unsigned int m_TotalSolutionIndex;
253 unsigned int m_DifferenceMatrixIndex;
254 unsigned int m_SumMatrixIndex;
255 unsigned int m_DiffMatrixBySolutionTMinus1Index;
264 #ifndef ITK_MANUAL_INSTANTIATION
265 #include "itkFEMSolverCrankNicolson.hxx"
268 #endif // #ifndef itkFEMSolverCrankNicolson_h
virtual void SetTimeStep(Float dt) ITK_OVERRIDE
Light weight base class for most itk classes.
Solver< TDimension > Superclass
Float GSMax(Float a, Float b)
SmartPointer< Self > Pointer
~SolverCrankNicolson() ITK_OVERRIDE
void ResetIterations(void)
FEM Solver for time dependent problems; uses Crank-Nicolson implicit discretization scheme...
SmartPointer< const Self > ConstPointer
Defines all functions required by Solver class to allocate, assemble and solve a linear system of equ...
virtual Float GetTimeStep(void) const ITK_OVERRIDE
FEM solver used to generate a solution for a FE formulation.
Float GSSign(Float a, Float b)
LinearSystemWrapper * GetLinearSystem()
Float GetCurrentMaxSolution()