Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | Private Attributes | Static Private Attributes | List of all members
Nektar::MultiRegions::GlobalMatrix Class Reference

Represents a matrix of all degrees of freedom. More...

#include <GlobalMatrix.h>

Collaboration diagram for Nektar::MultiRegions::GlobalMatrix:
Collaboration graph
[legend]

Public Types

typedef NekSparseMatrix
< StorageSmvBsr< NekDouble > > 
DNekSmvBsrMat
typedef boost::shared_ptr
< DNekSmvBsrMat
DNekSmvBsrMatSharedPtr

Public Member Functions

 GlobalMatrix (const LibUtilities::SessionReaderSharedPtr &pSession, unsigned int rows, unsigned int columns, const COOMatType &cooMat, const MatrixStorage &matStorage=eFULL)
 Construct a new matrix.
 ~GlobalMatrix ()
void Multiply (const Array< OneD, const NekDouble > &in, Array< OneD, NekDouble > &out)
 Perform a matrix-vector multiply.
const unsigned long GetMulCallsCounter () const
const unsigned int GetNumNonZeroEntries () const

Private Attributes

DNekSmvBsrMatSharedPtr m_smvbsrmatrix
 Pointer to a double-precision Nektar++ sparse matrix.
unsigned int m_rows
Array< OneD, NekDoublem_tmpin
Array< OneD, NekDoublem_tmpout
unsigned long m_mulCallsCounter
bool m_copyOp

Static Private Attributes

static std::string def
static std::string lookupIds []

Detailed Description

Represents a matrix of all degrees of freedom.

This matrix is essentially a wrapper around a DNekSparseMat.

Definition at line 47 of file GlobalMatrix.h.

Member Typedef Documentation

Definition at line 50 of file GlobalMatrix.h.

Definition at line 51 of file GlobalMatrix.h.

Constructor & Destructor Documentation

Nektar::MultiRegions::GlobalMatrix::GlobalMatrix ( const LibUtilities::SessionReaderSharedPtr pSession,
unsigned int  rows,
unsigned int  columns,
const COOMatType cooMat,
const MatrixStorage matStorage = eFULL 
)

Construct a new matrix.

Allocates a new DNekSparseMat object from the given specification.

Parameters
rowsNumber of rows in matrix.
columnsNumber of columns in matrix.
cooMat?

Definition at line 68 of file GlobalMatrix.cpp.

References ASSERTL1, Nektar::convertCooToBco(), ErrorUtil::efatal, Nektar::MultiRegions::eSmvBSR, m_copyOp, m_smvbsrmatrix, m_tmpin, m_tmpout, Nektar::MultiRegions::MatrixStorageTypeMap, and NEKERROR.

:
m_rows(rows),
{
MatrixStorageType storageType = pSession->
GetSolverInfoAsEnum<MatrixStorageType>("GlobalMatrixStorageType");
unsigned int brows, bcols;
// Size of dense matrix sub-blocks
int block_size = 1;
BCOMatType bcoMat;
// assuming current sparse format allows
// block-sparse data representation
if(pSession->DefinesParameter("SparseBlockSize"))
{
pSession->LoadParameter("SparseBlockSize", block_size);
ASSERTL1(block_size > 0,"SparseBlockSize parameter must to be positive");
}
brows = rows / block_size + (rows % block_size > 0);
bcols = columns / block_size + (columns % block_size > 0);
if (rows % block_size > 0) m_copyOp = true;
if (m_copyOp)
{
m_tmpin = Array<OneD, NekDouble> (brows*block_size, 0.0);
m_tmpout = Array<OneD, NekDouble> (brows*block_size, 0.0);
}
convertCooToBco(brows, bcols, block_size, cooMat, bcoMat);
size_t matBytes;
switch(storageType)
{
case eSmvBSR:
{
// Create zero-based Smv-multiply BSR sparse storage holder
brows, bcols, block_size, bcoMat, matStorage );
// Create sparse matrix
AllocateSharedPtr( sparseStorage );
matBytes = m_smvbsrmatrix->GetMemoryFootprint();
}
break;
default:
NEKERROR(ErrorUtil::efatal,"Unsupported sparse storage type chosen");
}
cout << "Global matrix storage type: "
<< MatrixStorageTypeMap[storageType] << endl;
std::cout << "Global matrix memory, bytes = " << matBytes;
if (matBytes/(1024*1024) > 0)
{
std::cout << " ("<< matBytes/(1024*1024) <<" MB)" << std::endl;
}
else
{
std::cout << " ("<< matBytes/1024 <<" KB)" << std::endl;
}
std::cout << "Sparse storage block size = " << block_size << std::endl;
}
Nektar::MultiRegions::GlobalMatrix::~GlobalMatrix ( )
inline

