46 namespace MultiRegions
74 GlobalLinSysStaticCond::GlobalLinSysStaticCond(
76 const std::weak_ptr<ExpList> &pExpList,
77 const std::shared_ptr<AssemblyMap> &pLocToGloMap)
79 m_locToGloMap (pLocToGloMap)
110 boost::ignore_unused(dirForcing);
112 "GlobalLinSysStaticCond: Not setup for dirForcing");
114 bool atLastLevel = pLocToGloMap->AtLastLevel();
115 int scLevel = pLocToGloMap->GetStaticCondLevel();
117 int nGlobDofs = pLocToGloMap->GetNumGlobalCoeffs();
118 int nLocBndDofs = pLocToGloMap->GetNumLocalBndCoeffs();
119 int nGlobBndDofs = pLocToGloMap->GetNumGlobalBndCoeffs();
120 int nDirBndDofs = pLocToGloMap->GetNumGlobalDirBndCoeffs();
121 int nIntDofs = nGlobDofs - nGlobBndDofs;
123 if((nGlobDofs-nDirBndDofs) == 0)
132 F_bnd1 =
m_wsp + nLocBndDofs;
133 V_bnd =
m_wsp + 2*nLocBndDofs;
134 F_int =
m_wsp + 3*nLocBndDofs;
136 pLocToGloMap->LocalToLocalBnd(pLocOutput,V_bnd);
147 if(nGlobBndDofs-nDirBndDofs)
149 pLocToGloMap->LocalToLocalBnd(pLocInput,F_bnd);
165 Vmath::Vsub(nLocBndDofs, F_bnd,1, F_bnd1,1, F_bnd,1);
178 F_Bnd = SchurCompl*V_Bnd;
180 Vmath::Vsub(nLocBndDofs, F_bnd,1, F_bnd1, 1, F_bnd,1);
184 pLocToGloMap->AssembleBnd(F_bnd, F_bnd1);
191 pLocToGloMap->GlobalToLocalBnd(pert,outloc);
194 Vmath::Vadd(nLocBndDofs, V_bnd, 1, outloc, 1, V_bnd,1);
205 GetNextLevelLocalToGlobalMap();
209 nextLevLocToGloMap->PatchAssemble (F_bnd,F_bnd);
210 nextLevLocToGloMap->PatchLocalToGlobal(V_bnd,V_bnd);
215 nextLevLocToGloMap->PatchGlobalToLocal(V_bnd,V_bnd);
232 F_Int = F_Int - C*V_Bnd;
248 const std::shared_ptr<AssemblyMap>& pLocToGloMap)
250 int nLocalBnd =
m_locToGloMap.lock()->GetNumLocalBndCoeffs();
252 GetNumLocalCoeffs() - nLocalBnd;
254 (3*nLocalBnd+nIntDofs, 0.0);
256 if (pLocToGloMap->AtLastLevel())
263 pLocToGloMap->GetNextLevelLocalToGlobalMap());
280 const std::shared_ptr<AssemblyMap>& pLocToGloMap)
283 int n_exp =
m_expList.lock()->GetNumElmts();
286 = pLocToGloMap->GetNumLocalBndCoeffsPerPatch();
288 = pLocToGloMap->GetNumLocalIntCoeffsPerPatch();
301 for(n = 0; n < n_exp; ++n)
315 m_schurCompl->SetBlock(n, n, t = loc_schur->GetBlock(0,0));
316 m_BinvD ->SetBlock(n, n, t = loc_schur->GetBlock(0,1));
317 m_C ->SetBlock(n, n, t = loc_schur->GetBlock(1,0));
318 m_invD ->SetBlock(n, n, t = loc_schur->GetBlock(1,1));
341 = pLocToGloMap->GetNumLocalBndCoeffsPerPatch();
343 = pLocToGloMap->GetNumLocalIntCoeffsPerPatch();
361 int nPatches = pLocToGloMap->GetNumPatches();
362 int nEntriesA = 0;
int nEntriesB = 0;
363 int nEntriesC = 0;
int nEntriesD = 0;
365 for(i = 0; i < nPatches; i++)
367 nEntriesA += nBndDofsPerPatch[i]*nBndDofsPerPatch[i];
368 nEntriesB += nBndDofsPerPatch[i]*nIntDofsPerPatch[i];
369 nEntriesC += nIntDofsPerPatch[i]*nBndDofsPerPatch[i];
370 nEntriesD += nIntDofsPerPatch[i]*nIntDofsPerPatch[i];
405 for(i = 0; i < nPatches; i++)
408 tmparray = storageA+cntA;
414 tmparray = storageB+cntB;
420 tmparray = storageC+cntC;
426 tmparray = storageD+cntD;
433 cntA += nBndDofsPerPatch[i] * nBndDofsPerPatch[i];
434 cntB += nBndDofsPerPatch[i] * nIntDofsPerPatch[i];
435 cntC += nIntDofsPerPatch[i] * nBndDofsPerPatch[i];
436 cntD += nIntDofsPerPatch[i] * nIntDofsPerPatch[i];
443 int schurComplSubMatnRows;
448 for(n = cnt = 0; n < SchurCompl->GetNumberOfBlockRows(); ++n)
450 schurComplSubMat = SchurCompl->GetBlock(n,n);
451 schurComplSubMatnRows = schurComplSubMat->GetRows();
453 patchId = pLocToGloMap->GetPatchMapFromPrevLevel()
454 ->GetPatchId() + cnt;
455 dofId = pLocToGloMap->GetPatchMapFromPrevLevel()
457 isBndDof = pLocToGloMap->GetPatchMapFromPrevLevel()
459 sign = pLocToGloMap->GetPatchMapFromPrevLevel()
463 for(i = 0; i < schurComplSubMatnRows; ++i)
465 int pId = patchId[i];
467 = substructuredMat[0][pId]->GetPtr();
469 = substructuredMat[1][patchId[i]]->GetPtr();
471 = substructuredMat[2][patchId[i]]->GetPtr();
473 = substructuredMat[3][patchId[i]];
474 int subMat0rows = substructuredMat[0][pId]->GetRows();
475 int subMat1rows = substructuredMat[1][pId]->GetRows();
476 int subMat2rows = substructuredMat[2][pId]->GetRows();
480 for(j = 0; j < schurComplSubMatnRows; ++j)
483 "These values should be equal");
487 subMat0[dofId[i]+dofId[j]*subMat0rows] +=
489 (*schurComplSubMat)(i,j);
493 subMat1[dofId[i]+dofId[j]*subMat1rows] +=
495 (*schurComplSubMat)(i,j);
501 for(j = 0; j < schurComplSubMatnRows; ++j)
504 "These values should be equal");
508 subMat2[dofId[i]+dofId[j]*subMat2rows] +=
510 (*schurComplSubMat)(i,j);
516 if (dofId[i] <= dofId[j])
518 (*subMat3)(dofId[i],dofId[j]) +=
520 (*schurComplSubMat)(i,j);
525 (*subMat3)(dofId[i],dofId[j]) +=
527 (*schurComplSubMat)(i,j);
533 cnt += schurComplSubMatnRows;
538 for(i = 0; i < nPatches; i++)
540 if(nIntDofsPerPatch[i])
543 = substructuredMat[0][i]->GetPtr();
545 = substructuredMat[1][i]->GetPtr();
547 = substructuredMat[2][i]->GetPtr();
548 int subMat0rows = substructuredMat[0][i]->GetRows();
549 int subMat1rows = substructuredMat[1][i]->GetRows();
550 int subMat2rows = substructuredMat[2][i]->GetRows();
551 int subMat2cols = substructuredMat[2][i]->GetColumns();
554 substructuredMat[3][i]->Invert();
556 (*substructuredMat[1][i]) = (*substructuredMat[1][i])*
557 (*substructuredMat[3][i]);
563 subMat2rows, -1.0, &subMat1[0], subMat1rows,
564 &subMat2[0], subMat2rows, 1.0, &subMat0[0],
573 = pLocToGloMap->GetNumLocalBndCoeffsPerPatch();
575 = pLocToGloMap->GetNumLocalIntCoeffsPerPatch();
588 for(i = 0; i < nPatches; i++)
590 for(j = 0; j < 4; j++)
594 blkMatrices[j]->SetBlock(i,i,tmpscalmat);
607 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)
virtual int v_GetNumBlocks()
Get the number of blocks in this system.
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()
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)
DNekScalBlkMatSharedPtr m_BinvD
Block matrix.
virtual void v_Initialise(const std::shared_ptr< AssemblyMap > &locToGloMap)
Initialise this object.
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 void v_Solve(const Array< OneD, const NekDouble > &in, Array< OneD, NekDouble > &out, const AssemblyMapSharedPtr &locToGloMap, const Array< OneD, const NekDouble > &dirForcing=NullNekDouble1DArray)
Solve the linear system for given input and output vectors using a specified local to global map.
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.