Cabana 0.8.0-dev
 
Loading...
Searching...
No Matches
Cabana::Grid::HypreSemiStructuredSolver< Scalar, EntityType, MemorySpace > Class Template Referenceabstract

Hypre semi-structured solver interface for scalar fields. More...

#include <Cabana_Grid_HypreSemiStructuredSolver.hpp>

Inheritance diagram for Cabana::Grid::HypreSemiStructuredSolver< Scalar, EntityType, MemorySpace >:

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.
 

Detailed Description

template<class Scalar, class EntityType, class MemorySpace>
class Cabana::Grid::HypreSemiStructuredSolver< Scalar, EntityType, MemorySpace >

Hypre semi-structured solver interface for scalar fields.

Constructor & Destructor Documentation

◆ HypreSemiStructuredSolver()

template<class Scalar, class EntityType, class MemorySpace>
template<class ArrayLayout_t>
Cabana::Grid::HypreSemiStructuredSolver< Scalar, EntityType, MemorySpace >::HypreSemiStructuredSolver ( const ArrayLayout_t & layout,
int n_vars,
const bool is_preconditioner = false )
inline

Hypre memory space compatibility check.

Constructor.

Parameters
layoutThe array layout defining the vector space of the solver.
n_varsNumber of variable in the system domain
is_preconditionerFlag indicating if this solver will be used as a preconditioner.

Member Function Documentation

◆ createMatrixStencil()

template<class Scalar, class EntityType, class MemorySpace>
void Cabana::Grid::HypreSemiStructuredSolver< Scalar, EntityType, MemorySpace >::createMatrixStencil ( int NumSpaceDim,
int var = 0,
int n_vars = 3,
std::vector< unsigned > stencil_length = { 7, 7, 7 } )
inline

Create the operator stencil to be filled by setMatrixStencil.

Parameters
NumSpaceDimThe number of spatial dimensions in the linear system being solved.
varThe variable number that the stencil corresponds to, in essence which equation number in the linear system
n_varsnumber of variables in the linear system
stencil_lengthA vector containing the length of the stencil for variable var for each variable in the system to be created for HYPRE

◆ getFinalRelativeResidualNormImpl()

template<class Scalar, class EntityType, class MemorySpace>
virtual double Cabana::Grid::HypreSemiStructuredSolver< Scalar, EntityType, MemorySpace >::getFinalRelativeResidualNormImpl ( )
protectedpure virtual

◆ getHypreSetupFunction()

template<class Scalar, class EntityType, class MemorySpace>
virtual HYPRE_PtrToSStructSolverFcn Cabana::Grid::HypreSemiStructuredSolver< Scalar, EntityType, MemorySpace >::getHypreSetupFunction ( ) const
pure virtual

◆ getHypreSolveFunction()

template<class Scalar, class EntityType, class MemorySpace>
virtual HYPRE_PtrToSStructSolverFcn Cabana::Grid::HypreSemiStructuredSolver< Scalar, EntityType, MemorySpace >::getHypreSolveFunction ( ) const
pure virtual

◆ getHypreSolver()

template<class Scalar, class EntityType, class MemorySpace>
virtual HYPRE_SStructSolver Cabana::Grid::HypreSemiStructuredSolver< Scalar, EntityType, MemorySpace >::getHypreSolver ( ) const
pure virtual

◆ getNumIterImpl()

template<class Scalar, class EntityType, class MemorySpace>
virtual int Cabana::Grid::HypreSemiStructuredSolver< Scalar, EntityType, MemorySpace >::getNumIterImpl ( )
protectedpure virtual

◆ printLHS()

template<class Scalar, class EntityType, class MemorySpace>
void Cabana::Grid::HypreSemiStructuredSolver< Scalar, EntityType, MemorySpace >::printLHS ( const char * prefix)
inline

Print the hypre LHS to output file.

Parameters
prefixFile prefix for where hypre output is written

