#include "NormalizedGeometricTypes"
#include <vector>
+#include <functional>
namespace MEDCoupling
{
static MEDCouplingSkyLineArray * New( const MEDCouplingSkyLineArray & other );
static MEDCouplingSkyLineArray * BuildFromPolyhedronConn( const DataArrayIdType* c, const DataArrayIdType* cI );
+
+ static std::vector< MCAuto<DataArrayIdType> > RetrieveVecIndex(const std::vector< MCAuto<MEDCouplingSkyLineArray> >& vecSka)
+ {
+ auto fct = [](MEDCouplingSkyLineArray *ska) { return ska->getIndexArray(); };
+ return RetrieveVecOfSkyLineArrayGen(vecSka,fct);
+ }
+
+ static std::vector< MCAuto<DataArrayIdType> > RetrieveVecValues(const std::vector< MCAuto<MEDCouplingSkyLineArray> >& vecSka)
+ {
+ auto fct = [](MEDCouplingSkyLineArray *ska) { return ska->getValuesArray(); };
+ return RetrieveVecOfSkyLineArrayGen(vecSka,fct);
+ }
+
+ static std::vector< MCAuto<DataArrayIdType> > RetrieveVecOfSkyLineArrayGen(const std::vector< MCAuto<MEDCouplingSkyLineArray> >& vecSka, std::function<DataArrayIdType *(MEDCouplingSkyLineArray *)> fct)
+ {
+ std::size_t sz(vecSka.size());
+ std::vector< MCAuto<DataArrayIdType> > ret(sz);
+ std::vector< MCAuto<DataArrayIdType> >::iterator it(ret.begin());
+ std::for_each(vecSka.begin(),vecSka.end(),[&it,fct](MCAuto<MEDCouplingSkyLineArray> elt) { *it++ = MCAuto<DataArrayIdType>::TakeRef(fct(elt)); } );
+ return ret;
+ }
+
std::string getClassName() const override { return std::string("MEDCouplingSkyLineArray"); }
std::size_t getHeapMemorySizeWithoutChildren() const;
std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const;
#include <memory>
#include <vector>
-using namespace std;
using namespace MEDCoupling;
ParaSkyLineArray::ParaSkyLineArray(MEDCouplingSkyLineArray *ska, DataArrayIdType *globalIds)
MCAuto<ParaSkyLineArray> ParaSkyLineArray::equiRedistribute(mcIdType nbOfEntities) const
{
- //TODO
+ MPI_Comm comm(MPI_COMM_WORLD);
+ CommInterface ci;
+ int size;
+ ci.commSize(comm,&size);
+ std::vector< MCAuto<MEDCouplingSkyLineArray> > skToBeSent(size);
+ std::vector< MCAuto<DataArrayIdType> > idsCaptured(size);
+ for(int curRk = 0 ; curRk < size ; ++curRk)
+ {
+ mcIdType curStart(0),curEnd(0);
+ DataArrayIdType::GetSlice(0,nbOfEntities,1,curRk,size,curStart,curEnd);
+ idsCaptured[curRk] = _global_ids->findIdsInRange(curStart,curEnd);
+ {
+ DataArrayIdType *tmpValues(nullptr),*tmpIndex(nullptr);
+ DataArrayIdType::ExtractFromIndexedArrays(idsCaptured[curRk]->begin(),idsCaptured[curRk]->end(),this->_ska->getValuesArray(),this->_ska->getIndexArray(),tmpValues,tmpIndex);
+ skToBeSent[curRk] = MEDCouplingSkyLineArray::New(tmpIndex,tmpValues);
+ }
+ }
+ // communication : 3 arrays are going to be all2allized : ids, SkyLine index and SyLine values
+ std::vector< MCAuto<DataArrayIdType> > myRkIdsCaptured, myRkSkIndex, myRkSkValues;
+ ci.allToAllArrays(comm,idsCaptured,myRkIdsCaptured);
+ {
+ std::vector< MCAuto<DataArrayIdType> > indexToBeSent(MEDCouplingSkyLineArray::RetrieveVecIndex(skToBeSent));
+ ci.allToAllArrays(comm,indexToBeSent,myRkSkIndex);
+ }
+ {
+ std::vector< MCAuto<DataArrayIdType> > valuesToBeSent(MEDCouplingSkyLineArray::RetrieveVecValues(skToBeSent));
+ ci.allToAllArrays(comm,valuesToBeSent,myRkSkValues);
+ }
+ // assemble the 3 arrays myRkIdsCaptured, myRkSkIndex, myRkSkValues
}
\ No newline at end of file