35 #include <boost/core/ignore_unused.hpp> 47 namespace MultiRegions
59 string GlobalLinSysPETScStaticCond::className
62 GlobalLinSysPETScStaticCond::create,
63 "PETSc static condensation.");
65 string GlobalLinSysPETScStaticCond::className2
67 "PETScMultiLevelStaticCond",
68 GlobalLinSysPETScStaticCond::create,
69 "PETSc multi-level static condensation.");
90 GlobalLinSysPETScStaticCond::GlobalLinSysPETScStaticCond(
92 const std::weak_ptr<ExpList> &pExpList,
93 const std::shared_ptr<AssemblyMap> &pLocToGloMap)
100 "This constructor is only valid when using static " 103 == pLocToGloMap->GetGlobalSysSolnType(),
104 "The local to global map is not set up for the requested " 113 const std::weak_ptr<ExpList> &pExpList,
118 const std::shared_ptr<AssemblyMap> &pLocToGloMap,
149 int n, n_exp =
m_expList.lock()->GetNumElmts();
153 = asmMap->GetNumLocalBndCoeffsPerPatch();
159 for (n = 0; n < n_exp; ++n)
170 for (n = 0; n < n_exp; ++n)
179 cnt += mat->GetRows();
195 int i, j, n, cnt, gid1, gid2, loc_lda;
198 const int nDirDofs = pLocToGloMap->GetNumGlobalDirBndCoeffs();
217 pLocToGloMap->GetGlobalToUniversalBndMapUnique(),
221 SetUpMatVec(pLocToGloMap->GetNumGlobalBndCoeffs(), nDirDofs);
227 SetUpSolver(pLocToGloMap->GetIterativeTolerance());
237 for(n = cnt = 0; n <
m_schurCompl->GetNumberOfBlockRows(); ++n)
240 loc_lda = loc_mat->GetRows();
242 for(i = 0; i < loc_lda; ++i)
244 gid1 = pLocToGloMap->GetLocalToGlobalBndMap(cnt + i)-nDirDofs;
245 sign1 = pLocToGloMap->GetLocalToGlobalBndSign(cnt + i);
249 for(j = 0; j < loc_lda; ++j)
251 gid2 = pLocToGloMap->GetLocalToGlobalBndMap(cnt + j)
253 sign2 = pLocToGloMap->GetLocalToGlobalBndSign(cnt + j);
257 value = sign1*sign2*(*loc_mat)(i,j);
259 m_matrix, gid1ro, gid2ro, value, ADD_VALUES);
268 MatAssemblyBegin(
m_matrix, MAT_FINAL_ASSEMBLY);
269 MatAssemblyEnd (
m_matrix, MAT_FINAL_ASSEMBLY);
279 unsigned int nbdry = localMat->GetRows();
280 unsigned int nblks = 1;
281 unsigned int esize[1] = {nbdry};
285 schurComplBlock->SetBlock(0, 0, localMat);
287 return schurComplBlock;
294 boost::ignore_unused(F_GlobBnd);
318 m_precon->DoTransformToLowEnergy(pInOut, offset);
324 m_precon->DoTransformFromLowEnergy(pInOut);
344 int nLocBndDofs = asmMap->GetNumLocalBndCoeffs();
345 int nDirDofs = asmMap->GetNumGlobalDirBndCoeffs();
348 asmMap->GlobalToLocalBnd(input, in.GetPtr(), nDirDofs);
349 out = (*m_schurCompl) * in;
350 asmMap->AssembleBnd(out.
GetPtr(), output, nDirDofs);
355 const std::weak_ptr<ExpList> &pExpList,
360 const std::shared_ptr<AssemblyMap> &l2gMap)
364 mkey, pExpList, pSchurCompl, pBinvD, pC, pInvD, l2gMap,
366 sys->Initialise(l2gMap);
std::shared_ptr< GlobalLinSysStaticCond > GlobalLinSysStaticCondSharedPtr
std::shared_ptr< GlobalLinSysPETScStaticCond > GlobalLinSysPETScStaticCondSharedPtr
virtual void v_BasisBwdTransform(Array< OneD, NekDouble > &pInOut)
PreconditionerSharedPtr m_precon
std::weak_ptr< AssemblyMap > m_locToGloMap
Local to global map.
std::shared_ptr< DNekScalMat > DNekScalMatSharedPtr
DNekScalBlkMatSharedPtr m_schurCompl
Block Schur complement matrix.
General purpose memory allocation routines with the ability to allocate from thread specific memory p...
std::shared_ptr< DNekScalBlkMat > DNekScalBlkMatSharedPtr
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.
virtual void v_BasisFwdTransform(Array< OneD, NekDouble > &pInOut, int offset)
void SetupTopLevel(const std::shared_ptr< AssemblyMap > &locToGloMap)
Set up the storage for the Schur complement or the top level of the multi-level Schur complement...
void SetUpSolver(NekDouble tolerance)
Set up KSP solver object.
DNekScalBlkMatSharedPtr m_invD
Block matrix.
DNekScalBlkMatSharedPtr m_S1Blk
std::shared_ptr< AssemblyMap > AssemblyMapSharedPtr
virtual DNekScalBlkMatSharedPtr v_GetStaticCondBlock(unsigned int n)
Retrieves a the static condensation block matrices from n-th expansion using the matrix key provided ...
virtual void v_AssembleSchurComplement(std::shared_ptr< AssemblyMap > locToGloMap)
Assemble the Schur complement matrix.
StdRegions::MatrixType GetMatrixType() const
Return the matrix type.
Mat m_matrix
PETSc matrix object.
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
Describe a linear system.
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.
GlobalLinSysPETScStaticCond(const GlobalLinSysKey &mkey, const std::weak_ptr< ExpList > &pExpList, const std::shared_ptr< AssemblyMap > &locToGloMap)
Constructor for full direct matrix solve.
virtual GlobalLinSysStaticCondSharedPtr v_Recurse(const GlobalLinSysKey &mkey, const std::weak_ptr< ExpList > &pExpList, const DNekScalBlkMatSharedPtr pSchurCompl, const DNekScalBlkMatSharedPtr pBinvD, const DNekScalBlkMatSharedPtr pC, const DNekScalBlkMatSharedPtr pInvD, const std::shared_ptr< AssemblyMap > &locToGloMap)
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.
const std::weak_ptr< ExpList > m_expList
Local Matrix System.
GlobalSysSolnType GetGlobalSysSolnType() const
Return the associated solution type.
void SetUpMatVec(int nGlobal, int nDir)
Construct PETSc matrix and vector handles.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
std::shared_ptr< Preconditioner > PreconditionerSharedPtr
virtual ~GlobalLinSysPETScStaticCond()
void Initialise(const std::shared_ptr< AssemblyMap > &pLocToGloMap)
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...