◆ printMatrix()

template<class Scalar, class EntityType, class MemorySpace>
void Cabana::Grid::HypreSemiStructuredSolver< Scalar, EntityType, MemorySpace >::printMatrix ( const char * prefix)
inline

Print the hypre matrix to output file.

Parameters
prefixFile prefix for where hypre output is written

◆ printRHS()

template<class Scalar, class EntityType, class MemorySpace>
void Cabana::Grid::HypreSemiStructuredSolver< Scalar, EntityType, MemorySpace >::printRHS ( const char * prefix)
inline

Print the hypre RHS to output file.

Parameters
prefixFile prefix for where hypre output is written

◆ setMatrixStencil()

template<class Scalar, class EntityType, class MemorySpace>
template<std::size_t NumSpaceDim>
void Cabana::Grid::HypreSemiStructuredSolver< Scalar, EntityType, MemorySpace >::setMatrixStencil ( const std::vector< std::array< int, NumSpaceDim > > & stencil,
int var = 0,
int dep = 0 )
inline

Set the operator stencil.

Parameters
stencilThe (i,j,k) offsets describing the structured matrix entries at each grid point. Offsets are defined relative to an index.
varThe variable number that the stencil corresponds to, in essence which equation number in the linear system
depThe integer for the independent variable in the linear system that is currently being set

◆ setMatrixValues()

template<class Scalar, class EntityType, class MemorySpace>
template<class Array_t>
void Cabana::Grid::HypreSemiStructuredSolver< Scalar, EntityType, MemorySpace >::setMatrixValues ( const Array_t & values,
int v_x,
int v_h )
inline

Set the matrix values.

Parameters
valuesThe 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_xThe variable index for the independent variable (column) that is being set by the current call to setMatrixValues
v_hThe variable index for the equation (row) that is being set by the current call to setMatrixValues

◆ setMaxIterImpl()

template<class Scalar, class EntityType, class MemorySpace>
virtual void Cabana::Grid::HypreSemiStructuredSolver< Scalar, EntityType, MemorySpace >::setMaxIterImpl ( const int max_iter)
protectedpure virtual

◆ setPreconditionerImpl()

template<class Scalar, class EntityType, class MemorySpace>
virtual void Cabana::Grid::HypreSemiStructuredSolver< Scalar, EntityType, MemorySpace >::setPreconditionerImpl ( const HypreSemiStructuredSolver< Scalar, EntityType, MemorySpace > & preconditioner)
protectedpure virtual

◆ setPrintLevelImpl()

template<class Scalar, class EntityType, class MemorySpace>
virtual void Cabana::Grid::HypreSemiStructuredSolver< Scalar, EntityType, MemorySpace >::setPrintLevelImpl ( const int print_level)
protectedpure virtual

◆ setSolverGraph()

template<class Scalar, class EntityType, class MemorySpace>
void Cabana::Grid::HypreSemiStructuredSolver< Scalar, EntityType, MemorySpace >::setSolverGraph ( int n_vars)
inline

Set the solver graph.

Parameters
n_varsThe number of variables (and equations) in the specified problem domain

◆ setToleranceImpl()

template<class Scalar, class EntityType, class MemorySpace>
virtual void Cabana::Grid::HypreSemiStructuredSolver< Scalar, EntityType, MemorySpace >::setToleranceImpl ( const double tol)
protectedpure virtual

◆ setupImpl()

◆ solve()

template<class Scalar, class EntityType, class MemorySpace>
template<class Array_t>
void Cabana::Grid::HypreSemiStructuredSolver< Scalar, EntityType, MemorySpace >::solve ( const Array_t & b,
Array_t & x,
int n_vars = 3 )
inline

Solve the problem Ax = b for x.

Parameters
bThe forcing term.
xThe solution.
n_varsNumber of variables in the solution domain

◆ solveImpl()


The documentation for this class was generated from the following file: