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

A global linear system. More...

#include <GlobalLinSysDirectFull.h>

Inheritance diagram for Nektar::MultiRegions::GlobalLinSysDirectFull:
Inheritance graph
[legend]
Collaboration diagram for Nektar::MultiRegions::GlobalLinSysDirectFull:
Collaboration graph
[legend]

Public Member Functions

 GlobalLinSysDirectFull (const GlobalLinSysKey &pLinSysKey, const boost::weak_ptr< ExpList > &pExpList, const boost::shared_ptr< AssemblyMap > &pLocToGloMap)
 Constructor for full direct matrix solve.
virtual ~GlobalLinSysDirectFull ()
- Public Member Functions inherited from Nektar::MultiRegions::GlobalLinSysDirect
 GlobalLinSysDirect (const GlobalLinSysKey &pKey, const boost::weak_ptr< ExpList > &pExp, const boost::shared_ptr< AssemblyMap > &pLocToGloMap)
 Constructor for full direct matrix solve.
virtual ~GlobalLinSysDirect ()
- Public Member Functions inherited from Nektar::MultiRegions::GlobalLinSys
 GlobalLinSys (const GlobalLinSysKey &pKey, const boost::weak_ptr< ExpList > &pExpList, const boost::shared_ptr< AssemblyMap > &pLocToGloMap)
 Constructor for full direct matrix solve.
virtual ~GlobalLinSys ()
const GlobalLinSysKeyGetKey (void) const
 Returns the key associated with the system.
const boost::weak_ptr< ExpList > & GetLocMat (void) const
void InitObject ()
void Initialise (const boost::shared_ptr< AssemblyMap > &pLocToGloMap)
void Solve (const Array< OneD, const NekDouble > &in, Array< OneD, NekDouble > &out, const AssemblyMapSharedPtr &locToGloMap, const Array< OneD, const NekDouble > &dirForcing=NullNekDouble1DArray)
 Solve the linear system for given input and output vectors using a specified local to global map.
boost::shared_ptr< GlobalLinSysGetSharedThisPtr ()
 Returns a shared pointer to the current object.
int GetNumBlocks ()
DNekScalMatSharedPtr GetBlock (unsigned int n)
DNekScalBlkMatSharedPtr GetStaticCondBlock (unsigned int n)
void DropStaticCondBlock (unsigned int n)
void SolveLinearSystem (const int pNumRows, const Array< OneD, const NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const AssemblyMapSharedPtr &locToGloMap, const int pNumDir=0)
 Solve the linear system for given input and output vectors.

Static Public Member Functions

static GlobalLinSysSharedPtr create (const GlobalLinSysKey &pLinSysKey, const boost::weak_ptr< ExpList > &pExpList, const boost::shared_ptr< AssemblyMap > &pLocToGloMap)
 Creates an instance of this class.

Static Public Attributes

static std::string className
 Name of class.

Private Member Functions

virtual void v_Solve (const Array< OneD, const NekDouble > &in, Array< OneD, NekDouble > &out, const AssemblyMapSharedPtr &locToGloMap, const Array< OneD, const NekDouble > &dirForcing=NullNekDouble1DArray)
 Solve the linear system for given input and output vectors using a specified local to global map.
void AssembleFullMatrix (const boost::shared_ptr< AssemblyMap > &locToGloMap)

Additional Inherited Members

- Protected Member Functions inherited from Nektar::MultiRegions::GlobalLinSysDirect
virtual void v_SolveLinearSystem (const int pNumRows, const Array< OneD, const NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const AssemblyMapSharedPtr &locToGloMap, const int pNumDir=0)
 Solve the linear system for given input and output vectors.
- Protected Attributes inherited from Nektar::MultiRegions::GlobalLinSysDirect
DNekLinSysSharedPtr m_linSys
 Basic linear system object.

Detailed Description

A global linear system.

Definition at line 51 of file GlobalLinSysDirectFull.h.

Constructor & Destructor Documentation

