46 namespace MultiRegions
55 string GlobalLinSysPETScFull::className
58 GlobalLinSysPETScFull::create,
59 "PETSc Full Matrix.");
63 GlobalLinSysPETScFull::GlobalLinSysPETScFull(
65 const boost::weak_ptr<ExpList> &pExp,
66 const boost::shared_ptr<AssemblyMap> &pLocToGloMap)
70 const int nDirDofs = pLocToGloMap->GetNumGlobalDirBndCoeffs();
72 int i, j, n, cnt, gid1, gid2, loc_lda;
78 pLocToGloMap->GetGlobalToUniversalMapUnique(),
82 SetUpMatVec(pLocToGloMap->GetNumGlobalCoeffs(), nDirDofs);
91 for(n = cnt = 0; n <
m_expList.lock()->GetNumElmts(); ++n)
94 loc_lda = loc_mat->GetRows();
96 for(i = 0; i < loc_lda; ++i)
98 gid1 = pLocToGloMap->GetLocalToGlobalMap(cnt+i) - nDirDofs;
99 sign1 = pLocToGloMap->GetLocalToGlobalSign(cnt + i);
103 for(j = 0; j < loc_lda; ++j)
105 gid2 = pLocToGloMap->GetLocalToGlobalMap(cnt + j)
107 sign2 = pLocToGloMap->GetLocalToGlobalSign(cnt + j);
111 value = sign1*sign2*(*loc_mat)(i,j);
113 m_matrix, gid1ro, gid2ro, value, ADD_VALUES);
122 MatAssemblyBegin(
m_matrix, MAT_FINAL_ASSEMBLY);
123 MatAssemblyEnd (
m_matrix, MAT_FINAL_ASSEMBLY);
142 bool dirForcCalculated = (bool) pDirForcing.num_elements();
143 int nDirDofs = pLocToGloMap->GetNumGlobalDirBndCoeffs();
144 int nGlobDofs = pLocToGloMap->GetNumGlobalCoeffs();
147 int nDirTotal = nDirDofs;
148 m_expList.lock()->GetComm()->GetRowComm()->AllReduce(
154 if(dirForcCalculated)
158 pDirForcing.get(), 1,
176 Vmath::Vadd(nGlobDofs-nDirDofs, &out [nDirDofs], 1,
177 &pOutput[nDirDofs], 1, &pOutput[nDirDofs], 1);
196 boost::shared_ptr<MultiRegions::ExpList> expList =
m_expList.lock();
199 expList->GeneralMatrixOp(
virtual ~GlobalLinSysPETScFull()
boost::shared_ptr< AssemblyMap > AssemblyMapSharedPtr
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.
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.
void SetUpSolver(NekDouble tolerance)
Set up KSP solver object.
boost::shared_ptr< DNekScalMat > DNekScalMatSharedPtr
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...
DNekScalMatSharedPtr GetBlock(unsigned int n)
Mat m_matrix
PETSc matrix object.
Describe a linear system.
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.
void Vsub(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Subtract vector z = x-y.
void SetUpMatVec(int nGlobal, int nDir)
Construct PETSc matrix and vector handles.
GlobalLinSysFactory & GetGlobalLinSysFactory()
std::vector< int > m_reorderedMap
Reordering that takes universal IDs to a unique row in the PETSc matrix.
void Vadd(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Add vector z = x+y.
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.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.
const boost::weak_ptr< ExpList > m_expList
Local Matrix System.