| 20 | |
| 21 | |
| 22 | def run(self, b): |
| 23 | logging.info(" AMG_python") |
| 24 | A = self.get_A0() |
| 25 | if self.copy_A: |
| 26 | A = A.copy()#FIXME: softbody no copy will cause bug, but cloth is good, why? |
| 27 | |
| 28 | if self.should_setup(): |
| 29 | tic = time.perf_counter() |
| 30 | self.Ps = build_Ps(A, self.args) |
| 31 | self.num_levels = len(self.Ps) + 1 |
| 32 | logging.info(f" build_Ps time:{time.perf_counter()-tic}") |
| 33 | |
| 34 | tic = time.perf_counter() |
| 35 | levels = self.build_levels(A, self.Ps) |
| 36 | logging.info(f" build_levels time:{time.perf_counter()-tic}") |
| 37 | |
| 38 | if self.should_setup(): |
| 39 | tic = time.perf_counter() |
| 40 | self.setup_smoothers(A) |
| 41 | logging.info(f" setup smoothers time:{perf_counter()-tic}") |
| 42 | x0 = np.zeros_like(b) |
| 43 | tic = time.perf_counter() |
| 44 | x, r_Axb = self.old_amg_cg_solve(levels, b, x0=x0, maxiter=self.args.maxiter_Axb, tol=self.args.tol_Axb) |
| 45 | toc = time.perf_counter() |
| 46 | logging.info(f" mgsolve time {toc-tic}") |
| 47 | return x, r_Axb |
| 48 | |
| 49 | |
| 50 | # https://github.com/pyamg/pyamg/blob/5a51432782c8f96f796d7ae35ecc48f81b194433/pyamg/relaxation/relaxation.py#L586 |