Skip to content

Commit

Permalink
Started KSP doc
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 12, 2024
1 parent 5549b2a commit ea56889
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
6 changes: 6 additions & 0 deletions docs/src/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ Welcome to ngsPETSc's documentation!

install

.. toctree::
:maxdepth: 1
:caption: PETSc KSP

PETScKSP/poisson.py

.. toctree::
:maxdepth: 1
:caption: PETSc PC
Expand Down
16 changes: 8 additions & 8 deletions ngsPETSc/ksp.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,31 +12,31 @@ def createFromBilinearForm(a, freeDofs, solverParameters):
"""
a.Assemble()
#Setting deafult matrix type
if "mat_type" not in solverParameters:
solverParameters["mat_type"] = "aij"
if "ngs_mat_type" not in solverParameters:
solverParameters["ngs_mat_type"] = "aij"
#Assembling matrix if not of type Python
if solverParameters["mat_type"] not in ["python"]:
if solverParameters["ngs_mat_type"] not in ["python"]:
if hasattr(a.mat, "row_pardofs"):
dofs = a.mat.row_pardofs
else:
dofs = None
mat = Matrix(a.mat, (dofs, freeDofs, None), solverParameters["mat_type"])
mat = Matrix(a.mat, (dofs, freeDofs, None), solverParameters["ngs_mat_type"])
return (a.mat, mat.mat)

def createFromMatrix(a, freeDofs, solverParameters):
"""
This function creates a PETSc matrix from an NGSolve bilinear form
"""
#Setting deafult matrix type
if "mat_type" not in solverParameters:
solverParameters["mat_type"] = "aij"
if "ngs_mat_type" not in solverParameters:
solverParameters["ngs_mat_type"] = "aij"
#Assembling matrix if not of type Python
if solverParameters["mat_type"] not in ["python"]:
if solverParameters["ngs_mat_type"] not in ["python"]:
if hasattr(a, "row_pardofs"):
dofs = a.row_pardofs
else:
dofs = None
mat = Matrix(a, (dofs, freeDofs, None), solverParameters["mat_type"])
mat = Matrix(a, (dofs, freeDofs, None), solverParameters["ngs_mat_type"])
return (a, mat.mat)

def createFromPC(a, freeDofs, solverParameters):
Expand Down
Empty file added ngsPETSc/utils/ngs/__init__.py
Empty file.
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
"License :: OSI Approved :: MIT License",
"Operating System :: OS Independent",
],
packages=["ngsPETSc", "ngsPETSc.utils", "ngsPETSc.utils.firedrake"],
packages=["ngsPETSc", "ngsPETSc.utils", "ngsPETSc.utils.firedrake", "ngsPETSc.utils.ngs"],
python_requires = ">=3.8",
install_requires=install_requires

Expand Down

0 comments on commit ea56889

Please sign in to comment.