void hypre_F90_IFACE(hypre_structvectorsetnumghost, HYPRE_STRUCTVECTORSETNUMGHOST) ( hypre_F90_Obj *vector, hypre_F90_IntArray *num_ghost, hypre_F90_Int *ierr ) { *ierr = (hypre_F90_Int) ( HYPRE_StructVectorSetNumGhost( hypre_F90_PassObj (HYPRE_StructVector, vector), hypre_F90_PassIntArray (num_ghost) ) ); }
void CCDivGradHypreLevelSolver::allocateHypreData() { // Get the MPI communicator. #ifdef HAVE_MPI MPI_Comm communicator = SAMRAI_MPI::getCommunicator(); #else MPI_Comm communicator; #endif // Setup the hypre grid. Pointer<PatchLevel<NDIM> > level = d_hierarchy->getPatchLevel(d_level_num); Pointer<CartesianGridGeometry<NDIM> > grid_geometry = d_hierarchy->getGridGeometry(); const IntVector<NDIM>& ratio = level->getRatio(); const IntVector<NDIM>& periodic_shift = grid_geometry->getPeriodicShift(ratio); #ifdef DEBUG_CHECK_ASSERTIONS TBOX_ASSERT(periodic_shift.min() > 0); #endif HYPRE_StructGridCreate(communicator, NDIM, &d_grid); for (PatchLevel<NDIM>::Iterator p(level); p; p++) { const Box<NDIM> patch_box = Box<NDIM>::coarsen(level->getPatch(p())->getBox(),2); Index<NDIM> lower = patch_box.lower(); Index<NDIM> upper = patch_box.upper(); HYPRE_StructGridSetExtents(d_grid, lower, upper); } int hypre_periodic_shift[3]; for (unsigned int d = 0; d < NDIM; ++d) { hypre_periodic_shift[d] = periodic_shift(d)/2; } for (int d = NDIM; d < 3; ++d) { hypre_periodic_shift[d] = 0; } HYPRE_StructGridSetPeriodic(d_grid, hypre_periodic_shift); HYPRE_StructGridAssemble(d_grid); // Allocate stencil data and set stencil offsets. static const int stencil_sz = 2*NDIM+1; #if (NDIM == 2) int stencil_offsets[stencil_sz][2] = { { -1, 0 }, { 0, -1}, { +1, 0}, { 0, +1 }, { 0, 0 } }; #endif #if (NDIM == 3) int stencil_offsets[stencil_sz][3] = { { -1, 0, 0}, { 0, -1, 0}, { 0, 0, -1}, { +1, 0, 0}, { 0, +1, 0}, { 0, 0, +1}, { 0, 0, 0} }; #endif HYPRE_StructStencilCreate(NDIM, stencil_sz, &d_stencil); for (int s = 0; s < stencil_sz; ++s) { HYPRE_StructStencilSetElement(d_stencil, s, stencil_offsets[s]); } // Allocate the hypre matrix. #if (NDIM == 2) int full_ghosts[2*3] = { 1, 1, 1, 1, 0, 0 }; #endif #if (NDIM == 3) int full_ghosts[2*3] = { 1, 1, 1, 1, 1, 1 }; #endif int no_ghosts[2*3] = { 0, 0, 0, 0, 0, 0 }; HYPRE_StructMatrixCreate(communicator, d_grid, d_stencil, &d_matrix); HYPRE_StructMatrixSetNumGhost(d_matrix, full_ghosts); HYPRE_StructMatrixSetSymmetric(d_matrix, 0); HYPRE_StructMatrixInitialize(d_matrix); // Allocate the hypre vectors. HYPRE_StructVectorCreate(communicator, d_grid, &d_sol_vec); HYPRE_StructVectorSetNumGhost(d_sol_vec, full_ghosts); HYPRE_StructVectorInitialize(d_sol_vec); HYPRE_StructVectorCreate(communicator, d_grid, &d_rhs_vec); HYPRE_StructVectorSetNumGhost(d_rhs_vec, no_ghosts); HYPRE_StructVectorInitialize(d_rhs_vec); return; }// allocateHypreData