Commit 040e4338 authored by Dave Moxey's avatar Dave Moxey Committed by Douglas Serson

Performance fix for ExtractDataToCoeffs

(cherry picked from commit a76f2691)
parent bfb7576d
......@@ -2179,17 +2179,19 @@ namespace Nektar
ASSERTL0(i != fielddef->m_fields.size(),
"Field (" + field + ") not found in file.");
// Determine mapping from element ids to location in expansion list
map<int, int> elmtToExpId;
// Loop in reverse order so that in case where using a Homogeneous
// expansion it sets geometry ids to first part of m_exp
// list. Otherwise will set to second (complex) expansion
for(i = (*m_exp).size()-1; i >= 0; --i)
if (m_elmtToExpId.size() == 0)
{
elmtToExpId[(*m_exp)[i]->GetGeom()->GetGlobalID()] = i;
// Loop in reverse order so that in case where using a
// Homogeneous expansion it sets geometry ids to first part of
// m_exp list. Otherwise will set to second (complex) expansion
for(i = (*m_exp).size()-1; i >= 0; --i)
{
m_elmtToExpId[(*m_exp)[i]->GetGeom()->GetGlobalID()] = i;
}
}
boost::unordered_map<int, int>::iterator eIt;
for (i = 0; i < fielddef->m_elementIDs.size(); ++i)
{
// Reset modes_offset in the case where all expansions of
......@@ -2203,14 +2205,16 @@ namespace Nektar
fielddef->m_numModes, modes_offset);
const int elmtId = fielddef->m_elementIDs[i];
if (elmtToExpId.count(elmtId) == 0)
eIt = m_elmtToExpId.find(elmtId);
if (eIt == m_elmtToExpId.end())
{
offset += datalen;
modes_offset += (*m_exp)[0]->GetNumBases();
continue;
}
expId = elmtToExpId[elmtId];
expId = eIt->second;
if (datalen == (*m_exp)[expId]->GetNcoeffs())
{
......@@ -2220,8 +2224,8 @@ namespace Nektar
else
{
(*m_exp)[expId]->ExtractDataToCoeffs(
&fielddata[offset], fielddef->m_numModes,
modes_offset, &coeffs[m_coeff_offset[expId]]);
&fielddata[offset], fielddef->m_numModes,
modes_offset, &coeffs[m_coeff_offset[expId]]);
}
offset += datalen;
......
......@@ -1007,6 +1007,9 @@ namespace Nektar
// or not
bool m_WaveSpace;
/// Mapping from geometry ID of element to index inside #m_exp
boost::unordered_map<int, int> m_elmtToExpId;
/// This function assembles the block diagonal matrix of local
/// matrices of the type \a mtype.
const DNekScalBlkMatSharedPtr GenBlockMatrix(
......
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