43#include <boost/format.hpp>
73 unsigned short int *
q = (
unsigned short int *)&
d;
75 q[2] = (
unsigned short int)b;
76 q[3] = (
unsigned short int)c;
82 unsigned short int *
q = (
unsigned short int *)&
d;
90 short int *
p = (
short int *)&c;
97 short int *
p = (
short int *)&c;
121 std::vector<std::string> &defaultValues)
123 m_comm = pFields[0]->GetComm();
129 int coordim = pFields[0]->GetGraph()->GetSpaceDimension();
133 "EvaluatePoints does not support more than 65536 threads.")
135 for (
size_t i = 0; i < defaultValues.size(); ++i)
141 session->GetInterpreter(), defaultValues[i]);
143 catch (
const std::runtime_error &)
146 "Error parsering expression" + defaultValues[i]);
159 int coordim = pField->GetGraph()->GetSpaceDimension();
166 int nPlanes = pField->GetHomogeneousBasis()->GetZ().size();
168 int nelmts = pField->GetPlane(0)->GetExpSize();
173 locCoord = x.second->GetLocalCoords();
174 int expId = x.second->m_eId;
179 NekDouble BetaT = 2. * M_PI * fmod(locCoord[coordim], lHom) / lHom;
180 std::vector<NekDouble> basis(planes.size(), 0.);
181 for (
size_t n = 0; n < planes.size(); ++n)
187 else if (planes[n] == 1)
189 basis[n] = cos(0.5 * nPlanes * BetaT);
191 else if (planes[n] % 2 == 0)
193 NekDouble phase = (planes[n] >> 1) * BetaT;
194 basis[n] = cos(phase);
198 NekDouble phase = (planes[n] >> 1) * BetaT;
199 basis[n] = -sin(phase);
203 pField->GetPlane(0)->GetExp(expId);
207 for (
size_t n = 0; n < planes.size(); ++n)
209 physvals = PhysicsData[j] +
210 pField->GetPhys_Offset(expId + n * nelmts);
211 NekDouble coeff = elmt->StdPhysEvaluate(locCoord, physvals);
212 value += basis[n] * coeff;
227 locCoord = x.second->GetLocalCoords();
228 int expId = x.second->m_eId;
233 physvals = PhysicsData[j] + pField->GetPhys_Offset(expId);
235 pField->GetExp(expId)->StdPhysEvaluate(locCoord, physvals);
244 if (x.second->m_eId >= 0)
282 std::map<int, std::set<int>> threadToSend;
285 threadToSend[
p.second->m_sRank].insert(
p.first);
287 for (
const auto &thread : threadToSend)
290 thread.second.size() * nPackageSize, 0.);
293 for (
const int p : thread.second)
297 tmp = dataToSend + offset + 1, 1);
298 offset += nPackageSize;
300 if (thread.first !=
m_rank)
302 m_comm->Send(thread.first, dataToSend);
306 revData[thread.first] = dataToSend;
315 m_comm->Recv(
p.first, dataToRecv);
316 revData[
p.first] = dataToRecv;
324 int nRows =
m_comm->GetRowComm()->GetSize();
325 int nColumn =
m_comm->GetColumnComm()->GetSize();
347 totPairs += npairs[t];
355 data[offset++] =
p.second;
370 for (
int t = 0; t < totPairs; ++t)
384 std::set<int> notfound;
391 std::map<
int, std::set<int>> &callbackUpdateMobCoords)
393 std::map<int, Array<OneD, NekDouble>> recvData;
396 for (
auto const &data : recvData)
399 while (offset < data.second.size())
401 int pid, mobt, statt;
402 unPack3Int(pid, mobt, statt, data.second[offset++]);
403 m_staticPts->SetPhysicsByPID(pid, data.second + offset);
404 callbackUpdateMobCoords[data.first].insert(pid);
411 std::map<
int, std::set<int>> &callbackUpdateMobCoords)
413 std::map<int, Array<OneD, NekDouble>> globalCoords;
414 for (
auto const &thread : callbackUpdateMobCoords)
418 for (
const auto &
p : thread.second)
424 globalCoords[thread.first] = data;
431 std::set<int> ¬found)
445 p.second->m_eId = pFields[0]->GetPlane(0)->GetExpIndex(
446 gloCoords, locCoords, 0.,
false,
p.second->m_eId);
450 p.second->m_eId = pFields[0]->GetExpIndex(gloCoords, locCoords, 0.,
451 false,
p.second->m_eId);
453 if (
p.second->m_eId < 0)
455 notfound.insert(
p.first);
466 std::set<int> ¬found)
470 int nExchange = 0, nTot = 0;
472 std::vector<int> npts(
m_comm->GetRowComm()->GetSize(), 0);
496 int count = nOffset * nDataPackage;
498 for (
auto &
p : notfound)
508 std::vector<int> eIds(nTot, -1);
509 std::vector<int> procIds(nTot, -1);
511 for (
int p = 0;
p < nTot; ++
p)
523 pFields[0]->GetPlane(0)->GetExpIndex(gloCoords, locCoords);
527 eIds[
p] = pFields[0]->GetExpIndex(gloCoords, locCoords);
535 for (
int p = 0;
p < nTot; ++
p)
553 for (
int p = nOffset;
p < nOffset + npts[
m_rowRank]; ++
p)
573 for (
int t = 0,
p = 0; t < npts.size(); ++t)
575 for (
int i = 0; i < npts[t]; ++i, ++
p)
581 Pack3Int(sRank, t, procIds[
p], exchangeInfo[accumulate++]);
592 if (
m_comm->GetColumnComm()->GetSize() > 1)
598 m_comm->GetColumnComm()->AllReduce(exchangeInfo,
602 for (
int p = 0;
p < nExchange; ++
p)
604 int sRank, fromRank, toRank;
605 unPack3Int(sRank, fromRank, toRank, exchangeInfo[
p]);
631 p.second->m_local[2] =
p.second->m_global[2];
638 if (
m_comm->GetColumnComm()->GetSize() == 1)
651 Pack2Int(
p.first,
p.second->m_eId, data[count++]);
652 Vmath::Vcopy(3,
p.second->m_local, 1, tmp = data + count, 1);
660 for (
int p = 0;
p < nPts; ++
p)
667 m_mobilePts[pId]->SetLocalCoords(eId, data + offset);
693 for (
auto &iter : globalCoords)
697 m_comm->Send(iter.first, iter.second);
706 m_comm->Recv(iter.first, data);
710 data = globalCoords[iter.first];
712 for (
int offset = 0; offset < data.size(); offset +=
m_spacedim)
725 "CopyStaticPtsToMobile shoule only be called by ColumnRank zero");
740 "CopyStaticPtsToMobile shoule only be called by ColumnRank zero");
745 m_staticPts->AssignPoint(
id,
p.first,
p.second->GetGlobalCoords());
#define ASSERTL0(condition, msg)
#define NEKERROR(type, msg)
Assert Level 0 – Fundamental assert which is used whether in FULLDEBUG, DEBUG or OPT compilation mode...
static std::shared_ptr< DataType > AllocateSharedPtr(const Args &...args)
Allocate a shared pointer from the memory pool.
void PartitionLocalPoints(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, std::set< int > ¬found)
SOLVER_UTILS_EXPORT void EvaluateMobilePhys(const MultiRegions::ExpListSharedPtr &pField, std::vector< Array< OneD, NekDouble > > &PhysicsData, NekDouble time)
std::map< int, int > m_recvStatInfo
SOLVER_UTILS_EXPORT void Initialise(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, const NekDouble &time, std::vector< std::string > &defaultValues)
NekDouble GetDefaultValue(const int i, const Array< OneD, const NekDouble > x, const NekDouble time)
SOLVER_UTILS_EXPORT void PassMobilePhysToStatic(std::map< int, std::set< int > > &callbackUpdateMobCoords)
void Pack2Int(const int &a, const int &b, double &d)
SOLVER_UTILS_EXPORT void PartitionMobilePts(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields)
virtual ~EvaluatePoints()
void unPack2Short(int &a, int &b, const int &c)
SOLVER_UTILS_EXPORT void SetUpCommInfo()
SOLVER_UTILS_EXPORT void CopyMobilePtsToStatic()
SOLVER_UTILS_EXPORT void CopyStaticPtsToMobile()
void Pack2Short(const int &a, const int &b, int &c)
StationaryPointsSharedPtr m_staticPts
virtual void v_ModifyVelocity(Array< OneD, NekDouble > gcoords, NekDouble time, Array< OneD, NekDouble > vel)
SOLVER_UTILS_EXPORT EvaluatePoints()
void PartitionExchangeNonlocalPoints(const Array< OneD, const MultiRegions::ExpListSharedPtr > &pFields, std::set< int > ¬found)
void GatherMobilePhysics(std::map< int, Array< OneD, NekDouble > > &revData)
void Pack3Int(const int &a, const int &b, const int &c, double &d)
void unPack2Int(int &a, int &b, const double &d)
void UpdateMobileCoords(std::map< int, Array< OneD, NekDouble > > &globalCoords)
std::map< int, int > m_recvMobInfo
std::map< int, MobilePointSharedPtr > m_mobilePts
LibUtilities::CommSharedPtr m_comm
std::map< int, LibUtilities::EquationSharedPtr > m_defaultValueFunction
SOLVER_UTILS_EXPORT void PassStaticCoordsToMobile(std::map< int, std::set< int > > &callbackUpdateMobCoords)
void unPack3Int(int &a, int &b, int &c, const double &d)
virtual void v_AssignPoint(int id, int pid, const Array< OneD, NekDouble > &gcoords)
std::map< int, int > m_globalIDToLocal
std::map< int, int > m_localIDToGlobal
std::shared_ptr< SessionReader > SessionReaderSharedPtr
std::shared_ptr< Expansion > ExpansionSharedPtr
std::shared_ptr< ExpList > ExpListSharedPtr
Shared pointer to an ExpList object.
std::vector< double > z(NPUPPER)
std::vector< double > d(NPUPPER *NPUPPER)
std::vector< double > q(NPUPPER *NPUPPER)
void Vcopy(int n, const T *x, const int incx, T *y, const int incy)