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::GlobalLinSysPETScFull Class Reference

A global linear system. More...

#include <GlobalLinSysPETScFull.h>

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

Public Member Functions

 GlobalLinSysPETScFull (const GlobalLinSysKey &pLinSysKey, const boost::weak_ptr< ExpList > &pExpList, const boost::shared_ptr< AssemblyMap > &pLocToGloMap)
 Constructor for full direct matrix solve.
virtual ~GlobalLinSysPETScFull ()
- Public Member Functions inherited from Nektar::MultiRegions::GlobalLinSysPETSc
 GlobalLinSysPETSc (const GlobalLinSysKey &pKey, const boost::weak_ptr< ExpList > &pExp, const boost::shared_ptr< AssemblyMap > &pLocToGloMap)
 Constructor for full direct matrix solve.
virtual ~GlobalLinSysPETSc ()
virtual void v_SolveLinearSystem (const int pNumRows, const Array< OneD, const NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const AssemblyMapSharedPtr &locToGloMap, const int pNumDir)
 Solve a basic matrix system.
- 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.

Additional Inherited Members

- Protected Member Functions inherited from Nektar::MultiRegions::GlobalLinSysPETSc
void SetUpScatter ()
void SetUpMatVec ()
void SetUpSolver (NekDouble tolerance)
void CalculateReordering (const Array< OneD, const int > &glo2uniMap, const Array< OneD, const int > &glo2unique, const AssemblyMapSharedPtr &pLocToGloMap)
- Protected Attributes inherited from Nektar::MultiRegions::GlobalLinSysPETSc
Mat m_matrix
Vec m_x
Vec m_b
Vec m_locVec
KSP m_ksp
vector< int > m_reorderedMap
VecScatter m_ctx
int m_nLocal

Detailed Description

A global linear system.

Definition at line 53 of file GlobalLinSysPETScFull.h.

Constructor & Destructor Documentation

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

Constructor for full direct matrix solve.

Definition at line 61 of file GlobalLinSysPETScFull.cpp.

References ASSERTL1, Nektar::MultiRegions::GlobalLinSysPETSc::CalculateReordering(), Nektar::MultiRegions::ePETScFullMatrix, Nektar::MultiRegions::GlobalLinSys::GetBlock(), Nektar::MultiRegions::GlobalLinSysKey::GetGlobalSysSolnType(), Nektar::MultiRegions::GlobalLinSys::m_expList, Nektar::MultiRegions::GlobalLinSys::m_linSysKey, Nektar::MultiRegions::GlobalLinSysPETSc::m_matrix, Nektar::MultiRegions::GlobalLinSysPETSc::m_reorderedMap, Nektar::MultiRegions::GlobalLinSysPETSc::SetUpMatVec(), Nektar::MultiRegions::GlobalLinSysPETSc::SetUpScatter(), and Nektar::MultiRegions::GlobalLinSysPETSc::SetUpSolver().

: GlobalLinSys (pLinSysKey, pExp, pLocToGloMap),
GlobalLinSysPETSc(pLinSysKey, pExp, pLocToGloMap)
{
"This routine should only be used when using a Full PETSc"
" matrix solve");
const int nDofs = pLocToGloMap->GetNumGlobalCoeffs();
const int nDirDofs = pLocToGloMap->GetNumGlobalDirBndCoeffs();
int i, j, n, cnt, gid1, gid2, loc_lda;
NekDouble sign1, sign2, value;
// CALCULATE REORDERING MAPPING
CalculateReordering(pLocToGloMap->GetGlobalToUniversalMap(),
pLocToGloMap->GetGlobalToUniversalMapUnique(),
pLocToGloMap);
// SET UP VECTORS AND MATRIX
// POPULATE MATRIX
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) - nDirDofs;
sign1 = pLocToGloMap->GetLocalToGlobalSign(cnt + i);
if(gid1 >= 0)
{
int gid1ro = m_reorderedMap[gid1];
for(j = 0; j < loc_lda; ++j)
{
gid2 = pLocToGloMap->GetLocalToGlobalMap(cnt + j)
- nDirDofs;
sign2 = pLocToGloMap->GetLocalToGlobalSign(cnt + j);
if(gid2 >= 0)
{
int gid2ro = m_reorderedMap[gid2];
value = sign1*sign2*(*loc_mat)(i,j);
MatSetValue(
m_matrix, gid1ro, gid2ro, value, ADD_VALUES);
}
}
}
}
cnt += loc_lda;
}
// ASSEMBLE MATRIX
MatAssemblyBegin(m_matrix, MAT_FINAL_ASSEMBLY);
MatAssemblyEnd (m_matrix, MAT_FINAL_ASSEMBLY);
// SET UP SCATTER OBJECTS
// CONSTRUCT KSP OBJECT
SetUpSolver(pLocToGloMap->GetIterativeTolerance());
}
Nektar::MultiRegions::GlobalLinSysPETScFull::~GlobalLinSysPETScFull ( )
virtual

Definition at line 130 of file GlobalLinSysPETScFull.cpp.

{
}

Member Function Documentation

static GlobalLinSysSharedPtr Nektar::MultiRegions::GlobalLinSysPETScFull::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 58 of file GlobalLinSysPETScFull.h.

{
::AllocateSharedPtr(pLinSysKey, pExpList, pLocToGloMap);
}
void Nektar::MultiRegions::GlobalLinSysPETScFull::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 139 of file GlobalLinSysPETScFull.cpp.

References Nektar::MultiRegions::eGlobal, Nektar::MultiRegions::GlobalLinSys::m_expList, Nektar::MultiRegions::GlobalLinSys::m_linSysKey, Nektar::LibUtilities::ReduceSum, 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), tmp2;
int nDirTotal = nDirDofs;
m_expList.lock()->GetComm()->GetRowComm()->AllReduce(
if(nDirTotal)
{
// calculate the dirichlet forcing
if(dirForcCalculated)
{
Vmath::Vsub(nGlobDofs,
pInput.get(), 1,
pDirForcing.get(), 1,
tmp.get(), 1);
}
else
{
// Calculate the dirichlet forcing and substract 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::GlobalLinSysPETScFull::className
static
Initial value:

Name of class.

Registers the class with the Factory.

Definition at line 68 of file GlobalLinSysPETScFull.h.