44 namespace MultiRegions
57 "PETSc Full Matrix.");
63 const boost::weak_ptr<ExpList> &pExp,
64 const boost::shared_ptr<AssemblyMap> &pLocToGloMap)
68 const int nDirDofs = pLocToGloMap->GetNumGlobalDirBndCoeffs();
70 int i, j, n, cnt, gid1, gid2, loc_lda;
76 pLocToGloMap->GetGlobalToUniversalMapUnique(),
80 SetUpMatVec(pLocToGloMap->GetNumGlobalCoeffs(), nDirDofs);
89 for(n = cnt = 0; n <
m_expList.lock()->GetNumElmts(); ++n)
92 loc_lda = loc_mat->GetRows();
94 for(i = 0; i < loc_lda; ++i)
96 gid1 = pLocToGloMap->GetLocalToGlobalMap(cnt+i) - nDirDofs;
97 sign1 = pLocToGloMap->GetLocalToGlobalSign(cnt + i);
101 for(j = 0; j < loc_lda; ++j)
103 gid2 = pLocToGloMap->GetLocalToGlobalMap(cnt + j)
105 sign2 = pLocToGloMap->GetLocalToGlobalSign(cnt + j);
109 value = sign1*sign2*(*loc_mat)(i,j);
111 m_matrix, gid1ro, gid2ro, value, ADD_VALUES);
120 MatAssemblyBegin(
m_matrix, MAT_FINAL_ASSEMBLY);
121 MatAssemblyEnd (
m_matrix, MAT_FINAL_ASSEMBLY);
140 bool dirForcCalculated = (bool) pDirForcing.num_elements();
141 int nDirDofs = pLocToGloMap->GetNumGlobalDirBndCoeffs();
142 int nGlobDofs = pLocToGloMap->GetNumGlobalCoeffs();
145 int nDirTotal = nDirDofs;
146 m_expList.lock()->GetComm()->GetRowComm()->AllReduce(
152 if(dirForcCalculated)
156 pDirForcing.get(), 1,
174 Vmath::Vadd(nGlobDofs-nDirDofs, &out [nDirDofs], 1,
175 &pOutput[nDirDofs], 1, &pOutput[nDirDofs], 1);
194 boost::shared_ptr<MultiRegions::ExpList> expList =
m_expList.lock();
197 expList->GeneralMatrixOp(
virtual ~GlobalLinSysPETScFull()
static std::string className
Name of class.
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.
GlobalLinSysPETScFull(const GlobalLinSysKey &pLinSysKey, const boost::weak_ptr< ExpList > &pExpList, const boost::shared_ptr< AssemblyMap > &pLocToGloMap)
Constructor for full direct matrix solve.
void SetUpSolver(NekDouble tolerance)
Set up KSP solver object.
vector< int > m_reorderedMap
Reordering that takes universal IDs to a unique row in the PETSc matrix.
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()
static GlobalLinSysSharedPtr create(const GlobalLinSysKey &pLinSysKey, const boost::weak_ptr< ExpList > &pExpList, const boost::shared_ptr< AssemblyMap > &pLocToGloMap)
Creates an instance of this class.
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.