Commit 112d3eef authored by Kilian Lackhove's avatar Kilian Lackhove

Coupling: Send (dummy) fields

parent 562fbd70
......@@ -383,7 +383,8 @@ namespace Nektar
"only partition mesh into N overlapping partitions.")
("part-info", "Output partition information")
#ifdef NEKTAR_USE_CWIPI
("cwipi", "use CWIPI")
("cwipi", po::value<std::string>(),
"set CWIPI name")
#endif
;
......
......@@ -64,8 +64,16 @@ CommCwipi::CommCwipi(int narg, char* arg[])
ASSERTL0(false, "Failed to initialise MPI");
}
std::string localName = "";
for (int i = 0; i < narg; ++i) {
if (!std::strcmp(arg[i], "--cwipi"))
{
localName = arg[i+1];
}
}
MPI_Comm localComm;
cwipi_init(MPI_COMM_WORLD, "nektar", &localComm);
cwipi_init(MPI_COMM_WORLD, localName.c_str(), &localComm);
m_comm = localComm;
MPI_Comm_size( m_comm, &m_size );
......
......@@ -176,6 +176,7 @@ void CwipiCoupling::ReadConfig(LibUtilities::SessionReaderSharedPtr session)
m_nSendVars = m_sendFieldNames.size();
m_recvSteps = boost::lexical_cast<int>(m_config["RECEIVESTEPS"]);
m_sendSteps = boost::lexical_cast<int>(m_config["SENDSTEPS"]);
m_filtWidth = boost::lexical_cast<NekDouble>(m_config["FILTERWIDTH"]);
......@@ -385,8 +386,9 @@ void CwipiCoupling::AnnounceRecvPoints()
}
if (m_nSendVars > 0)
{
m_sValsInterl =
(double *)malloc(sizeof(double) * m_nPoints * m_nSendVars);
m_sValsInterl = (double *)malloc(
sizeof(double) * m_evalField->GetGraph()->GetNvertices() *
m_nSendVars);
ASSERTL1(m_sValsInterl != NULL, "malloc failed for m_sValsInterl");
}
}
......@@ -454,9 +456,52 @@ void CwipiCoupling::PrintProgressbar(const int position, const int goal) const
void CwipiCoupling::SendFields(const int step,
const NekDouble time,
const NekDouble timestep,
Array<OneD, Array<OneD, NekDouble> > &field)
{
ASSERTL0(false, "not implemented yet")
if (m_sendSteps < 1)
{
return;
}
ASSERTL1(m_nSendVars == field.num_elements(), "field size mismatch");
cout << "sending fields at i = " << step << ", t = " << time << endl;
int nVerts = m_evalField->GetGraph()->GetNvertices();
Array<OneD, NekDouble> tmpC(m_evalField->GetNcoeffs());
Array<OneD, Array<OneD, NekDouble> > sVals(m_nSendVars);
for (int i = 0; i < m_nSendVars; ++i)
{
sVals[i] = Array<OneD, NekDouble>(nVerts, 1.2345);
}
for (int j = 0; j < m_nSendVars; ++j)
{
for (int i = 0; i < nVerts; ++i)
{
m_sValsInterl[i * m_nSendVars + j] = sVals[j][i];
}
}
int nNotLoc = 0;
// workaround a bug in cwipi: receiving_field_name should be const char* but
// is char*
char sendFN[10];
strcpy(sendFN, "dummyName");
cwipi_exchange(m_couplingName.c_str(),
"ex1",
m_nSendVars,
step,
time,
sendFN,
m_sValsInterl,
"",
NULL,
&nNotLoc);
}
void CwipiCoupling::ReceiveFields(const int step,
......@@ -464,13 +509,13 @@ void CwipiCoupling::ReceiveFields(const int step,
const NekDouble timestep,
Array<OneD, Array<OneD, NekDouble> > &field)
{
ASSERTL1(m_nRecvVars == field.num_elements(), "field size mismatch");
if (m_recvSteps < 1)
{
return;
}
ASSERTL1(m_nRecvVars == field.num_elements(), "field size mismatch");
int nq = m_evalField->GetTotPoints();
// make sure we have sensible data in old/new field the first time this
......
......@@ -68,6 +68,7 @@ public:
void SendFields(const int step,
const NekDouble time,
const NekDouble timestep,
Array<OneD, Array<OneD, NekDouble> > &field);
void ReceiveFields(const int step,
......
......@@ -94,6 +94,7 @@ Dummy::~Dummy()
bool Dummy::v_PostIntegrate(int step)
{
m_coupling->ReceiveFields(0, m_time, m_timestep, m_recFields);
m_coupling->SendFields(0, m_time, m_timestep, m_recFields);
return UnsteadySystem::v_PostIntegrate(step);
}
......
......@@ -93,7 +93,10 @@ protected:
private:
Array<OneD, Array<OneD, NekDouble> > m_recFields;
Array<OneD, Array<OneD, NekDouble> > m_sendFields;
std::vector<std::string> m_recvFieldNames;
std::vector<std::string> m_sendFieldNames;
};
}
......
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