@@ -1073,22 +1073,17 @@ PetscNonlinearSolver<T>::solve (SparseMatrix<T> & pre_in, // System Preconditi
10731073#endif
10741074 LibmeshPetscCall (SNESSetFromOptions (_snes ));
10751075
1076- #if defined(LIBMESH_HAVE_PETSC_HYPRE ) && !PETSC_VERSION_LESS_THAN (3 ,12 ,0 )
1077- // The above call set our PC type. If we're a hypre type we have to ensure that hypre is deployed
1078- // in the same memory space as our vector types
1079- PC pc ;
1080- LibmeshPetscCall (KSPGetPC (ksp , & pc ));
1081- PetscBool is_hypre ;
1082- LibmeshPetscCall (PetscObjectTypeCompare ((PetscObject )pc , PCHYPRE , & is_hypre ));
1083- if (is_hypre == PETSC_TRUE )
1084- {
1085- PetscScalar * dummyarray ;
1086- PetscMemType mtype ;
1087- LibmeshPetscCall (VecGetArrayAndMemType (x -> vec (), & dummyarray , & mtype ));
1088- LibmeshPetscCall (VecRestoreArrayAndMemType (x -> vec (), & dummyarray ));
1089- if (PetscMemTypeHost (mtype ))
1090- LibmeshPetscCallExternal (HYPRE_SetMemoryLocation , HYPRE_MEMORY_HOST );
1091- }
1076+ #if defined(LIBMESH_HAVE_PETSC_HYPRE ) && !PETSC_VERSION_LESS_THAN (3 ,12 ,0 ) && defined(PETSC_HAVE_HYPRE_DEVICE )
1077+ {
1078+ // Make sure hypre has been initialized
1079+ LibmeshPetscCallExternal (HYPRE_Initialize );
1080+ PetscScalar * dummyarray ;
1081+ PetscMemType mtype ;
1082+ LibmeshPetscCall (VecGetArrayAndMemType (x -> vec (), & dummyarray , & mtype ));
1083+ LibmeshPetscCall (VecRestoreArrayAndMemType (x -> vec (), & dummyarray ));
1084+ if (PetscMemTypeHost (mtype ))
1085+ LibmeshPetscCallExternal (HYPRE_SetMemoryLocation , HYPRE_MEMORY_HOST );
1086+ }
10921087#endif
10931088
10941089 if (this -> user_presolve )
0 commit comments