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);
137 int nGlobalBnd = asmMap->GetNumGlobalBndCoeffs();
138 int nDirBnd = asmMap->GetNumGlobalDirBndCoeffs();
139 int rows = nGlobalBnd - nDirBnd;
145 for (
unsigned int i = 0; i < rows; ++i)
147 vOutput[nDirBnd + i] = diagonals[i];
151 asmMap->UniversalAssembleBnd(vOutput);
170 int nGlobal = (isFull) ? asmMap->GetNumGlobalCoeffs()
171 : asmMap->GetNumGlobalBndCoeffs();
172 int nDir = asmMap->GetNumGlobalDirBndCoeffs();
173 int nNonDir = nGlobal - nDir;
178 (isFull) ? asmMap->Assemble(pInput, wk)
179 : asmMap->AssembleBnd(pInput, wk);
181 wk.data() + nDir, 1);
183 (isFull) ? asmMap->GlobalToLocal(wk, pOutput)
184 : asmMap->GlobalToLocalBnd(wk, pOutput);
203 const std::shared_ptr<GlobalLinSys> &plinsys,
237 int nGlobal = (isFull) ? asmMap->GetNumGlobalCoeffs()
238 : asmMap->GetNumGlobalBndCoeffs();
239 int nDir = asmMap->GetNumGlobalDirBndCoeffs();
244 (isFull) ? asmMap->Assemble(pInput, wk)
245 : asmMap->AssembleBnd(pInput, wk);
247 (isFull) ? asmMap->GlobalToLocal(wk, pOutput)
248 : asmMap->GlobalToLocalBnd(wk, pOutput);
270 const std::shared_ptr<GlobalLinSys> &plinsys,
284 auto expList = ((
m_linsys.lock())->GetLocMat()).lock();
285 std::shared_ptr<LibUtilities::SessionReader> session =
286 expList->GetSession();
290 if (session->DefinesGlobalSysSolnInfo(var,
"JacobiIterations"))
293 session->GetGlobalSysSolnInfo(var,
"JacobiIterations").c_str());
313 ? asmMap->GetNumGlobalCoeffs()
314 : asmMap->GetNumGlobalBndCoeffs();
315 int nDir = asmMap->GetNumGlobalDirBndCoeffs();
316 int nNonDir = nGlobal - nDir;
322 ? asmMap->GetNumLocalCoeffs()
323 : 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);
341 asmMap->Assemble(wk1, pOutput);
343 1, wk.data() + nDir, 1, wk.data() + nDir, 1);
346 asmMap->GlobalToLocal(wk, pOutput);
352 wk.data() + nDir, 1);
355 for (
int n = 1; n <
m_niter; ++n)
358 std::dynamic_pointer_cast<GlobalLinSysIterative>(
m_linsys.lock())
359 ->DoMatrixMultiply(wk, wk1);
362 Vmath::Vsub(nNonDir, pInput.data(), 1, wk1.data() + nDir, 1,
363 wk1.data() + nDir, 1);
367 wk.data() + nDir, 1, wk.data() + nDir, 1);
370 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.