45 namespace MultiRegions
50 string PreconditionerDiagonal::className
53 PreconditionerDiagonal::create,
54 "Diagonal Preconditioning");
62 PreconditionerDiagonal::PreconditionerDiagonal(
63 const std::shared_ptr<GlobalLinSys> &plinsys,
90 ASSERTL0(0,
"Unsupported solver type");
100 std::shared_ptr<MultiRegions::ExpList> expList =
101 ((
m_linsys.lock())->GetLocMat()).lock();
107 int i,j,n,cnt,gid1,gid2;
109 int nGlobal = asmMap->GetNumGlobalCoeffs();
110 int nDir = asmMap->GetNumGlobalDirBndCoeffs();
111 int nInt = nGlobal - nDir;
118 int nElmt = expList->GetNumElmts();
119 for(n = cnt = 0; n < nElmt; ++n)
121 loc_mat = (
m_linsys.lock())->GetBlock(n);
122 loc_row = loc_mat->GetRows();
124 for(i = 0; i < loc_row; ++i)
126 gid1 = asmMap->GetLocalToGlobalMap(cnt+i)-nDir;
127 sign1 = asmMap->GetLocalToGlobalSign(cnt+i);
131 for(j = 0; j < loc_row; ++j)
133 gid2 = asmMap->GetLocalToGlobalMap(cnt+j)
135 sign2 = asmMap->GetLocalToGlobalSign(cnt+j);
142 value = vOutput[gid1 + nDir]
143 + sign1*sign2*(*loc_mat)(i,j);
144 vOutput[gid1 + nDir] = value;
153 asmMap->UniversalAssemble(vOutput);
168 int nGlobalBnd = asmMap->GetNumGlobalBndCoeffs();
169 int nDirBnd = asmMap->GetNumGlobalDirBndCoeffs();
170 int rows = nGlobalBnd - nDirBnd;
176 for (
unsigned int i = 0; i < rows; ++i)
178 vOutput[nDirBnd + i] = diagonals[i];
182 asmMap->UniversalAssembleBnd(vOutput);
200 asmMap->GetNumGlobalCoeffs() :
201 asmMap->GetNumGlobalBndCoeffs();
202 int nDir = asmMap->GetNumGlobalDirBndCoeffs();
203 int nNonDir = nGlobal-nDir;
211 "No Preconditioning");
220 const std::shared_ptr<GlobalLinSys> &plinsys,
247 Vmath::Vcopy(pInput.num_elements(), pInput, 1, pOutput, 1);
#define ASSERTL0(condition, msg)
std::shared_ptr< DNekScalMat > DNekScalMatSharedPtr
virtual void v_DoPreconditioner(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)
Apply a preconditioner to the conjugate gradient method.
const std::weak_ptr< GlobalLinSys > m_linsys
static PreconditionerSharedPtr create(const std::shared_ptr< GlobalLinSys > &plinsys, const std::shared_ptr< AssemblyMap > &pLocToGloMap)
Creates an instance of this class.
virtual void v_DoPreconditioner(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)
Apply a preconditioner to the conjugate gradient method.
PreconFactory & GetPreconFactory()
void StaticCondDiagonalPreconditionerSum(void)
void Sdiv(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha/y.
virtual void v_BuildPreconditioner()
std::shared_ptr< AssemblyMap > AssemblyMapSharedPtr
virtual void v_InitObject()
virtual void v_InitObject()
Array< OneD, NekDouble > AssembleStaticCondGlobalDiagonals()
Performs global assembly of diagonal entries to global Schur complement matrix.
PreconditionerNull(const std::shared_ptr< GlobalLinSys > &plinsys, const AssemblyMapSharedPtr &pLocToGloMap)
std::shared_ptr< Expansion > ExpansionSharedPtr
Array< OneD, NekDouble > m_diagonals
void DiagonalPreconditionerSum(void)
static std::string className
Name of class.
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
std::weak_ptr< AssemblyMap > m_locToGloMap
void Vmul(int n, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
Multiply vector z = x*y.
virtual void v_BuildPreconditioner()