Nektar::MultiRegions::GlobalLinSysDirectFull::GlobalLinSysDirectFull ( const GlobalLinSysKey pLinSysKey,
const boost::weak_ptr< ExpList > &  pExpList,
const boost::shared_ptr< AssemblyMap > &  pLocToGloMap 
)

Constructor for full direct matrix solve.

Definition at line 79 of file GlobalLinSysDirectFull.cpp.

References AssembleFullMatrix(), ASSERTL1, Nektar::MultiRegions::eDirectFullMatrix, Nektar::MultiRegions::GlobalLinSysKey::GetGlobalSysSolnType(), and Nektar::MultiRegions::GlobalLinSys::m_linSysKey.

: GlobalLinSys(pLinSysKey, pExp, pLocToGloMap),
GlobalLinSysDirect(pLinSysKey, pExp, pLocToGloMap)
{
"This routine should only be used when using a Full Direct"
" matrix solve");
ASSERTL1(pExp.lock()->GetComm()->GetSize() == 1,
"Direct full matrix solve can only be used in serial.");
AssembleFullMatrix(pLocToGloMap);
}
Nektar::MultiRegions::GlobalLinSysDirectFull::~GlobalLinSysDirectFull ( )
virtual

Definition at line 98 of file GlobalLinSysDirectFull.cpp.

{
}

Member Function Documentation

void Nektar::MultiRegions::GlobalLinSysDirectFull::AssembleFullMatrix ( const boost::shared_ptr< AssemblyMap > &  locToGloMap)
private

Assemble a full matrix from the block matrix stored in #m_blkMatrices and the given local to global mapping information.

Parameters
locToGloMapLocal to global mapping information.

Definition at line 157 of file GlobalLinSysDirectFull.cpp.

References ErrorUtil::efatal, Nektar::eFULL, Nektar::StdRegions::eHelmholtz, Nektar::StdRegions::eHybridDGHelmBndLam, Nektar::StdRegions::eLaplacian, Nektar::StdRegions::eLinearAdvectionDiffusionReaction, Nektar::StdRegions::eLinearAdvectionReaction, Nektar::StdRegions::eMass, Nektar::ePOSITIVE_DEFINITE_SYMMETRIC, Nektar::ePOSITIVE_DEFINITE_SYMMETRIC_BANDED, Nektar::eWrapper, Nektar::MultiRegions::GlobalLinSys::GetBlock(), Nektar::MultiRegions::GlobalMatrixKey::GetMatrixType(), Nektar::MultiRegions::GlobalLinSys::m_expList, Nektar::MultiRegions::GlobalLinSysDirect::m_linSys, Nektar::MultiRegions::GlobalLinSys::m_linSysKey, and NEKERROR.

Referenced by GlobalLinSysDirectFull().

{
int i,j,n,cnt,gid1,gid2;
NekDouble sign1,sign2,value;
int totDofs = pLocToGloMap->GetNumGlobalCoeffs();
int NumDirBCs = pLocToGloMap->GetNumGlobalDirBndCoeffs();
unsigned int rows = totDofs - NumDirBCs;
unsigned int cols = totDofs - NumDirBCs;
NekDouble zero = 0.0;
int bwidth = pLocToGloMap->GetFullSystemBandWidth();
MatrixStorage matStorage;
{
// case for all symmetric matices
{
if( (2*(bwidth+1)) < rows)
{
::AllocateSharedPtr(rows, cols, zero,
matStorage,
bwidth, bwidth);
}
else
{
::AllocateSharedPtr(rows, cols, zero,
matStorage);
}
break;
}
{
matStorage = eFULL;
::AllocateSharedPtr(rows, cols, zero,
matStorage);
break;
}
default:
{
NEKERROR(ErrorUtil::efatal, "Add MatrixType to switch "
"statement");
}
}
// fill global matrix
int loc_lda;
for(n = cnt = 0; n < m_expList.lock()->GetNumElmts(); ++n)
{
loc_mat = GetBlock(m_expList.lock()->GetOffset_Elmt_Id(n));
loc_lda = loc_mat->GetRows();
for(i = 0; i < loc_lda; ++i)
{
gid1 = pLocToGloMap->GetLocalToGlobalMap(cnt + i)-NumDirBCs;
sign1 = pLocToGloMap->GetLocalToGlobalSign(cnt + i);
if(gid1 >= 0)
{
for(j = 0; j < loc_lda; ++j)
{
gid2 = pLocToGloMap->GetLocalToGlobalMap(cnt + j)
- NumDirBCs;
sign2 = pLocToGloMap->GetLocalToGlobalSign(cnt + j);
if(gid2 >= 0)
{
// When global matrix is symmetric,
// only add the value for the upper
// triangular part in order to avoid
// entries to be entered twice
if((matStorage == eFULL)||(gid2 >= gid1))
{
value = Gmat->GetValue(gid1,gid2)
+ sign1*sign2*(*loc_mat)(i,j);
Gmat->SetValue(gid1,gid2,value);
}
}
}
}
}
cnt += loc_lda;
}
if(rows)
{
}
}
static GlobalLinSysSharedPtr Nektar::MultiRegions::GlobalLinSysDirectFull::create ( const GlobalLinSysKey pLinSysKey,
const boost::weak_ptr< ExpList > &  pExpList,
const boost::shared_ptr< AssemblyMap > &  pLocToGloMap 
)
inlinestatic

