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

A global linear system. More...

#include <GlobalLinSysXxtFull.h>

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

Public Member Functions

 GlobalLinSysXxtFull (const GlobalLinSysKey &pLinSysKey, const boost::weak_ptr< ExpList > &pExpList, const boost::shared_ptr< AssemblyMap > &pLocToGloMap)
 Constructor for full direct matrix solve.
virtual ~GlobalLinSysXxtFull ()
- Public Member Functions inherited from Nektar::MultiRegions::GlobalLinSysXxt
 GlobalLinSysXxt (const GlobalLinSysKey &pKey, const boost::weak_ptr< ExpList > &pExp, const boost::shared_ptr< AssemblyMap > &pLocToGloMap)
 Constructor for full direct matrix solve.
virtual ~GlobalLinSysXxt ()
- 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 CreateMap (const boost::shared_ptr< AssemblyMap > &pLocToGloMap)
void AssembleMatrixArrays (const boost::shared_ptr< AssemblyMap > &pLocToGloMap)

Additional Inherited Members

- Protected Member Functions inherited from Nektar::MultiRegions::GlobalLinSysXxt
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.
void GlobalToLocalNoSign (const Array< OneD, const NekDouble > &global, Array< OneD, NekDouble > &local)
void LocalToGlobalNoSign (const Array< OneD, const NekDouble > &local, Array< OneD, NekDouble > &global)
- Protected Attributes inherited from Nektar::MultiRegions::GlobalLinSysXxt
struct Xxt::crs_datam_crsData
Array< OneD, unsigned int > m_Ai
Array< OneD, unsigned int > m_Aj
Array< OneD, double > m_Ar
Array< OneD, NekDoublem_locToGloSignMult
Array< OneD, int > m_map

Detailed Description

A global linear system.

Definition at line 51 of file GlobalLinSysXxtFull.h.

Constructor & Destructor Documentation

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

Constructor for full direct matrix solve.

Definition at line 59 of file GlobalLinSysXxtFull.cpp.

References AssembleMatrixArrays(), ASSERTL1, CreateMap(), Nektar::MultiRegions::eXxtFullMatrix, Nektar::MultiRegions::GlobalLinSysKey::GetGlobalSysSolnType(), and Nektar::MultiRegions::GlobalLinSys::m_linSysKey.

: GlobalLinSys (pLinSysKey, pExp, pLocToGloMap),
GlobalLinSysXxt(pLinSysKey, pExp, pLocToGloMap)
{
"This routine should only be used when using a Full XXT"
" matrix solve");
CreateMap(pLocToGloMap);
AssembleMatrixArrays(pLocToGloMap);
}
Nektar::MultiRegions::GlobalLinSysXxtFull::~GlobalLinSysXxtFull ( )
virtual

Definition at line 77 of file GlobalLinSysXxtFull.cpp.

{
}

Member Function Documentation

void Nektar::MultiRegions::GlobalLinSysXxtFull::AssembleMatrixArrays ( const boost::shared_ptr< AssemblyMap > &  pLocToGloMap)
private

Construct the local matrix row index, column index and value index arrays and initialize the XXT data structure with this information.

Parameters
locToGloMapLocal to global mapping information.

Definition at line 186 of file GlobalLinSysXxtFull.cpp.

References Nektar::StdRegions::ePreconLinearSpace, Nektar::StdRegions::ePreconLinearSpaceMass, Nektar::MultiRegions::GlobalLinSys::GetBlock(), Nektar::MultiRegions::GlobalMatrixKey::GetMatrixType(), Gs::Init(), Nektar::MultiRegions::GlobalLinSysXxt::m_Ai, Nektar::MultiRegions::GlobalLinSysXxt::m_Aj, Nektar::MultiRegions::GlobalLinSysXxt::m_Ar, Nektar::MultiRegions::GlobalLinSysXxt::m_crsData, Nektar::MultiRegions::GlobalLinSys::m_expList, Nektar::MultiRegions::GlobalLinSys::m_linSysKey, and Xxt::nektar_crs_stats().

Referenced by GlobalLinSysXxtFull().

