35 #include <boost/core/ignore_unused.hpp>    43     namespace MultiRegions
    60             return int(x > 0.0 ? x + 0.5 : x - 0.5);
    66             int size = inarray.num_elements();
    67             ASSERTL1(outarray.num_elements()>=size,
"Array sizes not compatible");
    70             for(
int i = 0; i < size; i++)
    73                 outarray[i] =  int(x > 0.0 ? x + 0.5 : x - 0.5);
    80         AssemblyMap::AssemblyMap():
    84             m_numLocalBndCoeffs(0),
    85             m_numGlobalBndCoeffs(0),
    86             m_numLocalDirBndCoeffs(0),
    87             m_numGlobalDirBndCoeffs(0),
    89             m_bndSystemBandWidth(0),
    98                 const std::string variable):
   118             if(pSession->DefinesGlobalSysSolnInfo(variable, 
"GlobalSysSoln"))
   120                 std::string sysSoln = pSession->GetGlobalSysSolnInfo(variable,
   123                                                     "GlobalSysSoln", sysSoln);
   126             if(pSession->DefinesGlobalSysSolnInfo(variable, 
"Preconditioner"))
   128                 std::string precon = pSession->GetGlobalSysSolnInfo(variable,
   131                                                     "Preconditioner", precon);
   134             if(pSession->DefinesGlobalSysSolnInfo(variable,
   135                                                   "IterativeSolverTolerance"))
   138                         pSession->GetGlobalSysSolnInfo(variable,
   139                                 "IterativeSolverTolerance").c_str());
   143                 pSession->LoadParameter(
"IterativeSolverTolerance",
   149             if(pSession->DefinesGlobalSysSolnInfo(variable,
   153                         pSession->GetGlobalSysSolnInfo(variable,
   154                                 "MaxIterations").c_str());
   158                 pSession->LoadParameter(
"MaxIterations",
   164             if(pSession->DefinesGlobalSysSolnInfo(variable,
"SuccessiveRHS"))
   167                         pSession->GetGlobalSysSolnInfo(variable,
   168                                 "SuccessiveRHS").c_str());
   172                 pSession->LoadParameter(
"SuccessiveRHS",
   216             int newLevel = staticCondLevelOld+1;
   237             multiLevelGraph->MaskPatches(newLevel,globHomPatchMask);
   256             int numPatchesWithIntNew = multiLevelGraph->GetNpatchesWithInterior(newLevel);
   257             int numPatchesNew        = numPatchesWithIntNew;
   261             std::map<int, int> numLocalBndCoeffsPerPatchNew;
   262             for(
int i = 0; i < numPatchesNew; i++)
   264                 numLocalBndCoeffsPerPatchNew[i] = 0;
   270             for(i = cnt = 0; i < numPatchesOld; i++)
   283                 minval = *min_element(&locPatchMask[cnt],
   284                                       &locPatchMask[cnt]+numLocalBndCoeffsPerPatchOld[i]);
   285                 maxval = *max_element(&locPatchMask[cnt],
   286                                       &locPatchMask[cnt]+numLocalBndCoeffsPerPatchOld[i]);
   287                 ASSERTL0((minval==maxval)||(minval==-1),
"These values should never be the same");
   291                     curPatch = numPatchesNew;
   292                     numLocalBndCoeffsPerPatchNew[curPatch] = 0;
   300                 for(j = 0; j < numLocalBndCoeffsPerPatchOld[i]; j++ )
   302                     ASSERTL0((locPatchMask[cnt]==maxval)||(locPatchMask[cnt]==minval),
   303                              "These values should never be the same");
   304                     if(locPatchMask[cnt] == -1)
   306                         ++numLocalBndCoeffsPerPatchNew[curPatch];
   323             multiLevelGraph->GetNintDofsPerPatch(newLevel,m_numLocalIntCoeffsPerPatch);
   331                      "This method should only be called for in "   332                      "case of multi-level static condensation.");
   357             for(
int i = 1; i < m_numPatches+1; i++)
   359                 numLocalBndCoeffsPerPatchOffset[i] += numLocalBndCoeffsPerPatchOffset[i-1] + numLocalBndCoeffsPerPatchNew[i-1];
   362             int additionalPatchCnt = numPatchesWithIntNew;
   368             for(i = cnt = 0; i < numPatchesOld; i++)
   370                 minval = *min_element(&locPatchMask[cnt],&locPatchMask[cnt]+numLocalBndCoeffsPerPatchOld[i]);
   371                 maxval = *max_element(&locPatchMask[cnt],&locPatchMask[cnt]+numLocalBndCoeffsPerPatchOld[i]);
   372                 ASSERTL0((minval==maxval)||(minval==-1),
"These values should never be the same");
   376                     curPatch = additionalPatchCnt;
   377                     additionalPatchCnt++;
   384                 for(j = 0; j < numLocalBndCoeffsPerPatchOld[i]; j++ )
   386                     ASSERTL0((locPatchMask[cnt]==maxval)||(locPatchMask[cnt]==minval),
   387                              "These values should never be the same");
   391                     if(locPatchMask[cnt] == -1)
   393                         newid = numLocalBndCoeffsPerPatchOffset[curPatch];
   401                         blockid = bndDofPerPatchCnt[curPatch];
   405                         numLocalBndCoeffsPerPatchOffset[curPatch]++;
   406                         bndDofPerPatchCnt[curPatch]++;
   418                     sign = isBndDof?1.0:
sign;
   420                     m_patchMapFromPrevLevel->SetPatchMap(cnt,curPatch,blockid,isBndDof,sign);
   470                 for(j = 0; j < locSize; j++)
   485                 bwidth = (bwidth>(maxId-minId))?bwidth:(maxId-minId);
   496             boost::ignore_unused(i);
   498                      "Not defined for this type of mapping.");
   504             boost::ignore_unused(i);
   506                      "Not defined for this type of mapping.");
   512             boost::ignore_unused(i);
   514                      "Not defined for this type of mapping.");
   521                      "Not defined for this type of mapping.");
   529                      "Not defined for this type of mapping.");
   537                      "Not defined for this type of mapping.");
   544             boost::ignore_unused(i);
   546                      "Not defined for this type of mapping.");
   553                      "Not defined for this type of mapping.");
   563             boost::ignore_unused(loc, global, useComm);
   565                      "Not defined for this type of mapping.");
   573             boost::ignore_unused(loc, global, useComm);
   575                      "Not defined for this type of mapping.");
   582             boost::ignore_unused(loc, global);
   584                      "Not defined for this type of mapping.");
   591             boost::ignore_unused(loc, global);
   593                      "Not defined for this type of mapping.");
   600             boost::ignore_unused(loc, global);
   602                      "Not defined for this type of mapping.");
   609             boost::ignore_unused(loc, global);
   611                      "Not defined for this type of mapping.");
   617             boost::ignore_unused(pGlobal);
   625             boost::ignore_unused(pGlobal);
   634             boost::ignore_unused(pGlobal, offset);
   642                      "Not defined for this type of mapping.");
   649                      "Not defined for this type of mapping.");
   656                      "Not defined for this type of mapping.");
   663                      "Not defined for this type of mapping.");
   670                      "Not defined for this type of mapping.");
   677                      "Not defined for this type of mapping.");
   684                      "Not defined for this type of mapping.");
   691                      "Not defined for this type of mapping.");
   698                      "Not defined for this type of mapping.");
   706             boost::ignore_unused(locexp, solnType);
   708                      "Not defined for this type of mapping.");
   709             static std::shared_ptr<AssemblyMap> result;
   933                      "Index out of range.");
  1190             if (offset > 0)  
