Hypre semi-structured solver interface for scalar fields. More...
#include <Cabana_Grid_HypreSemiStructuredSolver.hpp>
Public Types | |
using | entity_type = EntityType |
Entity type. | |
using | memory_space = MemorySpace |
Kokkos memory space.. | |
using | value_type = Scalar |
Scalar value type. | |
Public Member Functions | |
template<class ArrayLayout_t> | |
HypreSemiStructuredSolver (const ArrayLayout_t &layout, int n_vars, const bool is_preconditioner=false) | |
Hypre memory space compatibility check. | |
bool | isPreconditioner () const |
Return if this solver is a preconditioner. | |
void | createMatrixStencil (int NumSpaceDim, int var=0, int n_vars=3, std::vector< unsigned > stencil_length={ 7, 7, 7 }) |
Create the operator stencil to be filled by setMatrixStencil. | |
template<std::size_t NumSpaceDim> | |
void | setMatrixStencil (const std::vector< std::array< int, NumSpaceDim > > &stencil, int var=0, int dep=0) |
Set the operator stencil. | |
void | setSolverGraph (int n_vars) |
Set the solver graph. | |
template<class Array_t> | |
void | setMatrixValues (const Array_t &values, int v_x, int v_h) |
Set the matrix values. | |
void | printMatrix (const char *prefix) |
Print the hypre matrix to output file. | |
void | printLHS (const char *prefix) |
Print the hypre LHS to output file. | |
void | printRHS (const char *prefix) |
Print the hypre RHS to output file. | |
void | setTolerance (const double tol) |
Set convergence tolerance implementation. | |
void | setMaxIter (const int max_iter) |
Set maximum iteration implementation. | |
void | setPrintLevel (const int print_level) |
Set the output level. | |
void | setPreconditioner (const std::shared_ptr< HypreSemiStructuredSolver< Scalar, EntityType, MemorySpace > > &preconditioner) |
Set a preconditioner. | |
void | setup () |
Setup the problem. | |
template<class Array_t> | |
void | solve (const Array_t &b, Array_t &x, int n_vars=3) |
Solve the problem Ax = b for x. | |
int | getNumIter () |
Get the number of iterations taken on the last solve. | |
double | getFinalRelativeResidualNorm () |
Get the relative residual norm achieved on the last solve. | |
virtual HYPRE_SStructSolver | getHypreSolver () const =0 |
Get the preconditioner. | |
virtual HYPRE_PtrToSStructSolverFcn | getHypreSetupFunction () const =0 |
Get the preconditioner setup function. | |
virtual HYPRE_PtrToSStructSolverFcn | getHypreSolveFunction () const =0 |
Get the preconditioner solve function. | |
Public Attributes | |
const int | object_type = HYPRE_SSTRUCT |
Object Type for SStruct. | |
Protected Member Functions | |
virtual void | setToleranceImpl (const double tol)=0 |
Set convergence tolerance implementation. | |
virtual void | setMaxIterImpl (const int max_iter)=0 |
Set maximum iteration implementation. | |
virtual void | setPrintLevelImpl (const int print_level)=0 |
Set the output level. | |
virtual void | setupImpl ()=0 |
Setup implementation. | |
virtual void | solveImpl ()=0 |
Solver implementation. | |
virtual int | getNumIterImpl ()=0 |
Get the number of iterations taken on the last solve. | |
virtual double | getFinalRelativeResidualNormImpl ()=0 |
Get the relative residual norm achieved on the last solve. | |
virtual void | setPreconditionerImpl (const HypreSemiStructuredSolver< Scalar, EntityType, MemorySpace > &preconditioner)=0 |
Set a preconditioner. | |
void | checkHypreError (const int error) const |
Check a hypre error. | |
Protected Attributes | |
HYPRE_SStructMatrix | _A |
Matrix for the problem Ax = b. | |
HYPRE_SStructVector | _b |
Forcing term for the problem Ax = b. | |
HYPRE_SStructVector | _x |
Solution to the problem Ax = b. | |
Hypre semi-structured solver interface for scalar fields.
|
inline |
Hypre memory space compatibility check.
Constructor.
layout | The array layout defining the vector space of the solver. |
n_vars | Number of variable in the system domain |
is_preconditioner | Flag indicating if this solver will be used as a preconditioner. |
|
inline |
Create the operator stencil to be filled by setMatrixStencil.
NumSpaceDim | The number of spatial dimensions in the linear system being solved. |
var | The variable number that the stencil corresponds to, in essence which equation number in the linear system |
n_vars | number of variables in the linear system |
stencil_length | A vector containing the length of the stencil for variable var for each variable in the system to be created for HYPRE |
|
protectedpure virtual |
Get the relative residual norm achieved on the last solve.
Implemented in Cabana::Grid::HypreSemiStructBiCGSTAB< Scalar, EntityType, MemorySpace >, Cabana::Grid::HypreSemiStructDiagonal< Scalar, EntityType, MemorySpace >, Cabana::Grid::HypreSemiStructGMRES< Scalar, EntityType, MemorySpace >, and Cabana::Grid::HypreSemiStructPCG< Scalar, EntityType, MemorySpace >.
|
pure virtual |
Get the preconditioner setup function.
Implemented in Cabana::Grid::HypreSemiStructBiCGSTAB< Scalar, EntityType, MemorySpace >, Cabana::Grid::HypreSemiStructDiagonal< Scalar, EntityType, MemorySpace >, Cabana::Grid::HypreSemiStructGMRES< Scalar, EntityType, MemorySpace >, and Cabana::Grid::HypreSemiStructPCG< Scalar, EntityType, MemorySpace >.
|
pure virtual |
Get the preconditioner solve function.
Implemented in Cabana::Grid::HypreSemiStructBiCGSTAB< Scalar, EntityType, MemorySpace >, Cabana::Grid::HypreSemiStructDiagonal< Scalar, EntityType, MemorySpace >, Cabana::Grid::HypreSemiStructGMRES< Scalar, EntityType, MemorySpace >, and Cabana::Grid::HypreSemiStructPCG< Scalar, EntityType, MemorySpace >.
|
pure virtual |
Get the preconditioner.
Implemented in Cabana::Grid::HypreSemiStructBiCGSTAB< Scalar, EntityType, MemorySpace >, Cabana::Grid::HypreSemiStructDiagonal< Scalar, EntityType, MemorySpace >, Cabana::Grid::HypreSemiStructGMRES< Scalar, EntityType, MemorySpace >, and Cabana::Grid::HypreSemiStructPCG< Scalar, EntityType, MemorySpace >.
|
protectedpure virtual |
Get the number of iterations taken on the last solve.
Implemented in Cabana::Grid::HypreSemiStructBiCGSTAB< Scalar, EntityType, MemorySpace >, Cabana::Grid::HypreSemiStructDiagonal< Scalar, EntityType, MemorySpace >, Cabana::Grid::HypreSemiStructGMRES< Scalar, EntityType, MemorySpace >, and Cabana::Grid::HypreSemiStructPCG< Scalar, EntityType, MemorySpace >.
|
inline |
Print the hypre LHS to output file.
prefix | File prefix for where hypre output is written |
|
inline |
Print the hypre matrix to output file.
prefix | File prefix for where hypre output is written |
|
inline |
Print the hypre RHS to output file.
prefix | File prefix for where hypre output is written |
|
inline |
Set the operator stencil.
stencil | The (i,j,k) offsets describing the structured matrix entries at each grid point. Offsets are defined relative to an index. |
var | The variable number that the stencil corresponds to, in essence which equation number in the linear system |
dep | The integer for the independent variable in the linear system that is currently being set |
|
inline |
Set the matrix values.
values | The matrix entry values. For each entity over which the vector space is defined an entry for each stencil element is required. The order of the stencil elements is that same as that in the stencil definition. Note that values corresponding to stencil entries outside of the domain should be set to zero. |
v_x | The variable index for the independent variable (column) that is being set by the current call to setMatrixValues |
v_h | The variable index for the equation (row) that is being set by the current call to setMatrixValues |
|
protectedpure virtual |
Set maximum iteration implementation.
Implemented in Cabana::Grid::HypreSemiStructBiCGSTAB< Scalar, EntityType, MemorySpace >, Cabana::Grid::HypreSemiStructDiagonal< Scalar, EntityType, MemorySpace >, Cabana::Grid::HypreSemiStructGMRES< Scalar, EntityType, MemorySpace >, and Cabana::Grid::HypreSemiStructPCG< Scalar, EntityType, MemorySpace >.
|
protectedpure virtual |
Set a preconditioner.
Implemented in Cabana::Grid::HypreSemiStructBiCGSTAB< Scalar, EntityType, MemorySpace >, Cabana::Grid::HypreSemiStructDiagonal< Scalar, EntityType, MemorySpace >, Cabana::Grid::HypreSemiStructGMRES< Scalar, EntityType, MemorySpace >, and Cabana::Grid::HypreSemiStructPCG< Scalar, EntityType, MemorySpace >.
|
protectedpure virtual |
Set the output level.
Implemented in Cabana::Grid::HypreSemiStructBiCGSTAB< Scalar, EntityType, MemorySpace >, Cabana::Grid::HypreSemiStructDiagonal< Scalar, EntityType, MemorySpace >, Cabana::Grid::HypreSemiStructGMRES< Scalar, EntityType, MemorySpace >, and Cabana::Grid::HypreSemiStructPCG< Scalar, EntityType, MemorySpace >.
|
inline |
Set the solver graph.
n_vars | The number of variables (and equations) in the specified problem domain |
|
protectedpure virtual |
Set convergence tolerance implementation.
Implemented in Cabana::Grid::HypreSemiStructBiCGSTAB< Scalar, EntityType, MemorySpace >, Cabana::Grid::HypreSemiStructDiagonal< Scalar, EntityType, MemorySpace >, Cabana::Grid::HypreSemiStructGMRES< Scalar, EntityType, MemorySpace >, and Cabana::Grid::HypreSemiStructPCG< Scalar, EntityType, MemorySpace >.
|
protectedpure virtual |
Setup implementation.
Implemented in Cabana::Grid::HypreSemiStructBiCGSTAB< Scalar, EntityType, MemorySpace >, Cabana::Grid::HypreSemiStructDiagonal< Scalar, EntityType, MemorySpace >, Cabana::Grid::HypreSemiStructGMRES< Scalar, EntityType, MemorySpace >, and Cabana::Grid::HypreSemiStructPCG< Scalar, EntityType, MemorySpace >.
|
inline |
Solve the problem Ax = b for x.
b | The forcing term. |
x | The solution. |
n_vars | Number of variables in the solution domain |
|
protectedpure virtual |
Solver implementation.
Implemented in Cabana::Grid::HypreSemiStructBiCGSTAB< Scalar, EntityType, MemorySpace >, Cabana::Grid::HypreSemiStructDiagonal< Scalar, EntityType, MemorySpace >, Cabana::Grid::HypreSemiStructGMRES< Scalar, EntityType, MemorySpace >, and Cabana::Grid::HypreSemiStructPCG< Scalar, EntityType, MemorySpace >.