Commit 928c1202 authored by Chris Cantwell's avatar Chris Cantwell
Browse files

Merge branch 'feature/print-assembly-stats' of /opt/gitlab/repositories/nektar

parents 83224ffa d95a459a
...@@ -1202,5 +1202,155 @@ namespace Nektar ...@@ -1202,5 +1202,155 @@ namespace Nektar
Vmath::Gathr(m_numLocalBndCoeffs, global.get(), m_localToGlobalBndMap.get(), loc.get()); 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 totGlobDof = globCnt;
int totGlobBndDof = globBndCnt;
int totGlobDirDof = globDirCnt;
int totLocalDof = m_numLocalCoeffs;
int totLocalBndDof = m_numLocalBndCoeffs;
int totLocalDirDof = m_numLocalDirBndCoeffs;
int meanValence = 0;
int maxValence = 0;
int minValence = 10000000;
for (int i = 0; i < m_numGlobalBndCoeffs; ++i)
{
if (!m_globalToUniversalBndMapUnique[i])
{
continue;
}
if (tmpGlob[i] > maxValence)
{
maxValence = tmpGlob[i];
}
if (tmpGlob[i] < minValence)
{
minValence = tmpGlob[i];
}
meanValence += tmpGlob[i];
}
vRowComm->AllReduce(maxValence, LibUtilities::ReduceMax);
vRowComm->AllReduce(minValence, LibUtilities::ReduceMin);
vRowComm->AllReduce(meanValence, LibUtilities::ReduceSum);
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);
meanValence /= totGlobBndDof;
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 << " - dof valency (min/max/mean) : "
<< minValence << " " << maxValence << " " << meanValence
<< 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/dev) : "
<< 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];
if (tmp[0] > maxval)
{
maxval = tmp[0];
}
if (tmp[0] < minval)
{
minval = tmp[0];
}
}
out << " - Local bnd dof dist. (min/max/mean/dev) : "
<< 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
} // namespace } // namespace
...@@ -252,6 +252,8 @@ namespace Nektar ...@@ -252,6 +252,8 @@ namespace Nektar
MULTI_REGIONS_EXPORT int GetNumNonDirFaces() const; 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>& MULTI_REGIONS_EXPORT const Array<OneD, const int>&
GetExtraDirEdges(); GetExtraDirEdges();
......
...@@ -751,7 +751,5 @@ namespace Nektar ...@@ -751,7 +751,5 @@ namespace Nektar
{ {
return m_extraDirEdges; return m_extraDirEdges;
} }
} // namespace } // namespace
} // namespace } // namespace
...@@ -135,6 +135,10 @@ namespace Nektar ...@@ -135,6 +135,10 @@ namespace Nektar
CheckIfSingularSystem, CheckIfSingularSystem,
variable); variable);
if (m_session->DefinesCmdLineArgument("verbose"))
{
m_locToGloMap->PrintStats(std::cout, variable);
}
} }
...@@ -181,12 +185,16 @@ namespace Nektar ...@@ -181,12 +185,16 @@ namespace Nektar
m_periodicVerts, m_periodicVerts,
m_periodicEdges, m_periodicEdges,
CheckIfSingularSystem); CheckIfSingularSystem);
if (m_session->DefinesCmdLineArgument("verbose"))
{
m_locToGloMap->PrintStats(std::cout, variable);
}
} }
else else
{ {
m_locToGloMap = In.m_locToGloMap; m_locToGloMap = In.m_locToGloMap;
} }
} }
......
...@@ -87,6 +87,11 @@ namespace Nektar ...@@ -87,6 +87,11 @@ namespace Nektar
m_session,m_ncoeffs,*this,m_bndCondExpansions,m_bndConditions, m_session,m_ncoeffs,*this,m_bndCondExpansions,m_bndConditions,
m_periodicVerts, m_periodicEdges, m_periodicFaces, m_periodicVerts, m_periodicEdges, m_periodicFaces,
CheckIfSingularSystem, variable); CheckIfSingularSystem, variable);
if (m_session->DefinesCmdLineArgument("verbose"))
{
m_locToGloMap->PrintStats(std::cout, variable);
}
} }
...@@ -130,6 +135,11 @@ namespace Nektar ...@@ -130,6 +135,11 @@ namespace Nektar
m_session,m_ncoeffs,*this,m_bndCondExpansions,m_bndConditions, m_session,m_ncoeffs,*this,m_bndCondExpansions,m_bndConditions,
m_periodicVerts, m_periodicEdges, m_periodicFaces, m_periodicVerts, m_periodicEdges, m_periodicFaces,
CheckIfSingularSystem,variable); CheckIfSingularSystem,variable);
if (m_session->DefinesCmdLineArgument("verbose"))
{
m_locToGloMap->PrintStats(std::cout, variable);
}
} }
else 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