Creates an instance of this class.

Definition at line 56 of file GlobalLinSysDirectFull.h.

{
return MemoryManager<GlobalLinSysDirectFull>::AllocateSharedPtr(pLinSysKey, pExpList, pLocToGloMap);
}
void Nektar::MultiRegions::GlobalLinSysDirectFull::v_Solve ( const Array< OneD, const NekDouble > &  pInput,
Array< OneD, NekDouble > &  pOutput,
const AssemblyMapSharedPtr pLocToGloMap,
const Array< OneD, const NekDouble > &  pDirForcing = NullNekDouble1DArray 
)
privatevirtual

Solve the linear system for given input and output vectors using a specified local to global map.

Solve the linear system using a full global matrix system.

Definition at line 107 of file GlobalLinSysDirectFull.cpp.

References Nektar::MultiRegions::eGlobal, Nektar::MultiRegions::GlobalLinSys::m_expList, Nektar::MultiRegions::GlobalLinSys::m_linSysKey, Nektar::MultiRegions::GlobalLinSys::SolveLinearSystem(), Vmath::Vadd(), and Vmath::Vsub().

{
bool dirForcCalculated = (bool) pDirForcing.num_elements();
int nDirDofs = pLocToGloMap->GetNumGlobalDirBndCoeffs();
int nGlobDofs = pLocToGloMap->GetNumGlobalCoeffs();
Array<OneD, NekDouble> tmp(nGlobDofs);
if(nDirDofs)
{
// calculate the dirichlet forcing
if(dirForcCalculated)
{
Vmath::Vsub(nGlobDofs,
pInput.get(), 1,
pDirForcing.get(), 1,
tmp.get(), 1);
}
else
{
// Calculate Dirichlet forcing and subtract it from the rhs
m_expList.lock()->GeneralMatrixOp(
m_linSysKey, pOutput, tmp, eGlobal);
Vmath::Vsub(nGlobDofs,
pInput.get(), 1,
tmp.get(), 1,
tmp.get(), 1);
}
Array<OneD, NekDouble> out(nGlobDofs,0.0);
SolveLinearSystem(nGlobDofs, tmp, out, pLocToGloMap, nDirDofs);
Vmath::Vadd(nGlobDofs-nDirDofs, &out [nDirDofs], 1,
&pOutput[nDirDofs], 1, &pOutput[nDirDofs], 1);
}
else
{
SolveLinearSystem(nDirDofs, pInput, pOutput, pLocToGloMap);
}
}

Member Data Documentation

string Nektar::MultiRegions::GlobalLinSysDirectFull::className
static
Initial value:

Name of class.

Registers the class with the Factory.

Definition at line 65 of file GlobalLinSysDirectFull.h.