* - \a return is : [0, 1, 3, 5, 6, 8, 11, 12]
*
* \return a newly allocated array containing the indexed array format of groups by same consecutive value.
- * \throw if \a this is not allocated or if \a this has not exactly one component or if number of tuples is equal to 0.
+ * \throw if \a this is not allocated or if \a this has not exactly one component.
* \sa DataArrayInt::buildUnique, MEDCouplingSkyLineArray::groupPacks
*/
template <class T>
this->checkAllocated();
if(this->getNumberOfComponents()!=1)
throw INTERP_KERNEL::Exception("DataArrayInt::indexOfSameConsecutiveValueGroups : only single component allowed !");
- if(this->getNumberOfTuples()==0)
- throw INTERP_KERNEL::Exception("DataArrayInt::indexOfSameConsecutiveValueGroups : number of tuples must be > 0 !");
const T *pt(this->begin());
const T *const ptEnd(this->end()) , * const ptBg(this->begin());
const T *oldPt(pt);
my_reference operator*() const { T tt; return tt((*_data)[_num]); }
};
- struct UMeshIndexConnectivityFunctor { const DataArrayIdType *operator()(const MEDCouplingUMesh *um) { return um->getNodalConnectivity(); } };
+ struct UMeshIndexConnectivityFunctor { const DataArrayIdType *operator()(const MEDCouplingUMesh *um) { return um->getNodalConnectivityIndex(); } };
using UMeshConnectivityIndexIterator = UMeshGenIterator<UMeshIndexConnectivityFunctor,DataArrayIdType>;
std::vector< const DataArrayT *> arraysBis(FromVecAutoToVecOfConst<DataArrayT>(arrays));
std::unique_ptr<mcIdType[]> nbOfElems2(new mcIdType[size]),nbOfElems3(new mcIdType[size]);
+ mcIdType nbOfComponents(std::numeric_limits<mcIdType>::max());
for(int curRk = 0 ; curRk < size ; ++curRk)
{
- nbOfElems3[curRk] = arrays[curRk]->getNumberOfTuples();
+ mcIdType curNbOfCompo( ToIdType( arrays[curRk]->getNumberOfComponents() ) );
+ if(nbOfComponents != std::numeric_limits<mcIdType>::max())
+ {
+ if( nbOfComponents != curNbOfCompo )
+ throw INTERP_KERNEL::Exception("AllToAllArrays : internal error ! Nb of components is not homogeneous !");
+ }
+ else
+ {
+ nbOfComponents = curNbOfCompo;
+ }
+ nbOfElems3[curRk] = arrays[curRk]->getNbOfElems();
}
this->allToAll(nbOfElems3.get(),1,MPI_ID_TYPE,nbOfElems2.get(),1,MPI_ID_TYPE,comm);
mcIdType nbOfCellIdsSum(std::accumulate(nbOfElems2.get(),nbOfElems2.get()+size,0));
MCAuto<DataArrayT> cellIdsFromProcs(DataArrayT::New());
- cellIdsFromProcs->alloc(nbOfCellIdsSum,1);
+ cellIdsFromProcs->alloc(nbOfCellIdsSum/nbOfComponents,nbOfComponents);
std::unique_ptr<int[]> nbOfElemsInt( CommInterface::ToIntArray<mcIdType>(nbOfElems3,size) ),nbOfElemsOutInt( CommInterface::ToIntArray<mcIdType>(nbOfElems2,size) );
std::unique_ptr<int[]> offsetsIn( CommInterface::ComputeOffset(nbOfElemsInt,size) ), offsetsOut( CommInterface::ComputeOffset(nbOfElemsOutInt,size) );
{
for(int curRk = 0 ; curRk < size ; ++curRk)
{
arraysOut[curRk] = DataArrayT::NewFromArray(cellIdsFromProcs->begin()+offsetsOutIdType[curRk],cellIdsFromProcs->begin()+offsetsOutIdType[curRk]+nbOfElems2[curRk]);
+ arraysOut[curRk]->rearrange(nbOfComponents);
}
}
public:
MCAuto<DataArrayIdType> n2o_nodes(nodeIdsIntoAggregatedIds->selectByTupleIdSafe(idxOfSameNodeIds->begin(),idxOfSameNodeIds->end()-1));//new == new ordering so that global node ids are sorted . old == coarse ordering implied by the aggregation
MCAuto<DataArrayIdType> finalGlobalNodeIds(aggregatedNodeIdsSorted->selectByTupleIdSafe(idxOfSameNodeIds->begin(),idxOfSameNodeIds->end()-1));
MCAuto<DataArrayDouble> finalCoords(coords->selectByTupleIdSafe(n2o_nodes->begin(),n2o_nodes->end()));
+ finalCoords->copyStringInfoFrom(*_mesh->getCoords());
// secondly renumbering of node ids in connectivityReceived
for(int curRk = 0 ; curRk < size ; ++curRk)
{
auto current(globalNodeIdsReceived[curRk]);
MCAuto<DataArrayIdType> aa(finalGlobalNodeIds->findIdForEach(current->begin(),current->end()));
- connectivityReceived[curRk]->transformWithIndArr(aa->begin(),aa->end());
+ // work on connectivityReceived[curRk] with transformWithIndArr but do not forget type of cells that should be excluded !
+ auto connectivityToModify(connectivityReceived[curRk]);
+ auto connectivityIndex(connectivityIndexReceived[curRk]);
+ MCAuto<DataArrayIdType> types(connectivityToModify->selectByTupleIdSafe(connectivityIndex->begin(),connectivityIndex->end()-1));
+ connectivityToModify->setPartOfValuesSimple3(0,connectivityIndex->begin(),connectivityIndex->end()-1,0,1,1);
+ connectivityToModify->transformWithIndArr(aa->begin(),aa->end());
+ connectivityToModify->setPartOfValues3(types,connectivityIndex->begin(),connectivityIndex->end()-1,0,1,1,true);
}
// thirdly renumber cells
MCAuto<DataArrayIdType> aggregatedCellIds( DataArrayIdType::Aggregate(FromVecAutoToVecOfConst<DataArrayIdType>(globalCellIdsReceived)) );
MCAuto<DataArrayIdType> aggregatedCellIdsSorted(aggregatedCellIds->copySorted());
MCAuto<DataArrayIdType> idsIntoAggregatedIds(DataArrayIdType::FindPermutationFromFirstToSecondDuplicate(aggregatedCellIdsSorted,aggregatedCellIds));
+ MCAuto<DataArrayIdType> cellIdsOfSameNodeIds(aggregatedCellIdsSorted->indexOfSameConsecutiveValueGroups());
+ MCAuto<DataArrayIdType> n2o_cells(idsIntoAggregatedIds->selectByTupleIdSafe(cellIdsOfSameNodeIds->begin(),cellIdsOfSameNodeIds->end()-1));//new == new ordering so that global cell ids are sorted . old == coarse ordering implied by the aggregation
// TODO : check coordsReceived==globalCellIds
MCAuto<DataArrayIdType> connSorted,indicesSorted;
{
MCAuto<DataArrayIdType> connIndex(DataArrayIdType::AggregateIndexes(FromVecAutoToVecOfConst<DataArrayIdType>(connectivityIndexReceived)));
{
DataArrayIdType *indicesSortedTmp(nullptr),*valuesSortedTmp(nullptr);
- DataArrayIdType::ExtractFromIndexedArrays(idsIntoAggregatedIds->begin(),idsIntoAggregatedIds->end(),conn,connIndex,valuesSortedTmp,indicesSortedTmp);
+ DataArrayIdType::ExtractFromIndexedArrays(n2o_cells->begin(),n2o_cells->end(),conn,connIndex,valuesSortedTmp,indicesSortedTmp);
indicesSorted = indicesSortedTmp; connSorted=valuesSortedTmp;
}
}
MCAuto<MEDCouplingUMesh> mesh(MEDCouplingUMesh::New(_mesh->getName(),_mesh->getMeshDimension()));
mesh->setConnectivity(connSorted,indicesSorted,true);
mesh->setCoords(finalCoords);
+ mesh->setDescription(_mesh->getDescription());
MCAuto<ParaUMesh> ret(ParaUMesh::New(mesh,aggregatedCellIdsSorted,finalGlobalNodeIds));
return ret.retn();
}
static ParaUMesh *New(MEDCouplingUMesh *mesh, DataArrayIdType *globalCellIds, DataArrayIdType *globalNodeIds);
MCAuto<DataArrayIdType> getCellIdsLyingOnNodes(const DataArrayIdType *globalNodeIds, bool fullyIn) const;
ParaUMesh *redistributeCells(const DataArrayIdType *globalCellIds) const;
+ MEDCouplingUMesh *getMesh() { return _mesh; }
+ DataArrayIdType *getGlobalCellIds() { return _cell_global; }
+ DataArrayIdType *getGlobalNodeIds() { return _node_global; }
protected:
virtual ~ParaUMesh() { }
ParaUMesh(MEDCouplingUMesh *mesh, DataArrayIdType *globalCellIds, DataArrayIdType *globalNodeIds);
%include "ICoCoMEDField.hxx"
%newobject MEDCoupling::ParaUMesh::New;
+%newobject MEDCoupling::ParaUMesh::getMesh;
+%newobject MEDCoupling::ParaUMesh::getGlobalCellIds;
+%newobject MEDCoupling::ParaUMesh::getGlobalNodeIds;
%newobject MEDCoupling::ParaUMesh::getCellIdsLyingOnNodes;
%newobject MEDCoupling::ParaUMesh::redistributeCells;
%newobject MEDCoupling::ParaSkyLineArray::New;
return ParaUMesh::New(mesh,globalCellIds,globalNodeIds);
}
+ MEDCouplingUMesh *getMesh()
+ {
+ MEDCouplingUMesh *ret(self->getMesh());
+ if(ret) ret->incrRef();
+ return ret;
+ }
+
+ DataArrayIdType *getGlobalCellIds()
+ {
+ DataArrayIdType *ret(self->getGlobalCellIds());
+ if(ret) ret->incrRef();
+ return ret;
+ }
+
+ DataArrayIdType *getGlobalNodeIds()
+ {
+ DataArrayIdType *ret(self->getGlobalNodeIds());
+ if(ret) ret->incrRef();
+ return ret;
+ }
+
DataArrayIdType *getCellIdsLyingOnNodes(const DataArrayIdType *globalNodeIds, bool fullyIn) const
{
MCAuto<DataArrayIdType> ret(self->getCellIdsLyingOnNodes(globalNodeIds,fullyIn));