Skip to content

Commit

Permalink
Merge pull request #469 from sblauth/hotfix/2.1.4
Browse files Browse the repository at this point in the history
Fix PETSc segfault issues
  • Loading branch information
sblauth authored Jul 11, 2024
2 parents 6fb903a + f906275 commit b086200
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 13 deletions.
2 changes: 1 addition & 1 deletion cashocs/_forms/control_form_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ def scalar_product(
x = fenics.as_backend_type(a[i].vector()).vec()
y = fenics.as_backend_type(b[i].vector()).vec()

temp, _ = self.riesz_projection_matrices[i].getVecs()
temp = self.riesz_projection_matrices[i].createVecRight()
self.riesz_projection_matrices[i].mult(x, temp)
result += temp.dot(y)

Expand Down
2 changes: 1 addition & 1 deletion cashocs/_forms/shape_form_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ def scalar_product(
x = fenics.as_backend_type(a[0].vector()).vec()
y = fenics.as_backend_type(b[0].vector()).vec()

temp, _ = self.scalar_product_matrix.getVecs()
temp = self.scalar_product_matrix.createVecRight()
self.scalar_product_matrix.mult(x, temp)
result = temp.dot(y)

Expand Down
6 changes: 3 additions & 3 deletions cashocs/_optimization/line_search/line_search.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,9 @@ def perform(

transfer_matrix = cast(PETSc.Mat, transfer_matrix)

_, temp = transfer_matrix.getVecs()
transfer_matrix.mult(x, temp)
self.global_deformation_vector.axpy(1.0, temp)
transfer_matrix.multAdd(
x, self.global_deformation_vector, self.global_deformation_vector
)
self.deformation_function.vector().apply("")

self.post_line_search()
Expand Down
8 changes: 3 additions & 5 deletions cashocs/_utils/linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -518,10 +518,10 @@ def solve(
A = setup_matrix_and_preconditioner(ksp, A, P)

if b is None:
return A.getVecs()[0]
return A.createVecRight()

if fun is None:
x, _ = A.getVecs()
x = A.createVecRight()
else:
x = fun.vector().vec()

Expand Down Expand Up @@ -635,9 +635,7 @@ def interpolate(self, u: fenics.Function) -> fenics.Function:
"""
v = fenics.Function(self.target_space)
x = fenics.as_backend_type(u.vector()).vec()
_, temp = self.transfer_matrix.getVecs()
self.transfer_matrix.mult(x, temp)
v.vector().vec().aypx(0.0, temp)
self.transfer_matrix.mult(x, v.vector().vec())
v.vector().apply("")

return v
Expand Down
4 changes: 2 additions & 2 deletions docs/source/_static/version_switcher.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
},
{
"name": "2.1 (stable)",
"version": "2.1.3",
"url": "https://cashocs.readthedocs.io/en/v2.1.3/",
"version": "2.1.4",
"url": "https://cashocs.readthedocs.io/en/v2.1.4/",
"preferred": true
},
{
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ classifiers = [
dependencies = [
"meshio >= 4.1.0",
"numpy",
"scipy",
"scipy",
"typing_extensions",
"matplotlib",
]
Expand Down

0 comments on commit b086200

Please sign in to comment.