| 383 | } // allocateHypreData |
| 384 | |
| 385 | void |
| 386 | SCPoissonHypreLevelSolver::setMatrixCoefficients() |
| 387 | { |
| 388 | for (PatchLevel<NDIM>::Iterator p(d_level); p; p++) |
| 389 | { |
| 390 | Pointer<Patch<NDIM>> patch = d_level->getPatch(p()); |
| 391 | const Box<NDIM>& patch_box = patch->getBox(); |
| 392 | const auto stencil_size = d_stencil_offsets.size(); |
| 393 | SideData<NDIM, double> matrix_coefs(patch_box, stencil_size, IntVector<NDIM>(0)); |
| 394 | PoissonUtilities::computeMatrixCoefficients( |
| 395 | matrix_coefs, patch, d_stencil_offsets, d_poisson_spec, d_bc_coefs, d_solution_time); |
| 396 | |
| 397 | // Copy matrix entries to the hypre matrix structure. |
| 398 | std::vector<HYPRE_Int> stencil_indices(stencil_size); |
| 399 | std::iota(stencil_indices.begin(), stencil_indices.end(), HYPRE_Int(0)); |
| 400 | std::vector<double> mat_vals(stencil_size, 0.0); |
| 401 | for (unsigned int axis = 0; axis < NDIM; ++axis) |
| 402 | { |
| 403 | Box<NDIM> side_box = SideGeometry<NDIM>::toSideBox(patch_box, axis); |
| 404 | for (Box<NDIM>::Iterator b(side_box); b; b++) |
| 405 | { |
| 406 | SideIndex<NDIM> i(b(), axis, SideIndex<NDIM>::Lower); |
| 407 | for (unsigned int k = 0; k < stencil_size; ++k) |
| 408 | { |
| 409 | mat_vals[k] = matrix_coefs(i, k); |
| 410 | } |
| 411 | // NOTE: In SAMRAI, face-centered values are associated with the |
| 412 | // cell index located on the "upper" side of the face, but in |
| 413 | // hypre, face-centered values are associated with the cell |
| 414 | // index located on the "lower" side of the face. Similarly, |
| 415 | // in SAMRAI the index stores its axis, but here hypre expects |
| 416 | // that to be a second argument (so slicing i is okay). |
| 417 | i(axis) -= 1; |
| 418 | auto hypre_i = hypre_array(i); |
| 419 | HYPRE_SStructMatrixSetValues(d_matrix, |
| 420 | PART, |
| 421 | hypre_i.data(), |
| 422 | axis, |
| 423 | stencil_indices.size(), |
| 424 | stencil_indices.data(), |
| 425 | mat_vals.data()); |
| 426 | } |
| 427 | } |
| 428 | } |
| 429 | |
| 430 | // Assemble the hypre matrix. |
| 431 | HYPRE_SStructMatrixAssemble(d_matrix); |
| 432 | return; |
| 433 | } // setMatrixCoefficients |
| 434 | |
| 435 | void |
| 436 | SCPoissonHypreLevelSolver::setupHypreSolver() |
nothing calls this directly
no test coverage detected