59 const std::shared_ptr<GlobalLinSys> &plinsys,
85 ASSERTL0(0,
"Unsupported solver type");
95 std::shared_ptr<MultiRegions::ExpList> expList =
96 ((
m_linsys.lock())->GetLocMat()).lock();
99 int nGlobal = asmMap->GetNumGlobalCoeffs();
100 int nDir = asmMap->GetNumGlobalDirBndCoeffs();
101 int nInt = nGlobal - nDir;
102 int nElmt = expList->GetNumElmts();
105 for (
int n = 0, cnt = 0; n < nElmt; ++n)
107 auto loc_mat = (
m_linsys.lock())->GetBlock(n);
108 int loc_row = loc_mat->GetRows();
109 for (
int i = 0; i < loc_row; ++i)
111 int gid1 = asmMap->GetLocalToGlobalMap(cnt + i);
112 vOutput[gid1] += (*loc_mat)(i, i);
118 asmMap->UniversalAssemble(vOutput);
133 int nGlobalBnd = asmMap->GetNumGlobalBndCoeffs();
134 int nDirBnd = asmMap->GetNumGlobalDirBndCoeffs();
135 int rows = nGlobalBnd - nDirBnd;
141 for (
unsigned int i = 0; i < rows; ++i)
143 vOutput[nDirBnd + i] = diagonals[i];
147 asmMap->UniversalAssembleBnd(vOutput);
166 int nGlobal = (isFull) ? asmMap->GetNumGlobalCoeffs()
167 : asmMap->GetNumGlobalBndCoeffs();
168 int nDir = asmMap->GetNumGlobalDirBndCoeffs();
169 int nNonDir = nGlobal - nDir;
174 (isFull) ? asmMap->Assemble(pInput, wk)
175 : asmMap->AssembleBnd(pInput, wk);
177 wk.data() + nDir, 1);
179 (isFull) ? asmMap->GlobalToLocal(wk, pOutput)
180 : asmMap->GlobalToLocalBnd(wk, pOutput);
199 const std::shared_ptr<GlobalLinSys> &plinsys,
233 int nGlobal = (isFull) ? asmMap->GetNumGlobalCoeffs()
234 : asmMap->GetNumGlobalBndCoeffs();
235 int nDir = asmMap->GetNumGlobalDirBndCoeffs();
240 (isFull) ? asmMap->Assemble(pInput, wk)
241 : asmMap->AssembleBnd(pInput, wk);
243 (isFull) ? asmMap->GlobalToLocal(wk, pOutput)
244 : asmMap->GlobalToLocalBnd(wk, pOutput);
266 const std::shared_ptr<GlobalLinSys> &plinsys,
280 auto expList = ((
m_linsys.lock())->GetLocMat()).lock();
281 std::shared_ptr<LibUtilities::SessionReader> session =
282 expList->GetSession();
286 if (session->DefinesGlobalSysSolnInfo(var,
"JacobiIterations"))
288 m_niter = boost::lexical_cast<int>(
289 session->GetGlobalSysSolnInfo(var,
"JacobiIterations").c_str());
309 ? asmMap->GetNumGlobalCoeffs()
310 : asmMap->GetNumGlobalBndCoeffs();
311 int nDir = asmMap->GetNumGlobalDirBndCoeffs();
312 int nNonDir = nGlobal - nDir;
318 ? asmMap->GetNumLocalCoeffs()
319 : asmMap->GetNumLocalBndCoeffs();
322 asmMap->Assemble(pInput, wk);
324 wk.data() + nDir, 1);
327 for (
int n = 1; n <
m_niter; ++n)
329 asmMap->GlobalToLocal(wk, pOutput);
332 std::dynamic_pointer_cast<GlobalLinSysIterative>(
m_linsys.lock())
333 ->DoMatrixMultiply(pOutput, wk1);
337 asmMap->Assemble(wk1, pOutput);
339 1, wk.data() + nDir, 1, wk.data() + nDir, 1);
342 asmMap->GlobalToLocal(wk, pOutput);
348 wk.data() + nDir, 1);
351 for (
int n = 1; n <
m_niter; ++n)
354 std::dynamic_pointer_cast<GlobalLinSysIterative>(
m_linsys.lock())
355 ->DoMatrixMultiply(wk, wk1);
358 Vmath::Vsub(nNonDir, pInput.data(), 1, wk1.data() + nDir, 1,
359 wk1.data() + nDir, 1);
363 wk.data() + nDir, 1, wk.data() + nDir, 1);
366 Vmath::Vcopy(nNonDir, wk.data() + nDir, 1, pOutput.data(), 1);
#define ASSERTL0(condition, msg)
tKey RegisterCreatorFunction(tKey idKey, CreatorFunction classCreator, std::string pDesc="")
Register a class with the factory.
void v_BuildPreconditioner() override
void StaticCondDiagonalPreconditionerSum(void)
static PreconditionerSharedPtr create(const std::shared_ptr< GlobalLinSys > &plinsys, const std::shared_ptr< AssemblyMap > &pLocToGloMap)
Creates an instance of this class.
Array< OneD, NekDouble > m_diagonals
void v_InitObject() override
void DiagonalPreconditionerSum(void)
PreconditionerDiagonal(const std::shared_ptr< GlobalLinSys > &plinsys, const AssemblyMapSharedPtr &pLocToGloMap)
void v_DoPreconditioner(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const bool &IsLocal=false) override
Apply a preconditioner to the conjugate gradient method.
static std::string className
Name of class.
const std::weak_ptr< GlobalLinSys > m_linsys
Array< OneD, NekDouble > AssembleStaticCondGlobalDiagonals()
Performs global assembly of diagonal entries to global Schur complement matrix.
std::weak_ptr< AssemblyMap > m_locToGloMap
void v_InitObject() override
static PreconditionerSharedPtr create(const std::shared_ptr< GlobalLinSys > &plinsys, const std::shared_ptr< AssemblyMap > &pLocToGloMap)
Creates an instance of this class.
PreconditionerJacobi(const std::shared_ptr< GlobalLinSys > &plinsys, const AssemblyMapSharedPtr &pLocToGloMap)
void v_BuildPreconditioner() override
static std::string className
Name of class.
void v_DoPreconditioner(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const bool &IsLocal=false) override
Apply a preconditioner to the conjugate gradient method.
void v_BuildPreconditioner() override
void v_DoPreconditioner(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput, const bool &isLocal=false) override
Apply a preconditioner to the conjugate gradient method.
static std::string className
Name of class.
void v_InitObject() override
PreconditionerNull(const std::shared_ptr< GlobalLinSys > &plinsys, const AssemblyMapSharedPtr &pLocToGloMap)
static PreconditionerSharedPtr create(const std::shared_ptr< GlobalLinSys > &plinsys, const std::shared_ptr< AssemblyMap > &pLocToGloMap)
Creates an instance of this class.
@ eIterativeMultiLevelStaticCond
@ ePETScMultiLevelStaticCond
PreconFactory & GetPreconFactory()
std::shared_ptr< AssemblyMap > AssemblyMapSharedPtr
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.
void Vvtvp(int n, const T *w, const int incw, const T *x, const int incx, const T *y, const int incy, T *z, const int incz)
vvtvp (vector times vector plus vector): z = w*x + y
void Sdiv(int n, const T alpha, const T *x, const int incx, T *y, const int incy)
Scalar multiply y = alpha/x.
void Zero(int n, T *x, const int incx)
Zero vector.
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
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.