using namespace MEDCoupling;
+ParaUMesh *ParaUMesh::New(MEDCouplingUMesh *mesh, DataArrayIdType *globalCellIds, DataArrayIdType *globalNodeIds)
+{
+ return new ParaUMesh(mesh,globalCellIds,globalNodeIds);
+}
+
ParaUMesh::ParaUMesh(MEDCouplingUMesh *mesh, DataArrayIdType *globalCellIds, DataArrayIdType *globalNodeIds)
{
_mesh.takeRef(mesh);
throw INTERP_KERNEL::Exception("ParaUMesh constructor : mismatch between # cells and len of global # cells.");
}
+std::size_t ParaUMesh::getHeapMemorySizeWithoutChildren() const
+{
+ return 0;
+}
+
+std::vector<const BigMemoryObject *> ParaUMesh::getDirectChildrenWithNull() const
+{
+ return {_mesh,_cell_global,_node_global};
+}
+
/*!
* This method computes the cells part of distributed mesh lying on \a globalNodeIds nodes.
* The input \a globalNodeIds are not supposed to reside on the current process.
/*!
*/
-MCAuto<ParaUMesh> ParaUMesh::redistributeCells(const DataArrayIdType *globalCellIds) const
+ParaUMesh *ParaUMesh::redistributeCells(const DataArrayIdType *globalCellIds) const
{
MPI_Comm comm(MPI_COMM_WORLD);
CommInterface ci;
std::vector<const DataArrayDouble *> coordsToBeSent(UMeshCoordsIterator(0,&meshPartsToBeSent2),UMeshCoordsIterator(meshPartsToBeSent2.size(),&meshPartsToBeSent2));
ci.allToAllArrays(comm,FromVecConstToVecAuto<DataArrayDouble>(coordsToBeSent),coordsReceived);
}
- // Sort it all !
+ /////// Sort it all !
+ // firstly deal with nodes.
+ MCAuto<DataArrayDouble> coords( DataArrayDouble::Aggregate(FromVecAutoToVecOfConst<DataArrayDouble>(coordsReceived)) );
+ MCAuto<DataArrayIdType> aggregatedNodeIds( DataArrayIdType::Aggregate(FromVecAutoToVecOfConst<DataArrayIdType>(globalNodeIdsReceived)) );
+ MCAuto<DataArrayIdType> aggregatedNodeIdsSorted(aggregatedNodeIds->copySorted());
+ MCAuto<DataArrayIdType> nodeIdsIntoAggregatedIds(DataArrayIdType::FindPermutationFromFirstToSecondDuplicate(aggregatedNodeIdsSorted,aggregatedNodeIds));
+ MCAuto<DataArrayIdType> idxOfSameNodeIds(aggregatedNodeIdsSorted->indexOfSameConsecutiveValueGroups());
+ 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()));
+ // 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());
+ }
+ // thirdly renumber cells
MCAuto<DataArrayIdType> aggregatedCellIds( DataArrayIdType::Aggregate(FromVecAutoToVecOfConst<DataArrayIdType>(globalCellIdsReceived)) );
MCAuto<DataArrayIdType> aggregatedCellIdsSorted(aggregatedCellIds->copySorted());
+ MCAuto<DataArrayIdType> idsIntoAggregatedIds(DataArrayIdType::FindPermutationFromFirstToSecondDuplicate(aggregatedCellIdsSorted,aggregatedCellIds));
+ // TODO : check coordsReceived==globalCellIds
+ MCAuto<DataArrayIdType> connSorted,indicesSorted;
+ {
+ MCAuto<DataArrayIdType> conn(DataArrayIdType::Aggregate(FromVecAutoToVecOfConst<DataArrayIdType>(connectivityReceived)));
+ MCAuto<DataArrayIdType> connIndex(DataArrayIdType::AggregateIndexes(FromVecAutoToVecOfConst<DataArrayIdType>(connectivityIndexReceived)));
+ {
+ DataArrayIdType *indicesSortedTmp(nullptr),*valuesSortedTmp(nullptr);
+ DataArrayIdType::ExtractFromIndexedArrays(idsIntoAggregatedIds->begin(),idsIntoAggregatedIds->end(),conn,connIndex,valuesSortedTmp,indicesSortedTmp);
+ indicesSorted = indicesSortedTmp; connSorted=valuesSortedTmp;
+ }
+ }
+ // finalize all
+ MCAuto<MEDCouplingUMesh> mesh(MEDCouplingUMesh::New(_mesh->getName(),_mesh->getMeshDimension()));
+ mesh->setConnectivity(connSorted,indicesSorted,true);
+ mesh->setCoords(finalCoords);
+ MCAuto<ParaUMesh> ret(ParaUMesh::New(mesh,aggregatedCellIdsSorted,finalGlobalNodeIds));
+ return ret.retn();
}
*
* This class is very specific to the requirement of parallel code computations.
*/
- class ParaUMesh
+ class ParaUMesh : public RefCountObject
{
public:
- ParaUMesh(MEDCouplingUMesh *mesh, DataArrayIdType *globalCellIds, DataArrayIdType *globalNodeIds);
+ static ParaUMesh *New(MEDCouplingUMesh *mesh, DataArrayIdType *globalCellIds, DataArrayIdType *globalNodeIds);
MCAuto<DataArrayIdType> getCellIdsLyingOnNodes(const DataArrayIdType *globalNodeIds, bool fullyIn) const;
- MCAuto<ParaUMesh> redistributeCells(const DataArrayIdType *globalCellIds) const;
+ ParaUMesh *redistributeCells(const DataArrayIdType *globalCellIds) const;
+ protected:
virtual ~ParaUMesh() { }
+ ParaUMesh(MEDCouplingUMesh *mesh, DataArrayIdType *globalCellIds, DataArrayIdType *globalNodeIds);
+ std::string getClassName() const override { return "ParaUMesh"; }
+ std::size_t getHeapMemorySizeWithoutChildren() const override;
+ std::vector<const BigMemoryObject *> getDirectChildrenWithNull() const override;
private:
MCAuto<MEDCouplingUMesh> _mesh;
MCAuto<DataArrayIdType> _cell_global;
%rename(ICoCoMEDField) ICoCo::MEDField;
%include "ICoCoMEDField.hxx"
+%newobject MEDCoupling::ParaUMesh::New;
%newobject MEDCoupling::ParaUMesh::getCellIdsLyingOnNodes;
+%newobject MEDCoupling::ParaUMesh::redistributeCells;
+%newobject MEDCoupling::ParaSkyLineArray::New;
%newobject MEDCoupling::ParaSkyLineArray::equiRedistribute;
%newobject MEDCoupling::ParaSkyLineArray::getSkyLineArray;
%newobject MEDCoupling::ParaSkyLineArray::getGlobalIdsArray;
%feature("unref") ParaSkyLineArray "$this->decrRef();"
+%feature("unref") ParaUMesh "$this->decrRef();"
%nodefaultctor;
}
};
- class ParaUMesh
+ class ParaUMesh : public RefCountObject
{
public:
- ParaUMesh(MEDCouplingUMesh *mesh, DataArrayIdType *globalCellIds, DataArrayIdType *globalNodeIds);
+ static ParaUMesh *New(MEDCouplingUMesh *mesh, DataArrayIdType *globalCellIds, DataArrayIdType *globalNodeIds);
+ ParaUMesh *redistributeCells(const DataArrayIdType *globalCellIds) const;
%extend
{
+ ParaUMesh(MEDCouplingUMesh *mesh, DataArrayIdType *globalCellIds, DataArrayIdType *globalNodeIds)
+ {
+ return ParaUMesh::New(mesh,globalCellIds,globalNodeIds);
+ }
+
DataArrayIdType *getCellIdsLyingOnNodes(const DataArrayIdType *globalNodeIds, bool fullyIn) const
{
MCAuto<DataArrayIdType> ret(self->getCellIdsLyingOnNodes(globalNodeIds,fullyIn));