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 if (asmMap->GetLocalToGlobalSign(
114 int gid1 = asmMap->GetLocalToGlobalMap(cnt + i);
115 vOutput[gid1] += (*loc_mat)(i, i);
122 asmMap->UniversalAssemble(vOutput);
136 int nGlobalBnd = asmMap->GetNumGlobalBndCoeffs();
137 int nDirBnd = asmMap->GetNumGlobalDirBndCoeffs();
138 int rows = nGlobalBnd - nDirBnd;
144 for (
unsigned int i = 0; i < rows; ++i)
146 vOutput[nDirBnd + i] = diagonals[i];
150 asmMap->UniversalAssembleBnd(vOutput);
169 int nGlobal = (isFull) ? asmMap->GetNumGlobalCoeffs()
170 : asmMap->GetNumGlobalBndCoeffs();
171 int nDir = asmMap->GetNumGlobalDirBndCoeffs();
172 int nNonDir = nGlobal - nDir;
177 (isFull) ? asmMap->Assemble(pInput, wk)
178 : asmMap->AssembleBnd(pInput, wk);
180 wk.data() + nDir, 1);
182 (isFull) ? asmMap->GlobalToLocal(wk, pOutput)
183 : asmMap->GlobalToLocalBnd(wk, pOutput);
202 const std::shared_ptr<GlobalLinSys> &plinsys,
236 int nGlobal = (isFull) ? asmMap->GetNumGlobalCoeffs()
237 : asmMap->GetNumGlobalBndCoeffs();
238 int nDir = asmMap->GetNumGlobalDirBndCoeffs();
243 (isFull) ? asmMap->Assemble(pInput, wk)
244 : asmMap->AssembleBnd(pInput, wk);
246 (isFull) ? asmMap->GlobalToLocal(wk, pOutput)
247 : asmMap->GlobalToLocalBnd(wk, pOutput);
269 const std::shared_ptr<GlobalLinSys> &plinsys,
283 auto expList = ((
m_linsys.lock())->GetLocMat()).lock();
284 std::shared_ptr<LibUtilities::SessionReader> session =
285 expList->GetSession();
289 if (session->DefinesGlobalSysSolnInfo(var,
"JacobiIterations"))
292 session->GetGlobalSysSolnInfo(var,
"JacobiIterations").c_str());
312 ? asmMap->GetNumGlobalCoeffs()
313 : asmMap->GetNumGlobalBndCoeffs();
314 int nDir = asmMap->GetNumGlobalDirBndCoeffs();
315 int nNonDir = nGlobal - nDir;
321 ? asmMap->GetNumLocalCoeffs()
322 : asmMap->GetNumLocalBndCoeffs();
326 asmMap->Assemble(pInput, wk);
328 wk.data() + nDir, 1);
331 for (
int n = 1; n <
m_niter; ++n)
333 asmMap->GlobalToLocal(wk, pOutput);
336 std::dynamic_pointer_cast<GlobalLinSysIterative>(
m_linsys.lock())
337 ->DoMatrixMultiply(pOutput, wk1);
342 asmMap->Assemble(wk1, pOutput);
345 1, wk.data() + nDir, 1, wk.data() + nDir, 1);
348 asmMap->GlobalToLocal(wk, pOutput);
356 wk.data() + nDir, 1);
359 for (
int n = 1; n <
m_niter; ++n)
362 std::dynamic_pointer_cast<GlobalLinSysIterative>(
m_linsys.lock())
363 ->DoMatrixMultiply(wk, wk1);
366 Vmath::Vsub(nNonDir, pInput.data(), 1, wk1.data() + nDir, 1,
367 wk1.data() + nDir, 1);
371 wk.data() + nDir, 1, wk.data() + nDir, 1);
374 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.