Vmath::Vcopy(offset, pGlobal, 1, tmp, 1);
  1192             if (offset > 0)  
Vmath::Vcopy(offset, tmp, 1, pGlobal, 1);
  1278             std::ostream &out, std::string variable, 
bool printHeader)
 const  1282             bool isRoot = vRowComm->GetRank() == 0;
  1283             int n = vRowComm->GetSize();
  1287             int globBndCnt = 0, globDirCnt = 0;
  1313             int totGlobDof     = globCnt;
  1314             int totGlobBndDof  = globBndCnt;
  1315             int totGlobDirDof  = globDirCnt;
  1320             int meanValence = 0;
  1322             int minValence = 10000000;
  1330                 if (tmpGlob[i] > maxValence)
  1332                     maxValence = tmpGlob[i];
  1334                 if (tmpGlob[i] < minValence)
  1336                     minValence = tmpGlob[i];
  1338                 meanValence += tmpGlob[i];
  1351             meanValence /= totGlobBndDof;
  1357                     out << 
"Assembly map statistics for field " << variable
  1361                 out << 
"  - Number of local/global dof             : "  1362                     << totLocalDof << 
" " << totGlobDof << endl;
  1363                 out << 
"  - Number of local/global boundary dof    : "  1364                     << totLocalBndDof << 
" " << totGlobBndDof << endl;
  1365                 out << 
"  - Number of local/global Dirichlet dof   : "  1366                     << totLocalDirDof << 
" " << totGlobDirDof << endl;
  1367                 out << 
