DFT-EFE
 
Loading...
Searching...
No Matches
dftefe::linearAlgebra Namespace Reference

Namespaces

namespace  blasLapack
 
namespace  CGLinearSolverInternal
 
namespace  LanczosExtremeEigenSolverInternal
 
namespace  OrthonormalizationFunctionsInternal
 

Classes

class  ChebyshevFilteredEigenSolver
 A derived class of OperatorContext to encapsulate the action of a discrete operator on vectors, matrices, etc. More...
 
struct  EigenSolverError
 
class  EigenSolverErrorMsg
 
class  IdentityOperatorContext
 Abstract class to encapsulate the action of a discrete operator on vectors, matrices, etc. More...
 
class  JacobiPreconditioner
 A class to encapsulate the Jacobi preconditioner in a linear or non-linear solve. More...
 
class  LanczosExtremeEigenSolver
 A derived class of OperatorContext to encapsulate the action of a discrete operator on vectors, matrices, etc. More...
 
struct  LapackError
 
class  LapackErrorMsg
 A class to map Error to a message. More...
 
class  LinAlgOpContext
 
class  LinearAlgebraProfiler
 
class  LinearSolverDefaults
 
struct  LinearSolverError
 
class  LinearSolverErrorMsg
 A class to map Error to a message. More...
 
class  LinearSolverImpl
 Abstract class that implements the LinearSolver algorithm. For example, the derived classes of it, such as CGLinearSolver, GMRESLinearSolver implement the Conjugate-Gradient (CG) and Generalized Minimum Residual (GMRES) Krylov subspace based approches, respectively, to solve a linear system of equations. More...
 
class  MultiPassLowdinDefaults
 
class  MultiVector
 An class template to encapsulate a MultiVector. A MultiVector is a collection of \(N\) vectors belonging to the same finite-dimensional vector space, where usual notion of vector size denotes the dimension of the vector space. Note that this in the mathematical sense and not in the sense of an multi-dimensional array.The MultiVector is stored contiguously with the vector index being the fastest index, or in other words a matrix of size \(M \times N\) in row major format with \(M \) denoting the dimension of the vector space (size of individual vector). More...
 
struct  NewtonRaphsonError
 
class  NewtonRaphsonErrorMsg
 
class  NewtonRaphsonSolver
 A class that implements the Newton-Raphson solver to find root of a function. More...
 
class  NewtonRaphsonSolverFunction
 
class  OperatorContext
 Abstract class to encapsulate the action of a discrete operator on vectors, matrices, etc. More...
 
struct  OrthonormalizationError
 
class  OrthonormalizationErrorMsg
 
class  OrthonormalizationFunctions
 
class  Preconditioner
 Abstract class to encapsulate a preconditioner. More...
 
class  PreconditionerJacobi
 Class to encapsulate the Jacobi preconditioner. More...
 
class  PreconditionerNone
 Class to encapsulate the NONE preconditioner. Just takes in a vector and returns it. More...
 
class  PrintControlDefaults
 
class  RayleighRitzEigenSolver
 A derived class of OperatorContext to encapsulate the action of a discrete operator on vectors, matrices, etc. More...
 
class  Vector
 A class that encapsulates a vector. This is a vector in the mathematical sense and not in the sense of an array or STL container. This class handles both serial and distributed vector in a unfied way. There are different constructors provided for the serial and distributed case. More...
 
class  VectorAttributes
 

Enumerations

enum class  LinearSolverType { CG , CG }
 
enum class  PreconditionerType { NONE , JACOBI }
 
enum class  NonLinearSolverType { CG , LBFGS }
 
enum class  ParallelPrintType { NONE , ROOT_ONLY , ALL }
 
enum class  LapackErrorCode {
  SUCCESS , FAILED_DENSE_MATRIX_INVERSE , FAILED_TRIA_MATRIX_INVERSE , FAILED_CHOLESKY_FACTORIZATION ,
  FAILED_REAL_TRIDIAGONAL_EIGENPROBLEM , FAILED_STANDARD_EIGENPROBLEM , FAILED_GENERALIZED_EIGENPROBLEM , FAILED_LINEAR_SYSTEM_SOLVE ,
  OTHER_ERROR
}
 
enum class  LinearSolverErrorCode {
  SUCCESS , FAILED_TO_CONVERGE , RESIDUAL_DIVERGENCE , DIVISON_BY_ZERO ,
  OTHER_ERROR
}
 
