| 62 | """ + linear_solver_param_doc |
| 63 | name = "LinearSolver" |
| 64 | def __init__(self, mat : BaseMatrix, |
| 65 | pre : Optional[Preconditioner] = None, |
| 66 | freedofs : Optional[BitArray] = None, |
| 67 | tol : float = None, |
| 68 | maxiter : int = 100, |
| 69 | atol : float = None, |
| 70 | callback : Optional[Callable[[int, float], None]] = None, |
| 71 | callback_sol : Optional[Callable[[BaseVector], None]] = None, |
| 72 | printrates : bool = False, |
| 73 | plotrates : bool = False): |
| 74 | super().__init__() |
| 75 | if atol is None and tol is None: |
| 76 | tol = 1e-12 |
| 77 | self.mat = mat |
| 78 | assert (freedofs is None) != (pre is None) # either pre or freedofs must be given |
| 79 | self.pre = pre if pre else Projector(freedofs, True) |
| 80 | self.tol = tol |
| 81 | self.atol = atol |
| 82 | self.maxiter = maxiter |
| 83 | self.callback = callback |
| 84 | self.callback_sol = callback_sol |
| 85 | self.printrates = printrates |
| 86 | self.plotrates = plotrates |
| 87 | self.residuals = [] |
| 88 | self.iterations = 0 |
| 89 | |
| 90 | @TimeFunction |
| 91 | def Solve(self, rhs : BaseVector, sol : Optional[BaseVector] = None, |