Commit 5df0a5a5 authored by Dave Moxey's avatar Dave Moxey

Add some code to print rudimentary statistics from assembly map

parent de6bf027
......@@ -1202,5 +1202,120 @@ namespace Nektar
Vmath::Gathr(m_numLocalBndCoeffs, global.get(), m_localToGlobalBndMap.get(), loc.get());
}
void AssemblyMap::PrintStats(
std::ostream &out, std::string variable) const
{
LibUtilities::CommSharedPtr vRowComm
= m_session->GetComm()->GetRowComm();
bool isRoot = vRowComm->GetRank() == 0;
int n = vRowComm->GetSize();
int p = vRowComm->GetRank();
int i;
// Determine number of global degrees of freedom.
int globBndCnt = 0, globDirCnt = 0;
for (i = 0; i < m_numGlobalBndCoeffs; ++i)
{
if (m_globalToUniversalBndMapUnique[i] > 0)
{
globBndCnt++;
if (i < m_numGlobalDirBndCoeffs)
{
globDirCnt++;
}
}
}
int globCnt = m_numGlobalCoeffs - m_numGlobalBndCoeffs + globBndCnt;
// Calculate maximum valency
Array<OneD, NekDouble> tmpLoc (m_numLocalBndCoeffs, 1.0);
Array<OneD, NekDouble> tmpGlob(m_numGlobalBndCoeffs, 0.0);
AssembleBnd(tmpLoc, tmpGlob);
int highValence = Vmath::Vmax(m_numGlobalBndCoeffs, tmpGlob, 1);
int totGlobDof = globCnt;
int totGlobBndDof = globBndCnt;
int totGlobDirDof = globDirCnt;
int totLocalDof = m_numLocalCoeffs;
int totLocalBndDof = m_numLocalBndCoeffs;
int totLocalDirDof = m_numLocalDirBndCoeffs;
vRowComm->AllReduce(highValence, LibUtilities::ReduceMax);
vRowComm->AllReduce(totGlobDof, LibUtilities::ReduceSum);
vRowComm->AllReduce(totGlobBndDof, LibUtilities::ReduceSum);
vRowComm->AllReduce(totGlobDirDof, LibUtilities::ReduceSum);
vRowComm->AllReduce(totLocalDof, LibUtilities::ReduceSum);
vRowComm->AllReduce(totLocalBndDof, LibUtilities::ReduceSum);
vRowComm->AllReduce(totLocalDirDof, LibUtilities::ReduceSum);
if (isRoot)
{
out << "Assembly map statistics for field " << variable << ":"
<< endl;
out << " - Number of local/global dof : "
<< totLocalDof << " " << totGlobDof << endl;
out << " - Number of local/global boundary dof : "
<< totLocalBndDof << " " << totGlobBndDof << endl;
out << " - Number of local/global Dirichlet dof : "
<< totLocalDirDof << " " << totGlobDirDof << endl;
out << " - Highest dof valency : "
<< highValence << endl;
if (n > 1)
{
NekDouble mean = m_numLocalCoeffs, mean2 = mean * mean;
NekDouble minval = mean, maxval = mean;
Array<OneD, NekDouble> tmp(1);
for (i = 1; i < n; ++i)
{
vRowComm->Recv(i, tmp);
mean += tmp[0];
mean2 += tmp[0]*tmp[0];
if (tmp[0] > maxval)
{
maxval = tmp[0];
}
if (tmp[0] < minval)
{
minval = tmp[0];
}
}
out << " - Local dof dist. (min/max/mean) : "
<< minval << " " << maxval << " " << (mean / n) << " "
<< sqrt(mean2/n - mean*mean/n/n) << endl;
vRowComm->Block();
mean = minval = maxval = m_numLocalBndCoeffs;
mean2 = mean * mean;
for (i = 1; i < n; ++i)
{
vRowComm->Recv(i, tmp);
mean += tmp[0];
mean2 += tmp[0]*tmp[0];
}
out << " - Local bnd dof dist. (min/max/mean) : "
<< minval << " " << maxval << " " << (mean / n) << " "
<< sqrt(mean2/n - mean*mean/n/n) << endl;
}
}
else
{
Array<OneD, NekDouble> tmp(1);
tmp[0] = m_numLocalCoeffs;
vRowComm->Send(0, tmp);
vRowComm->Block();
tmp[0] = m_numLocalBndCoeffs;
vRowComm->Send(0, tmp);
}
}
} // namespace
} // namespace
......@@ -252,6 +252,8 @@ namespace Nektar
MULTI_REGIONS_EXPORT int GetNumNonDirFaces() const;
MULTI_REGIONS_EXPORT void PrintStats(std::ostream &out, std::string variable) const;
MULTI_REGIONS_EXPORT const Array<OneD, const int>&
GetExtraDirEdges();
......
......@@ -751,7 +751,5 @@ namespace Nektar
{
return m_extraDirEdges;
}
} // namespace
} // namespace
......@@ -135,6 +135,10 @@ namespace Nektar
CheckIfSingularSystem,
variable);
if (m_session->DefinesCmdLineArgument("verbose"))
{
m_locToGloMap->PrintStats(std::cout, variable);
}
}
......@@ -181,12 +185,16 @@ namespace Nektar
m_periodicVerts,
m_periodicEdges,
CheckIfSingularSystem);
if (m_session->DefinesCmdLineArgument("verbose"))
{
m_locToGloMap->PrintStats(std::cout, variable);
}
}
else
{
m_locToGloMap = In.m_locToGloMap;
}
}
......
......@@ -87,6 +87,11 @@ namespace Nektar
m_session,m_ncoeffs,*this,m_bndCondExpansions,m_bndConditions,
m_periodicVerts, m_periodicEdges, m_periodicFaces,
CheckIfSingularSystem, variable);
if (m_session->DefinesCmdLineArgument("verbose"))
{
m_locToGloMap->PrintStats(std::cout, variable);
}
}
......@@ -130,6 +135,11 @@ namespace Nektar
m_session,m_ncoeffs,*this,m_bndCondExpansions,m_bndConditions,
m_periodicVerts, m_periodicEdges, m_periodicFaces,
CheckIfSingularSystem,variable);
if (m_session->DefinesCmdLineArgument("verbose"))
{
m_locToGloMap->PrintStats(std::cout, variable);
}
}
else
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment