-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mutivec implemented in algorithms, random method modifed in utils #19
Conversation
V-Rang
commented
Apr 3, 2024
- mutivec implemented in alogorithms, data is list of petsc Vectors
- random method modifed in utils to extend to multivectors and made more concise.
We also need a new file in the test suite to check the methods of MultiVector work as intended. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Last minor tweaks missing before we can merge :)
hippylibX/algorithms/linalg.py
Outdated
self, | ||
S: Any, | ||
mpi_comm=MPI.COMM_WORLD, | ||
init_vector=None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's replace init_vector=None
with createVecLeft=None
and createVecRight=None
.
This two input arguments will be user-defined function handler that can be used to generate the correct vectors for this operator.
Then inside the class do:
self.createVecLeft = createVecLeft
self.createVecRight = createVecRight
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modifications have been made here:
hippylibx/hippylibX/algorithms/linalg.py
Lines 11 to 21 in 9d2273a
class Solver2Operator: | |
def __init__( | |
self, | |
S: Any, | |
mpi_comm=MPI.COMM_WORLD, | |
createVecLeft=None, | |
createVecRight=None, | |
) -> None: | |
self.S = S | |
self.createVecLeft = createVecLeft | |
self.createVecRight = createVecRight |
hippylibX/algorithms/linalg.py
Outdated
) -> None: | ||
self.S = S | ||
|
||
if hasattr(self.S, "generate_vector"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
self.tmp
is not used anymore. self.tmp
was used only in the inner
method that we delete.
You can safely remove all this piece of code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code has been removed.
k: int, | ||
s=1, | ||
check=False, | ||
) -> dict: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The return type dict
is not correct here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
return type changed to tuple:
hippylibx/hippylibX/algorithms/randomizedEigensolver.py
Lines 9 to 17 in 9d2273a
def doublePassG( | |
A: petsc4py.PETSc.Mat, | |
B: petsc4py.PETSc.Mat, | |
Binv: Any, | |
Omega: MultiVector, | |
k: int, | |
s=1, | |
check=False, | |
) -> tuple[np.array, MultiVector]: |
hippylibX/test/test_multivector.py
Outdated
) | ||
M = dlx.fem.petsc.assemble_matrix(dlx.fem.form(varfM)) | ||
M.assemble() | ||
sample_vec1 = dlx.fem.Function(Vh) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can simply write:
sample_petsc_vec = dlx.fem.petsc.create_vector(dlx.fem.form(test*ufl.dx))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the suggestion. Code changed here:
hippylibx/hippylibX/test/test_multivector.py
Lines 28 to 31 in 9d2273a
M.assemble() | |
sample_petsc_vec = dlx.fem.petsc.create_vector(dlx.fem.form(test * ufl.dx)) | |
Omega = hpx.MultiVector.createFromVec(sample_petsc_vec, nvec) | |
sample_petsc_vec.destroy() |