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

A global linear system. More...

#include <GlobalLinSysXxtStaticCond.h>

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

Public Member Functions

 GlobalLinSysXxtStaticCond (const GlobalLinSysKey &mkey, const boost::weak_ptr< ExpList > &pExpList, const boost::shared_ptr< AssemblyMap > &locToGloMap)
 Constructor for full direct matrix solve.
 GlobalLinSysXxtStaticCond (const GlobalLinSysKey &mkey, const boost::weak_ptr< ExpList > &pExpList, const DNekScalBlkMatSharedPtr pSchurCompl, const DNekScalBlkMatSharedPtr pBinvD, const DNekScalBlkMatSharedPtr pC, const DNekScalBlkMatSharedPtr pInvD, const boost::shared_ptr< AssemblyMap > &locToGloMap)
 Constructor for full direct matrix solve.
virtual ~GlobalLinSysXxtStaticCond ()
- 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.
- Public Member Functions inherited from Nektar::MultiRegions::GlobalLinSysStaticCond
 GlobalLinSysStaticCond (const GlobalLinSysKey &mkey, const boost::weak_ptr< ExpList > &pExpList, const boost::shared_ptr< AssemblyMap > &locToGloMap)
 Constructor for full direct matrix solve.
virtual ~GlobalLinSysStaticCond ()

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.
static std::string className2

Protected Member Functions

void CreateMap (const boost::shared_ptr< AssemblyMap > &pLocToGloMap)
virtual void v_AssembleSchurComplement (boost::shared_ptr< AssemblyMap > locToGloMap)
 Assemble the Schur complement matrix.
virtual
GlobalLinSysStaticCondSharedPtr 
v_Recurse (const GlobalLinSysKey &mkey, const boost::weak_ptr< ExpList > &pExpList, const DNekScalBlkMatSharedPtr pSchurCompl, const DNekScalBlkMatSharedPtr pBinvD, const DNekScalBlkMatSharedPtr pC, const DNekScalBlkMatSharedPtr pInvD, const boost::shared_ptr< AssemblyMap > &locToGloMap)
- 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 Member Functions inherited from Nektar::MultiRegions::GlobalLinSys
virtual DNekScalMatSharedPtr v_GetBlock (unsigned int n)
 Retrieves the block matrix from n-th expansion using the matrix key provided by the m_linSysKey.
virtual DNekScalBlkMatSharedPtr v_GetStaticCondBlock (unsigned int n)
 Retrieves a the static condensation block matrices from n-th expansion using the matrix key provided by the m_linSysKey.
virtual void v_DropStaticCondBlock (unsigned int n)
 Releases the static condensation block matrices from NekManager of n-th expansion using the matrix key provided by the m_linSysKey.
- Protected Member Functions inherited from Nektar::MultiRegions::GlobalLinSysStaticCond
virtual DNekScalBlkMatSharedPtr v_PreSolve (int scLevel, NekVector< NekDouble > &F_GlobBnd)
virtual void v_BasisTransform (Array< OneD, NekDouble > &pInOut, int offset)
virtual void v_BasisInvTransform (Array< OneD, NekDouble > &pInOut)
virtual int v_GetNumBlocks ()
 Get the number of blocks in this system.
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.
virtual void v_InitObject ()
virtual void v_Initialise (const boost::shared_ptr< AssemblyMap > &locToGloMap)
 Initialise this object.
void SetupTopLevel (const boost::shared_ptr< AssemblyMap > &locToGloMap)
 Set up the storage for the Schur complement or the top level of the multi-level Schur complement.
void ConstructNextLevelCondensedSystem (const boost::shared_ptr< AssemblyMap > &locToGloMap)

Additional Inherited Members

- 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
- Protected Attributes inherited from Nektar::MultiRegions::GlobalLinSysStaticCond
GlobalLinSysStaticCondSharedPtr m_recursiveSchurCompl
 Schur complement for Direct Static Condensation.
DNekScalBlkMatSharedPtr m_schurCompl
 Block Schur complement matrix.
DNekScalBlkMatSharedPtr m_BinvD
 Block $ BD^{-1} $ matrix.
DNekScalBlkMatSharedPtr m_C
 Block $ C $ matrix.
DNekScalBlkMatSharedPtr m_invD
 Block $ D^{-1} $ matrix.
boost::shared_ptr< AssemblyMapm_locToGloMap
 Local to global map.
Array< OneD, NekDoublem_wsp
 Workspace array for matrix multiplication.

Detailed Description

A global linear system.

Definition at line 57 of file GlobalLinSysXxtStaticCond.h.

Constructor & Destructor Documentation

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

Constructor for full direct matrix solve.

For a matrix system of the form

\[ \left[ \begin{array}{cc} \boldsymbol{A} & \boldsymbol{B}\\ \boldsymbol{C} & \boldsymbol{D} \end{array} \right] \left[ \begin{array}{c} \boldsymbol{x_1}\\ \boldsymbol{x_2} \end{array}\right] = \left[ \begin{array}{c} \boldsymbol{y_1}\\ \boldsymbol{y_2} \end{array}\right], \]

where $\boldsymbol{D}$ and $(\boldsymbol{A-BD^{-1}C})$ are invertible, store and assemble a static condensation system, according to a given local to global mapping. #m_linSys is constructed by AssembleSchurComplement().

Parameters
mKeyAssociated matrix key.
pLocMatSysLocalMatrixSystem
locToGloMapLocal to global mapping.

Definition at line 86 of file GlobalLinSysXxtStaticCond.cpp.

References ASSERTL1, Nektar::MultiRegions::eXxtMultiLevelStaticCond, Nektar::MultiRegions::eXxtStaticCond, and Nektar::MultiRegions::GlobalLinSysKey::GetGlobalSysSolnType().

: GlobalLinSys (pKey, pExpList, pLocToGloMap),
GlobalLinSysXxt (pKey, pExpList, pLocToGloMap),
GlobalLinSysStaticCond(pKey, pExpList, pLocToGloMap)
{
ASSERTL1((pKey.GetGlobalSysSolnType()==eXxtStaticCond)||
(pKey.GetGlobalSysSolnType()==eXxtMultiLevelStaticCond),
"This constructor is only valid when using static "
"condensation");
ASSERTL1(pKey.GetGlobalSysSolnType()
== pLocToGloMap->GetGlobalSysSolnType(),
"The local to global map is not set up for the requested "
"solution type");
}
Nektar::MultiRegions::GlobalLinSysXxtStaticCond::GlobalLinSysXxtStaticCond ( const GlobalLinSysKey mkey,
const boost::weak_ptr< ExpList > &  pExpList,
const DNekScalBlkMatSharedPtr  pSchurCompl,
const DNekScalBlkMatSharedPtr  pBinvD,
const DNekScalBlkMatSharedPtr  pC,
const DNekScalBlkMatSharedPtr  pInvD,
const boost::shared_ptr< AssemblyMap > &  locToGloMap 
)

Constructor for full direct matrix solve.

Definition at line 109 of file GlobalLinSysXxtStaticCond.cpp.

References Nektar::MultiRegions::GlobalLinSysStaticCond::m_BinvD, Nektar::MultiRegions::GlobalLinSysStaticCond::m_C, Nektar::MultiRegions::GlobalLinSysStaticCond::m_invD, Nektar::MultiRegions::GlobalLinSysStaticCond::m_locToGloMap, and Nektar::MultiRegions::GlobalLinSysStaticCond::m_schurCompl.

: GlobalLinSys (pKey, pExpList, pLocToGloMap),
GlobalLinSysXxt (pKey, pExpList, pLocToGloMap),
GlobalLinSysStaticCond(pKey, pExpList, pLocToGloMap)
{
m_schurCompl = pSchurCompl;
m_BinvD = pBinvD;
m_C = pC;
m_invD = pInvD;
m_locToGloMap = pLocToGloMap;
}
Nektar::MultiRegions::GlobalLinSysXxtStaticCond::~GlobalLinSysXxtStaticCond ( )
virtual

Definition at line 133 of file GlobalLinSysXxtStaticCond.cpp.

{
}

Member Function Documentation

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

{
GlobalLinSysXxtStaticCond>::AllocateSharedPtr(
pLinSysKey, pExpList, pLocToGloMap);
p->InitObject();
return p;
}
void Nektar::MultiRegions::GlobalLinSysXxtStaticCond::CreateMap ( const boost::shared_ptr< AssemblyMap > &  pLocToGloMap)
protected

Create the inverse multiplicity map.

Parameters
locToGloMapLocal to global mapping information.

Definition at line 142 of file GlobalLinSysXxtStaticCond.cpp.

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

Referenced by v_AssembleSchurComplement().

{
const Array<OneD, const int> &vMap
= pLocToGloMap->GetLocalToGlobalBndMap();
unsigned int nGlo = pLocToGloMap->GetNumGlobalBndCoeffs();
unsigned int nEntries = pLocToGloMap->GetNumLocalBndCoeffs();
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->UniversalAssembleBnd(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->GetLocalToGlobalBndMap();
}
void Nektar::MultiRegions::GlobalLinSysXxtStaticCond::v_AssembleSchurComplement ( boost::shared_ptr< AssemblyMap pLocToGloMap)
protectedvirtual

Assemble the Schur complement matrix.

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.

Reimplemented from Nektar::MultiRegions::GlobalLinSysStaticCond.

Definition at line 176 of file GlobalLinSysXxtStaticCond.cpp.

References CreateMap(), 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::GlobalLinSysStaticCond::m_schurCompl, and Xxt::nektar_crs_stats().

{
CreateMap(pLocToGloMap);
ExpListSharedPtr vExp = m_expList.lock();
unsigned int nElmt = m_schurCompl->GetNumberOfBlockRows();
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->GetNumLocalBndCoeffs();
const Array<OneD, NekDouble> &vMapSign
= pLocToGloMap->GetLocalToGlobalBndSign();
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
for (n = 0; n < nElmt; ++n)
{
loc_mat = m_schurCompl->GetBlock(n,n);
vSizes[n] = loc_mat->GetRows();
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 = m_schurCompl->GetBlock(n,n);
nRows = loc_mat->GetRows();
for(i = 0; i < nRows; ++i)
{
gid1 = pLocToGloMap->GetLocalToGlobalBndMap(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->GetGlobalToUniversalBndMap()[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);
}
GlobalLinSysStaticCondSharedPtr Nektar::MultiRegions::GlobalLinSysXxtStaticCond::v_Recurse ( const GlobalLinSysKey mkey,
const boost::weak_ptr< ExpList > &  pExpList,
const DNekScalBlkMatSharedPtr  pSchurCompl,
const DNekScalBlkMatSharedPtr  pBinvD,
const DNekScalBlkMatSharedPtr  pC,
const DNekScalBlkMatSharedPtr  pInvD,
const boost::shared_ptr< AssemblyMap > &  locToGloMap 
)
protectedvirtual

Implements Nektar::MultiRegions::GlobalLinSysStaticCond.

Definition at line 258 of file GlobalLinSysXxtStaticCond.cpp.

{
GlobalLinSysXxtStaticCond>::AllocateSharedPtr(
mkey, pExpList, pSchurCompl, pBinvD, pC, pInvD, l2gMap);
sys->Initialise(l2gMap);
return sys;
}

Member Data Documentation

string Nektar::MultiRegions::GlobalLinSysXxtStaticCond::className
static
Initial value:
"XxtStaticCond",
"Iterative static condensation.")

Name of class.

Registers the class with the Factory.

Definition at line 76 of file GlobalLinSysXxtStaticCond.h.

string Nektar::MultiRegions::GlobalLinSysXxtStaticCond::className2
static
Initial value:
"XxtMultiLevelStaticCond",
"Xxt multi-level static condensation.")

Definition at line 77 of file GlobalLinSysXxtStaticCond.h.