-
Notifications
You must be signed in to change notification settings - Fork 160
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
from firedrake.preconditioners.base import PCBase | ||
from firedrake.preconditioners.patch import bcdofs | ||
from firedrake.petsc import PETSc | ||
from firedrake.dmhooks import get_appctx | ||
import numpy | ||
|
||
|
||
__all__ = ("BDDCPC",) | ||
|
||
|
||
class BDDCPC(PCBase): | ||
"""PC for PETSc PCBDDC""" | ||
|
||
_prefix = "bddc" | ||
|
||
def initialize(self, pc): | ||
# Get context from pc | ||
_, P = pc.getOperators() | ||
dm = pc.getDM() | ||
self.prefix = pc.getOptionsPrefix() + self._prefix | ||
|
||
# Create new PC object as BDDC type | ||
bddcpc = PETSc.PC().create(comm=pc.comm) | ||
bddcpc.incrementTabLevel(1, parent=pc) | ||
bddcpc.setOptionsPrefix(self.prefix) | ||
bddcpc.setOperators(*pc.getOperators()) | ||
bddcpc.setType(PETSc.PC.Type.BDDC) | ||
|
||
ctx = get_appctx(dm) | ||
bcs = tuple(ctx._problem.bcs) | ||
if len(bcs) > 0: | ||
bc_nodes = numpy.unique(numpy.concatenate([bcdofs(bc, ghost=False) for bc in bcs])) | ||
bndr = PETSc.IS().createGeneral(bc_nodes, comm=pc.comm) | ||
bddcpc.setBDDCDirichletBoundariesLocal(bndr) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
stefanozampini
Contributor
|
||
|
||
bddcpc.setFromOptions() | ||
self.pc = bddcpc | ||
|
||
def view(self, pc, viewer=None): | ||
self.pc.view(viewer=viewer) | ||
|
||
def update(self, pc): | ||
pass | ||
|
||
def apply(self, pc, x, y): | ||
self.pc.apply(x, y) | ||
|
||
def applyTranspose(self, pc, x, y): | ||
self.pc.applyTranspose(x, y) |
bcdofs is in global ordering? if so, you must remove the Local from the BDDC call.
Local is always an ordering associated with the way you create the MATIS.
Try to use global ordering here, BDDC will do the proper global to local inside the setup