From 1659fd9b45bbb157ff79066c6a061c5e3cd5bc01 Mon Sep 17 00:00:00 2001 From: eap Date: Wed, 27 May 2015 15:31:24 +0300 Subject: [PATCH] 0022875: debug --- src/MEDCoupling/MEDCouplingUMesh.cxx | 13 ++++-- src/MEDLoader/MEDFileJoint.cxx | 4 +- .../MEDPARTITIONER_MeshCollection.cxx | 45 +++++++++++++------ .../MEDPARTITIONER_ParallelTopology.cxx | 4 +- 4 files changed, 46 insertions(+), 20 deletions(-) diff --git a/src/MEDCoupling/MEDCouplingUMesh.cxx b/src/MEDCoupling/MEDCouplingUMesh.cxx index 05e86db3e..e9c46e8a0 100644 --- a/src/MEDCoupling/MEDCouplingUMesh.cxx +++ b/src/MEDCoupling/MEDCouplingUMesh.cxx @@ -8653,12 +8653,19 @@ DataArrayInt *MEDCouplingUMesh::buildUnionOf3DMesh() const } /*! - * generate graph. - * - * \return sky line array + * \brief Creates a graph of cell neighbors + * \return MEDCouplingSkyLineArray * - an sky line array the user should delete. + * In the sky line array, graph arcs are stored in terms of (index,value) notation. + * For example + * - index: 0 3 5 6 6 + * - value: 1 2 3 2 3 3 + * means 6 arcs (0,1), (0,2), (0,3), (1,2), (1,3), (2,3) + * Arcs are not doubled but reflexive (1,1) arcs are present for each cell */ MEDCouplingSkyLineArray *MEDCouplingUMesh::generateGraph() const { + checkConnectivityFullyDefined(); + int meshDim = this->getMeshDimension(); ParaMEDMEM::DataArrayInt* indexr=ParaMEDMEM::DataArrayInt::New(); ParaMEDMEM::DataArrayInt* revConn=ParaMEDMEM::DataArrayInt::New(); diff --git a/src/MEDLoader/MEDFileJoint.cxx b/src/MEDLoader/MEDFileJoint.cxx index 20875a284..afd525b78 100644 --- a/src/MEDLoader/MEDFileJoint.cxx +++ b/src/MEDLoader/MEDFileJoint.cxx @@ -117,7 +117,7 @@ void MEDFileJointCorrespondence::write(const std::string& fileName, int mode, co { throw INTERP_KERNEL::Exception( "Geometric type not specified for a cell Joint" ); } - + if ( (const DataArrayInt *)_correspondence ) { writeLL(fid, localMeshName, jointName, order, iteration); @@ -320,7 +320,7 @@ void MEDFileJointOneStep::write(const std::string& fileName, int mode, const std std::ostringstream oss; oss << "MEDFileJointOneStep : error on attempt to write in file : \"" << fileName << "\""; MEDFileUtilities::CheckMEDCode(fid,fid,oss.str()); if ( _correspondences.empty() ) - throw INTERP_KERNEL::Exception("MEDFileJointOneStep::write : no correspondences defined !"); + throw INTERP_KERNEL::Exception("MEDFileJointOneStep::write : no correspondences defined !"); writeLL(fid, localMeshName, jointName); } diff --git a/src/MEDPartitioner/MEDPARTITIONER_MeshCollection.cxx b/src/MEDPartitioner/MEDPARTITIONER_MeshCollection.cxx index 103982508..1dd9950c2 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_MeshCollection.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_MeshCollection.cxx @@ -164,7 +164,7 @@ MEDPARTITIONER::MeshCollection::MeshCollection(MeshCollection& initialCollection std::cout << "treating groups" << std::endl; _family_info=initialCollection.getFamilyInfo(); _group_info=initialCollection.getGroupInfo(); - + #ifdef HAVE_MPI if (MyGlobals::_Verbose>0 && MyGlobals::_World_Size>1) MPI_Barrier(MPI_COMM_WORLD); //synchronize verbose messages @@ -189,10 +189,15 @@ MEDPARTITIONER::MeshCollection::MeshCollection(MeshCollection& initialCollection //building the connect zones necessary for writing joints buildConnectZones( nodeMapping, o2nRenumber, initialCollection.getTopology()->nbDomain() ); + + // delete o2nRenumber + for ( size_t i = 0; i < o2nRenumber.size(); ++i ) + if ( o2nRenumber[i] ) + o2nRenumber[i]->decrRef(); } /*! - Creates the meshes using the topology underlying he mesh collection and the mesh data + Creates the meshes using the topology underlying he mesh collection and the mesh data coming from the ancient collection \param initialCollection collection from which the data is extracted to create the new meshes \param [out] o2nRenumber returns for each new domain a permutation array returned by sortCellsInMEDFileFrmt() @@ -953,6 +958,7 @@ namespace * \brief Sort correspondence ids of one domain and permute ids of the other accordingly * \param [in,out] ids1 - ids of one domain * \param [in,out] ids2 - ids of another domain + * \param [in] delta - a delta to change all ids * \param [in] removeEqual - to remove equal ids * \return DataArrayInt* - array of ids joined back */ @@ -960,6 +966,7 @@ namespace DataArrayInt* sortCorrespondences( DataArrayInt* ids1, DataArrayInt* ids2, + int delta, bool removeEqual = false) { // sort @@ -972,6 +979,15 @@ namespace ids1 = ids1->buildUnique(); ids2 = ids2->buildUnique(); } + if ( delta != 0 ) + { + int * id = ids1->getPointer(); + for ( ; id < ids1->end(); ++id ) + ++(*id); + id = ids2->getPointer(); + for ( ; id < ids2->end(); ++id ) + ++(*id); + } // join DataArrayInt* ids12 = DataArrayInt::Meld( ids1, ids2 ); // two components @@ -1005,6 +1021,9 @@ namespace * \brief Fill up ConnectZone's stored in _topology with nodal correspondences * \param [in] nodeMapping - mapping between old nodes and new nodes * (iolddomain,ioldnode)->(inewdomain,inewnode) + * \param [in] o2nRenumber - renumbering array returned by mesh->sortCellsInMEDFileFrmt() + * per a new domain + * \param [in] nbInitialDomains - nb of old domains */ //================================================================================ @@ -1123,8 +1142,8 @@ void MEDPARTITIONER::MeshCollection::buildConnectZones( const NodeMapping& nodeM const ParaMEDMEM::MEDCouplingSkyLineArray *corrArray = cz->getEntityCorresp( 0, 0 ); const DataArrayInt* ids12 = corrArray->getValueArray(); MEDCouplingAutoRefCountObjectPtr ids1, ids2, ids12Sorted; - ids1 = ids12->selectByTupleId2( 0, corrArray->getLength()+1, 2 ); - ids2 = ids12->selectByTupleId2( 1, corrArray->getLength()+1, 2 ); + ids1 = ids12->selectByTupleId2( 0, corrArray->getLength(), 2 ); + ids2 = ids12->selectByTupleId2( 1, corrArray->getLength(), 2 ); // renumber cells according to mesh->sortCellsInMEDFileFrmt() renumber( ids1, o2nRenumber[ cz->getLocalDomainNumber() ]); @@ -1146,13 +1165,13 @@ void MEDPARTITIONER::MeshCollection::buildConnectZones( const NodeMapping& nodeM if ( types1.size() == 1 && types2.size() == 1 ) // split not needed, only sort { - ids12Sorted = sortCorrespondences( ids1, ids2 ); + ids12Sorted = sortCorrespondences( ids1, ids2, /*delta=*/1 ); cz->setEntityCorresp( *types1.begin(), *types2.begin(), ids12Sorted->begin(), ids12Sorted->getNbOfElems() / 2 ); if ( cz21 )// set 2->1 correspondence { - ids12Sorted = sortCorrespondences( ids2, ids1 ); + ids12Sorted = sortCorrespondences( ids2, ids1, /*delta=*/0 ); cz21->setEntityCorresp( *types2.begin(), *types1.begin(), ids12Sorted->begin(), ids12Sorted->getNbOfElems() / 2 ); } @@ -1186,14 +1205,14 @@ void MEDPARTITIONER::MeshCollection::buildConnectZones( const NodeMapping& nodeM ids1->pushBackValsSilent( p1, p1+ids.first.size() ); ids2->desallocate(); ids2->pushBackValsSilent( p2, p2+ids.first.size() ); - ids12Sorted = sortCorrespondences( ids1, ids2 ); + ids12Sorted = sortCorrespondences( ids1, ids2, /*delta=*/1 ); cz->setEntityCorresp( t1, t2, ids12Sorted->begin(), ids12Sorted->getNbOfElems() / 2 ); if ( cz21 )// set 2->1 correspondence { - ids12Sorted = sortCorrespondences( ids2, ids1 ); + ids12Sorted = sortCorrespondences( ids2, ids1, /*delta=*/0 ); cz21->setEntityCorresp( t2, t1, ids12Sorted->begin(), ids12Sorted->getNbOfElems() / 2 ); break; @@ -1217,7 +1236,7 @@ void MEDPARTITIONER::MeshCollection::buildConnectZones( const NodeMapping& nodeM for ( size_t i = 0; i < czVec.size(); ++i ) { MEDPARTITIONER::ConnectZone* cz = czVec[i]; - if ( !cz || cz->getNodeNumber() == 0 ) + if ( !cz || cz->getNodeNumber() < 1 ) continue; if ( cz->getDistantDomainNumber() < cz->getLocalDomainNumber() ) continue; // treat a pair of domains once @@ -1233,15 +1252,15 @@ void MEDPARTITIONER::MeshCollection::buildConnectZones( const NodeMapping& nodeM const ParaMEDMEM::MEDCouplingSkyLineArray *corrArray = cz->getNodeCorresp(); const DataArrayInt *ids12 = corrArray->getValueArray(); MEDCouplingAutoRefCountObjectPtr ids1, ids2, ids12Sorted; - ids1 = ids12->selectByTupleId2( 0, corrArray->getLength()+1, 2 ); - ids2 = ids12->selectByTupleId2( 1, corrArray->getLength()+1, 2 ); + ids1 = ids12->selectByTupleId2( 0, corrArray->getLength(), 2 ); + ids2 = ids12->selectByTupleId2( 1, corrArray->getLength(), 2 ); - ids12Sorted = sortCorrespondences( ids1, ids2, removeEqual ); + ids12Sorted = sortCorrespondences( ids1, ids2, /*delta=*/0, removeEqual ); cz->setNodeCorresp( ids12Sorted->begin(), ids12Sorted->getNbOfElems() / 2 ); if ( cz21 )// set 2->1 correspondence { - ids12Sorted = sortCorrespondences( ids2, ids1, false ); + ids12Sorted = sortCorrespondences( ids2, ids1, /*delta=*/0, false ); cz->setNodeCorresp( ids12Sorted->begin(), ids12Sorted->getNbOfElems() / 2 ); } } diff --git a/src/MEDPartitioner/MEDPARTITIONER_ParallelTopology.cxx b/src/MEDPartitioner/MEDPARTITIONER_ParallelTopology.cxx index 207208994..a8a4ab5bf 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_ParallelTopology.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_ParallelTopology.cxx @@ -343,8 +343,8 @@ ParallelTopology::ParallelTopology(Graph* graph, Topology* oldTopology, int nb_d int iGlobNearDom = part[ iGlobNear ]; if ( iGlobDom != iGlobNearDom ) { - int iLoc = convertGlobalCell( iGlob ).second; - int iLocNear = convertGlobalCell( iGlobNear ).second; + int iLoc = convertGlobalCell( iGlob ).second - 1; // to MEDCoupling fmt + int iLocNear = convertGlobalCell( iGlobNear ).second - 1; cellCorresp[ iGlobDom ][ iGlobNearDom ].push_back( iLoc ); cellCorresp[ iGlobDom ][ iGlobNearDom ].push_back( iLocNear ); cellCorresp[ iGlobNearDom ][ iGlobDom ].push_back( iLocNear ); -- 2.39.2