iMSTK
Interactive Medical Simulation Toolkit
imstkIterativeLinearSolver.cpp
1 /*
2 ** This file is part of the Interactive Medical Simulation Toolkit (iMSTK)
3 ** iMSTK is distributed under the Apache License, Version 2.0.
4 ** See accompanying NOTICE for details.
5 */
6 
7 #include "imstkIterativeLinearSolver.h"
8 #include "imstkLogger.h"
9 #include "imstkMacros.h"
10 
11 namespace imstk
12 {
13 void
15 {
16  m_maxIterations = maxIter;
17 }
18 
19 size_t
20 IterativeLinearSolver::getMaxNumIterations() const
21 {
22  return m_maxIterations;
23 }
24 
25 const Vectord&
27 {
28  return m_residual;
29 }
30 
31 const Vectord&
33 {
34  m_linearSystem->computeResidual(x, this->m_residual);
35  return m_residual;
36 }
37 
38 double
40 {
41  m_linearSystem->computeResidual(x, this->m_residual);
42  return m_residual.squaredNorm();
43 }
44 
45 void
47 {
48  // Print Type
50 
51  LOG(INFO) << "Solver type (direct/iterative): Iterative";
52 }
53 
54 void
55 IterativeLinearSolver::solve(Vectord& imstkNotUsed(x))
56 {
57  LOG(WARNING) << "IterativeLinearSolver::solve is not implemented!";
58  /*
59  if (!m_linearSystem)
60  {
61  LOG(WARNING) << "The linear system should be assigned before solving!";
62  return;
63  }
64 
65  auto epsilon = m_tolerance * m_tolerance;
66  m_linearSystem->computeResidual(x, m_residual);
67 
68  for (size_t i = 0; i < m_maxIterations; ++i)
69  {
70  if (m_residual.squaredNorm() < epsilon)
71  {
72  return;
73  }
74 
75  this->iterate(x);
76  }
77  */
78 }
79 } // namespace imstk
size_t m_maxIterations
Maximum number of iterations to be performed.
virtual void solve(Vectord &x) override
Solve the linear system using Gauss-Seidel iterations.
Vectord m_residual
Storage for residual vector.
Compound Geometry.
virtual void setMaxNumIterations(const size_t maxIter)
Do one iteration of the method.
void print() const override
Print solver information.
virtual const Vectord & getResidualVector()
Return residual vector.
virtual void print() const
Print solver information.
virtual double getResidual(const Vectord &x)
Return residue in 2-norm.
std::shared_ptr< LinearSystemType > m_linearSystem
Linear system of equations.