46 namespace MultiRegions
74 GlobalLinSysStaticCond::GlobalLinSysStaticCond(
76 const std::shared_ptr<AssemblyMap> &pLocToGloMap)
77 :
GlobalLinSys(pKey, pExpList, pLocToGloMap), m_locToGloMap(pLocToGloMap)
106 boost::ignore_unused(dirForcing);
108 "GlobalLinSysStaticCond: Not setup for dirForcing");
110 bool atLastLevel = pLocToGloMap->AtLastLevel();
111 int scLevel = pLocToGloMap->GetStaticCondLevel();
113 int nGlobDofs = pLocToGloMap->GetNumGlobalCoeffs();
114 int nLocBndDofs = pLocToGloMap->GetNumLocalBndCoeffs();
115 int nGlobBndDofs = pLocToGloMap->GetNumGlobalBndCoeffs();
116 int nDirBndDofs = pLocToGloMap->GetNumGlobalDirBndCoeffs();
117 int nIntDofs = nGlobDofs - nGlobBndDofs;
119 if ((nGlobDofs - nDirBndDofs) == 0)
128 F_bnd1 =
m_wsp + nLocBndDofs;
129 V_bnd =
m_wsp + 2 * nLocBndDofs;
130 F_int =
m_wsp + 3 * nLocBndDofs;
132 pLocToGloMap->LocalToLocalBnd(pLocOutput, V_bnd);
143 if (nGlobBndDofs - nDirBndDofs)
145 pLocToGloMap->LocalToLocalBnd(pLocInput, F_bnd);
158 F_Bnd = BinvD * F_Int;
160 Vmath::Vsub(nLocBndDofs, F_bnd, 1, F_bnd1, 1, F_bnd, 1);
173 F_Bnd = SchurCompl * V_Bnd;
175 Vmath::Vsub(nLocBndDofs, F_bnd, 1, F_bnd1, 1, F_bnd, 1);
179 pLocToGloMap->AssembleBnd(F_bnd, F_bnd1);
186 pLocToGloMap->GlobalToLocalBnd(pert, outloc);
189 Vmath::Vadd(nLocBndDofs, V_bnd, 1, outloc, 1, V_bnd, 1);
200 pLocToGloMap->GetNextLevelLocalToGlobalMap();
204 nextLevLocToGloMap->PatchAssemble(F_bnd, F_bnd);
205 nextLevLocToGloMap->PatchLocalToGlobal(V_bnd, V_bnd);
210 nextLevLocToGloMap->PatchGlobalToLocal(V_bnd, V_bnd);
227 F_Int = F_Int - C * V_Bnd;
243 const std::shared_ptr<AssemblyMap> &pLocToGloMap)
245 int nLocalBnd =
m_locToGloMap.lock()->GetNumLocalBndCoeffs();
246 int nIntDofs =
m_locToGloMap.lock()->GetNumLocalCoeffs() - nLocalBnd;
249 if (pLocToGloMap->AtLastLevel())
256 pLocToGloMap->GetNextLevelLocalToGlobalMap());
273 const std::shared_ptr<AssemblyMap> &pLocToGloMap)
276 int n_exp =
m_expList.lock()->GetNumElmts();
279 pLocToGloMap->GetNumLocalBndCoeffsPerPatch();
281 pLocToGloMap->GetNumLocalIntCoeffsPerPatch();
286 nbdry_size, nbdry_size, blkmatStorage);
288 nbdry_size, nint_size, blkmatStorage);
290 nint_size, nbdry_size, blkmatStorage);
292 nint_size, nint_size, blkmatStorage);
294 for (n = 0; n < n_exp; ++n)
306 m_schurCompl->SetBlock(n, n, t = loc_schur->GetBlock(0, 0));
307 m_BinvD->SetBlock(n, n, t = loc_schur->GetBlock(0, 1));
308 m_C->SetBlock(n, n, t = loc_schur->GetBlock(1, 0));
309 m_invD->SetBlock(n, n, t = loc_schur->GetBlock(1, 1));
332 pLocToGloMap->GetNumLocalBndCoeffsPerPatch();
334 pLocToGloMap->GetNumLocalIntCoeffsPerPatch();
352 int nPatches = pLocToGloMap->GetNumPatches();
358 for (i = 0; i < nPatches; i++)
360 nEntriesA += nBndDofsPerPatch[i] * nBndDofsPerPatch[i];
361 nEntriesB += nBndDofsPerPatch[i] * nIntDofsPerPatch[i];
362 nEntriesC += nIntDofsPerPatch[i] * nBndDofsPerPatch[i];
363 nEntriesD += nIntDofsPerPatch[i] * nIntDofsPerPatch[i];
398 for (i = 0; i < nPatches; i++)
401 tmparray = storageA + cntA;
403 nBndDofsPerPatch[i], nBndDofsPerPatch[i], tmparray, wType);
405 tmparray = storageB + cntB;
407 nBndDofsPerPatch[i], nIntDofsPerPatch[i], tmparray, wType);
409 tmparray = storageC + cntC;
411 nIntDofsPerPatch[i], nBndDofsPerPatch[i], tmparray, wType);
413 tmparray = storageD + cntD;
415 nIntDofsPerPatch[i], nIntDofsPerPatch[i], tmparray, wType,
418 cntA += nBndDofsPerPatch[i] * nBndDofsPerPatch[i];
419 cntB += nBndDofsPerPatch[i] * nIntDofsPerPatch[i];
420 cntC += nIntDofsPerPatch[i] * nBndDofsPerPatch[i];
421 cntD += nIntDofsPerPatch[i] * nIntDofsPerPatch[i];
428 int schurComplSubMatnRows;
433 for (n = cnt = 0; n < SchurCompl->GetNumberOfBlockRows(); ++n)
435 schurComplSubMat = SchurCompl->GetBlock(n, n);
436 schurComplSubMatnRows = schurComplSubMat->GetRows();
439 pLocToGloMap->GetPatchMapFromPrevLevel()->GetPatchId() + cnt;
440 dofId = pLocToGloMap->GetPatchMapFromPrevLevel()->GetDofId() + cnt;
442 pLocToGloMap->GetPatchMapFromPrevLevel()->IsBndDof() + cnt;
443 sign = pLocToGloMap->GetPatchMapFromPrevLevel()->GetSign() + cnt;
446 for (i = 0; i < schurComplSubMatnRows; ++i)
448 int pId = patchId[i];
450 substructuredMat[0][pId]->GetPtr();
452 substructuredMat[1][patchId[i]]->GetPtr();
454 substructuredMat[2][patchId[i]]->GetPtr();
456 int subMat0rows = substructuredMat[0][pId]->GetRows();
457 int subMat1rows = substructuredMat[1][pId]->GetRows();
458 int subMat2rows = substructuredMat[2][pId]->GetRows();
462 for (j = 0; j < schurComplSubMatnRows; ++j)
465 "These values should be equal");
469 subMat0[dofId[i] + dofId[j] * subMat0rows] +=
470 sign[i] *
sign[j] * (*schurComplSubMat)(i, j);
474 subMat1[dofId[i] + dofId[j] * subMat1rows] +=
475 sign[i] *
sign[j] * (*schurComplSubMat)(i, j);
481 for (j = 0; j < schurComplSubMatnRows; ++j)
484 "These values should be equal");
488 subMat2[dofId[i] + dofId[j] * subMat2rows] +=
489 sign[i] *
sign[j] * (*schurComplSubMat)(i, j);
495 if (dofId[i] <= dofId[j])
497 (*subMat3)(dofId[i], dofId[j]) +=
499 (*schurComplSubMat)(i, j);
504 (*subMat3)(dofId[i], dofId[j]) +=
506 (*schurComplSubMat)(i, j);
512 cnt += schurComplSubMatnRows;
517 for (i = 0; i < nPatches; i++)
519 if (nIntDofsPerPatch[i])
522 substructuredMat[0][i]->GetPtr();
524 substructuredMat[1][i]->GetPtr();
526 substructuredMat[2][i]->GetPtr();
527 int subMat0rows = substructuredMat[0][i]->GetRows();
528 int subMat1rows = substructuredMat[1][i]->GetRows();
529 int subMat2rows = substructuredMat[2][i]->GetRows();
530 int subMat2cols = substructuredMat[2][i]->GetColumns();
533 substructuredMat[3][i]->Invert();
535 (*substructuredMat[1][i]) =
536 (*substructuredMat[1][i]) * (*substructuredMat[3][i]);
541 if (subMat1rows && subMat2cols)
543 Blas::Dgemm(
'N',
'N', subMat1rows, subMat2cols, subMat2rows,
544 -1.0, &subMat1[0], subMat1rows, &subMat2[0],
545 subMat2rows, 1.0, &subMat0[0], subMat0rows);
554 pLocToGloMap->GetNumLocalBndCoeffsPerPatch();
556 pLocToGloMap->GetNumLocalIntCoeffsPerPatch();
560 nbdry_size, nbdry_size, blkmatStorage);
562 nbdry_size, nint_size, blkmatStorage);
564 nint_size, nbdry_size, blkmatStorage);
566 nint_size, nint_size, blkmatStorage);
569 for (i = 0; i < nPatches; i++)
571 for (j = 0; j < 4; j++)
574 1.0, substructuredMat[j][i]);
575 blkMatrices[j]->SetBlock(i, i, tmpscalmat);
588 blkMatrices[2], blkMatrices[3], pLocToGloMap);
#define ASSERTL0(condition, msg)
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode....
#define sign(a, b)
return the sign(b)*a
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
const std::weak_ptr< ExpList > m_expList
Local Matrix System.
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.
const GlobalLinSysKey m_linSysKey
Key associated with this linear system.
virtual DNekScalMatSharedPtr v_GetBlock(unsigned int n)
Retrieves the block matrix from n-th expansion using the matrix key provided by the m_linSysKey.
virtual DNekScalBlkMatSharedPtr v_GetStaticCondBlock(unsigned int n)
Retrieves a the static condensation block matrices from n-th expansion using the matrix key provided ...
void Initialise(const std::shared_ptr< AssemblyMap > &pLocToGloMap)
Describe a linear system.
DNekScalBlkMatSharedPtr m_schurCompl
Block Schur complement matrix.
virtual void v_CoeffsFwdTransform(const Array< OneD, NekDouble > &pInput, Array< OneD, NekDouble > &pOutput)
std::weak_ptr< AssemblyMap > m_locToGloMap
Local to global map.
void SetupTopLevel(const std::shared_ptr< AssemblyMap > &locToGloMap)
Set up the storage for the Schur complement or the top level of the multi-level Schur complement.
virtual ~GlobalLinSysStaticCond()
Array< OneD, NekDouble > m_wsp
Workspace array for matrix multiplication.
virtual void v_AssembleSchurComplement(std::shared_ptr< AssemblyMap > pLoctoGloMap)
virtual void v_InitObject() override
virtual void v_PreSolve(int scLevel, Array< OneD, NekDouble > &F_bnd)
virtual void v_BasisFwdTransform(Array< OneD, NekDouble > &pInOut)
GlobalLinSysStaticCondSharedPtr m_recursiveSchurCompl
Schur complement for Direct Static Condensation.
virtual void v_CoeffsBwdTransform(Array< OneD, NekDouble > &pInOut)
virtual void v_Initialise(const std::shared_ptr< AssemblyMap > &locToGloMap) override
Initialise this object.
virtual void v_Solve(const Array< OneD, const NekDouble > &in, Array< OneD, NekDouble > &out, const AssemblyMapSharedPtr &locToGloMap, const Array< OneD, const NekDouble > &dirForcing=NullNekDouble1DArray) override
Solve the linear system for given input and output vectors using a specified local to global map.
DNekScalBlkMatSharedPtr m_BinvD
Block matrix.
virtual GlobalLinSysStaticCondSharedPtr v_Recurse(const GlobalLinSysKey &mkey, const std::weak_ptr< ExpList > &pExpList, const DNekScalBlkMatSharedPtr pSchurCompl, const DNekScalBlkMatSharedPtr pBinvD, const DNekScalBlkMatSharedPtr pC, const DNekScalBlkMatSharedPtr pInvD, const std::shared_ptr< AssemblyMap > &locToGloMap)=0
void ConstructNextLevelCondensedSystem(const std::shared_ptr< AssemblyMap > &locToGloMap)
DNekScalBlkMatSharedPtr m_C
Block matrix.
virtual int v_GetNumBlocks() override
Get the number of blocks in this system.
DNekScalBlkMatSharedPtr m_invD
Block matrix.
StdRegions::MatrixType GetMatrixType() const
Return the matrix type.
static void Dgemm(const char &transa, const char &transb, const int &m, const int &n, const int &k, const double &alpha, const double *a, const int &lda, const double *b, const int &ldb, const double &beta, double *c, const int &ldc)
BLAS level 3: Matrix-matrix multiply C = A x B where op(A)[m x k], op(B)[k x n], C[m x n] DGEMM perfo...
std::shared_ptr< AssemblyMap > AssemblyMapSharedPtr
The above copyright notice and this permission notice shall be included.
std::shared_ptr< DNekScalMat > DNekScalMatSharedPtr
void Multiply(NekMatrix< ResultDataType, StandardMatrixTag > &result, const NekMatrix< LhsDataType, LhsMatrixType > &lhs, const ResultDataType &rhs)
std::shared_ptr< DNekScalBlkMat > DNekScalBlkMatSharedPtr
std::shared_ptr< DNekMat > DNekMatSharedPtr
PointerWrapper
Specifies if the pointer passed to a NekMatrix or NekVector is copied into an internal representation...
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.
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.