enum class  EigenSolverErrorCode {
  SUCCESS , LAPACK_ERROR , LANCZOS_BETA_ZERO , LANCZOS_SUBSPACE_INSUFFICIENT ,
  CHFSI_ORTHONORMALIZATION_ERROR , CHFSI_RAYLEIGH_RITZ_ERROR , KS_MAX_PASS_ERROR , KS_CHFSI_ERROR ,
  KS_LANCZOS_ERROR , KS_NEWTON_RAPHSON_ERROR , OTHER_ERROR
}
 
enum class  OrthonormalizationErrorCode { SUCCESS , LAPACK_ERROR , NON_ORTHONORMALIZABLE_MULTIVECTOR , MAX_PASS_EXCEEDED }
 
enum class  NewtonRaphsonErrorCode { SUCCESS , FORCE_TOLERANCE_ERR , FAILED_TO_CONVERGE , OTHER_ERROR }
 
enum class  LinearSolverType { CG , CG }
 
enum class  PCType { NONE , JACOBI }
 
enum class  LinearSolverReturnType {
  SUCCESS , FAILURE , MAX_ITER_REACHED , INDEFINITE_PC ,
  NAN_RES
}
 

Functions

 CGLinearSolver (const size_type maxIter, const double absoluteTol, const double relativeTol, const double divergenceTol, LinearAlgebraProfiler profiler=LinearAlgebraProfiler())
 A class that implements the Conjugate-Gradient (CG) based Krylov subspace algorithm to solve a linear system of (i.e., solve for \( \mathbf{Ax}=\mathbf{b}$\f). @see <em>An Introduction to the Conjugate Gradient Method Without the Agonizing Pain</em>, Jonathan Richard Shewchuk (<a href="https://www.cs.cmu.edu/~quake-papers/painless-conjugate-gradient.pdf">Painless Conjugate-Gradient</a>) @see <em> Numerical Linear Algebra </em>, Trefethen, Lloyd N., and David Bau III., Vol. 50. Siam, 1997. @tparam ValueTypeOperator The datatype (float, double, complex<double>, etc.) for the operator (e.g. Matrix) associated with the linear solve @tparam ValueTypeOperand The datatype (float, double, complex<double>, etc.) of the vector, matrices, etc. on which the operator will act @tparam memorySpace The meory space (HOST, DEVICE, HOST_PINNED, etc.) in which the data of the operator and its operands reside */ template <typename ValueTypeOperator, typename ValueTypeOperand, utils::MemorySpace memorySpace> class CGLinearSolver : public LinearSolverImpl<ValueTypeOperator, ValueTypeOperand, memorySpace> { public: /** @brief Constructor @param[in] maxIter Maximum number of iterations to allow the solver to iterate. Generally, this determines the maximum size of the Krylov subspace that will be used. @param[in] absoluteTol Convergence tolerane on the absolute \) L_2 $\f norm of the residual (i.e., on \(||\mathbf{Ax}-\mathbf{b}||$\f) @param[in] relativeTol Convergence tolerane on the relative L2 norm of the residual (i.e., on \)||\mathbf{Ax}-\mathbf{b}||/||\mathbf{b}||$\f) More...
 
 ~CGLinearSolver ()=default
 Default Destructor. More...
 
LinearSolverError solve (LinearSolverFunction< ValueTypeOperator, ValueTypeOperand, memorySpace > &linearSolverFunction) override
 Function that initiates the linear solve. More...
 
template<typename ValueTypeOperator , typename ValueTypeOperand , utils::MemorySpace memorySpace>
void ChebyshevFilter (const OperatorContext< ValueTypeOperator, ValueTypeOperand, memorySpace > &A, const OperatorContext< ValueTypeOperator, ValueTypeOperand, memorySpace > &BInv, MultiVector< ValueTypeOperand, memorySpace > &eigenSubspaceGuess, const size_type polynomialDegree, const double wantedSpectrumLowerBound, const double wantedSpectrumUpperBound, const double unWantedSpectrumUpperBound, MultiVector< blasLapack::scalar_type< ValueTypeOperator, ValueTypeOperand >, memorySpace > &filteredSubspace)
 A class to get chebyshevFiletered subspace "filteredSubspace" from original subspace "eigenSubspaceGuess". Note both of these vectors have to be apriori allocated and both will change after the function is called. More...
 
template<typename ValueType , dftefe::utils::MemorySpace memorySpace>
void swap (MultiVector< ValueType, memorySpace > &X, MultiVector< ValueType, memorySpace > &Y)
 Swaps the data of u with this multivector. More...
 
template<typename ValueType1 , typename ValueType2 , utils::MemorySpace memorySpace>
void add (blasLapack::scalar_type< ValueType1, ValueType2 > a, const MultiVector< ValueType1, memorySpace > &u, blasLapack::scalar_type< ValueType1, ValueType2 > b, const MultiVector< ValueType2, memorySpace > &v, MultiVector< blasLapack::scalar_type< ValueType1, ValueType2 >, memorySpace > &w)
 Perform \( w = au + bv \). More...
 
template<typename ValueType1 , typename ValueType2 , utils::MemorySpace memorySpace>
void add (const std::vector< blasLapack::scalar_type< ValueType1, ValueType2 > > &a, const MultiVector< ValueType1, memorySpace > &u, const std::vector< blasLapack::scalar_type< ValueType1, ValueType2 > > &b, const MultiVector< ValueType2, memorySpace > &v, MultiVector< blasLapack::scalar_type< ValueType1, ValueType2 >, memorySpace > &w)
 Perform \( w = au + bv \). More...
 
template<typename ValueType1 , typename ValueType2 , utils::MemorySpace memorySpace>
void dot (const MultiVector< ValueType1, memorySpace > &u, const MultiVector< ValueType2, memorySpace > &v, blasLapack::scalar_type< ValueType1, ValueType2 > *dotProds, const blasLapack::ScalarOp &opU, const blasLapack::ScalarOp &opV)
 
template<typename ValueType1 , typename ValueType2 , utils::MemorySpace memorySpace>
void dot (const MultiVector< ValueType1, memorySpace > &u, const MultiVector< ValueType2, memorySpace > &v, std::vector< blasLapack::scalar_type< ValueType1, ValueType2 > > &dotProds, const blasLapack::ScalarOp &opU, const blasLapack::ScalarOp &opV)
 
template<typename ValueType1 , typename ValueType2 , utils::MemorySpace memorySpace>
void dot (const Vector< ValueType1, memorySpace > &u, const Vector< ValueType2, memorySpace > &v, blasLapack::scalar_type< ValueType1, ValueType2 > &dotProd, const blasLapack::ScalarOp &opU, const blasLapack::ScalarOp &opV)
 

Variables

LinearAlgebraProfiler d_profiler
 
size_type d_maxIter
 
double d_absoluteTol
 
double d_relativeTol
 
double d_divergenceTol
 

Enumeration Type Documentation

◆ EigenSolverErrorCode

Enumerator
SUCCESS 
LAPACK_ERROR 
LANCZOS_BETA_ZERO 
LANCZOS_SUBSPACE_INSUFFICIENT 
CHFSI_ORTHONORMALIZATION_ERROR 
CHFSI_RAYLEIGH_RITZ_ERROR 
KS_MAX_PASS_ERROR 
KS_CHFSI_ERROR 
KS_LANCZOS_ERROR 
KS_NEWTON_RAPHSON_ERROR 
OTHER_ERROR 

◆ LapackErrorCode

Enumerator
SUCCESS 
FAILED_DENSE_MATRIX_INVERSE 
FAILED_TRIA_MATRIX_INVERSE 
FAILED_CHOLESKY_FACTORIZATION 
FAILED_REAL_TRIDIAGONAL_EIGENPROBLEM 
FAILED_STANDARD_EIGENPROBLEM 
FAILED_GENERALIZED_EIGENPROBLEM 
FAILED_LINEAR_SYSTEM_SOLVE 
OTHER_ERROR 

◆ LinearSolverErrorCode

Enumerator
SUCCESS 
FAILED_TO_CONVERGE 
RESIDUAL_DIVERGENCE 
DIVISON_BY_ZERO 
OTHER_ERROR 

◆ LinearSolverReturnType

Enumerator
SUCCESS 
FAILURE 
MAX_ITER_REACHED 
INDEFINITE_PC 
NAN_RES 

◆ LinearSolverType [1/2]

Enumerator
CG 
CG 

◆ LinearSolverType [2/2]

Enumerator
CG 
CG 

◆ NewtonRaphsonErrorCode

Enumerator
SUCCESS 
FORCE_TOLERANCE_ERR 
FAILED_TO_CONVERGE 
OTHER_ERROR 

◆ NonLinearSolverType

Enumerator
CG 
LBFGS 

◆ OrthonormalizationErrorCode

Enumerator
SUCCESS 
LAPACK_ERROR 
NON_ORTHONORMALIZABLE_MULTIVECTOR 
MAX_PASS_EXCEEDED 

◆ ParallelPrintType

Enumerator
NONE 
ROOT_ONLY 
ALL 

◆ PCType

enum class dftefe::linearAlgebra::PCType
strong
Enumerator
NONE 
JACOBI 

◆ PreconditionerType

Enumerator
NONE 
JACOBI 

Function Documentation

◆ add() [1/2]

template<typename ValueType1 , typename ValueType2 , utils::MemorySpace memorySpace>
void dftefe::linearAlgebra::add ( blasLapack::scalar_type< ValueType1, ValueType2 >  a,
const MultiVector< ValueType1, memorySpace > &  u,
blasLapack::scalar_type< ValueType1, ValueType2 >  b,
const MultiVector< ValueType2, memorySpace > &  v,
MultiVector< blasLapack::scalar_type< ValueType1, ValueType2 >, memorySpace > &  w 
)

Perform \( w = au + bv \).

Parameters
[in]ascalar
[in]ufirst MultiVector on the right
[in]bscalar
[in]vsecond MultiVector on the right
[out]wresulting MultiVector
Template Parameters
ValueType1DataType (double, float, complex<double>, etc.) of u vector
ValueType2DataType (double, float, complex<double>, etc.) of v vector
memorySpacedefines the MemorySpace (i.e., HOST or DEVICE) in which the vector must reside.
Note
The datatype of the scalars a, b, and the resultant MultiVector w is decided through a union of ValueType1 and ValueType2 (e.g., union of double and complex<double> is complex<double>)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ add() [2/2]

template<typename ValueType1 , typename ValueType2 , utils::MemorySpace memorySpace>
void dftefe::linearAlgebra::add ( const std::vector< blasLapack::scalar_type< ValueType1, ValueType2 > > &  a,
const MultiVector< ValueType1, memorySpace > &  u,
const std::vector< blasLapack::scalar_type< ValueType1, ValueType2 > > &  b,
const MultiVector< ValueType2, memorySpace > &  v,
MultiVector< blasLapack::scalar_type< ValueType1, ValueType2 >, memorySpace > &  w 
)

Perform \( w = au + bv \).

Parameters
[in]avector
[in]ufirst MultiVector on the right
[in]bvector
[in]vsecond MultiVector on the right
[out]wresulting MultiVector
Template Parameters
ValueType1DataType (double, float, complex<double>, etc.) of u vector
ValueType2DataType (double, float, complex<double>, etc.) of v vector
memorySpacedefines the MemorySpace (i.e., HOST or DEVICE) in which the vector must reside.
Note
The datatype of the scalars a, b, and the resultant MultiVector w is decided through a union of ValueType1 and ValueType2 (e.g., union of double and complex<double> is complex<double>)
Here is the call graph for this function:

◆ CGLinearSolver()

dftefe::linearAlgebra::CGLinearSolver ( const size_type  maxIter,
const double  absoluteTol,
const double  relativeTol,
const double  divergenceTol,
LinearAlgebraProfiler  profiler = LinearAlgebraProfiler() 
)

A class that implements the Conjugate-Gradient (CG) based Krylov subspace algorithm to solve a linear system of (i.e., solve for \( \mathbf{Ax}=\mathbf{b}$\f). @see <em>An Introduction to the Conjugate Gradient Method Without the Agonizing Pain</em>, Jonathan Richard Shewchuk (<a href="https://www.cs.cmu.edu/~quake-papers/painless-conjugate-gradient.pdf">Painless Conjugate-Gradient</a>) @see <em> Numerical Linear Algebra </em>, Trefethen, Lloyd N., and David Bau III., Vol. 50. Siam, 1997. @tparam ValueTypeOperator The datatype (float, double, complex<double>, etc.) for the operator (e.g. Matrix) associated with the linear solve @tparam ValueTypeOperand The datatype (float, double, complex<double>, etc.) of the vector, matrices, etc. on which the operator will act @tparam memorySpace The meory space (HOST, DEVICE, HOST_PINNED, etc.) in which the data of the operator and its operands reside */ template <typename ValueTypeOperator, typename ValueTypeOperand, utils::MemorySpace memorySpace> class CGLinearSolver : public LinearSolverImpl<ValueTypeOperator, ValueTypeOperand, memorySpace> { public: /** @brief Constructor @param[in] maxIter Maximum number of iterations to allow the solver to iterate. Generally, this determines the maximum size of the Krylov subspace that will be used. @param[in] absoluteTol Convergence tolerane on the absolute \) L_2 $\f norm of the residual (i.e., on \(||\mathbf{Ax}-\mathbf{b}||$\f) @param[in] relativeTol Convergence tolerane on the relative L2 norm of the residual (i.e., on \)||\mathbf{Ax}-\mathbf{b}||/||\mathbf{b}||$\f)

Parameters
[in]divergenceTolTolerance to abort the linear solver if the L2 norm of the residual exceeds it (i.e., if \(||\mathbf{Ax}-\mathbf{b}|| > divergenceTol$\f) @note Convergence is achieved if \)||\mathbf{Ax}-\mathbf{b}|| < max(absoluteTol, relativeTol*||\mathbf{b}||)$\f
Here is the caller graph for this function:

◆ ChebyshevFilter()

template<typename ValueTypeOperator , typename ValueTypeOperand , utils::MemorySpace memorySpace>
void dftefe::linearAlgebra::ChebyshevFilter ( const OperatorContext< ValueTypeOperator, ValueTypeOperand, memorySpace > &  A,
const OperatorContext< ValueTypeOperator, ValueTypeOperand, memorySpace > &  BInv,
MultiVector< ValueTypeOperand, memorySpace > &  eigenSubspaceGuess,
const size_type  polynomialDegree,
const double  wantedSpectrumLowerBound,
const double  wantedSpectrumUpperBound,
const double  unWantedSpectrumUpperBound,
MultiVector< blasLapack::scalar_type< ValueTypeOperator, ValueTypeOperand >, memorySpace > &  filteredSubspace 
)

A class to get chebyshevFiletered subspace "filteredSubspace" from original subspace "eigenSubspaceGuess". Note both of these vectors have to be apriori allocated and both will change after the function is called.

Template Parameters
ValueTypeOperatorThe datatype (float, double, complex<double>, etc.) for the underlying operator
ValueTypeOperandThe datatype (float, double, complex<double>, etc.) of the vector, matrices, etc. on which the operator will act
memorySpaceThe meory space (HOST, DEVICE, HOST_PINNED, etc.) in which the data of the operator and its operands reside
Here is the call graph for this function:

◆ dot() [1/3]

template<typename ValueType1 , typename ValueType2 , utils::MemorySpace memorySpace>
void dftefe::linearAlgebra::dot ( const MultiVector< ValueType1, memorySpace > &  u,
const MultiVector< ValueType2, memorySpace > &  v,
blasLapack::scalar_type< ValueType1, ValueType2 > *  dotProds,
const blasLapack::ScalarOp opU,
const blasLapack::ScalarOp opV 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ dot() [2/3]

template<typename ValueType1 , typename ValueType2 , utils::MemorySpace memorySpace>
void dftefe::linearAlgebra::dot ( const MultiVector< ValueType1, memorySpace > &  u,
const MultiVector< ValueType2, memorySpace > &  v,
std::vector< blasLapack::scalar_type< ValueType1, ValueType2 > > &  dotProds,
const blasLapack::ScalarOp opU,
const blasLapack::ScalarOp opV 
)
Here is the call graph for this function:

◆ dot() [3/3]

template<typename ValueType1 , typename ValueType2 , utils::MemorySpace memorySpace>
void dftefe::linearAlgebra::dot ( const Vector< ValueType1, memorySpace > &  u,
const Vector< ValueType2, memorySpace > &  v,
blasLapack::scalar_type< ValueType1, ValueType2 > &  dotProd,
const blasLapack::ScalarOp opU,
const blasLapack::ScalarOp opV 
)
Here is the call graph for this function:

◆ solve()

LinearSolverError dftefe::linearAlgebra::solve ( LinearSolverFunction< ValueTypeOperator, ValueTypeOperand, memorySpace > &  linearSolverFunction)
override

Function that initiates the linear solve.

Parameters
[in]linearSolverFunctionReference to a LinearSolverFunction object that encapsulates the discrete partial differential equation that is being solved as a linear solve. Typically, the linearSolverFunction provides the right hand side vector (i.e., \(\mathbf{b}$\f) and the handle to the action of the discrete operator on a Vector. It also stores the final solution \)\mathbf{x}$\f

◆ swap()

template<typename ValueType , dftefe::utils::MemorySpace memorySpace>
void dftefe::linearAlgebra::swap ( MultiVector< ValueType, memorySpace > &  X,
MultiVector< ValueType, memorySpace > &  Y 
)

Swaps the data of u with this multivector.

Here is the caller graph for this function:

◆ ~CGLinearSolver()

dftefe::linearAlgebra::~CGLinearSolver ( )
default

Default Destructor.

Variable Documentation

◆ d_absoluteTol

double dftefe::linearAlgebra::d_absoluteTol
private

◆ d_divergenceTol

double dftefe::linearAlgebra::d_divergenceTol
private

◆ d_maxIter

size_type dftefe::linearAlgebra::d_maxIter
private

◆ d_profiler

LinearAlgebraProfiler dftefe::linearAlgebra::d_profiler
private

◆ d_relativeTol

double dftefe::linearAlgebra::d_relativeTol
private