Solve BVP over selected subproblems. Parameters ---------- subproblems : Subproblem object or list of Subproblem objects, optional Subproblems for which to solve the BVP (default: None (all)). rebuild_matrices : bool, optional Rebuild
(self, subproblems=None, rebuild_matrices=False)
| 367 | print(f"MPI rank: {self.dist.comm.rank}, subproblem: {i}, group: {sp.group}, matrix rank: {np.linalg.matrix_rank(L)}/{L.shape[0]}, cond: {np.linalg.cond(L):.1e}") |
| 368 | |
| 369 | def solve(self, subproblems=None, rebuild_matrices=False): |
| 370 | """ |
| 371 | Solve BVP over selected subproblems. |
| 372 | |
| 373 | Parameters |
| 374 | ---------- |
| 375 | subproblems : Subproblem object or list of Subproblem objects, optional |
| 376 | Subproblems for which to solve the BVP (default: None (all)). |
| 377 | rebuild_matrices : bool, optional |
| 378 | Rebuild LHS matrices if coefficients have changed (default: False). |
| 379 | """ |
| 380 | # Resolve subproblems |
| 381 | if subproblems is None: |
| 382 | subproblems = self.subproblems |
| 383 | if isinstance(subproblems, subsystems.Subproblem): |
| 384 | subproblems = [subproblems] |
| 385 | # Build matrices and matsolvers if directed or not yet built |
| 386 | if rebuild_matrices: |
| 387 | sp_to_build = subproblems |
| 388 | else: |
| 389 | sp_to_build = [sp for sp in subproblems if sp not in self.subproblem_matsolvers] |
| 390 | if sp_to_build: |
| 391 | self.build_matrices(sp_to_build, ['L']) |
| 392 | for sp in sp_to_build: |
| 393 | self.subproblem_matsolvers[sp] = self.matsolver(sp.L_min, self) |
| 394 | # Compute RHS |
| 395 | self.evaluator.evaluate_scheduled(iteration=self.iteration) |
| 396 | # Ensure coeff space before subsystem gathers/scatters |
| 397 | for field in self.F: |
| 398 | field.change_layout('c') |
| 399 | for field in self.state: |
| 400 | field.preset_layout('c') |
| 401 | # Solve system for each subproblem |
| 402 | for sp in subproblems: |
| 403 | # Gather RHS |
| 404 | spF = sp.gather_outputs(self.F) |
| 405 | # Solve |
| 406 | spX = self.subproblem_matsolvers[sp].solve(spF) # CREATES TEMPORARY |
| 407 | # Scatter solution |
| 408 | sp.scatter_inputs(spX, self.state) |
| 409 | self.iteration += 1 |
| 410 | |
| 411 | def evaluate_handlers(self, handlers=None): |
| 412 | """Evaluate specified list of handlers (all by default).""" |