Skip to content
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

Merged
merged 25 commits into from
Apr 10, 2024

Conversation

V-Rang
Copy link
Collaborator

@V-Rang V-Rang commented Apr 3, 2024

  1. mutivec implemented in alogorithms, data is list of petsc Vectors
  2. random method modifed in utils to extend to multivectors and made more concise.

hippylibX/algorithms/multivector.py Outdated Show resolved Hide resolved
hippylibX/algorithms/multivector.py Outdated Show resolved Hide resolved
hippylibX/algorithms/multivector.py Show resolved Hide resolved
hippylibX/algorithms/multivector.py Outdated Show resolved Hide resolved
hippylibX/utils/random.py Show resolved Hide resolved
hippylibX/utils/random.py Outdated Show resolved Hide resolved
@uvilla
Copy link
Member

uvilla commented Apr 4, 2024

We also need a new file in the test suite to check the methods of MultiVector work as intended.

.github/workflows/CI_testing.yml Show resolved Hide resolved
example/poisson_dirichlet_example.py Outdated Show resolved Hide resolved
hippylibX/algorithms/cgsolverSteihaug.py Outdated Show resolved Hide resolved
hippylibX/algorithms/linalg.py Outdated Show resolved Hide resolved
hippylibX/algorithms/linalg.py Outdated Show resolved Hide resolved
hippylibX/modeling/model.py Outdated Show resolved Hide resolved
hippylibX/modeling/model.py Outdated Show resolved Hide resolved
hippylibX/test/test_eigendecomposition.py Outdated Show resolved Hide resolved
hippylibX/test/test_model.py Outdated Show resolved Hide resolved
hippylibX/test/test_multivector.py Show resolved Hide resolved
Copy link
Member

@uvilla uvilla left a 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 :)

self,
S: Any,
mpi_comm=MPI.COMM_WORLD,
init_vector=None,
Copy link
Member

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

Copy link
Collaborator Author

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:

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

) -> None:
self.S = S

if hasattr(self.S, "generate_vector"):
Copy link
Member

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.

Copy link
Collaborator Author

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:
Copy link
Member

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.

Copy link
Collaborator Author

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:

def doublePassG(
A: petsc4py.PETSc.Mat,
B: petsc4py.PETSc.Mat,
Binv: Any,
Omega: MultiVector,
k: int,
s=1,
check=False,
) -> tuple[np.array, MultiVector]:

)
M = dlx.fem.petsc.assemble_matrix(dlx.fem.form(varfM))
M.assemble()
sample_vec1 = dlx.fem.Function(Vh)
Copy link
Member

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))

Copy link
Collaborator Author

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:

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()

@V-Rang V-Rang merged commit 9d2273a into main Apr 10, 2024
1 check passed
@V-Rang V-Rang deleted the multi_vec_branch branch April 10, 2024 16:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants