46 namespace MultiRegions
58 string GlobalLinSysPETScStaticCond::className
61 GlobalLinSysPETScStaticCond::create,
62 "PETSc static condensation.");
64 string GlobalLinSysPETScStaticCond::className2
66 "PETScMultiLevelStaticCond",
67 GlobalLinSysPETScStaticCond::create,
68 "PETSc multi-level static condensation.");
89 GlobalLinSysPETScStaticCond::GlobalLinSysPETScStaticCond(
91 const boost::weak_ptr<ExpList> &pExpList,
92 const boost::shared_ptr<AssemblyMap> &pLocToGloMap)
99 "This constructor is only valid when using static "
102 == pLocToGloMap->GetGlobalSysSolnType(),
103 "The local to global map is not set up for the requested "
112 const boost::weak_ptr<ExpList> &pExpList,
117 const boost::shared_ptr<AssemblyMap> &pLocToGloMap,
146 int n, n_exp =
m_expList.lock()->GetNumElmts();
156 for (n = 0; n < n_exp; ++n)
166 for (n = 0; n < n_exp; ++n)
173 m_expList.lock()->GetOffset_Elmt_Id(n), mat);
190 int i, j, n, cnt, gid1, gid2, loc_lda;
193 const int nDirDofs = pLocToGloMap->GetNumGlobalDirBndCoeffs();
212 pLocToGloMap->GetGlobalToUniversalBndMapUnique(),
216 SetUpMatVec(pLocToGloMap->GetNumGlobalBndCoeffs(), nDirDofs);
222 SetUpSolver(pLocToGloMap->GetIterativeTolerance());
232 for(n = cnt = 0; n <
m_schurCompl->GetNumberOfBlockRows(); ++n)
235 loc_lda = loc_mat->GetRows();
237 for(i = 0; i < loc_lda; ++i)
239 gid1 = pLocToGloMap->GetLocalToGlobalBndMap(cnt + i)-nDirDofs;
240 sign1 = pLocToGloMap->GetLocalToGlobalBndSign(cnt + i);
244 for(j = 0; j < loc_lda; ++j)
246 gid2 = pLocToGloMap->GetLocalToGlobalBndMap(cnt + j)
248 sign2 = pLocToGloMap->GetLocalToGlobalBndSign(cnt + j);
252 value = sign1*sign2*(*loc_mat)(i,j);
254 m_matrix, gid1ro, gid2ro, value, ADD_VALUES);
263 MatAssemblyBegin(
m_matrix, MAT_FINAL_ASSEMBLY);
264 MatAssemblyEnd (
m_matrix, MAT_FINAL_ASSEMBLY);
274 unsigned int nbdry = localMat->GetRows();
275 unsigned int nblks = 1;
276 unsigned int esize[1] = {nbdry};
280 schurComplBlock->SetBlock(0, 0, localMat);
282 return schurComplBlock;
311 m_precon->DoTransformToLowEnergy(pInOut, offset);
317 m_precon->DoTransformFromLowEnergy(pInOut);
339 m_locToGloMap->GlobalToLocalBnd(input, in.GetPtr(), nDirDofs);
340 out = (*m_schurCompl) * in;
346 const boost::weak_ptr<ExpList> &pExpList,
351 const boost::shared_ptr<AssemblyMap> &l2gMap)
355 mkey, pExpList, pSchurCompl, pBinvD, pC, pInvD, l2gMap,
357 sys->Initialise(l2gMap);
GlobalSysSolnType GetGlobalSysSolnType() const
Return the associated solution type.
boost::shared_ptr< GlobalLinSysPETScStaticCond > GlobalLinSysPETScStaticCondSharedPtr
virtual void v_BasisInvTransform(Array< OneD, NekDouble > &pInOut)
virtual void v_BasisTransform(Array< OneD, NekDouble > &pInOut, int offset)
PreconditionerSharedPtr m_precon
static boost::shared_ptr< DataType > AllocateSharedPtr()
Allocate a shared pointer from the memory pool.
boost::shared_ptr< AssemblyMap > AssemblyMapSharedPtr
DNekScalBlkMatSharedPtr m_schurCompl
Block Schur complement matrix.
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
virtual DNekScalBlkMatSharedPtr v_PreSolve(int scLevel, NekVector< NekDouble > &F_GlobBnd)
DNekScalBlkMatSharedPtr m_C
Block matrix.
void CalculateReordering(const Array< OneD, const int > &glo2uniMap, const Array< OneD, const int > &glo2unique, const AssemblyMapSharedPtr &pLocToGloMap)
Calculate a reordering of universal IDs for PETSc.
GlobalLinSysPETScStaticCond(const GlobalLinSysKey &mkey, const boost::weak_ptr< ExpList > &pExpList, const boost::shared_ptr< AssemblyMap > &locToGloMap)
Constructor for full direct matrix solve.
boost::shared_ptr< Preconditioner > PreconditionerSharedPtr
void SetUpSolver(NekDouble tolerance)
Set up KSP solver object.
void Initialise(const boost::shared_ptr< AssemblyMap > &pLocToGloMap)
DNekScalBlkMatSharedPtr m_invD
Block matrix.
DNekScalBlkMatSharedPtr m_S1Blk
boost::shared_ptr< DNekScalMat > DNekScalMatSharedPtr
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)
virtual DNekScalBlkMatSharedPtr v_GetStaticCondBlock(unsigned int n)
Retrieves a the static condensation block matrices from n-th expansion using the matrix key provided ...
Mat m_matrix
PETSc matrix object.
boost::shared_ptr< DNekScalBlkMat > DNekScalBlkMatSharedPtr
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...
Describe a linear system.
StdRegions::MatrixType GetMatrixType() const
Return the matrix type.
virtual void v_InitObject()
A PETSc global linear system.
void SetUpScatter()
Set up PETSc local (equivalent to Nektar++ global) and global (equivalent to universal) scatter maps...
const GlobalLinSysKey m_linSysKey
Key associated with this linear system.
virtual void v_DoMatrixMultiply(const Array< OneD, const NekDouble > &input, Array< OneD, NekDouble > &output)
Apply matrix-vector multiplication using local approach and the assembly map.
virtual void v_AssembleSchurComplement(boost::shared_ptr< AssemblyMap > locToGloMap)
Assemble the Schur complement matrix.
void SetUpMatVec(int nGlobal, int nDir)
Construct PETSc matrix and vector handles.
virtual ~GlobalLinSysPETScStaticCond()
boost::shared_ptr< AssemblyMap > m_locToGloMap
Local to global map.
GlobalLinSysFactory & GetGlobalLinSysFactory()
std::vector< int > m_reorderedMap
Reordering that takes universal IDs to a unique row in the PETSc matrix.
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
DNekScalBlkMatSharedPtr m_BinvD
Block matrix.
Array< OneD, DataType > & GetPtr()
PETScMatMult m_matMult
Enumerator to select matrix multiplication type.
PreconditionerSharedPtr CreatePrecon(AssemblyMapSharedPtr asmMap)
Create a preconditioner object from the parameters defined in the supplied assembly map...
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.
boost::shared_ptr< GlobalLinSysStaticCond > GlobalLinSysStaticCondSharedPtr
const boost::weak_ptr< ExpList > m_expList
Local Matrix System.