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(),
83 for(n = cnt = 0; n <
m_expList.lock()->GetNumElmts(); ++n)
86 loc_lda = loc_mat->GetRows();
88 for(i = 0; i < loc_lda; ++i)
90 gid1 = pLocToGloMap->GetLocalToGlobalMap(cnt+i) - nDirDofs;
91 sign1 = pLocToGloMap->GetLocalToGlobalSign(cnt + i);
95 for(j = 0; j < loc_lda; ++j)
97 gid2 = pLocToGloMap->GetLocalToGlobalMap(cnt + j)
99 sign2 = pLocToGloMap->GetLocalToGlobalSign(cnt + j);
103 value = sign1*sign2*(*loc_mat)(i,j);
105 m_matrix, gid1ro, gid2ro, value, ADD_VALUES);
114 MatAssemblyBegin(
m_matrix, MAT_FINAL_ASSEMBLY);
115 MatAssemblyEnd (
m_matrix, MAT_FINAL_ASSEMBLY);
121 SetUpSolver(pLocToGloMap->GetIterativeTolerance());
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);
virtual ~GlobalLinSysPETScFull()
static std::string className
Name of class.
void SetUpMatVec()
Construct PETSc matrix and vector handles.
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
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)
Describe a 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.
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.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, tDescription pDesc="")
Register a class with the factory.
const boost::weak_ptr< ExpList > m_expList
Local Matrix System.