"  - dof valency (min/max/mean)             : "  1368                     << minValence << 
" " << maxValence << 
" " << meanValence
  1377                     for (i = 1; i < n; ++i)
  1379                         vRowComm->Recv(i, tmp);
  1381                         mean2    += tmp[0]*tmp[0];
  1383                         if (tmp[0] > maxval)
  1387                         if (tmp[0] < minval)
  1395                         out << 
"  - Local dof dist. (min/max/mean/dev)     : "  1396                             << minval << 
" " << maxval << 
" " << (mean / n)
  1397                             << 
" " << sqrt(mean2/n - mean*mean/n/n) << endl;
  1403                     mean2 = mean * mean;
  1405                     for (i = 1; i < n; ++i)
  1407                         vRowComm->Recv(i, tmp);
  1409                         mean2    += tmp[0]*tmp[0];
  1411                         if (tmp[0] > maxval)
  1415                         if (tmp[0] < minval)
  1421                     out << 
"  - Local bnd dof dist. (min/max/mean/dev) : "  1422                         << minval << 
" " << maxval << 
" " << (mean / n) << 
" "  1423                         << sqrt(mean2/n - mean*mean/n/n) << endl;
  1430                 vRowComm->Send(0, tmp);
  1433                 vRowComm->Send(0, tmp);
  1445             while (tmp->m_nextLevelLocalToGlobalMap)
  1447                 tmp = tmp->m_nextLevelLocalToGlobalMap;
  1460                     for (i = 1; i < n; ++i)
  1462                         vRowComm->Recv(i, tmpRecv);
  1464                         mean2 += tmpRecv[0]*tmpRecv[0];
  1466                         if (tmpRecv[0] > maxval)
  1468                             maxval = (int)(tmpRecv[0] + 0.5);
  1470                         if (tmpRecv[0] < minval)
  1472                             minval = (int)(tmpRecv[0] + 0.5);
  1476                     out << 
"  - M-level sc. dist. (min/max/mean/dev)   : "  1477                         << minval << 
" " << maxval << 
" " << (mean / n) << 
" "  1478                         << sqrt(mean2/n - mean*mean/n/n) << endl;
  1484                     vRowComm->Send(0, tmpSend);
  1489                 out << 
"  - Number of static cond. levels          : "  1495                 out << 
"Stats at lowest static cond. level:" << endl;
  1497             tmp->PrintStats(out, variable, 
false);
 const Array< OneD, const int > & GetBndCondTraceToGlobalTraceMap()
