On Mon, Feb 7, 2022 at 9:17 AM Sijie Tang <[email protected]> wrote:
> I make a mistake there is no hypre_ParCSRVector, that should be > hypre_ParVector. > > Sijie > > On Feb 5, 2022, at 21:53, Sijie Tang <[email protected]> wrote: > > Hi developer, > > I have many questions about he Matrix and Vector Format Convert between > PETSc and HYPRE, could you give me some answers or hints? > > > 1. Can I convert MATHYPRE (in PETSc) to hypre_ParCSRMatrix ( HYPRE ) > use function MatHYPREGetParCSR() (in PETSc) ? > > You specify a hypre matrix with '-mat_type hypre' and then you can use: PetscErrorCode MatHYPREGetParCSR(Mat A, hypre_ParCSRMatrix **parcsr) > > 1. for 2, or I should use MatHYPRE_IJMatrixCreate and > MatHYPRE_IJMatrixCopy to get hypre_IJMatrix, then hypre_IJMatrix > convert to hypre_ParCSRMatrix ? > > Not sure. It easier to use MatSetFromOptions and '-mat_type hypre' as above > > 1. for the vector, I don't find any function can convert vector in > PETSc to hypre_ParCSRVector, Is there any function can do this work ? > > We don't use hypre vectors, or at least we don't expose them. You specify the vector type (CPU is the default) like -vec_type cuda Then you use a normal Vec in your code. And use MatCreateVecs to get the right type. Hypre will use the device if it is available and MatCreateVecs will create the correct type. > > 1. But I find I can use VecHYPRE_IJVectorCreate and VecHYPRE_IJVectorCopy > to get hypre_IJVector, then hypre_IJVector convert to > hypre_ParCSRVector? > 2. Is there any function can convert the format back? like > hypre_ParCSRMatrix > convert to MATHYPRE, > > Maybe. I don't see docs on this (very new) but I see: include/petscmathypre.h:PETSC_EXTERN PetscErrorCode MatCreateFromParCSR(hypre_ParCSRMatrix*,MatType,PetscCopyMode,Mat*); And there is a test that you should look at that tests hypre matrices: src/mat/tests/ex115.c Mark > > 1. and hypre_ParCSRVector convert to PETSc's vector? > > > Thanks, > Sijie > > >
