Skip to content

Commit

Permalink
Python action
Browse files Browse the repository at this point in the history
Signed-off-by: Umberto Zerbinati <[email protected]>
  • Loading branch information
Umberto Zerbinati committed Jun 15, 2024
1 parent c240c16 commit a3be966
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
6 changes: 3 additions & 3 deletions docs/src/PETScKSP/poisson.py.rst
Original file line number Diff line number Diff line change
Expand Up @@ -140,12 +140,12 @@ Notice that because in NGSolve one needs to "register" the preconditioner before


a = BilinearForm(grad(u)*grad(v)*dx)
el_bddc = Preconditioner(a, "local")
el_bddc = Preconditioner(a, "bddc")
a.Assemble()
solver = KrylovSolver(a.mat, fes.FreeDofs(), p=None,
solver = KrylovSolver(a.mat, fes.FreeDofs(), p=el_bddc.mat,
solverParameters={"ksp_type": "cg",
"ksp_monitor": "",
"pc_type": "none",
"pc_type": "mat",
"ngs_mat_type": "python",
"ksp_rtol": 1e-10})
gfu = GridFunction(fes)
Expand Down
2 changes: 1 addition & 1 deletion docs/src/PETScPC/oseen.py.rst
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ Notice that while the smoother is very similar to the one used in :doc:`stokes.p
Draw(gfu)
vtk = VTKOutput(ma=mesh, coefs=[gfu],
names = ["velocity"],
filename="Oseen_{}".format(nu.Get()),
filename="output/Oseen_{}".format(nu.Get()),
subdivision=0)
vtk.Do()

Expand Down
11 changes: 9 additions & 2 deletions ngsPETSc/ksp.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,19 @@ def mult(self, mat, X, Y):
dofs = a.row_pardofs
comm = dofs.comm.mpi4py
entrysize = a.local_mat.entrysizes[0]
_, rnumberGlobal = dofs.EnumerateGlobally(freeDofs) #samrc
elif "dofs" in solverParameters:
dofs = solverParameters["dofs"]
comm = dofs.comm.mpi4py
entrysize = dofs.entrysize
_, rnumberGlobal = dofs.EnumerateGlobally(freeDofs) #samrc
else:
dofs = None
comm = PETSc.COMM_SELF
entrysize = 1
_, rnumberGlobal = dofs.EnumerateGlobally(freeDofs) #samrc
rnumberGlobal = sum(freeDofs)
pythonA = Wrap(a, dofs, freeDofs, comm)
pscA = PETSc.Mat().create(comm=comm)
print(comm.Get_rank(),sum(freeDofs))
pscA.setSizes(size=(rnumberGlobal*entrysize,
rnumberGlobal*entrysize), bsize=entrysize)
pscA.setType("python")
Expand Down Expand Up @@ -145,6 +150,8 @@ def __init__(self, a, dofsDescr, p=None, nullspace=None, optionsPrefix="", solve
if p is not None:
for key in parse:
if isinstance(p, key):
if hasattr(ngsA, "row_pardofs"):
solverParameters["dofs"] = ngsA.row_pardofs
ngsP, pscP = parse[key](p, freeDofs, solverParameters)
break
else:
Expand Down

0 comments on commit a3be966

Please sign in to comment.