45 namespace MultiRegions
54 string GlobalLinSysPETScFull::className
57 GlobalLinSysPETScFull::create,
58 "PETSc Full Matrix.");
62 GlobalLinSysPETScFull::GlobalLinSysPETScFull(
64 const std::weak_ptr<ExpList> &pExp,
65 const std::shared_ptr<AssemblyMap> &pLocToGloMap)
69 const int nDirDofs = pLocToGloMap->GetNumGlobalDirBndCoeffs();
71 int i, j, n, cnt, gid1, gid2, loc_lda;
77 pLocToGloMap->GetGlobalToUniversalMapUnique(),
81 SetUpMatVec(pLocToGloMap->GetNumGlobalCoeffs(), nDirDofs);
90 for(n = cnt = 0; n <
m_expList.lock()->GetNumElmts(); ++n)
93 loc_lda = loc_mat->GetRows();
95 for(i = 0; i < loc_lda; ++i)
97 gid1 = pLocToGloMap->GetLocalToGlobalMap(cnt+i) - nDirDofs;
98 sign1 = pLocToGloMap->GetLocalToGlobalSign(cnt + i);
102 for(j = 0; j < loc_lda; ++j)
104 gid2 = pLocToGloMap->GetLocalToGlobalMap(cnt + j)
106 sign2 = pLocToGloMap->GetLocalToGlobalSign(cnt + j);
110 value = sign1*sign2*(*loc_mat)(i,j);
112 m_matrix, gid1ro, gid2ro, value, ADD_VALUES);
121 MatAssemblyBegin(
m_matrix, MAT_FINAL_ASSEMBLY);
122 MatAssemblyEnd (
m_matrix, MAT_FINAL_ASSEMBLY);
141 bool dirForcCalculated = (bool) pDirForcing.num_elements();
142 int nDirDofs = pLocToGloMap->GetNumGlobalDirBndCoeffs();
143 int nGlobDofs = pLocToGloMap->GetNumGlobalCoeffs();
146 int nDirTotal = nDirDofs;
147 m_expList.lock()->GetComm()->GetRowComm()->AllReduce(
153 if(dirForcCalculated)
157 pDirForcing.get(), 1,
175 Vmath::Vadd(nGlobDofs-nDirDofs, &out [nDirDofs], 1,
176 &pOutput[nDirDofs], 1, &pOutput[nDirDofs], 1);
195 std::shared_ptr<MultiRegions::ExpList> expList =
m_expList.lock();
198 expList->GeneralMatrixOp(
virtual ~GlobalLinSysPETScFull()
std::shared_ptr< DNekScalMat > DNekScalMatSharedPtr
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.
std::shared_ptr< AssemblyMap > AssemblyMapSharedPtr
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.
const std::weak_ptr< ExpList > m_expList
Local Matrix System.
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.
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.