Definition at line 61 of file GlobalMatrix.h.

{}

Member Function Documentation

const unsigned long Nektar::MultiRegions::GlobalMatrix::GetMulCallsCounter ( ) const

Definition at line 176 of file GlobalMatrix.cpp.

References m_smvbsrmatrix.

{
if (m_smvbsrmatrix) return m_smvbsrmatrix->GetMulCallsCounter();
return -1;
}
const unsigned int Nektar::MultiRegions::GlobalMatrix::GetNumNonZeroEntries ( ) const

Definition at line 182 of file GlobalMatrix.cpp.

References m_smvbsrmatrix.

{
if (m_smvbsrmatrix) return m_smvbsrmatrix->GetNumNonZeroEntries();
return -1;
}
void Nektar::MultiRegions::GlobalMatrix::Multiply ( const Array< OneD, const NekDouble > &  in,
Array< OneD, NekDouble > &  out 
)

Perform a matrix-vector multiply.

Performs a matrix-vector multiply using the sparse format-specific multiply routine.

Parameters
inInput vector.
outOutput vector.

Definition at line 155 of file GlobalMatrix.cpp.

References m_copyOp, m_mulCallsCounter, m_rows, m_smvbsrmatrix, m_tmpin, m_tmpout, and Vmath::Vcopy().

{
if (!m_copyOp)
{
if (m_smvbsrmatrix) m_smvbsrmatrix->Multiply(in,out);
}
else
{
// if block size makes the last row/column bigger, one needs
// using temporary storage for rhs and result vectors.
Vmath::Vcopy(m_rows, &in[0], 1, &m_tmpin[0], 1);
Vmath::Vcopy(m_rows, &m_tmpout[0], 1, &out[0], 1);
}
}

Member Data Documentation

std::string Nektar::MultiRegions::GlobalMatrix::def
staticprivate
Initial value:
RegisterDefaultSolverInfo("GlobalMatrixStorageType","SmvBSR")

Definition at line 84 of file GlobalMatrix.h.

std::string Nektar::MultiRegions::GlobalMatrix::lookupIds
staticprivate
Initial value:
{
"GlobalMatrixStorageType", "SmvBSR", MultiRegions::eSmvBSR)
}

Definition at line 85 of file GlobalMatrix.h.

bool Nektar::MultiRegions::GlobalMatrix::m_copyOp
private

Definition at line 82 of file GlobalMatrix.h.

Referenced by GlobalMatrix(), and Multiply().

unsigned long Nektar::MultiRegions::GlobalMatrix::m_mulCallsCounter
private

Definition at line 80 of file GlobalMatrix.h.

Referenced by Multiply().

unsigned int Nektar::MultiRegions::GlobalMatrix::m_rows
private

Definition at line 76 of file GlobalMatrix.h.

Referenced by Multiply().

DNekSmvBsrMatSharedPtr Nektar::MultiRegions::GlobalMatrix::m_smvbsrmatrix
private

Pointer to a double-precision Nektar++ sparse matrix.

Definition at line 74 of file GlobalMatrix.h.

Referenced by GetMulCallsCounter(), GetNumNonZeroEntries(), GlobalMatrix(), and Multiply().

Array<OneD, NekDouble> Nektar::MultiRegions::GlobalMatrix::m_tmpin
private

Definition at line 77 of file GlobalMatrix.h.

Referenced by GlobalMatrix(), and Multiply().

Array<OneD, NekDouble> Nektar::MultiRegions::GlobalMatrix::m_tmpout
private

Definition at line 78 of file GlobalMatrix.h.

Referenced by GlobalMatrix(), and Multiply().