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)
129 unused =
m_wsp + 1 * nLocBndDofs;
130 F_bnd1 =
m_wsp + 2 * nLocBndDofs;
131 V_bnd =
m_wsp + 3 * nLocBndDofs;
132 F_int =
m_wsp + 4 * nLocBndDofs;
134 pLocToGloMap->LocalToLocalBnd(pLocOutput, V_bnd);
145 if (nGlobBndDofs - nDirBndDofs)
147 pLocToGloMap->LocalToLocalBnd(pLocInput, F_bnd);
160 F_Bnd = BinvD * F_Int;
162 Vmath::Vsub(nLocBndDofs, F_bnd, 1, F_bnd1, 1, F_bnd, 1);
175 F_Bnd = SchurCompl * V_Bnd;
177 Vmath::Vsub(nLocBndDofs, F_bnd, 1, F_bnd1, 1, F_bnd, 1);
186 Vmath::Vadd(nLocBndDofs, V_bnd, 1, F_bnd1, 1, V_bnd, 1);
197 pLocToGloMap->GetNextLevelLocalToGlobalMap();
201 nextLevLocToGloMap->PatchAssemble(F_bnd, F_bnd);
202 nextLevLocToGloMap->PatchLocalToGlobal(V_bnd, V_bnd);
207 nextLevLocToGloMap->PatchGlobalToLocal(V_bnd, V_bnd);
224 F_Int = F_Int - C * V_Bnd;
240 const std::shared_ptr<AssemblyMap> &pLocToGloMap)
242 int nLocalBnd =
m_locToGloMap.lock()->GetNumLocalBndCoeffs();
243 int nIntDofs =
m_locToGloMap.lock()->GetNumLocalCoeffs() - nLocalBnd;
246 if (pLocToGloMap->AtLastLevel())
253 pLocToGloMap->GetNextLevelLocalToGlobalMap());
270 const std::shared_ptr<AssemblyMap> &pLocToGloMap)
273 int n_exp =
m_expList.lock()->GetNumElmts();
276 pLocToGloMap->GetNumLocalBndCoeffsPerPatch();
278 pLocToGloMap->GetNumLocalIntCoeffsPerPatch();
283 nbdry_size, nbdry_size, blkmatStorage);
285 nbdry_size, nint_size, blkmatStorage);
287 nint_size, nbdry_size, blkmatStorage);
289 nint_size, nint_size, blkmatStorage);
291 for (n = 0; n < n_exp; ++n)
303 m_schurCompl->SetBlock(n, n, t = loc_schur->GetBlock(0, 0));
304 m_BinvD->SetBlock(n, n, t = loc_schur->GetBlock(0, 1));
305 m_C->SetBlock(n, n, t = loc_schur->GetBlock(1, 0));
306 m_invD->SetBlock(n, n, t = loc_schur->GetBlock(1, 1));
329 pLocToGloMap->GetNumLocalBndCoeffsPerPatch();
331 pLocToGloMap->GetNumLocalIntCoeffsPerPatch();
349 int nPatches = pLocToGloMap->GetNumPatches();
355 for (i = 0; i < nPatches; i++)
357 nEntriesA += nBndDofsPerPatch[i] * nBndDofsPerPatch[i];
358 nEntriesB += nBndDofsPerPatch[i] * nIntDofsPerPatch[i];
359 nEntriesC += nIntDofsPerPatch[i] * nBndDofsPerPatch[i];
360 nEntriesD += nIntDofsPerPatch[i] * nIntDofsPerPatch[i];
395 for (i = 0; i < nPatches; i++)
398 tmparray = storageA + cntA;
400 nBndDofsPerPatch[i], nBndDofsPerPatch[i], tmparray, wType);
402 tmparray = storageB + cntB;
404 nBndDofsPerPatch[i], nIntDofsPerPatch[i], tmparray, wType);
406 tmparray = storageC + cntC;
408 nIntDofsPerPatch[i], nBndDofsPerPatch[i], tmparray, wType);
410 tmparray = storageD + cntD;
412 nIntDofsPerPatch[i], nIntDofsPerPatch[i], tmparray, wType,
415 cntA += nBndDofsPerPatch[i] * nBndDofsPerPatch[i];
416 cntB += nBndDofsPerPatch[i] * nIntDofsPerPatch[i];
417 cntC += nIntDofsPerPatch[i] * nBndDofsPerPatch[i];
418 cntD += nIntDofsPerPatch[i] * nIntDofsPerPatch[i];
425 int schurComplSubMatnRows;
430 for (n = cnt = 0; n < SchurCompl->GetNumberOfBlockRows(); ++n)
432 schurComplSubMat = SchurCompl->GetBlock(n, n);
433 schurComplSubMatnRows = schurComplSubMat->GetRows();
436 pLocToGloMap->GetPatchMapFromPrevLevel()->GetPatchId() + cnt;
437 dofId = pLocToGloMap->GetPatchMapFromPrevLevel()->GetDofId() + cnt;
439 pLocToGloMap->GetPatchMapFromPrevLevel()->IsBndDof() + cnt;
440 sign = pLocToGloMap->GetPatchMapFromPrevLevel()->GetSign() + cnt;
443 for (i = 0; i < schurComplSubMatnRows; ++i)
445 int pId = patchId[i];
447 substructuredMat[0][pId]->GetPtr();
449 substructuredMat[1][patchId[i]]->GetPtr();
451 substructuredMat[2][patchId[i]]->GetPtr();
453 int subMat0rows = substructuredMat[0][pId]->GetRows();
454 int subMat1rows = substructuredMat[1][pId]->GetRows();
455 int subMat2rows = substructuredMat[2][pId]->GetRows();
459 for (j = 0; j < schurComplSubMatnRows; ++j)
462 "These values should be equal");
466 subMat0[dofId[i] + dofId[j] * subMat0rows] +=
467 sign[i] *
sign[j] * (*schurComplSubMat)(i, j);
471 subMat1[dofId[i] + dofId[j] * subMat1rows] +=
472 sign[i] *
sign[j] * (*schurComplSubMat)(i, j);
478 for (j = 0; j < schurComplSubMatnRows; ++j)
481 "These values should be equal");
485 subMat2[dofId[i] + dofId[j] * subMat2rows] +=
486 sign[i] *
sign[j] * (*schurComplSubMat)(i, j);
492 if (dofId[i] <= dofId[j])
494 (*subMat3)(dofId[i], dofId[j]) +=
496 (*schurComplSubMat)(i, j);
501 (*subMat3)(dofId[i], dofId[j]) +=
503 (*schurComplSubMat)(i, j);
509 cnt += schurComplSubMatnRows;
514 for (i = 0; i < nPatches; i++)
516 if (nIntDofsPerPatch[i])
519 substructuredMat[0][i]->GetPtr();
521 substructuredMat[1][i]->GetPtr();
523 substructuredMat[2][i]->GetPtr();
524 int subMat0rows = substructuredMat[0][i]->GetRows();
525 int subMat1rows = substructuredMat[1][i]->GetRows();
526 int subMat2rows = substructuredMat[2][i]->GetRows();
527 int subMat2cols = substructuredMat[2][i]->GetColumns();
530 substructuredMat[3][i]->Invert();
532 (*substructuredMat[1][i]) =
533 (*substructuredMat[1][i]) * (*substructuredMat[3][i]);
538 if (subMat1rows && subMat2cols)
540 Blas::Dgemm(
'N',
'N', subMat1rows, subMat2cols, subMat2rows,
541 -1.0, &subMat1[0], subMat1rows, &subMat2[0],
542 subMat2rows, 1.0, &subMat0[0], subMat0rows);
551 pLocToGloMap->GetNumLocalBndCoeffsPerPatch();
553 pLocToGloMap->GetNumLocalIntCoeffsPerPatch();
557 nbdry_size, nbdry_size, blkmatStorage);
559 nbdry_size, nint_size, blkmatStorage);
561 nint_size, nbdry_size, blkmatStorage);
563 nint_size, nint_size, blkmatStorage);
566 for (i = 0; i < nPatches; i++)
568 for (j = 0; j < 4; j++)
571 1.0, substructuredMat[j][i]);
572 blkMatrices[j]->SetBlock(i, i, tmpscalmat);
585 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)
GlobalLinSysStaticCond(const GlobalLinSysKey &mkey, const std::weak_ptr< ExpList > &pExpList, const std::shared_ptr< AssemblyMap > &locToGloMap)
Constructor for full direct matrix solve.
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.