int GetNumNonDirVertexModes() const
void GlobalToLocalBnd(const NekVector< NekDouble > &global, NekVector< NekDouble > &loc, int offset) const
#define ASSERTL0(condition, msg)
int GetNumLocalDirBndCoeffs() const
Returns the number of local Dirichlet boundary coefficients. 
virtual int v_GetFullSystemBandWidth() const
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mod...
bool m_systemSingular
Flag indicating if the system is singular or not. 
const Array< OneD, const int > & GetGlobalToUniversalMap()
bool m_signChange
Flag indicating if modes require sign reversal. 
PreconditionerType GetPreconType() const
PreconditionerType m_preconType
Type type of preconditioner to use in iterative solver. 
NekDouble GetLocalToGlobalBndSign(const int i) const
Retrieve the sign change of a given local boundary mode. 
int m_numGlobalBndCoeffs
Total number of global boundary coefficients. 
int GetNumGlobalCoeffs() const
Returns the total number of global coefficients. 
LibUtilities::CommSharedPtr GetComm()
Retrieves the communicator. 
bool GetSingularSystem() const
Retrieves if the system is singular (true) or not (false) 
int GetBndSystemBandWidth() const
Returns the bandwidth of the boundary system. 
LibUtilities::CommSharedPtr m_comm
Communicator. 
virtual ~AssemblyMap()
Destructor. 
static void Gather(Nektar::Array< OneD, NekDouble > pU, gs_op pOp, gs_data *pGsh, Nektar::Array< OneD, NekDouble > pBuffer=NullNekDouble1DArray)
Performs a gather-scatter operation of the provided values. 
void Gathr(int n, const T *x, const int *y, T *z)
Gather vector z[i] = x[y[i]]. 
#define sign(a, b)
return the sign(b)*a 
static const NekDouble kNekIterativeTol
Array< OneD, int > m_bndCondTraceToGlobalTraceMap
Integer map of bnd cond trace number to global trace number. 
virtual int v_GetNumNonDirFaceModes() const
int GetNumNonDirFaces() const
std::shared_ptr< Comm > CommSharedPtr
Pointer to a Communicator object. 
virtual int v_GetNumNonDirEdgeModes() const
virtual int v_GetNumNonDirEdges() const
virtual void v_LocalToGlobal(const Array< OneD, const NekDouble > &loc, Array< OneD, NekDouble > &global, bool useComm) const
int m_numLocalCoeffs
Total number of local coefficients. 
const Array< OneD, const int > & GetExtraDirEdges()
void UniversalAssemble(Array< OneD, NekDouble > &pGlobal) const
PatchMapSharedPtr m_patchMapFromPrevLevel
Mapping information for previous level in MultiLevel Solver. 
const Array< OneD, const int > & GetGlobalToUniversalBndMapUnique()
int GetNumDirEdges() const
int GetSuccessiveRHS() const
std::shared_ptr< AssemblyMap > AssemblyMapSharedPtr
int GetNumNonDirEdgeModes() const
const Array< OneD, const int > & GetLocalToGlobalBndMap()
Retrieve the global indices of the local boundary modes. 
AssemblyMapSharedPtr m_nextLevelLocalToGlobalMap
Map from the patches of the previous level to the patches of the current level. 
virtual std::shared_ptr< AssemblyMap > v_LinearSpaceMap(const ExpList &locexp, GlobalSysSolnType solnType)
Generate a linear space mapping from existing mapping. 
Base class for constructing local to global mapping of degrees of freedom. 
virtual int v_GetNumDirEdges() const
int m_successiveRHS
sucessive RHS for iterative solver 
const PatchMapSharedPtr & GetPatchMapFromPrevLevel(void) const
Returns the patch map from the previous level of the multi-level static condensation. 
virtual void v_UniversalAssemble(Array< OneD, NekDouble > &pGlobal) const
int GetNumLocalBndCoeffs() const
Returns the total number of local boundary coefficients. 
bool AtLastLevel() const
Returns true if this is the last level in the multi-level static condensation. 
size_t m_hash
Hash for map. 
int GetLocalToGlobalBndMap(const int i) const
Retrieve the global index of a given local boundary mode. 
Base class for all multi-elemental spectral/hp expansions. 
std::shared_ptr< PatchMap > PatchMapSharedPtr
int GetNumGlobalBndCoeffs() const
Returns the total number of global boundary coefficients. 
int GetNumNonDirFaceModes() const
void RoundNekDoubleToInt(const Array< OneD, const NekDouble > inarray, Array< OneD, int > outarray)
Rounds an array of double precision numbers to integers. 
virtual void v_Assemble(const Array< OneD, const NekDouble > &loc, Array< OneD, NekDouble > &global) const
int m_bndSystemBandWidth
The bandwith of the global bnd system. 
virtual void v_GlobalToLocal(const Array< OneD, const NekDouble > &global, Array< OneD, NekDouble > &loc) const
NekDouble m_iterativeTolerance
Tolerance for iterative solver. 
virtual int v_GetNumNonDirFaces() const
NekDouble GetIterativeTolerance() const
Array< OneD, unsigned int > m_numLocalBndCoeffsPerPatch
The number of bnd dofs per patch. 
GlobalSysSolnType m_solnType
The solution type of the global system. 
Array< OneD, NekDouble > m_bndCondCoeffsToGlobalCoeffsSign
Integer map of bnd cond coeffs to global coefficients. 
int GetNumNonDirEdges() const
int m_numGlobalDirBndCoeffs
Number of Global Dirichlet Boundary Coefficients. 
NekDouble GetBndCondCoeffsToGlobalCoeffsSign(const int i)
Returns the modal sign associated with a given boundary expansion mode. 
void LocalBndToGlobal(const NekVector< NekDouble > &loc, NekVector< NekDouble > &global, int offset) const
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool. 
void Scatr(int n, const T *x, const int *y, T *z)
Scatter vector z[y[i]] = x[i]. 
Array< OneD, const NekDouble > GetLocalToGlobalBndSign() const
Retrieve the sign change for all local boundary modes. 
void UniversalAssembleBnd(Array< OneD, NekDouble > &pGlobal) const
size_t GetHash() const
Retrieves the hash of this map. 
virtual int v_GetNumDirFaces() const
void Assmb(int n, const T *x, const int *y, T *z)
Assemble z[y[i]] += x[i]; z should be zero'd first. 
GlobalSysSolnType GetGlobalSysSolnType() const
Returns the method of solving global systems. 
virtual int v_GetNumNonDirVertexModes() const
Array< OneD, unsigned int > m_numLocalIntCoeffsPerPatch
The number of int dofs per patch. 
const AssemblyMapSharedPtr GetNextLevelLocalToGlobalMap() const
Returns the local to global mapping for the next level in the multi-level static condensation. 
int GetNumGlobalDirBndCoeffs() const
Returns the number of global Dirichlet boundary coefficients. 
int m_lowestStaticCondLevel
Lowest static condensation level. 
void CalculateBndSystemBandWidth()
Calculates the bandwidth of the boundary system. 
Array< OneD, int > m_localToGlobalBndMap
Integer map of local boundary coeffs to global space. 
const Array< OneD, const int > & GetBndCondCoeffsToGlobalCoeffsMap()
Retrieves the global indices corresponding to the boundary expansion modes. 
int m_numLocalDirBndCoeffs
Number of Local Dirichlet Boundary Coefficients. 
bool GetSignChange()
Returns true if using a modal expansion requiring a change of sign of some modes. ...
const Array< OneD, const int > & GetLocalToGlobalMap()
const Array< OneD, const int > & GetGlobalToUniversalBndMap()
Array< OneD, int > m_bndCondCoeffsToGlobalCoeffsMap
Integer map of bnd cond coeffs to global coefficients. 
const Array< OneD, NekDouble > & GetLocalToGlobalSign() const
int m_numLocalBndCoeffs
Number of local boundary coefficients. 
void LocalToGlobal(const Array< OneD, const NekDouble > &loc, Array< OneD, NekDouble > &global, bool useComm=true) const
int m_staticCondLevel
The level of recursion in the case of multi-level static condensation. 
Array< OneD, NekDouble > m_localToGlobalBndSign
Integer sign of local boundary coeffs to global space. 
void Assemble(const Array< OneD, const NekDouble > &loc, Array< OneD, NekDouble > &global) const
AssemblyMap()
Default constructor. 
int m_maxIterations
Maximum iterations for iterative solver. 
int GetStaticCondLevel() const
Returns the level of static condensation for this map. 
virtual const Array< OneD, NekDouble > & v_GetLocalToGlobalSign() const
const Array< OneD, const unsigned int > & GetNumLocalBndCoeffsPerPatch()
Returns the number of local boundary coefficients in each patch. 
void AssembleBnd(const NekVector< NekDouble > &loc, NekVector< NekDouble > &global, int offset) const
void GlobalToLocalBndWithoutSign(const Array< OneD, const NekDouble > &global, Array< OneD, NekDouble > &loc)
int RoundNekDoubleToInt(NekDouble x)
Rounds a double precision number to an integer. 
const Array< OneD, const int > & GetGlobalToUniversalMapUnique()
int GetNumPatches() const
Returns the number of patches in this static condensation level. 
void PrintStats(std::ostream &out, std::string variable, bool printHeader=true) const
LibUtilities::SessionReaderSharedPtr m_session
Session object. 
int GetNumLocalCoeffs() const
Returns the total number of local coefficients. 
int GetFullSystemBandWidth() const
virtual const Array< OneD, const int > & v_GetExtraDirEdges()
Array< OneD, int > m_globalToUniversalBndMap
Integer map of process coeffs to universal space. 
Array< OneD, int > m_globalToUniversalBndMapUnique
Integer map of unique process coeffs to universal space (signed) 
virtual const Array< OneD, const int > & v_GetGlobalToUniversalMapUnique()
No Solution type specified. 
int GetNumDirFaces() const
int m_numGlobalCoeffs
Total number of global coefficients. 
const Array< OneD, const unsigned int > & GetNumLocalIntCoeffsPerPatch()
Returns the number of local interior coefficients in each patch. 
void Zero(int n, T *x, const int incx)
Zero vector. 
std::shared_ptr< AssemblyMap > LinearSpaceMap(const ExpList &locexp, GlobalSysSolnType solnType)
virtual const Array< OneD, const int > & v_GetGlobalToUniversalMap()
#define ASSERTL1(condition, msg)
Assert Level 1 – Debugging which is used whether in FULLDEBUG or DEBUG compilation mode...
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)
std::shared_ptr< BottomUpSubStructuredGraph > BottomUpSubStructuredGraphSharedPtr
std::shared_ptr< SessionReader > SessionReaderSharedPtr
Array< OneD, DataType > & GetPtr()
virtual const Array< OneD, const int > & v_GetLocalToGlobalMap()
int m_numPatches
The number of patches (~elements) in the current level. 
int GetMaxIterations() const
void GlobalToLocal(const Array< OneD, const NekDouble > &global, Array< OneD, NekDouble > &loc) const