Commit 70aef5b5 authored by Chris Cantwell's avatar Chris Cantwell
Browse files

Fixed compile error (due to uncommitted update)

Fixed history point output in parallel.


git-svn-id: https://gforge.sci.utah.edu/svn/nektar/trunk@3991 305cdda6-5ce1-45b3-a98d-dfc68c8b3305
parent 99ba9b85
......@@ -123,68 +123,87 @@ namespace Nektar
}
// Determine the element in which each history point resides.
// If point is not in mesh (on this process), id is -1.
Array<OneD, int> idList(m_historyPoints.size());
SpatialDomains::VertexComponentSharedPtr vtx;
// Determine the unique process responsible for each history point
// For points on a partition boundary, must select a single process
LibUtilities::CommSharedPtr vComm = pFields[0]->GetComm();
int vRank = vComm->GetRank();
Array<OneD, int> idList(m_historyPoints.size());
Array<OneD, int> procList(m_historyPoints.size(), -1);
for (i = 0; i < m_historyPoints.size(); ++i)
{
vtx = m_historyPoints[i];
vtx->GetCoords(gloCoord[0], gloCoord[1], gloCoord[2]);
m_historyPoints[i]->GetCoords( gloCoord[0],
gloCoord[1],
gloCoord[2]);
idList[i] = pFields[0]->GetExpIndex(gloCoord);
if (idList[i] != -1) {
procList[i] = vRank;
}
}
vComm->AllReduce(procList, LibUtilities::ReduceMax);
// Determine the element in which each history point resides.
// If point is not in mesh (on this process), id is -1.
for (i = 0; i < m_historyPoints.size(); ++i)
{
// If point lies on partition boundary, only the proc with max
// rank retains posession.
if (procList[i] != vRank)
{
idList[i] = -1;
}
if (idList[i] != -1)
{
m_historyLocalPointMap[m_historyList.size()] = i;
m_historyList.push_back(
std::pair<SpatialDomains::VertexComponentSharedPtr, int>(
vtx, idList[i]));
m_historyPoints[i], idList[i]));
}
}
// Collate the element ID list across processes
// Collate the element ID list across processes and check each
// history point is allocated to a process
vComm->AllReduce(idList, LibUtilities::ReduceMax);
// Check each history point has been located on one process
if (vComm->GetRank() == 0)
{
for (i = 0; i < m_historyPoints.size(); ++i)
{
vtx = m_historyPoints[i];
vtx->GetCoords(gloCoord[0], gloCoord[1], gloCoord[2]);
m_historyPoints[i]->GetCoords( gloCoord[0],
gloCoord[1],
gloCoord[2]);
ASSERTL0(idList[i] != -1, "History point " +
boost::lexical_cast<std::string>(gloCoord[0]) + ", " +
boost::lexical_cast<std::string>(gloCoord[1]) + ", " +
boost::lexical_cast<std::string>(gloCoord[2]) +
" cannot be found in the mesh.");
}
}
// Open output stream
m_outputStream.open(m_outputFile.c_str());
m_outputStream << "# History data for variables (:";
// Open output stream
m_outputStream.open(m_outputFile.c_str());
m_outputStream << "# History data for variables (:";
for (i = 0; i < pFields.num_elements(); ++i)
{
m_outputStream << m_session->GetVariable(i) <<",";
}
for (i = 0; i < pFields.num_elements(); ++i)
{
m_outputStream << m_session->GetVariable(i) <<",";
}
m_outputStream << ") at points:" << endl;
m_outputStream << ") at points:" << endl;
for (i = 0; i < m_historyPoints.size(); ++i)
{
m_historyPoints[i]->GetCoords(gloCoord[0], gloCoord[1], gloCoord[2]);
m_outputStream << "# \t" << i;
m_outputStream.width(8);
m_outputStream << gloCoord[0];
m_outputStream.width(8);
m_outputStream << gloCoord[1];
m_outputStream.width(8);
m_outputStream << gloCoord[2];
m_outputStream << endl;
for (i = 0; i < m_historyPoints.size(); ++i)
{
m_historyPoints[i]->GetCoords( gloCoord[0],
gloCoord[1],
gloCoord[2]);
m_outputStream << "# \t" << i;
m_outputStream.width(8);
m_outputStream << gloCoord[0];
m_outputStream.width(8);
m_outputStream << gloCoord[1];
m_outputStream.width(8);
m_outputStream << gloCoord[2];
m_outputStream << endl;
}
}
v_Update(pFields, time);
}
......@@ -225,12 +244,13 @@ namespace Nektar
}
}
// Exchange history data
// This could be improved to reduce communication but works for now
vComm->AllReduce(data, LibUtilities::ReduceSum);
// Only the root process writes out history data
if (vComm->GetRank() == 0)
{
// Exchange history data
// This could be improved to reduce communication but works for now
vComm->AllReduce(data, LibUtilities::ReduceSum);
// Write data values point by point
for (k = 0; k < m_historyPoints.size(); ++k)
......@@ -245,13 +265,6 @@ namespace Nektar
m_outputStream << endl;
}
}
else
{
// Exchange history data
// This could be improved to reduce communication but works for now
vComm->AllReduce(data, LibUtilities::ReduceSum);
}
}
......@@ -260,7 +273,10 @@ namespace Nektar
*/
void FilterHistoryPoints::v_Finalise(const Array<OneD, const MultiRegions::ExpListSharedPtr> &pFields, const NekDouble &time)
{
m_outputStream.close();
if (pFields[0]->GetComm()->GetRank() == 0)
{
m_outputStream.close();
}
}
......
......@@ -88,36 +88,36 @@ namespace Nektar
// --------------------------------------
// Compute reaction term f(u,v)
// --------------------------------------
if (m_spatialParameters->Exists("a"))
{
Vmath::Vmul(m_nq, &m_spatialParameters->GetData("a")->GetPhys()[0], 1,
&inarray[0][0], 1, &m_tmp1[0], 1);
Vmath::Vvtvm(m_nq, &m_spatialParameters->GetData("a")->GetPhys()[0], 1,
&m_uu[0], 1, &m_tmp1[0], 1, &m_tmp1[0], 1);
Vmath::Svtvm(m_nq, -1.0, &m_uu[0], 1, &m_tmp1[0], 1, &m_tmp1[0], 1);
}
else
{
// if (m_spatialParameters->Exists("a"))
// {
// Vmath::Vmul(m_nq, &m_spatialParameters->GetData("a")->GetPhys()[0], 1,
// &inarray[0][0], 1, &m_tmp1[0], 1);
//
// Vmath::Vvtvm(m_nq, &m_spatialParameters->GetData("a")->GetPhys()[0], 1,
// &m_uu[0], 1, &m_tmp1[0], 1, &m_tmp1[0], 1);
//
// Vmath::Svtvm(m_nq, -1.0, &m_uu[0], 1, &m_tmp1[0], 1, &m_tmp1[0], 1);
// }
// else
// {
// Ru = au
Vmath::Smul(m_nq, m_a, &inarray[0][0], 1, &m_tmp1[0], 1);
// Ru = (-1-a)u*u + au
Vmath::Svtvp(m_nq, (-1.0-m_a), &m_uu[0], 1, &m_tmp1[0], 1,
&m_tmp1[0], 1);
}
// }
// Ru = u*u*u - (1+a)u*u + au
Vmath::Vadd(m_nq, &m_uuu[0], 1, &m_tmp1[0], 1, &m_tmp1[0], 1);
// Ru = k(u*u*u - (1+a)u*u + au)
if (m_spatialParameters->Exists("k"))
{
Vmath::Vmul(m_nq, &m_spatialParameters->GetData("k")->GetPhys()[0], 1,
&m_tmp1[0], 1, &m_tmp1[0], 1);
}
else
{
// if (m_spatialParameters->Exists("k"))
// {
// Vmath::Vmul(m_nq, &m_spatialParameters->GetData("k")->GetPhys()[0], 1,
// &m_tmp1[0], 1, &m_tmp1[0], 1);
// }
// else
// {
Vmath::Smul(m_nq, m_k, &m_tmp1[0], 1, &m_tmp1[0], 1);
}
// }
// Ru = k(u*u*u - (1+a)u*u + au) + I_stim
Vmath::Vadd(m_nq, &outarray[0][0], 1, &m_tmp1[0], 1, &outarray[0][0], 1);
......@@ -145,29 +145,29 @@ namespace Nektar
Vmath::Sadd(m_nq, m_eps, &m_tmp2[0], 1, &m_tmp2[0], 1);
// tmp1 = (-a-1) + u
if (m_spatialParameters->Exists("a"))
{
Vmath::Vsub(m_nq, &inarray[0][0], 1,
&m_spatialParameters->GetData("a")->GetPhys()[0], 1,
&m_tmp1[0], 1);
Vmath::Sadd(m_nq, -1.0, &inarray[0][0], 1, &m_tmp1[0], 1);
}
else
{
// if (m_spatialParameters->Exists("a"))
// {
// Vmath::Vsub(m_nq, &inarray[0][0], 1,
// &m_spatialParameters->GetData("a")->GetPhys()[0], 1,
// &m_tmp1[0], 1);
//
// Vmath::Sadd(m_nq, -1.0, &inarray[0][0], 1, &m_tmp1[0], 1);
// }
// else
// {
Vmath::Sadd(m_nq, (-m_a-1), &inarray[0][0], 1, &m_tmp1[0], 1);
}
// }
// tmp1 = k(u-a-1)
if (m_spatialParameters->Exists("k"))
{
Vmath::Vmul(m_nq, &m_spatialParameters->GetData("k")->GetPhys()[0], 1,
&m_tmp1[0], 1, &m_tmp1[0], 1);
}
else
{
// if (m_spatialParameters->Exists("k"))
// {
// Vmath::Vmul(m_nq, &m_spatialParameters->GetData("k")->GetPhys()[0], 1,
// &m_tmp1[0], 1, &m_tmp1[0], 1);
// }
// else
// {
Vmath::Smul(m_nq, m_k, &m_tmp1[0], 1, &m_tmp1[0], 1);
}
// }
// tmp1 = ku(u-a-1) + v
Vmath::Vvtvp(m_nq, &inarray[0][0], 1, &m_tmp1[0], 1, &inarray[1][0], 1,
......
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