{
ExpListSharedPtr vExp = m_expList.lock();
unsigned int nElmt = vExp->GetNumElmts();
unsigned int iCount = 0;
unsigned int rCount = 0;
unsigned int nRows = 0;
unsigned int nEntries = 0;
unsigned int numDirBnd = pLocToGloMap->GetNumGlobalDirBndCoeffs();
unsigned int nLocal = pLocToGloMap->GetNumLocalCoeffs();
const Array<OneD, NekDouble> &vMapSign
= pLocToGloMap->GetLocalToGlobalSign();
bool doSign = pLocToGloMap->GetSignChange();
unsigned int i = 0, j = 0, k = 0, n = 0;
int gid1;
Array<OneD, unsigned int> vSizes(nElmt);
// First construct a map of the number of local DOFs in each block
// and the number of matrix entries for each block
// Dimension of matrix is just the linear vertex space
{
for (n = 0; n < nElmt; ++n)
{
i = vExp->GetOffset_Elmt_Id(n);
vSizes[n] = vExp->GetExp(i)->GetNverts();
nEntries += vSizes[n]*vSizes[n];
}
}
else
{
for (n = 0; n < nElmt; ++n)
{
i = vExp->GetOffset_Elmt_Id(n);
vSizes[n] = vExp->GetExp(i)->GetNcoeffs();
nEntries += vSizes[n]*vSizes[n];
}
}
// Set up i-index, j-index and value arrays
m_Ai = Array<OneD, unsigned int>(nEntries);
m_Aj = Array<OneD, unsigned int>(nEntries);
m_Ar = Array<OneD, double>(nEntries, 0.0);
// Set up the universal ID array for XXT
Array<OneD, unsigned long> vId(nLocal);
// Loop over each elemental block, extract matrix indices and value
// and set the universal ID array
for(n = iCount = 0; n < nElmt; ++n)
{
loc_mat = GetBlock(vExp->GetOffset_Elmt_Id(n));
nRows = loc_mat->GetRows();
for(i = 0; i < nRows; ++i)
{
gid1 = pLocToGloMap->GetLocalToGlobalMap(iCount + i);
for(j = 0; j < nRows; ++j)
{
k = rCount + i*vSizes[n] + j;
m_Ai[k] = iCount + i;
m_Aj[k] = iCount + j;
m_Ar[k] = (*loc_mat)(i,j);
if (doSign)
{
m_Ar[k] *= vMapSign[iCount+i]*vMapSign[iCount+j];
}
}
// Dirichlet DOFs are not included in the solve, so we set
// these to the special XXT id=0.
if (gid1 < numDirBnd)
{
vId[iCount + i] = 0;
}
else
{
vId[iCount + i]
= pLocToGloMap->GetGlobalToUniversalMap(gid1);
}
}
iCount += vSizes[n];
rCount += vSizes[n]*vSizes[n];
}
// Set up XXT and output some stats
LibUtilities::CommSharedPtr vComm = pLocToGloMap->GetComm();
m_crsData = Xxt::Init(nLocal, vId, m_Ai, m_Aj, m_Ar, vComm);
}
static GlobalLinSysSharedPtr Nektar::MultiRegions::GlobalLinSysXxtFull::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 GlobalLinSysXxtFull.h.

{
return MemoryManager<GlobalLinSysXxtFull>::AllocateSharedPtr(pLinSysKey, pExpList, pLocToGloMap);
}
void Nektar::MultiRegions::GlobalLinSysXxtFull::CreateMap ( const boost::shared_ptr< AssemblyMap > &  pLocToGloMap)
private

Create the inverse multiplicity map.

Parameters
locToGloMapLocal to global mapping information.

Definition at line 151 of file GlobalLinSysXxtFull.cpp.

References Nektar::MultiRegions::GlobalLinSysXxt::m_locToGloSignMult, and Nektar::MultiRegions::GlobalLinSysXxt::m_map.

Referenced by GlobalLinSysXxtFull().

{
const Array<OneD, const int> &vMap
= pLocToGloMap->GetLocalToGlobalMap();
unsigned int nGlo = pLocToGloMap->GetNumGlobalCoeffs();
unsigned int nEntries = pLocToGloMap->GetNumLocalCoeffs();
unsigned int i;
// Count the multiplicity of each global DOF on this process
Array<OneD, NekDouble> vCounts(nGlo, 0.0);
for (i = 0; i < nEntries; ++i)
{
vCounts[vMap[i]] += 1.0;
}
// Get universal multiplicity by globally assembling counts
pLocToGloMap->UniversalAssemble(vCounts);
// Construct a map of 1/multiplicity for use in XXT solve
m_locToGloSignMult = Array<OneD, NekDouble>(nEntries);
for (i = 0; i < nEntries; ++i)
{
m_locToGloSignMult[i] = 1.0/vCounts[vMap[i]];
}
m_map = pLocToGloMap->GetLocalToGlobalMap();
}
void Nektar::MultiRegions::GlobalLinSysXxtFull::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 86 of file GlobalLinSysXxtFull.cpp.

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

{
bool dirForcCalculated = (bool) pDirForcing.num_elements();
int nDirDofs = pLocToGloMap->GetNumGlobalDirBndCoeffs();
int nGlobDofs = pLocToGloMap->GetNumGlobalCoeffs();
Array<OneD, NekDouble> tmp (nGlobDofs);
Array<OneD, NekDouble> tmp2(nGlobDofs);
Array<OneD, NekDouble> tmp3 = pOutput + nDirDofs;
if(nDirDofs)
{
// 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
//int nLocDofs = pLocToGloMap->GetNumLocalCoeffs();
m_expList.lock()->GeneralMatrixOp(
pOutput, tmp, eGlobal);
Vmath::Vsub( nGlobDofs, pInput.get(),1,
tmp.get(), 1,
tmp.get(), 1);
}
SolveLinearSystem(pLocToGloMap->GetNumLocalCoeffs(),
tmp, tmp2, pLocToGloMap);
// Enforce the Dirichlet boundary conditions on the solution
// array as XXT discards them.
Vmath::Vcopy(nDirDofs, pOutput, 1,
tmp2, 1);
}
else
{
Vmath::Vcopy(nGlobDofs, pInput, 1, tmp, 1);
SolveLinearSystem(pLocToGloMap->GetNumLocalCoeffs(),
tmp,tmp2, pLocToGloMap);
}
// Perturb the output array (previous solution) by the result of
// this solve to get full solution.
Vmath::Vadd(nGlobDofs - nDirDofs,
tmp2 + nDirDofs, 1, tmp3, 1, tmp3, 1);
}

Member Data Documentation

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

Name of class.

Registers the class with the Factory.

Definition at line 65 of file GlobalLinSysXxtFull.h.