std::ostringstream oss; oss << "DataArray::GetSlice : sliceId (" << nbOfSlices << ") must be in [0 , nbOfSlices (" << nbOfSlices << ") ) !";
throw INTERP_KERNEL::Exception(oss.str().c_str());
}
- mcIdType nbElems=DataArrayTemplate<T>::GetNumberOfItemGivenBESRelative(start,stop,step,"DataArray::GetSlice");
+ mcIdType nbElems=DataArrayTools<T>::GetNumberOfItemGivenBESRelative(start,stop,step,"DataArray::GetSlice");
mcIdType minNbOfElemsPerSlice=nbElems/nbOfSlices;
startSlice=start+minNbOfElemsPerSlice*step*sliceId;
if(sliceId<nbOfSlices-1)
rank = -1;
this->commRank(comm,&rank);
std::unique_ptr<mcIdType[]> nbOfElems;
- if(rank==0)
+ if(rank==root)
nbOfElems.reset(new mcIdType[size]);
mcIdType nbOfCellsRequested(array->getNumberOfTuples());
this->gather(&nbOfCellsRequested,1,MPI_ID_TYPE,nbOfElems.get(),1,MPI_ID_TYPE,root,comm);
- mcIdType nbOfCellIdsSum(std::accumulate(nbOfElems.get(),nbOfElems.get()+size,0));
- if(rank==0)
- result.reset(new T[nbOfCellIdsSum]);
std::unique_ptr<int[]> nbOfElemsInt,offsetsIn;
- if(rank==0)
+ if(rank==root)
{
+ mcIdType nbOfCellIdsSum(std::accumulate(nbOfElems.get(),nbOfElems.get()+size,0));
+ result.reset(new T[nbOfCellIdsSum]);
nbOfElemsInt = CommInterface::ToIntArray<mcIdType>(nbOfElems,size);
offsetsIn = CommInterface::ComputeOffset(nbOfElemsInt,size);
}
this->gatherV(array->begin(),nbOfCellsRequested,ParaTraits<T>::MPIDataType,result.get(),nbOfElemsInt.get(),offsetsIn.get(),ParaTraits<T>::MPIDataType,root,comm);
- resultIndex = ComputeOffsetFull<mcIdType>(nbOfElems,size);
+ if(rank==root)
+ {
+ resultIndex = ComputeOffsetFull<mcIdType>(nbOfElems,size);
+ }
return size;
}
for(int i = 0 ; i < size ; ++i)
{
arraysOut[i] = DataArrayT::New();
- if(rank == 0)
+ if(rank == root)
{
mcIdType nbOfEltPack(resultIndex[i+1]-resultIndex[i]);
arraysOut[i]->alloc(nbOfEltPack,1);
template class ParaDataArrayTemplate<Int32>;
template class ParaDataArrayTemplate<Int64>;
+template class ParaDataArrayDiscrete<Int32>;
+template class ParaDataArrayDiscrete<Int64>;
ParaDataArrayInt32 *ParaDataArrayInt32::New(DataArrayInt32 *seqDa)
{
protected:
std::size_t getHeapMemorySizeWithoutChildren() const override;
std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const override;
- void checkOKOneComponent(const std::string& msg);
+ void checkOKOneComponent(const std::string& msg) const;
protected:
MCAuto<typename Traits<T>::ArrayType> _seq_da;
};
class ParaDataArrayDiscrete : public ParaDataArrayTemplate<T>
{
public:
- typename Traits<T>::ArrayType *buildComplement(T nbOfElems) const;
+ DataArrayIdType *buildComplement(T nbOfElems) const;
protected:
ParaDataArrayDiscrete(typename Traits<T>::ArrayType *seqDa):ParaDataArrayTemplate<T>(seqDa) { }
};
#include "ParaDataArray.hxx"
#include "CommInterface.hxx"
+#include "MEDCouplingMemArray.txx"
#include <sstream>
}
template<class T>
- void ParaDataArrayTemplate<T>::checkOKOneComponent(const std::string& msg)
+ void ParaDataArrayTemplate<T>::checkOKOneComponent(const std::string& msg) const
{
if(this->_seq_da.isNull())
{
Parallel version of DataArrayInt::buildComplement. Returns result on proc 0. Not allocated DataArrayT is returned for all procs.
*/
template<class T>
- typename Traits<T>::ArrayType *ParaDataArrayDiscrete<T>::buildComplement(T nbOfElems) const
+ DataArrayIdType *ParaDataArrayDiscrete<T>::buildComplement(T nbOfElems) const
{
using DataArrayT = typename Traits<T>::ArrayType;
this->checkOKOneComponent("ParaDataArray::buildComplement");
std::vector< MCAuto<DataArrayT> > idsCaptured(size);
for(int curRk = 0 ; curRk < size ; ++curRk)
{
- mcIdType curStart(0),curEnd(0);
- DataArrayTools<T>::GetSlice(0,nbOfElems,1,static_cast<T>(curRk),static_cast<T>(size),curStart,curEnd);
+ T curStart(0),curEnd(0);
+ DataArrayTools<T>::GetSlice(0,nbOfElems,1,ToIdType(curRk),ToIdType(size),curStart,curEnd);
MCAuto<DataArrayIdType> idsInGlobalIds(this->_seq_da->findIdsInRange(curStart,curEnd));
idsCaptured[curRk] = this->_seq_da->selectByTupleIdSafe(idsInGlobalIds->begin(),idsInGlobalIds->end());
}
// communication : 1 arrays are going to be all2allized : ids
- MCAuto<DataArrayIdType> aggregatedIds;
+ MCAuto<DataArrayT> aggregatedIds;
{
std::vector< MCAuto<DataArrayT> > myRkIdsCaptured;
ci.allToAllArraysT<T>(comm,idsCaptured,myRkIdsCaptured);
- aggregatedIds = DataArrayIdType::Aggregate(FromVecAutoToVecOfConst<DataArrayIdType>(myRkIdsCaptured));
+ aggregatedIds = DataArrayT::Aggregate(FromVecAutoToVecOfConst<DataArrayT>(myRkIdsCaptured));
}
aggregatedIds->sort();
aggregatedIds = aggregatedIds->buildUnique();
ci.commRank(comm,&rank);
T vmin(std::numeric_limits<T>::max()),vmax(-std::numeric_limits<T>::max());
DataArrayTools<T>::GetSlice(0,nbOfElems,1,static_cast<T>(rank),static_cast<T>(size),vmin,vmax);
- MCAuto<DataArrayIdType> retIds(aggregatedIds->findIdsNotInRange(vmin,vmax));
- MCAuto<DataArrayT> ret(aggregatedIds->selectByTupleIdSafe(retIds->begin(),retIds->end()));
- return nullptr;
+ aggregatedIds->applyLin(1,-vmin);
+ MCAuto<DataArrayIdType> seqComp(aggregatedIds->buildComplement(ToIdType(vmax-vmin)));
+ seqComp->applyLin(1,ToIdType(vmin));
+ //
+ std::vector< MCAuto<DataArrayIdType> > arraysOut;
+ ci.gatherArrays(comm,0,seqComp,arraysOut);
+ MCAuto<DataArrayIdType> ret(DataArrayIdType::Aggregate(FromVecAutoToVecOfConst<DataArrayIdType>(arraysOut)));
+ return ret.retn();
}
}
def MEDCouplingDenseMatrixIsub(self,*args):
import _ParaMEDMEM
return _ParaMEDMEM.DenseMatrix____isub___(self, self, *args)
-
-if MEDCouplingUse64BitIDs():
- ParaDataArrayInt = ParaDataArrayInt64
-else:
- ParaDataArrayInt = ParaDataArrayInt32
-pass
-
%}
%include "MEDCouplingFinalize.i"
{
public:
static ParaDataArrayInt32 *New(DataArrayInt32 *seqDa);
- DataArrayInt32 *buildComplement(int nbOfElems) const;
+ DataArrayIdType *buildComplement(int nbOfElems) const;
%extend
{
ParaDataArrayInt32(DataArrayInt32 *seqDa)
{
public:
static ParaDataArrayInt64 *New(DataArrayInt64 *seqDa);
- DataArrayInt64 *buildComplement(long nbOfElems) const;
+ DataArrayIdType *buildComplement(long nbOfElems) const;
%extend
{
ParaDataArrayInt64(DataArrayInt64 *seqDa)
return ret;
}
}
+
+%pythoncode %{
+if MEDCouplingUse64BitIDs():
+ ParaDataArrayInt = ParaDataArrayInt64
+else:
+ ParaDataArrayInt = ParaDataArrayInt32
+%}