19 CGrid* gridDest, CGrid* gridSource,
20 CGenerateRectilinearDomain* genRectDomain)
21 : CDomainAlgorithmTransformation(domainDestination, domainSource), nbDomainDistributedPart_(0)
25 genRectDomain->checkValid(domainDestination);
26 if (0 != gridSource) computeDistributionGridSource(gridSource);
29 computeDistributionGridDestination(gridDest);
52 std::vector<CDomain*> domListSrcP = gridSrc->getDomains();
53 std::vector<CAxis*> axisListSrcP = gridSrc->getAxis();
55 for (
int i = 0; i < domListSrcP.size(); ++i)
58 if (axisListSrcP.empty()) nbDomainDistributedPart_ = client->
clientSize;
61 gridSrc->solveAxisRef(
false);
62 int nbAxis = axisListSrcP.size();
63 std::vector<int> nbLocalAxis(nbAxis, 0);
64 for (
int j = 0; j < nbAxis; ++j)
66 std::vector<int> globalAxisIndex(axisListSrcP[j]->n);
67 for (
int idx = 0; idx < axisListSrcP[j]->n; ++idx)
68 globalAxisIndex[idx] = axisListSrcP[j]->begin + idx;
71 std::vector<StdSize> recvBuff(client->
clientSize);
72 MPI_Gather(&hashValue, 1, MPI_UNSIGNED_LONG,
73 &recvBuff[0], 1, MPI_UNSIGNED_LONG,
78 std::set<StdSize> setTmp;
79 for (
int k = 0; k < recvBuff.size(); ++k)
81 if (setTmp.end() == setTmp.find(recvBuff[k]))
84 setTmp.insert(recvBuff[k]);
89 MPI_Bcast(&nbLocalAxis[0], nbAxis, MPI_INT,
93 int nbAxisDistributedPart = 1;
94 for (
int j = 0; j < nbAxis; ++j) nbAxisDistributedPart *= nbLocalAxis[j];
95 nbDomainDistributedPart_ = client->
clientSize/nbAxisDistributedPart;
104 void CDomainAlgorithmGenerateRectilinear::computeDistributionGridDestination(
CGrid* gridDest)
108 std::vector<CAxis*> axisListDestP = gridDest->getAxis();
109 int nbPartition = 1, idx = 0;
110 for (
int i = 0; i < gridDest->axis_domain_order.numElements(); ++i)
112 if (
false == (gridDest->axis_domain_order)(i))
114 nbPartition *= (axisListDestP[idx]->n_distributed_partition.isEmpty()) ? 1: (axisListDestP[idx]->n_distributed_partition.getValue());
119 CContext* context = CContext::getCurrent();
121 int modPart = (client->
clientSize) % nbPartition;
123 ERROR(
"CDomainAlgorithmGenerateRectilinear::computeDistributionGridDestination(CGrid* gridDest)",
124 <<
"The grid " <<gridDest->getId() <<
" is not well-distributed. There is an incompatibility between distribution of axis and domain.");
125 nbDomainDistributedPart_ = client->
clientSize/nbPartition;
136 if (!domainDest_->distributionAttributesHaveValue())
137 domainDest_->redistribute(nbDomainDistributedPart_);
138 domainDest_->fillInLonLat();
fillInAttributesDomainDestination()
MPI_Comm intraComm
Communicator of client group.
void computeDistributionGridSource(CGrid *gridSrc)
Calculate the number of distributed parts on domain source.
std::size_t hashVec(const std::vector< T > &vec)
int clientSize
Size of client group.
CDomainAlgorithmGenerateRectilinear(CDomain *domainDestination, CDomain *domainSource, CGrid *gridDest, CGrid *gridSource, CGenerateRectilinearDomain *zoomDomain)
void computeIndexSourceMapping_(const std::vector< CArray< double, 1 > * > &dataAuxInputs)
Compute the index mapping between domain on grid source and one on grid destination.
A context can be both on client and on server side.
Algorithm for automatic generation of rectilinear domain.
int clientRank
Rank of current client.
static CContext * getCurrent(void)
Get current context.
CContextClient * client
Concrete contex client.