From: vbd Date: Wed, 20 Jul 2011 14:41:43 +0000 (+0000) Subject: working version X-Git-Tag: MEDPartitioner_first_compilable_version~6 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=440eb06f91e8d0dfab5eaf1789d3ceb7b9f7ea2f;p=tools%2Fmedcoupling.git working version --- diff --git a/src/MEDPartitioner/MEDPARTITIONER_MESHCollection.cxx b/src/MEDPartitioner/MEDPARTITIONER_MESHCollection.cxx index 132f31da5..cf35052cb 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_MESHCollection.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_MESHCollection.cxx @@ -32,8 +32,6 @@ #include "MEDPARTITIONER_ParallelTopology.hxx" #include "MEDPARTITIONER_SequentialTopology.hxx" #include "MEDPARTITIONER_ParaDomainSelector.hxx" -//#include "MEDPARTITIONER_MeshSendReceive.hxx" -//#include "MEDPARTITIONER_JointExchangeData.hxx" #include "MEDPARTITIONER_MESHCollection.hxx" #include "MEDPARTITIONER_MESHCollectionDriver.hxx" @@ -54,11 +52,6 @@ #include #include -#ifndef WNT -# include -#else -# include -#endif #include #include @@ -72,8 +65,6 @@ using namespace __gnu_cxx; using namespace std; #endif -//template inclusion -//#include "MEDPARTITIONER_MESHCollection.txx" MESHCollection::MESHCollection() : _topology(0), @@ -115,12 +106,6 @@ MESHCollection::MESHCollection(MESHCollection& initialCollection, Topology* topo std::vector > > new2oldIds(initialCollection.getTopology()->nbDomain()); castCellMeshes(initialCollection, new2oldIds); - - - //casting cell families on new meshes - _cellFamilyIds.resize(topology->nbDomain()); - castIntField(initialCollection.getMesh(), this->getMesh(),initialCollection.getCellFamilyIds(),_cellFamilyIds, new2oldIds); - //defining the name for the collection and the underlying meshes setName(initialCollection.getName()); @@ -133,14 +118,12 @@ MESHCollection::MESHCollection(MESHCollection& initialCollection, Topology* topo std::vector > > new2oldFaceIds; castMeshes(initialCollection.getFaceMesh(), this->getFaceMesh(),initialCollection, nodeMapping, new2oldFaceIds); - - //////////////////// //treating families //////////////////// _faceFamilyIds.resize(topology->nbDomain()); - + _cellFamilyIds.resize(topology->nbDomain()); //allocating family ids arrays for (int inew=0; inewnbDomain();inew++) { @@ -158,7 +141,9 @@ MESHCollection::MESHCollection(MESHCollection& initialCollection, Topology* topo _faceFamilyIds[inew]->useArray(ptrFaceIds,true, ParaMEDMEM::CPP_DEALLOC,nbFaces,1); } - castIntField(initialCollection.getFaceMesh(), this->getFaceMesh(),initialCollection.getFaceFamilyIds(),_faceFamilyIds,new2oldFaceIds); + //casting cell and face families on new meshes + castIntField(initialCollection.getMesh(), this->getMesh(),initialCollection.getCellFamilyIds(),_cellFamilyIds); + castIntField(initialCollection.getFaceMesh(), this->getFaceMesh(),initialCollection.getFaceFamilyIds(),_faceFamilyIds); /////////////////////// @@ -217,17 +202,13 @@ void MESHCollection::castCellMeshes(MESHCollection& initialCollection, std::vect for(int inew=0;inew<_topology->nbDomain();inew++) { if (initialCollection._domain_selector->isMyDomain(iold) && _domain_selector->isMyDomain(inew)) continue; + if(initialCollection._domain_selector->isMyDomain(iold)) - { _domain_selector->sendMesh(*(splitMeshes[inew][iold]),_domain_selector->getProcessorID(inew)); - std::cout<<"send iold"<getNumberOfCells()<isMyDomain(inew)) - { - _domain_selector->recvMesh(splitMeshes[inew][iold],_domain_selector->getProcessorID(iold)); - std::cout<<"recv iold"<recvMesh(splitMeshes[inew][iold],_domain_selector->getProcessorID(iold)); + } } @@ -238,14 +219,15 @@ void MESHCollection::castCellMeshes(MESHCollection& initialCollection, std::vect for (int i=0; i< splitMeshes[inew].size();i++) if (splitMeshes[inew][i]!=0) meshes.push_back(splitMeshes[inew][i]); - std::cout<< "nb of meshes"<isMyDomain(inew)) { _mesh[inew]=ParaMEDMEM::MEDCouplingUMesh::MergeUMeshes(meshes); + bool areNodesMerged; + int nbNodesMerged; + ParaMEDMEM::DataArrayInt* array=_mesh[inew]->mergeNodes(1e-12,areNodesMerged,nbNodesMerged); + array->decrRef(); // array is not used in this case _mesh[inew]->zipCoords(); - cout <<"new mesh "<getNumberOfCells()<<" cells"<< - _mesh[inew]->getNumberOfNodes()<<" nodes"<decrRef(); @@ -270,12 +252,9 @@ void MESHCollection::createNodeMapping( MESHCollection& initialCollection, NodeM { // std::map >, int > nodeClassifier; int nvertices=initialCollection.getMesh(iold)->getNumberOfNodes(); - cout <<"nvertices "<getCoords(); double* coordsPtr=coords->getPointer(); - for (int i=0; inbDomain(); inew++) { //sending meshes for parallel computation - if (isParallelMode() && _domain_selector->isMyDomain(inew) && !_domain_selector->isMyDomain(iold)) - { - std::cout<<"sendTo"<<_domain_selector->getProcessorID(iold)<isMyDomain(inew) && !_domain_selector->isMyDomain(iold)) _domain_selector->sendMesh(*(getMesh(inew)), _domain_selector->getProcessorID(iold)); - - } else if (isParallelMode() && !_domain_selector->isMyDomain(inew)&& _domain_selector->isMyDomain(iold)) { ParaMEDMEM::MEDCouplingUMesh* mesh; - std::cout<<"recvFrom" << _domain_selector->getProcessorID(inew) <recvMesh(mesh, _domain_selector->getProcessorID(inew)); ParaMEDMEM::DataArrayDouble* coords = mesh->getCoords(); for (int inode=0; inodegetNumberOfNodes();inode++) @@ -307,7 +281,7 @@ void MESHCollection::createNodeMapping( MESHCollection& initialCollection, NodeM tree->getElementsAroundPoint(coordsPtr,elems); if (elems.size()==0) continue; nodeMapping.insert(make_pair(make_pair(iold,elems[0]),make_pair(inew,inode))); - } + } } else if (!isParallelMode() || (_domain_selector->isMyDomain(inew) && _domain_selector->isMyDomain(iold))) { @@ -317,18 +291,20 @@ void MESHCollection::createNodeMapping( MESHCollection& initialCollection, NodeM { double* coordsPtr=coords->getPointer()+inode*3; - cout<<"coords new "< elems; tree->getElementsAroundPoint(coordsPtr,elems); - if (elems.size()==0) {cout<<"warning " <("<isMyDomain(iold))) + { + delete tree; + delete[] bbox; + } } - std::cout<<"NodeMapping size"<& mesh for (int iold=0; ioldisMyDomain(iold)) continue; - cout <<"-----------MESH OLD "<advancedRepr(); new2oldIds[iold].resize(newSize); for (int ielem=0;ielemgetNumberOfCells();ielem++) { @@ -371,15 +345,19 @@ void MESHCollection::castMeshes(std::vector& mesh meshesCastFrom[iold]->getNodeIdsOfCell(ielem,nodes); map faces; - // cout<<"----------------"<,pair >::const_iterator MI; int mynode=nodes[inode]; - if (mynode <0 || mynode > 1000000000) exit(1); + pair myRange = nodeMapping.equal_range(make_pair(iold,mynode)); - // cout << iold <<" " <second.first; @@ -387,7 +365,6 @@ void MESHCollection::castMeshes(std::vector& mesh faces[inew]=1; else faces[inew]++; - // cout<<"idomain" << iter->second.first<<" facemapping "<second.first]<& mesh //creating the splitMeshes from the face ids for (int inew=0;inew<_topology->nbDomain();inew++) { - cout<<"nb faces - iold "<buildPartOfMySelf(&new2oldIds[iold][inew][0],&new2oldIds[iold][inew][0]+new2oldIds[iold][inew].size(),true)); - cout << "split face Meshes "<advancedRepr(); + splitMeshes[inew][iold]->zipCoords(); } } @@ -432,13 +408,13 @@ void MESHCollection::castMeshes(std::vector& mesh myMeshes.push_back(splitMeshes[inew][iold]); } meshesCastTo[inew]=ParaMEDMEM::MEDCouplingUMesh::MergeUMeshes(myMeshes); - meshesCastTo[inew]->zipCoords(); + // meshesCastTo[inew]->zipCoords(); for (int iold=0; iold < meshesCastFrom.size();iold++) if (splitMeshes[inew][iold]!=0) splitMeshes[inew][iold]->decrRef(); } } -void MESHCollection::castIntField(std::vector& meshesCastFrom,std::vector& meshesCastTo, std::vector& arrayFrom, std::vector& arrayTo, std::vector< std::vector< std::vector > >& new2oldMapping) +void MESHCollection::castIntField(std::vector& meshesCastFrom,std::vector& meshesCastTo, std::vector& arrayFrom, std::vector& arrayTo) { vector > splitIds; splitIds.resize(meshesCastTo.size()); @@ -451,23 +427,20 @@ void MESHCollection::castIntField(std::vector& me //sending arrays for distant domains if (isParallelMode() && _domain_selector->isMyDomain(iold) && !_domain_selector->isMyDomain(inew)) { - int* ptr=&(new2oldMapping[iold][inew][0]); - int size=new2oldMapping[iold][inew].size(); - ParaMEDMEM::DataArrayInt* sendSplitIds=arrayFrom[iold]->selectByTupleId(ptr,ptr+size); + _domain_selector->sendMesh(*meshesCastFrom[iold],_domain_selector->getProcessorID(inew)); + int size=arrayFrom[iold]->getNumberOfTuples(); vectorsendIds(size); - std::copy(sendSplitIds->getPointer(),sendSplitIds->getPointer()+size,&sendIds[0]); + std::copy(arrayFrom[iold]->getPointer(),arrayFrom[iold]->getPointer()+size,&sendIds[0]); _domain_selector->sendIntVec(sendIds, _domain_selector->getProcessorID(inew)); } //receiving arrays from distant domains if (isParallelMode()&&!_domain_selector->isMyDomain(iold) && _domain_selector->isMyDomain(inew)) { vector recvIds; - ParaMEDMEM::DataArrayInt* recvSplitIds=ParaMEDMEM::DataArrayInt::New(); + ParaMEDMEM::MEDCouplingUMesh* recvMesh; + _domain_selector->recvMesh(recvMesh,_domain_selector->getProcessorID(iold)); _domain_selector->recvIntVec(recvIds, _domain_selector->getProcessorID(iold)); - int* intSplitIds=new int[recvIds.size()]; - std::copy(&recvIds[0],&recvIds[0]+recvIds.size(),intSplitIds); - recvSplitIds->useArray(intSplitIds, true, ParaMEDMEM::CPP_DEALLOC, recvIds.size(),1); - splitIds[inew].push_back(recvSplitIds); + remapIntField(*recvMesh,*meshesCastTo[inew],&recvIds[0],arrayTo[inew]->getPointer()); } } @@ -475,17 +448,39 @@ void MESHCollection::castIntField(std::vector& me for (int inew=0; inew < meshesCastTo.size();inew++) { for (int iold=0; iold < meshesCastFrom.size();iold++) - if (isParallelMode() && _domain_selector->isMyDomain(iold) && _domain_selector->isMyDomain(inew)) + if (!isParallelMode() || ( _domain_selector->isMyDomain(iold) && _domain_selector->isMyDomain(inew))) { - int* ptr=&(new2oldMapping[iold][inew][0]); - splitIds[inew].push_back(arrayFrom[iold]->selectByTupleId(ptr,ptr+new2oldMapping[iold][inew].size())); + remapIntField(*meshesCastFrom[iold],*meshesCastTo[inew],arrayFrom[iold]->getConstPointer(),arrayTo[inew]->getPointer()); } - if (!isParallelMode()||_domain_selector->isMyDomain(inew)) - arrayTo[inew]=ParaMEDMEM::DataArrayInt::Aggregate(splitIds[inew]); } } - +void MESHCollection::remapIntField(const ParaMEDMEM::MEDCouplingUMesh& sourceMesh, + const ParaMEDMEM::MEDCouplingUMesh& targetMesh, + const int* fromArray, + int* toArray) +{ + ParaMEDMEM::DataArrayDouble* sourceCoords=sourceMesh.getBarycenterAndOwner(); + ParaMEDMEM::DataArrayDouble* targetCoords=targetMesh.getBarycenterAndOwner(); + + ParaMEDMEM::MEDCouplingUMesh* tmpMesh=ParaMEDMEM::MEDCouplingUMesh::New(); + tmpMesh->setCoords(sourceCoords); + vectorc; + vector cI; + tmpMesh->getNodeIdsNearPoints(targetCoords->getConstPointer(),targetMesh.getNumberOfCells(),1e-10,c,cI); + if (cI.size()!= targetMesh.getNumberOfCells()+1) throw INTERP_KERNEL::Exception("Error in source/target projection"); + for (int itargetnode=0; itargetnodedecrRef(); + targetCoords->decrRef(); + tmpMesh->decrRef(); + + +} /*! constructing the MESH collection from a distributed file * * \param filename name of the master file containing the list of all the MED files @@ -613,11 +608,17 @@ MESHCollection::MESHCollection(const string& filename, const string& meshname) MESHCollection::~MESHCollection() { for (int i=0; i<_mesh.size();i++) - if (_mesh[i]!=0) {/*delete*/ _mesh[i]->decrRef(); } + { + if (_mesh[i]!=0) _mesh[i]->decrRef(); + if (_cellFamilyIds[i]!=0) _cellFamilyIds[i]->decrRef(); + } + for (int i=0; i<_faceMesh.size();i++) - if (_mesh[i]!=0) {/*delete*/ _faceMesh[i]->decrRef(); } - for (int i=0; i<_connect_zones.size();i++) - if (_connect_zones[i]!=0) {delete _connect_zones[i];} + { + if (_faceMesh[i]!=0) _faceMesh[i]->decrRef(); + if (_faceFamilyIds[i]!=0) _faceFamilyIds[i]->decrRef(); + } + if (_driver !=0) {delete _driver; _driver=0;} if (_topology!=0 && _owns_topology) {delete _topology; _topology=0;} } @@ -636,10 +637,8 @@ MESHCollection::~MESHCollection() void MESHCollection::write(const string& filename) { //building the connect zones necessary for writing joints - cout<<"Building Connect Zones"<nbDomain()>1) // buildConnectZones(); - cout <<"End of connect zones building"<getPointer()[i]getPointer()[i]; if (revConn->getPointer()[i]>max) max=revConn->getPointer()[i]; } - cout <<"min:"<getNumberOfNodes()]; _topology->getNodeList(idomain,globalNodeIds); @@ -786,9 +784,6 @@ void MESHCollection::buildCellGraph(MEDPARTITIONER::MEDSKYLINEARRAY* & array,int for (int mydomain=0; mydomain<_topology->nbDomain();mydomain++) { if (_domain_selector->isMyDomain(mydomain)) continue; - // for (int idomain=0; idomain<_topology->nbDomain();idomain++) - // { - // if (_domain_selector->isMyDomain(idomain)) continue; multimap::iterator iter; for (iter=commonDistantNodes[idomain][mydomain].begin();iter!=commonDistantNodes[idomain][mydomain].end();iter++) { @@ -796,7 +791,6 @@ void MESHCollection::buildCellGraph(MEDPARTITIONER::MEDSKYLINEARRAY* & array,int int icell=iter->second; node2cell.insert(make_pair(globalNodeIds[ilocnode],icell+offset)); - // cout<<"pair "<nbCells(); } - cout<<"mincell"<nbNodes();inode++) { typedef multimap::const_iterator MI; @@ -870,97 +863,6 @@ void MESHCollection::buildCellGraph(MEDPARTITIONER::MEDSKYLINEARRAY* & array,int cout<< "end of graph creation"< > >& commonDistantNodes) -// { -// int nbdomain=_topology->nbDomain(); -// commonDistantNodes.resize(nbdomain); -// for (int i=0; inbProcs(); -// vector* > bbtree(nbdomain); -// vector rev(nbdomain); -// vectorrevIndx(nbdomain); -// int meshDim; -// int spaceDim; - -// for (int mydomain=0;mydomainisMyDomain(mydomain)) continue; -// meshDim=_mesh[mydomain]->getMeshDimension(); -// spaceDim= _mesh[mydomain]->getSpaceDimension(); -// rev[mydomain] = ParaMEDMEM::DataArrayInt::New(); -// revIndx[mydomain] = ParaMEDMEM::DataArrayInt::New(); -// _mesh[mydomain]->getReverseNodalConnectivity(rev[mydomain],revIndx[mydomain]); -// double* bbx=new double[2*spaceDim*_mesh[mydomain]->getNumberOfNodes()]; -// for (int i=0; i<_mesh[mydomain]->getNumberOfNodes()*spaceDim;i++) -// { -// const double* coords=_mesh[mydomain]->getCoords()->getConstPointer(); -// bbx[2*i]=(coords[i])-1e-12; -// bbx[2*i+1]=bbx[2*i]+2e-12; -// } -// bbtree[mydomain]=new BBTree<3> (bbx,0,0,_mesh[mydomain]->getNumberOfNodes(),-1e-12); -// } -// for (int isource=0;isourceisMyDomain(isource)&&_domain_selector->isMyDomain(itarget)) continue; -// if (_domain_selector->isMyDomain(isource)) -// { -// //preparing data for treatment on target proc -// int targetProc = _domain_selector->getProccessorID(itarget); - -// std::vector vec(spaceDim*_mesh[isource]->getNumberOfNodes()); -// std::copy(_mesh[isource]->getCoords()->getConstPointer(),_mesh[isource]->getCoords()->getConstPointer()+_mesh[isource]->getNumberOfNodes()*spaceDim,&vec[0]); -// _domain_selector->sendDoubleVec (vec,targetProc); - -// //retrieving target data for storage in commonDistantNodes array -// vector localCorrespondency; -// _domain_selector->recvIntVec(localCorrespondency, targetProc); -// cout<<"size "<isMyDomain(itarget)) -// { -// //receiving data from source proc -// int sourceProc = isource%nbproc; -// std::vector recvVec; -// _domain_selector->recvDoubleVec(recvVec,sourceProc); -// std::map commonNodes; // (local nodes, distant nodes) list -// for (int inode=0; inode<(recvVec.size()/meshDim);inode++) -// { -// double* bbox=new double[2*spaceDim]; -// for (int i=0; i inodes; -// bbtree[itarget]->getIntersectingElems(bbox,inodes); -// delete[] bbox; - -// if (inodes.size()>0) commonNodes.insert(make_pair(inodes[0],inode)); -// } -// std::vector nodeCellCorrespondency; -// for (map::iterator iter=commonNodes.begin();iter!=commonNodes.end();iter++) -// { -// const int*revIndxPtr=revIndx[itarget]->getConstPointer(); -// const int*revPtr=rev[itarget]->getConstPointer(); -// for (int icell=revIndxPtr[iter->first];icellfirst+1];icell++) -// { -// nodeCellCorrespondency.push_back(iter->second); -// nodeCellCorrespondency.push_back(revPtr[icell]); -// } -// } -// _domain_selector->sendIntVec(nodeCellCorrespondency, sourceProc); -// } - -// } -// } - /*! Creates the partition corresponding to the cell graph and the partition number * @@ -1011,14 +913,6 @@ Topology* MESHCollection::createPartition(int nbdomain, cout<<"Partitioning graph"; cellGraph->partGraph(nbdomain,options_string,_domain_selector); - // DEBUG - // MEDMEM::STRING out("RESULT GRAPH #"); - // out << (_domain_selector?_domain_selector->rank():0) << ": "; - // const int* part = cellGraph->getPart(); - // int n = cellGraph->nbVertices(); - // for ( int e=0; e < n; ++e ) - // out << part[e] <<" "; - // cout << out << endl; cout<<"Building new topology"; @@ -1064,1226 +958,6 @@ Topology* MESHCollection::createPartition(const int* partition) return topology; } - -/*! building Connect Zones for storing the informations - * of the connectivity - * - * The connect zones are created for every domain that has common nodes with - * domain \a idomain - * - * \param idomain domain number for which the connect zones are created - * */ - -// void MESHCollection::buildConnectZones(int idomain) -// { -// // constructing node/node correspondencies -// vector node_node_correspondency; -// node_node_correspondency.resize(_topology->nbDomain()); - -// cout << "Computing node/node corresp"<computeNodeNodeCorrespondencies(idomain, node_node_correspondency ); - -// for (int idistant=0; idistant< _topology->nbDomain(); idistant++) -// { -// // on regarde si une correspondance noeud/noeud a été trouvée -// // entre idomain et idistant -// // si oui, on crée une connectzone -// if (node_node_correspondency[idistant]!=0) -// { -// MEDMEM::CONNECTZONE* cz= new MEDMEM::CONNECTZONE(); -// cz->setLocalMesh(_mesh[idomain]); -// cz->setDistantMesh(_mesh[idistant]); -// cz->setLocalDomainNumber(idomain); -// cz->setDistantDomainNumber(idistant); -// cz-> setName ("Connect zone defined by PARTITIONER"); -// cz->setNodeCorresp(node_node_correspondency[idistant]); -// _connect_zones.push_back(cz); -// } -// } -// cout << "Computing node/node corresp"< cell_cell_correspondency; -// cell_cell_correspondency.resize(_topology->nbDomain()); -// _topology->computeCellCellCorrespondencies(idomain, cell_cell_correspondency, _cell_graph.get()); - -// for (int idistant=0; idistant< _topology->nbDomain(); idistant++) -// { -// //the connect zone has been created by the node/node computation -// if (cell_cell_correspondency[idistant]!=0) -// { -// MEDMEM::CONNECTZONE* cz=0; -// for (int icz=0; icz<_connect_zones.size();icz++) -// if (_connect_zones[icz]->getLocalDomainNumber()==idomain && -// _connect_zones[icz]->getDistantDomainNumber()==idistant) -// cz = _connect_zones[icz]; -// if (cz!=0) -// cz->setEntityCorresp(MED_EN::MED_CELL,MED_EN::MED_CELL, cell_cell_correspondency[idistant]); -// else -// throw MEDEXCEPTION("MESHCollection::buildConnectZones() -A connect zone should exist"); -// //delete cell_cell_correspondency[idistant]; -// } - -// } -// } - -// //================================================================================ -// /*! -// * \brief Adds a group of joint faces -// * \param loc_face_ids - local numbers of faces -// * \param idomian - domain index where faces are local -// * \param idistant - the other domain index -// */ -// //================================================================================ - -// void MESHCollection::addJointGroup(const std::vector& loc_face_ids, int idomain, int idistant) -// { -// MEDMEM::MESHING* meshing = dynamic_cast (_mesh[idomain]); -// MED_EN::medEntityMesh constituent_entity = getSubEntity(); - -// MEDMEM::STRING jointname("joint_"); -// jointname< groups = meshing->getGroups( constituent_entity ); -// // for ( int g = 0; g < groups.size(); ++g ) -// // if ( groups[g]->getName() == jointname.str() ) -// // { -// // joint_group = groups[g]; -// // break; -// // } -// // assure uniqueness of group name -// bool unique = false; -// vector groups = meshing->getGroups( constituent_entity ); -// do -// { -// unique = true; -// for ( int g = 0; unique && g < groups.size(); ++g ) -// unique = ( groups[g]->getName() != jointname ); -// if ( !unique ) -// jointname << "_" << idomain+1; -// } -// while ( !unique ); -// joint_group->setName(jointname); -// joint_group->setMesh(meshing); -// joint_group->setEntity(constituent_entity); -// map > joint_types; - -// int nbfaces = loc_face_ids.size(); -// for (int i=0; igetElementType(constituent_entity,loc_face_ids[i]); -// joint_types[type].push_back(loc_face_ids[i]); -// } -// joint_group->setNumberOfGeometricType(joint_types.size()); -// MED_EN::medGeometryElement* types=new MED_EN::medGeometryElement[joint_types.size()]; -// int* nb_in_types=new int[joint_types.size()]; -// int* group_index=new int[joint_types.size()+1]; - -// group_index[0]=1; -// int itype=0; -// int iface =0; -// int* group_value=new int[nbfaces]; -// for (map >::const_iterator iterj=joint_types.begin(); -// iterj != joint_types.end(); -// iterj++) -// { -// nb_in_types[itype]=(iterj->second).size(); -// types[itype]=iterj->first; -// itype++; -// group_index[itype]=group_index[itype-1]+(iterj->second).size(); -// for (int i=0; i< (iterj->second).size(); i++) -// group_value[iface++]=(iterj->second)[i]; -// } -// joint_group->setGeometricType(types); -// joint_group->setNumberOfElements(nb_in_types); -// joint_group->setNumber(group_index, group_value, /*shallowCopy=*/true); -// delete[] types; -// delete[] nb_in_types; - -// if ( joint_group == tmp_grp ) -// meshing->addGroup(*tmp_grp); -// tmp_grp->removeReference(); -// } - -// /*! building Connect Zones for storing the informations -// * of the connectivity -// * */ - -// void MESHCollection::buildConnectZones() -// { -// vector > > face_map(_topology->nbDomain()); -// map< pair, MEDMEM::MEDSKYLINEARRAY*> cell_corresp_here; - -// MED_EN::medEntityMesh constituent_entity = getSubEntity(); - -// if ( isParallelMode() ) -// { -// buildConnectZonesBetweenProcs(face_map, cell_corresp_here); -// } - -// cout << "Computing node/node corresp"<nbDomain(); idomain++) -// { - -// // constructing node/node correspondencies -// vector node_node_correspondency(_topology->nbDomain()); -// _topology->computeNodeNodeCorrespondencies(idomain, node_node_correspondency ); - -// for (int idistant=0; idistant< _topology->nbDomain(); idistant++) -// { -// // on regarde si une correspondance noeud/noeud a été trouvée -// // entre idomain et idistant -// // si oui, on crée une connectzone -// if (node_node_correspondency[idistant]!=0) -// { -// MEDMEM::CONNECTZONE* cz= new MEDMEM::CONNECTZONE(); -// cz->setLocalMesh(_mesh[idomain]); -// cz->setDistantMesh(_mesh[idistant]); -// cz->setLocalDomainNumber(idomain); -// cz->setDistantDomainNumber(idistant); -// cz-> setName ("Connect zone defined by PARTITIONER"); -// cz->setNodeCorresp(node_node_correspondency[idistant]); -// _connect_zones.push_back(cz); -// } -// } -// } -// cout << "Computing face corresp"<getFaceNumber()+1; -// //int global_face_id = _topology->getMaxGlobalFace()+1; - -// map , vector > faces_in_joint; - -// if ( !isParallelMode() ) -// // taking faces that are already present in the mesh into account -// for (int idomain=0; idomain<_topology->nbDomain(); idomain++) -// { -// getFaces(idomain,face_map[idomain]); -// } - -// // creating faces that are located at the interface between -// // subdomains - -// vector nb_added_groups( _topology->nbDomain(), 0 ); - -// for (int idomain=0; idomain<_topology->nbDomain(); idomain++) -// { -// vector cell_cell_correspondency( _topology->nbDomain() ); -// if ( !isParallelMode() ) -// _topology->computeCellCellCorrespondencies(idomain, cell_cell_correspondency, _cell_graph.get()); - -// for (int idistant=0; idistant< _topology->nbDomain(); idistant++) -// { -// if (idistant <= idomain) continue; - -// MEDMEM::MEDSKYLINEARRAY* cell_correspondency = 0; -// if ( isParallelMode() ) -// cell_correspondency = cell_corresp_here[ make_pair (idomain,idistant)]; -// else -// cell_correspondency = cell_cell_correspondency[idistant]; - -// //the connect zone has been created by the node/node computation - -// if ( cell_correspondency ) -// { -// int nbcells = cell_correspondency->getNumberOf(); -// const int* index = cell_correspondency->getIndex(); -// const int* value = cell_correspondency->getValue(); -// if ( isParallelMode() ) -// global_face_id = _domain_selector->getFisrtGlobalIdOfSubentity( idomain, idistant ); - -// for (int ilocal=0; ilocalgetType()].push_back(face); -// MEDPARTITIONER_FaceModel* face2 = getCommonFace(idistant,distant_id,idomain, ilocal+1,global_face_id); -// face_map[idistant][face->getType()].push_back(face2); -// faces_in_joint[make_pair(idomain,idistant)].push_back(global_face_id); -// global_face_id++; -// } -// } -// } - -// } -// //cleaning up -// for (int idistant=0; idistant< _topology->nbDomain(); idistant++) -// delete cell_cell_correspondency[idistant]; -// } - - -// _topology->recreateFaceMapping(face_map); - -// //transforming the face_map into a constituent entity connectivity -// for (int idomain=0; idomain< _topology->nbDomain();idomain++) -// { -// int nbtypes = face_map[idomain].size(); -// vector types; -// vector nb_elems; -// vector conn; - -// MEDMEM::MESHING* meshing = dynamic_cast (_mesh[idomain]); -// if ( !meshing->getConnectivityptr() ) -// continue; // no cells in idomain - -// for (map >::const_iterator iter= face_map[idomain].begin(); -// iter != face_map[idomain].end(); iter ++) -// { -// types.push_back(iter->first); -// int nb_elem_in_type = (iter->second).size(); -// nb_elems.push_back(nb_elem_in_type); -// int nb_node_per_type=(iter->first)%100; -// int* connectivity= new int [nb_node_per_type*nb_elem_in_type]; -// for (int ielem=0; ielemsecond)[ielem])[inode]; -// } -// conn.push_back(connectivity); - -// } -// //setting the faces in the mesh -// meshing->setNumberOfTypes(nbtypes,constituent_entity); -// meshing->setTypes(&types[0],constituent_entity); -// meshing->setNumberOfElements(&nb_elems[0],constituent_entity); - -// for (int itype=0; itypesetConnectivity(conn[itype], constituent_entity, types[itype]); -// delete[]conn[itype]; -// } -// for (int idistant =0; idistant<_topology->nbDomain(); idistant++) -// { -// map , vector >::iterator iter; -// iter = faces_in_joint.find(make_pair(idomain,idistant)); -// if (iter == faces_in_joint.end()) -// { -// iter = faces_in_joint.find (make_pair(idistant,idomain)); -// if (iter == faces_in_joint.end()) -// continue; -// } - -// int nbfaces = (iter->second).size(); -// vector face_joint(nbfaces*2); -// MEDMEM::CONNECTZONE* cz=0; -// for (int icz=0; icz<_connect_zones.size();icz++) -// if (_connect_zones[icz]->getLocalDomainNumber()==idomain && -// _connect_zones[icz]->getDistantDomainNumber()==idistant) -// cz = _connect_zones[icz]; - -// int nbtotalfaces= _topology->getFaceNumber(idomain); - -// //creating arrays for the MEDSKYLINEARRAY structure containing the joint -// int* index =new int[nbtotalfaces+1]; -// for (int i=0; i faces; -// vector local_faces( nbfaces ); -// for (int iface=0; ifacesecond)[iface]; -// int localid=_topology->convertGlobalFace(iglobal,idomain); -// int distantid=_topology->convertGlobalFace(iglobal,idistant); -// faces.insert(make_pair(localid,distantid)); -// local_faces[iface]=localid; -// } - -// int iloc=0; -// index[0]=1; -// for (map::const_iterator iter=faces.begin(); -// iter != faces.end(); -// iter++) -// { -// index[iter->first]=1; -// value[iloc++]=iter->second; -// } - -// for (int i=0; isetEntityCorresp(constituent_entity,constituent_entity,skarray); -// else -// throw MEDEXCEPTION("MESHCollection::buildConnectZones() -A connect zone should exist"); -// // Creating a group of the faces constituting the joint -// addJointGroup( local_faces, idomain, idistant ); -// nb_added_groups[ idomain ]++; -// } -// } - -// if ( isParallelMode() ) -// { -// // Now all faces have got local ids and we can receive local ids from other procs. -// // Set face/face data to zones with other procs and create a group -// for (int icz=0; icz<_connect_zones.size();icz++) -// { -// MEDMEM::CONNECTZONE* cz=_connect_zones[icz]; -// if ( _domain_selector->isMyDomain( cz->getDistantDomainNumber()) ) continue; - -// int glob_id = _domain_selector->getFisrtGlobalIdOfSubentity( cz->getLocalDomainNumber(), -// cz->getDistantDomainNumber()); -// int nb_cz_faces = _domain_selector->getNbCellPairs( cz->getDistantDomainNumber(), -// cz->getLocalDomainNumber()); -// vector< int > loc_ids_here( nb_cz_faces ); -// for ( int i = 0; i < nb_cz_faces; ++i ) -// loc_ids_here[i] = _topology->convertGlobalFace(glob_id++,cz->getLocalDomainNumber()); - -// int* loc_ids_dist = _domain_selector->exchangeSubentityIds( cz->getLocalDomainNumber(), -// cz->getDistantDomainNumber(), -// loc_ids_here ); -// int nb_faces_here= _topology->getFaceNumber(cz->getLocalDomainNumber()); -// int* face_index = new int[ nb_faces_here+1 ]; -// face_index[0]=1; -// for ( int loc_id = 0, i = 0; loc_id < nb_faces_here; ++loc_id) -// { -// face_index[ loc_id+1 ] = face_index[ loc_id ]; -// if ( i < loc_ids_here.size() && loc_ids_here[i] == loc_id+1 ) -// { -// face_index[ loc_id+1 ]++; -// i++; -// } -// } -// MEDMEM::MEDSKYLINEARRAY* skarray= -// new MEDMEM::MEDSKYLINEARRAY(nb_faces_here, nb_cz_faces, face_index, loc_ids_dist, true); -// cz->setEntityCorresp(constituent_entity,constituent_entity,skarray); - -// addJointGroup( loc_ids_here, cz->getLocalDomainNumber(), cz->getDistantDomainNumber()); -// nb_added_groups[ cz->getLocalDomainNumber() ]++; -// } -// } - -// for (int idomain=0; idomain<_topology->nbDomain(); idomain++) -// { -// // delete face_map -// for (map >::const_iterator iter= face_map[idomain].begin(); -// iter != face_map[idomain].end(); iter ++) -// for (int i=0; i<(iter->second).size();i++) -// delete (iter->second)[i]; - -// if ( nb_added_groups[ idomain ] > 0 && -// _mesh[idomain]->getNumberOfFamilies( constituent_entity ) > 0 ) -// // needed because if there were face families before, driver won't -// // create families from just added groups (see MEDMEM_MedMeshDriver22.cxx:3330), -// // actually it is a bug of driver - it must check presence of groups in families -// _mesh[idomain]->createFamilies(); -// } -// } - -// if ( isParallelMode() ) -// // Excange info on types of constituent_entity needed while writing joints -// // to get ids local in geom type for distant procs -// _domain_selector->gatherEntityTypesInfo( _mesh, constituent_entity ); - -// cout << "Computing cell/cell corresp"<nbDomain();idomain++) -// { -// vector cell_cell_correspondency( _topology->nbDomain() ); -// if ( !isParallelMode() ) -// _topology->computeCellCellCorrespondencies(idomain,cell_cell_correspondency,_cell_graph.get()); - -// for (int idistant=0; idistant< _topology->nbDomain(); idistant++) -// { -// MEDMEM::MEDSKYLINEARRAY* cell_correspondency = 0; -// if ( isParallelMode() ) -// cell_correspondency = cell_corresp_here[ make_pair (idomain,idistant)]; -// else -// cell_correspondency = cell_cell_correspondency[idistant]; - -// //the connect zone has been created by the node/node computation -// if ( cell_correspondency ) -// { -// MEDMEM::CONNECTZONE* cz=0; -// for (int icz=0; icz<_connect_zones.size();icz++) -// if (_connect_zones[icz]->getLocalDomainNumber()==idomain && -// _connect_zones[icz]->getDistantDomainNumber()==idistant) -// cz = _connect_zones[icz]; -// if (cz!=0) -// cz->setEntityCorresp(MED_EN::MED_CELL,MED_EN::MED_CELL, cell_correspondency); -// else -// throw MEDEXCEPTION("MESHCollection::buildConnectZones() -A connect zone should exist"); -// } -// } -// } -// } - -// /*! building Connect Zones for storing the informations -// * of the connectivity in the parallel mode -// * */ - -// void MESHCollection::buildConnectZonesBetweenProcs(TGeom2FacesByDomian & face_map, -// map< pair, MEDMEM::MEDSKYLINEARRAY*> & cell_cell_correspondency_here) -// { -// using namespace MED_EN; - -// // graph over all procs -// auto_ptr global_graph( _domain_selector->gatherGraph( _cell_graph.get() )); - -// vector< vector< JointExchangeData > > joints_of_domain( _topology->nbDomain() ); - -// for (int idomain=0; idomain<_topology->nbDomain(); idomain++) -// { -// if ( !_domain_selector->isMyDomain( idomain )) continue; - -// vector< JointExchangeData > & joints = joints_of_domain[ idomain ]; -// joints.resize( _topology->nbDomain() ); - -// // Find corresponding cells on other procs - -// const int* gra_index = global_graph->getGraph()->getIndex(); -// const int* gra_value = global_graph->getGraph()->getValue(); -// const int* partition = global_graph->getPart(); -// const int dj = gra_index[0]; - -// vector< int > glob_cells_here( _topology->getCellNumber( idomain )); -// _topology->getCellList( idomain, & glob_cells_here[0]); -// for ( int loc_here = 0; loc_here < glob_cells_here.size(); ++loc_here ) -// { -// int glob_here = glob_cells_here[ loc_here ]; -// for ( int j = gra_index[ glob_here-1 ]; j < gra_index[ glob_here ]; ++j ) -// { -// int glob_neighbor = gra_value[ j-dj ]; -// int neighbor_dom = partition[ glob_neighbor-1 ]; -// if ( neighbor_dom == idomain ) continue; - -// if ( _domain_selector->isMyDomain( neighbor_dom )) -// { -// joints[ neighbor_dom ].addCellCorrespondence -// (_mesh[idomain], neighbor_dom, idomain, glob_neighbor, glob_here, loc_here + 1, -// _topology->convertGlobalCell(glob_neighbor).second ); -// } -// else -// { -// joints[ neighbor_dom ].addCellCorrespondence -// (_mesh[idomain], neighbor_dom, idomain, glob_neighbor, glob_here, loc_here + 1 ); -// } -// } -// } -// } -// global_graph.reset(); // free memory - -// // set joints in a queue to exchange -// typedef map< int, JointExchangeData* > TOrderedJoints; -// TOrderedJoints queue; -// for (int idomain=0; idomain<_topology->nbDomain(); idomain++) -// { -// if ( !_domain_selector->isMyDomain( idomain )) continue; - -// vector< JointExchangeData > & joints = joints_of_domain[ idomain ]; -// for (int idist=0; idist<_topology->nbDomain(); ++idist ) -// { -// JointExchangeData& joint = joints[idist]; - -// int nb_cell_pairs = joint.nbCellPairs(); -// if ( nb_cell_pairs == 0 ) -// continue; -// else -// _domain_selector->setNbCellPairs( nb_cell_pairs, idist, idomain ); - -// joint.setMeshes( idist, _mesh[idist], idomain, _mesh[idomain] ); - -// if ( _domain_selector->isMyDomain( idist )) -// { -// // a joint on this proc -// cell_cell_correspondency_here[ make_pair( idomain, idist )] = joint.makeCellCorrespArray(); -// } -// else -// { -// // a joint with distant proc -// joint.setConnectivity( & ((MEDMEM::MeshFuse*)_mesh[idomain])->getNodeNumbers()[0] ); -// int order = _domain_selector->jointId( idomain, idist ); -// queue[ order ] = & joint; -// } -// } -// } -// // gather info on cell geom types needed to exchange joints -// _domain_selector->gatherEntityTypesInfo( _mesh, MED_EN::MED_CELL ); - -// // gather info on nb of sub-entities to compute their global numbers for joints -// _domain_selector->gatherNbOf( getSubEntity(), _mesh ); -// _domain_selector->gatherNbCellPairs(); -// if ( _subdomain_boundary_creates ) -// { -// // taking faces that are already present in the mesh into account -// for (int idomain=0; idomain<_topology->nbDomain(); idomain++) -// if ( _domain_selector->isMyDomain( idomain )) -// getFaces(idomain,face_map[idomain]); -// } -// else -// { -// face_map.clear(); // mark for the joint not to create faces -// } - -// // exchange joint data with other procs and make CONNECTZONEs -// TOrderedJoints::iterator ord_joint = queue.begin(); -// for ( ; ord_joint != queue.end(); ++ord_joint ) -// { -// JointExchangeData* joint = ord_joint->second; - -// _domain_selector->exchangeJoint( joint ); -// if ( _subdomain_boundary_creates ) -// { -// int first_sub_id = _domain_selector->getFisrtGlobalIdOfSubentity( joint->localDomain(), -// joint->distantDomain() ); -// joint->setFisrtGlobalIdOfSubentity( first_sub_id ); -// } -// _connect_zones.push_back ( joint->makeConnectZone( face_map )); -// } -// } - -// /*! projects old collection families on new collection families -// */ -// void MESHCollection::castFamilies(const MESHCollection& old_collection) -// { -// vector > element_array (_topology->nbDomain()); - -// //loop on old domains to create groups out of the existing families -// if (_family_splitting) -// for (int idomain=0; idomain < old_collection._topology->nbDomain(); idomain++) -// old_collection.getMesh(idomain)->createGroups(); - -// //definition of the entities array which -// //defines the entities over which the information is cast -// MED_EN::medEntityMesh entities[3]; -// entities[0]=MED_EN::MED_NODE; -// entities[1]=getSubEntity(); -// entities[2]=MED_EN::MED_CELL; - -// for (int ientity=0; ientity<=2;ientity++) -// { - -// //int nbgroups = old_collection.getMesh(0)->getNumberOfGroups(entities[ientity]); - -// map > group_map; -// for (int idomain=0; idomain < old_collection._topology->nbDomain(); idomain++) -// { -// if ( !old_collection.getMesh(idomain) ) continue; -// for (int igroup=0; igroupgetNumberOfGroups(entities[ientity]); igroup++) -// { -// //retrieves a group -// MEDMEM::GROUP* group = (old_collection.getMesh(idomain)->getGroups(entities[ientity]))[igroup]; -// //increments the number of groups if it is a new group -// //if (group_map.find(group->getName())==group_map.end()) - -// group_map[group->getName()].insert(idomain); -// // group_map.insert(make_pair(group->getName(), idomain); - -// } -// } -// int nbgroups=group_map.size(); -// vector igroupold(old_collection._topology->nbDomain(),0); -// map >::const_iterator iter=group_map.begin(); - -// for (int igroup=0; igroup old_supports(old_collection._topology->nbDomain()); -// string group_name = iter->first; -// iter++; - -// //parameters stored for passing group description -// // from the old meshes to the new ones - -// for (int idomain=0; idomain < old_collection._topology->nbDomain(); idomain++) -// { -// // for (set::iterator iter=group_map[group_name].begin(); iter!=group_map[group_name].end(); iter++) -// // cout << *iter<<" "; -// // cout <getGroups(entities[ientity]))[igroupold[idomain]]; -// old_supports[idomain] = static_cast (group); -// igroupold[idomain]++; -// } - -// vector new_groups(_topology->nbDomain()); -// vector new_supports(_topology->nbDomain()); -// for (int i=0; i<_topology->nbDomain(); i++) -// { -// new_groups[i]=new MEDMEM::GROUP(); -// new_supports[i]=static_cast(new_groups[i]); -// } -// castSupport(old_collection,old_supports,new_supports); - -// //creating new groups from the previous list of elements -// for (int idomain=0; idomain <_topology->nbDomain(); idomain++) -// { -// MEDMEM::MESHING* mesh_builder=static_cast (_mesh[idomain]); -// if ( new_supports[idomain] ) -// mesh_builder->addGroup(*new_groups[idomain]); -// } -// //groups are copied by the addGroup method, -// //so they can be safely deleted here -// for (int i=0; i<_topology->nbDomain(); i++) -// { -// if ( new_supports[i] ) new_groups[i]->removeReference(); -// } - -// }// on groups -// }//on entities -// } - - -// void MESHCollection::castSupport(const MESHCollection& old_collection, vector& old_support, vector& new_support) -// { - -// if (old_collection._topology->nbDomain() != old_support.size()) -// { -// throw MED_EXCEPTION(STRING("Error : wrong call to MESHCollection::castSupport")); -// } -// vector > element_array (_topology->nbDomain()); - -// //parameters stored for passing description -// // from the old meshes to the new ones -// string name; -// string description; -// MED_EN::medEntityMesh entity; -// vector support_name(1); -// support_name[0]="support"; -// for (int inew=0; inew< _topology->nbDomain(); inew++) -// element_array[inew].clear(); - -// for (int idomain=0; idomain < old_collection._topology->nbDomain(); idomain++) -// { -// //retrieves the group igroup on domain idomain -// const MEDMEM::SUPPORT* support = old_support[idomain]; -// if (old_support[idomain]==0) continue; -// name = support->getName(); -// description=support->getDescription(); -// int nbelem = support->getNumberOfElements(MED_EN::MED_ALL_ELEMENTS); -// if (nbelem==0 && !_create_empty_groups) continue; - -// int* list_of_elems; -// if (support->isOnAllElements()) -// { -// list_of_elems = new int[nbelem]; -// for (int i=0; i (support->getNumber(MED_EN::MED_ALL_ELEMENTS)); - -// int* array=new int[nbelem]; -// int* ip=0; -// int* local=0; -// int* full_array=0; -// entity = support->getEntity(); -// int size; - -// switch (entity) -// { -// case MED_EN::MED_CELL : -// ip=new int[nbelem]; -// local= new int[nbelem]; -// size=nbelem; -// old_collection.getTopology()->convertCellToGlobal(idomain,list_of_elems,nbelem,array); -// _topology->convertGlobalCellList(array,nbelem,local,ip); -// for (int i=0; iconvertFaceToGlobal(idomain,list_of_elems,nbelem,array); -// _topology->convertGlobalFaceListWithTwins(array,nbelem,local,ip,full_array,size); -// for (int i=0; iconvertNodeToGlobal(idomain,list_of_elems,nbelem,array); -// _topology->convertGlobalNodeListWithTwins(array,nbelem,local,ip,full_array,size); -// for (int i=0; iisOnAllElements()) delete[] list_of_elems; -// } - -// //creating new groups from the previous list of elements -// for (int idomain=0; idomain <_topology->nbDomain(); idomain++) -// { -// if ( _mesh[idomain]->getNumberOfNodes() < 1 || -// (element_array[idomain].empty() && !_create_empty_groups)) -// { -// new_support[idomain]->removeReference(); -// new_support[idomain]=0; -// continue; -// } -// MEDMEM::SUPPORT* support= new_support[idomain]; -// support->setName(name); -// support->setMesh(_mesh[idomain]); -// support->setDescription(description); -// support->setEntity(entity); - -// element_array[idomain].sort(); -// element_array[idomain].unique(); - -// if ( element_array[idomain].empty() ) -// { -// support->setNumberOfGeometricType(0); -// } -// else -// { -// if (entity != MED_EN::MED_NODE) -// support->fillFromElementList(element_array[idomain]); -// else -// { -// support->fillFromNodeList(element_array[idomain]); -// } -// } -// } -// } - -// void MESHCollection::castFieldDouble(const MESHCollection& old_collection, const string& fieldname, int itnumber, int ordernumber) -// { -// int type=old_collection.getDriver()->getFieldType(fieldname); -// char field_char[80]; -// strcpy(field_char,fieldname.c_str()); -// std::vector fieldTypes =MEDLoader::GetTypesOfField(fileName, fieldName,meshName); - -// } - -// void MESHCollection::castAllFields(const MESHCollection& initial_collection) -// { -// vector field_names; -// vector iternumber; -// vector ordernumber; -// vector types; - -// string filename=initial_collection.getDriver()->getFilename(); -// field_names=MEDLoader::GetAllFieldNames(filename.c_str()); - -// readFileStruct(field_names,iternumber,ordernumber,types); - -// for (int i=0; igetCellNumber(idomain); -// break; -// case MED_EN::MED_EDGE: -// case MED_EN::MED_FACE: -// dimension=initial_collection.getMeshDimension()-1; -// nb_elems=m_topology->getFaceNumber(idomain); -// break; -// default: -// nb_elems=0; -// break; -// } - -// if (nb_elems == 0) return; -// SCRUTE_MED(nb_elems); - - -// int *list= new int[nb_elems]; -// MED_EN::medGeometryElement *cell_type_list= new MED_EN::medGeometryElement[nb_elems]; - - -// // cout << "Beginning of retrieval "<getCellList(idomain,list); -// break; -// case MED_EN::MED_EDGE: -// case MED_EN::MED_FACE: -// m_topology->getFaceList(idomain,list); -// break; -// default: - -// break; -// } - -// //retrieving cell_types -// initial_collection.getTypeList(list,nb_elems,entity,cell_type_list); -// // cout <<"end of type retrieval"<::iterator iter= type_numbers.find(cell_type_list[icell]); -// if (iter!=type_numbers.end()) -// (iter->second)++; -// else -// type_numbers[cell_type_list[icell]]=1; - -// } -// //cout << "Nombre de tetras"< index; - -// map type_cell_list; - -// MED_EN::MESH_ENTITIES::const_iterator currentEntity; -// std::map::const_iterator iter; -// //currentEntity = MED_EN::meshEntities.find(entity); -// for (iter = type_numbers.begin();iter != type_numbers.end(); iter++) -// { -// MED_EN::medGeometryElement type = iter->first; -// if (!isDimensionOK(type,dimension)) continue; -// //if (iter->second==0) continue; -// index[type]=0; -// type_cell_list[type]=new int[type_numbers[type]]; -// // cout << "type :"<first; -// if (!isDimensionOK(type,dimension)) continue; - -// type_array[itype]=type; - -// present_type_numbers[itype]=type_numbers[type]; - -// MESSAGE_MED("Nombre d'elements de type "<get -// map type_connectivity; -// vector polygon_conn; -// vector polygon_conn_index; -// vector polyhedron_conn; -// vector polyhedron_conn_index; -// vector polyhedron_face_index; - -// //Treating nodes - -// DataArrayInt* conn_index = (initial_collection.getMesh())[idomain].getConnIndex(); -// DataArrayInt* index=(initial_collection.getMesh())[idomain].getIndex(); - - -// _topology->convertGlobalCellList(cell_list,nb_cells,local,ip); -// for (iter = type_numbers.begin();iter != type_numbers.end(); iter++) -// { -// MED_EN::medGeometryElement type = iter->first; - - -// if (!isDimensionOK(type,dimension)) continue; -// //if (type_numbers[type]==0) continue; -// if (type != MED_EN::MED_POLYGON && type != MED_EN::MED_POLYHEDRA) -// { -// int nbnode_per_type = (int)type%100; -// type_connectivity[type]=new int[type_numbers[type]*nbnode_per_type]; -// initial_collection.getNodeConnectivity(type_cell_list[type],type_numbers[type],entity,type,type_connectivity[type]); -// } -// else if (type == MED_EN::MED_POLYGON && dimension==2) -// { -// initial_collection.getPolygonNodeConnectivity(type_cell_list[type],type_numbers[type],entity,polygon_conn,polygon_conn_index); -// //type_connectivity[type]=&polygon_conn[0]; -// } -// else if (type == MED_EN::MED_POLYHEDRA && dimension==3) -// { -// initial_collection.getPolyhedraNodeConnectivity(type_cell_list[type],type_numbers[type],entity,polyhedron_conn, -// polyhedron_conn_index, polyhedron_face_index); -// //type_connectivity[type]=&polygon_conn[0]; -// } -// delete[] type_cell_list[type]; -// } - -// //creating node mapping -// //!TODO : compute the total number of nodes -// if (entity==MED_EN::MED_CELL) -// { -// m_topology->createNodeMapping(type_connectivity,type_numbers,polygon_conn,polygon_conn_index, -// polyhedron_conn,polyhedron_conn_index,polyhedron_face_index,idomain); -// } - -// //converting node global numberings to local numberings -// //for (iter = (*currentEntity).second.begin();iter != (*currentEntity).second.end(); iter++) -// for (iter = type_numbers.begin();iter != type_numbers.end(); iter++) -// { -// MED_EN::medGeometryElement type = iter->first; - -// if (!isDimensionOK(type, dimension)) continue; -// if (type_numbers[type]==0) continue; -// if (type != MED_EN::MED_POLYGON && type != MED_EN::MED_POLYHEDRA) -// { -// int nbnode_per_type = (int)type%100; -// m_topology->convertToLocal2ndVersion(type_connectivity[type],type_numbers[type]*nbnode_per_type,idomain); -// } -// else if (type == MED_EN::MED_POLYGON && dimension==2) -// { -// int nbpoly = type_numbers[type]; -// m_topology->convertToLocal2ndVersion(&polygon_conn[0], polygon_conn_index[nbpoly]-1, idomain); -// } -// else if (type == MED_EN::MED_POLYHEDRA && dimension==3) -// { -// int nbpoly = type_numbers[type]; -// m_topology->convertToLocal2ndVersion(&polyhedron_conn[0], polyhedron_face_index[polyhedron_conn_index[nbpoly]-1]-1, idomain); -// } - -// } - - -// //writing coordinates -// if (entity==MED_EN::MED_CELL) -// { -// //setting coordinates from initial_collection coordinates -// int nbnode=m_topology->getNodeNumber(idomain); -// MESSAGE_MED("Number of nodes on domain "<< idomain <<" : "<getNodeList(idomain,node_list); -// initial_collection.getCoordinates(node_list,nbnode,coordinates); -// delete[] node_list; - -// // redundant specification of number of nodes is required!! MED imperfection, sorry... - -// mesh_builder->setNumberOfNodes(nbnode); -// //TODO : change MEDMEM so that it accepts a direct setting of coordinates -// // (in the present version, it is deep-copied) -// mesh_builder->setCoordinates(initial_collection.getSpaceDimension(), -// m_topology->getNodeNumber(idomain), coordinates, initial_collection.getSystem(), -// MED_EN::MED_FULL_INTERLACE); -// delete [] coordinates; -// } - -// int nb_plain_types=0; -// for (iter = type_numbers.begin();iter != type_numbers.end(); iter++) -// { -// MED_EN::medGeometryElement type = iter->first; - -// if (!isDimensionOK(type, dimension)) continue; -// if (type_numbers[type]==0) continue; -// if (type != MED_EN::MED_POLYGON && type != MED_EN::MED_POLYHEDRA) -// nb_plain_types++; -// } -// mesh_builder->setNumberOfTypes(nb_plain_types,entity); -// mesh_builder->setTypes(type_array,entity); -// mesh_builder->setNumberOfElements(present_type_numbers,entity); -// if (entity==MED_EN::MED_CELL) -// mesh_builder->setMeshDimension(dimension); - -// delete[]present_type_numbers; -// delete[]type_array; -// //setting node connectivities -// for (iter = type_numbers.begin();iter != type_numbers.end(); iter++) -// { -// MED_EN::medGeometryElement type = iter->first; - -// if (!isDimensionOK(type,dimension)) continue; -// if (type_numbers[type]==0) continue; - -// if (type != MED_EN::MED_POLYHEDRA && type != MED_EN::MED_POLYGON) -// { -// mesh_builder->setConnectivity(type_connectivity[type],entity,type); -// delete[] type_connectivity[type]; -// } -// else if (type == MED_EN::MED_POLYGON && dimension ==2) -// { -// mesh_builder->setPolygonsConnectivity(&polygon_conn_index[0], -// &polygon_conn[0], -// type_numbers[type], -// entity); -// } -// else if (type == MED_EN::MED_POLYHEDRA && dimension ==3) -// { -// mesh_builder->setPolyhedraConnectivity(&polyhedron_conn_index[0], -// &polyhedron_face_index[0], -// &polyhedron_conn[0], -// type_numbers[type], -// entity); - -// } -// } -// MESSAGE_MED("end of createNodalConnectivity"); -// } - - -// /*! retrieves the faces that are present in a mesh and stores them in a -// * dynamic structure made of a map of MEDPARTITIONER_FaceModel -// * -// * \param idomain domain id on which the faces are collected -// * \param face_map container storing the faces -// */ -// void MESHCollection::getFaces(int idomain, -// map >& face_map) -// { -// MED_EN::medEntityMesh constituent_entity = getSubEntity(); -// const medGeometryElement* types; -// try -// { -// types = _mesh[idomain]->getTypes(constituent_entity); -// } -// catch(MEDEXCEPTION&){ return;} - -// int nbtypes = _mesh[idomain]->getNumberOfTypes(constituent_entity); -// const int* global_numbering= _mesh[idomain]->getGlobalNumberingIndex(constituent_entity); -// int* conn = const_cast (_mesh[idomain]->getConnectivity(MED_EN::MED_FULL_INTERLACE,MED_EN::MED_NODAL,constituent_entity, MED_EN::MED_ALL_ELEMENTS)); -// for (int itype=0; itypesetType(type); -// int nbnodes = type%100; -// face_model->setNbNodes(nbnodes); -// face_model->setGlobal(_topology->convertFaceToGlobal(idomain,iface)); -// for (int i=0; igetElementType(MED_EN::MED_CELL,ilocal1); -// MEDMEM::CELLMODEL celltype1 (type1); - -// const int* conn_index1 = _mesh[ip1]->getConnectivityIndex(MED_EN::MED_NODAL,MED_EN::MED_CELL); -// const int* conn1 = _mesh[ip1]->getConnectivity(MED_EN::MED_FULL_INTERLACE,MED_EN::MED_NODAL,MED_EN::MED_CELL,MED_EN::MED_ALL_ELEMENTS); - -// // MED_EN::medGeometryElement type2 = _mesh[ip2]->getElementType(MED_EN::MED_CELL,ilocal2); -// //MEDMEM::CELLTYPE celltype2 (type2); -// const int* conn_index2 = _mesh[ip2]->getConnectivityIndex(MED_EN::MED_NODAL,MED_EN::MED_CELL); -// const int* conn2 = _mesh[ip2]->getConnectivity(MED_EN::MED_FULL_INTERLACE,MED_EN::MED_NODAL,MED_EN::MED_CELL,MED_EN::MED_ALL_ELEMENTS); - -// vector nodes1, nodes1_local; -// vector nodes2; -// for (int i= conn_index1[ilocal1-1]; iconvertNodeToGlobal(ip1,*(conn1+i-1))); -// nodes1_local.push_back( conn1[i-1] ); -// } -// for (int i= conn_index2[ilocal2-1]; iconvertNodeToGlobal(ip2,*(conn2+i-1))); - -// return MEDPARTITIONER_FaceModel::getCommonFace( &nodes1[0], &nodes1_local[0], celltype1, -// &nodes2[0], nodes2.size(), face_index); -// } - -// //================================================================================ -// /*! -// * \brief Makes a face common for two given cells -// * \param nodes1 - globl nodes of the first cell -// * \param nodes1_local - local nodes of the first cell -// * \param celltype1 - cell model of the first cell -// * \param nodes2 - globl nodes of the second cell -// * \param nb_nodes2 - nb of nodes of the second cell -// * \param global_id - id of the new common face -// */ -// //================================================================================ - -// MEDPARTITIONER_FaceModel* -// MEDPARTITIONER_FaceModel::getCommonFace(const int* nodes1, -// const int* nodes1_local, -// const MEDMEM::CELLMODEL& celltype1, -// const int* nodes2, -// int nb_nodes2, -// int global_id) -// { -// int nbfaces= celltype1.getNumberOfConstituents(1); -// int ** faces = celltype1.getConstituents(1); -// MED_EN::medGeometryElement* types = celltype1.getConstituentsType(1); -// int iface=0; -// int dimension=celltype1.getDimension(); - -// while (iface=dimension) break; -// iface++; -// } - -// if (iface==nbfaces) -// throw MEDEXCEPTION("MEDPARTITIONER::getCommonFace - No common face found !"); - -// MEDPARTITIONER_FaceModel* face_model = new MEDPARTITIONER_FaceModel; -// face_model->setType(types[iface]); -// int nbnodes = types[iface]%100; -// face_model->setNbNodes(nbnodes); -// face_model->setGlobal(global_id); -// for (int i=0; inbDomain(); i++) diff --git a/src/MEDPartitioner/MEDPARTITIONER_MESHCollection.hxx b/src/MEDPartitioner/MEDPARTITIONER_MESHCollection.hxx index 72fb537f1..331d33339 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_MESHCollection.hxx +++ b/src/MEDPartitioner/MEDPARTITIONER_MESHCollection.hxx @@ -167,64 +167,17 @@ namespace MEDPARTITIONER //creates faces on the new collection void castMeshes(std::vector& meshCastFrom,std::vector& meshCastTo, MESHCollection& initialCollection,const std::multimap,std::pair >& nodeMapping, std::vector > >& old2newIds); - - //!transfers families from an old MESHCollection to new mesh - // void castFamilies(const MESHCollection& old_collection); - - //void castSupport(const MESHCollection& old_collection, std::vector& old_support, std::vector& new_support); - -// //!casts all the fields to the new mesh collection -// void castAllFields(const MESHCollection& old_collection); - -// //!casts one specific field to the new mesh collection -// void castField(const MESHCollection& old_collection, const string& fieldname, int itnumber, int ordernumber); - -// //choosing a group to be indivisible -// void setIndivisibleGroup(const string& a); - -// //!constructing connect zones -// // void buildConnectZones(int idomain); -// void buildConnectZones(); -// void buildConnectZonesBetweenProcs(std::vector > > &, map< pair, MEDPARTITIONER::MEDSKYLINEARRAY*> & local_cell_cell_correspondency); - -// void addJointGroup(const std::vector&, int idomain, int idistant); - -// static bool isDimensionOK(MED_EN::medGeometryElement type, int dim) -// { -// return ((type/100 == dim) || (dim==2 && type == MED_EN::MED_POLYGON) || (dim==3 && type == MED_EN::MED_POLYHEDRA)); -// } -// void setSubdomainBoundaryCreates(bool flag) { _subdomain_boundary_creates=flag;} -// bool getSubdomainBoundaryCreates(){return _subdomain_boundary_creates;} - -// void setFamilySplitting(bool flag){_family_splitting=flag;} -// bool getFamilySplitting(){return _family_splitting;} - -// void setCreateEmptyGroups(bool flag){_create_empty_groups=flag;} -// bool getCreateEmptyGroups(){return _create_empty_groups;} - - private: - // //!creates connectivities for a domain and an entity (face or cell) -// void createNodalConnectivity(const MESHCollection & initial_collection, int idomain, MED_EN::medEntityMesh entity); - - -// //!projects a field from an old collection to the present one -// //!field is identified by (name, dt, it) - - void castIntField(std::vector& meshesCastFrom,std::vector& meshesCastTo, std::vector& arrayFrom, std::vector& arrayTo, std::vector > > & old2newMapping); + void castIntField(std::vector& meshesCastFrom,std::vector& meshesCastTo, std::vector& arrayFrom, std::vector& arrayTo); void findCommonDistantNodes(std::vector > >& commonDistantNodes); - // template - // void castFields(const MESHCollection& old_collection, const string& fieldname, int itnumber, int ordernumber); - - // void getFaces(int idomain, std::map >&); - -// MEDPARTITIONER_FaceModel* getCommonFace(int ip1,int ilocal1,int ip2,int ilocal2,int face_index); -// template -// void fillGlobalConnectivity(TID2CONN & node2cell, TID2CONN & cell2node ); +void remapIntField(const ParaMEDMEM::MEDCouplingUMesh& sourceMesh, + const ParaMEDMEM::MEDCouplingUMesh& targetMesh, + const int* fromArray, + int* toArray); //!link to mesh_collection topology Topology* _topology; diff --git a/src/MEDPartitioner/MEDPARTITIONER_MESHCollectionDriver.cxx b/src/MEDPartitioner/MEDPARTITIONER_MESHCollectionDriver.cxx index 3d4ff58c8..b91d40cd2 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_MESHCollectionDriver.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_MESHCollectionDriver.cxx @@ -145,16 +145,11 @@ void MESHCollectionDriver::readSubdomain(vector& cellglobal, vector& faceglobal, vector& nodeglobal, int idomain) { -// const char* LOC = "MEDPARTITIONER::MESHCollectionDriver::readSubdomain()"; -// BEGIN_OF_MED(LOC); -// char file[256]; - //char meshname[MED_TAILLE_NOM+1]; string meshname=_meshname[idomain]; string file=_filename[idomain]; - //strcpy(meshname,_meshname[idomain].c_str()); - //strcpy(file,_filename[idomain].c_str()); + cout << "Reading "<<_meshname[idomain]<<" in "<<_filename[idomain]<getMesh())[idomain]=new MEDMEM::MESH(MEDMEM::MED_DRIVER,file, meshname); + ParaMEDMEM::MEDFileUMesh* mfm=ParaMEDMEM::MEDFileUMesh::New(file.c_str(),meshname.c_str()); (_collection->getMesh())[idomain]=mfm->getLevel0Mesh(false); (_collection->getFaceMesh())[idomain]=mfm->getLevelM1Mesh(false); @@ -172,146 +167,28 @@ void MESHCollectionDriver::readSubdomain(vector& cellglobal, _collection->getGroupInfo()=mfm->getGroupInfo(); cout <<"End of Read"<setName(string(name)); - // cz->setDescription(joint_description); - // cz->setLocalDomainNumber(idomain); - // cz->setDistantDomainNumber(distant); - // cz->setLocalMesh((_collection->getMesh())[idomain]); - // cz->setDistantMesh((_collection->getMesh())[distant]); - // cz->setNodeCorresp(node_corresp,ncouples); - // (_collection->getCZ()).push_back(cz); - - // }//loop on correspom_topology->nbDomain())ndances - // }//loop on joints - // // Reading global numbering - // // à faire dans MEDLoader - - // // MEDCouplingFieldDouble globalcell=MEDLoader::GetGlobalNumbering(file,meshname,0); - - - // MEDfermer(fid); - - // END_OF_MED(LOC); + mfm->decrRef(); } -void MESHCollectionDriver::writeSubdomain(int idomain, int nbdomains, const char* distfilename, - ParaDomainSelector* domain_selector) -{ - //build connect zones - // if (nbdomains>1) - // _collection->buildConnectZones(idomain); - - // MESSAGE_MED(" Number of connect zones "<<(_collection->getCZ()).size()); - - //writing connect zones in joints - - // med_idt fid = MEDouvrir(distfilename,MED_LECTURE_ECRITURE); -// int index_joint=0; - - -// for (int icz=0; icz<(_collection->getCZ()).size(); icz++) -// { -// if ((_collection->getCZ())[icz]->getLocalDomainNumber()==idomain) -// { -// med_err error; -// int idistant=(_collection->getCZ())[icz]->getDistantDomainNumber(); -// char joint_name[MED_TAILLE_NOM+1]; -// sprintf(joint_name,"joint_%i",idistant+1); -// char desc[MED_TAILLE_DESC+1]; -// sprintf(desc,"connect_zone_%d",icz+1); - -// char distant_name[MED_TAILLE_NOM+1]; -// //sprintf(distant_name,"domain_%i",(_collection->getCZ())[icz]->getDistantDomainNumber()); - -// // sprintf(distant_name,(_collection->getMesh())[idistant]->getName().c_str()); -// sprintf(distant_name,"domain_%i",idistant); -// char mesh_name[MED_TAILLE_NOM+1]; - -// strcpy (mesh_name, (_collection->getMesh())[idomain]->getName()); -// // SCRUTE_MED((_collection->getMesh())[idomain]->getName()); -// error = MEDjointCr(fid,mesh_name, joint_name, desc, -// idistant, distant_name); -// if (error==-1) cout << "erreur creation de joint "<getCZ())[icz]->getNodeNumber(); -// int* node_corresp=const_cast((_collection->getCZ())[icz]->getNodeCorrespValue()); - -// /* Nodes are reordered so that the ordering on the local and the distant domain -// correspond. The chosen order is the natural ordering on the domain -// with lowest proc id*/ -// // if (_collection->getSubdomainBoundaryCreates()) -// // if (idomaingetSubdomainBoundaryCreates()) -// // { -// // MED_EN::medEntityMesh constituent_entity = -// // (_collection->getMeshDimension()==3)?MED_EN::MED_FACE:MED_EN::MED_EDGE; -// // writeElementJoint(constituent_entity, icz, idomain, idistant, mesh_name,joint_name,fid); -// // } -// index_joint++; -// } -// } - -// char meshchar[MED_TAILLE_NOM+1]; -// strcpy(meshchar,(_collection->getMesh())[idomain]->getName()); +void MESHCollectionDriver::writeMedFile(int idomain, const string& distfilename) +{ + vector meshes; + ParaMEDMEM::MEDCouplingUMesh* cellMesh=_collection->getMesh(idomain); + ParaMEDMEM::MEDCouplingUMesh*faceMesh =_collection->getFaceMesh(idomain); - -// MEDfermer(fid); - std::cout<<"End of writing"<zipCoords(); + faceMesh->checkCoherency(); + faceMesh->tryToShareSameCoordsPermute(*cellMesh,1e-10); + meshes.push_back(faceMesh); + MEDLoader::WriteUMeshes(distfilename.c_str(), meshes,true); + ParaMEDMEM::MEDFileUMesh* mfm=ParaMEDMEM::MEDFileUMesh::New(distfilename.c_str(),_collection->getMesh(idomain)->getName()); + mfm->setFamilyFieldArr(-1,(_collection->getFaceFamilyIds())[idomain]); + mfm->setFamilyInfo(_collection->getFamilyInfo()); + mfm->setGroupInfo(_collection->getGroupInfo()); + mfm->write(distfilename.c_str(),0); + mfm->decrRef(); + // writeSubdomain(idomain, nbdomains, distfilename.c_str(), domainSelector); } diff --git a/src/MEDPartitioner/MEDPARTITIONER_MESHCollectionDriver.hxx b/src/MEDPartitioner/MEDPARTITIONER_MESHCollectionDriver.hxx index 1efde1d60..01502b62b 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_MESHCollectionDriver.hxx +++ b/src/MEDPartitioner/MEDPARTITIONER_MESHCollectionDriver.hxx @@ -20,6 +20,7 @@ #define MEDPARTITIONER_MESHCOLLECTIONDRIVER_HXX_ #include "MEDPARTITIONER.hxx" +#include namespace MEDPARTITIONER { @@ -59,8 +60,7 @@ namespace MEDPARTITIONER void readSubdomain(vector& cellglobal, vector& faceglobal, vector& nodeglobal, int idomain); - void writeSubdomain(int idomain,int nbdomain, const char*filename, - ParaDomainSelector* domain_selector); + void writeMedFile(int idomain, const std::string& distfilename); // void writeElementJoint(medEntityMesh entity , // int icz, diff --git a/src/MEDPartitioner/MEDPARTITIONER_ParaDomainSelector.cxx b/src/MEDPartitioner/MEDPARTITIONER_ParaDomainSelector.cxx index 49bf43691..9c1a29202 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_ParaDomainSelector.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_ParaDomainSelector.cxx @@ -21,16 +21,11 @@ // Author : Edward AGAPOV (eap) #include "MEDCouplingUMesh.hxx" -#include "MEDMEM_Exception.hxx" + #include "MEDPARTITIONER_ParaDomainSelector.hxx" #include "MEDPARTITIONER_UserGraph.hxx" -//#include "MEDPARTITIONER_JointExchangeData.hxx" - -//#include -#include -#include #include #ifdef HAVE_MPI2 @@ -141,7 +136,6 @@ int ParaDomainSelector::getProcessorID(int domainIndex) const //================================================================================ int ParaDomainSelector::gatherNbOf( - //MED_EN::medEntityMesh entity, const vector& domain_meshes) { evaluateMemory(); @@ -207,7 +201,7 @@ int ParaDomainSelector::gatherNbOf( */ //================================================================================ -#define gatherNbOf_NOT_CALLED(meth) throw MED_EXCEPTION \ +#define gatherNbOf_NOT_CALLED(meth) throw INTERP_KERNEL::Exception \ ("ParaDomainSelector::" #meth "(): gatherNbOf( MED_CELL ) must be called before") int* ParaDomainSelector::getNbVertOfProcs() const @@ -360,87 +354,6 @@ auto_ptr ParaDomainSelector::gatherGraph(const Graph* graph) const return auto_ptr( glob_graph ); } -//================================================================================ -/*! - * \brief Sets global numbering for the entity. - * - * This method must be once called for MED_CELL before exchangeJoint() calls - */ -//================================================================================ - -// void ParaDomainSelector::gatherEntityTypesInfo(vector& domain_meshes, -// MED_EN::medEntityMesh entity) -// { -// const list & all_types = meshEntities[ entity ]; - -// evaluateMemory(); - -// // Put nb of elements of the entity of all domains in one vector -// // and by the way find out mesh dimension - -// vector nb_of_type( domain_meshes.size() * all_types.size(), 0 ); -// int mesh_dim = -1, space_dim = -1; - -// for ( int idomain = 0; idomain < domain_meshes.size(); ++idomain ) -// { -// if ( !isMyDomain(idomain)) continue; - -// int* domain_nbs = & nb_of_type[ idomain * all_types.size()]; - -// list::const_iterator type = all_types.begin(); -// for ( int t = 0; type != all_types.end(); ++t,++type ) -// domain_nbs[t] = domain_meshes[idomain]->getNumberOfCells(); - -// int i_mesh_dim = domain_meshes[idomain]->getMeshDimension(); -// int i_space_dim = domain_meshes[idomain]->getSpaceDimension(); -// if ( mesh_dim < i_mesh_dim && i_mesh_dim <= 3 ) -// mesh_dim = i_mesh_dim; -// if ( space_dim < i_space_dim && i_space_dim <= 3 ) -// space_dim = i_space_dim; -// } - -// // Receive nbs from other procs - -// vector< int > nb_recv( nb_of_type.size() ); -// #ifdef HAVE_MPI2 -// MPI_Allreduce((void*)&nb_of_type[0], (void*)&nb_recv[0], nb_of_type.size(), -// MPI_INT, MPI_SUM, MPI_COMM_WORLD); -// #endif - -// // Set info to meshes of distant domains - -// for ( int idomain = 0; idomain < domain_meshes.size(); ++idomain ) -// { -// if ( isMyDomain(idomain)) continue; - -// MEDMEM::MESHING* meshing = (MEDMEM::MESHING*) domain_meshes[idomain]; -// if ( meshing->getMeshDimension() < mesh_dim ) -// { -// meshing->setMeshDimension( mesh_dim ); -// meshing->setSpaceDimension( space_dim ); -// } - -// vector< medGeometryElement > types; -// vector< int > nb_elems; - -// int* domain_nbs = & nb_recv[ idomain * all_types.size()]; - -// list::const_iterator type = all_types.begin(); -// for ( int t = 0; type != all_types.end(); ++t,++type ) -// { -// if ( domain_nbs[t]==0 ) continue; -// types.push_back( *type ); -// nb_elems.push_back( domain_nbs[t] ); -// } -// meshing->setNumberOfTypes( types.size(), entity ); -// if ( !types.empty() ) -// { -// meshing->setTypes ( & types[0], entity ); -// meshing->setNumberOfElements( & nb_elems[0], entity ); -// } -// } -// evaluateMemory(); -// } //================================================================================ /*! @@ -501,32 +414,9 @@ void ParaDomainSelector::gatherNbCellPairs() // namely that each joint is treated on one proc only for ( int j = 0; j < _nb_cell_pairs_by_joint.size(); ++j ) if ( _nb_cell_pairs_by_joint[j] != send_buf[j] && send_buf[j]>0 ) - throw MED_EXCEPTION("invalid nb of cell pairs"); + throw INTERP_KERNEL::Exception("invalid nb of cell pairs"); } -//================================================================================ -/*! - * \brief Send-receive joint data - */ -//================================================================================ - -// void ParaDomainSelector::exchangeJoint( JointExchangeData* joint ) const -// { -// vector send_data, recv_data( joint->serialize( send_data )); - -// int dest = getProcessorID( joint->distantDomain() ); -// int tag = 1001 + jointId( joint->localDomain(), joint->distantDomain() ); - -// #ifdef HAVE_MPI2 -// MPI_Status status; -// MPI_Sendrecv((void*)&send_data[0], send_data.size(), MPI_INT, dest, tag, -// (void*)&recv_data[0], recv_data.size(), MPI_INT, dest, tag, -// MPI_COMM_WORLD, &status); -// #endif - -// joint->deserialize( recv_data ); -// } - //================================================================================ /*! * \brief Return the first global id of sub-entity for the joint @@ -543,7 +433,7 @@ int ParaDomainSelector::getFisrtGlobalIdOfSubentity( int loc_domain, int dist_do int id = total_nb_faces + 1; if ( _nb_cell_pairs_by_joint.empty() ) - throw MED_EXCEPTION("MEDPARTITIONER::ParaDomainSelector::getFisrtGlobalIdOfSubentity(), " + throw INTERP_KERNEL::Exception("MEDPARTITIONER::ParaDomainSelector::getFisrtGlobalIdOfSubentity(), " "gatherNbCellPairs() must be called before"); int joint_id = jointId( loc_domain, dist_domain ); for ( int j = 0; j < joint_id; ++j ) @@ -585,23 +475,13 @@ int ParaDomainSelector::jointId( int local_domain, int distant_domain ) const { evaluateMemory(); if (_nb_result_domains < 0) - throw MED_EXCEPTION("ParaDomainSelector::jointId(): setNbDomains() must be called before()"); + throw INTERP_KERNEL::Exception("ParaDomainSelector::jointId(): setNbDomains() must be called before()"); if ( local_domain < distant_domain ) swap( local_domain, distant_domain ); return local_domain * _nb_result_domains + distant_domain; } -//================================================================================ -/*! - * \brief Return domain order so that first go domains on proc 0 and so n - */ -//================================================================================ - -// int ParaDomainSelector::getDomianOrder(int idomain, int nb_domains) const -// { -// return nb_domains / nbProcs() * getProcessorID( idomain ) + idomain / nbProcs(); -// } //================================================================================ /*! @@ -645,6 +525,11 @@ int ParaDomainSelector::evaluateMemory() const return _max_memory - _init_memory; } +/*! +Sends content of \a mesh to processor \a target. To be used with \a recvMesh method. +\param mesh mesh to be sent +\param target processor id of the target +*/ void ParaDomainSelector::sendMesh(const ParaMEDMEM::MEDCouplingUMesh& mesh, int target) const { @@ -696,6 +581,13 @@ void ParaDomainSelector::sendMesh(const ParaMEDMEM::MEDCouplingUMesh& mesh, int v2Local->decrRef(); } + +/*! Receives messages from proc \a source to fill mesh \a mesh. +To be used with \a sendMesh method. + +\param mesh pointer to mesh that is filled +\param source processor id of the incoming messages + */ void ParaDomainSelector::recvMesh(ParaMEDMEM::MEDCouplingUMesh*& mesh, int source)const { @@ -749,17 +641,20 @@ void ParaDomainSelector::recvMesh(ParaMEDMEM::MEDCouplingUMesh*& mesh, int sourc MPI_Recv(ptDist2, nbDistElem, MPI_DOUBLE,source, 1110, MPI_COMM_WORLD, &status); #endif // - //mesh=dynamic_cast (distant_mesh_tmp); //finish unserialization mesh->unserialization(tinyInfoDistantD,tinyInfoDistant,v1Distant,v2Distant,unusedTinyDistantSts); - std::cout<<"mesh size on recv"<getNumberOfCells()<decrRef(); if(v2Distant) v2Distant->decrRef(); } +/*! +Sends content of \a vec to processor \a target. To be used with \a recvDoubleVec method. +\param vec vector to be sent +\param target processor id of the target +*/ void ParaDomainSelector::sendDoubleVec(const std::vector& vec, int target)const { int size=vec.size(); @@ -768,6 +663,12 @@ void ParaDomainSelector::sendDoubleVec(const std::vector& vec, int targe MPI_Send(const_cast(&vec[0]), size,MPI_DOUBLE, target, 1212, MPI_COMM_WORLD); #endif } +/*! Receives messages from proc \a source to fill vector vec. +To be used with \a sendDoubleVec method. + +\param vec vector that is filled +\param source processor id of the incoming messages + */ void ParaDomainSelector::recvDoubleVec(std::vector& vec, int source)const { int size; @@ -778,6 +679,11 @@ void ParaDomainSelector::recvDoubleVec(std::vector& vec, int source)cons MPI_Recv(&vec[0],size,MPI_DOUBLE,source, 1212, MPI_COMM_WORLD,&status); #endif } +/*! +Sends content of \a vec to processor \a target. To be used with \a recvIntVec method. +\param vec vector to be sent +\param target processor id of the target +*/ void ParaDomainSelector::sendIntVec(const std::vector& vec, int target)const { int size=vec.size(); @@ -786,6 +692,12 @@ void ParaDomainSelector::sendIntVec(const std::vector& vec, int target)cons MPI_Send(const_cast(&vec[0]), size,MPI_INT, target, 1212, MPI_COMM_WORLD); #endif } +/*! Receives messages from proc \a source to fill vector vec. +To be used with \a sendIntVec method. + +\param vec vector that is filled +\param source processor id of the incoming messages + */ void ParaDomainSelector::recvIntVec(std::vector& vec, int source)const { int size; diff --git a/src/MEDPartitioner/MEDPARTITIONER_ParaDomainSelector.hxx b/src/MEDPartitioner/MEDPARTITIONER_ParaDomainSelector.hxx index 79c277502..465e121cb 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_ParaDomainSelector.hxx +++ b/src/MEDPartitioner/MEDPARTITIONER_ParaDomainSelector.hxx @@ -92,15 +92,10 @@ const std::vector& domain_meshes); // Return nb of cells in domains with lower index int getDomainShift(int domainIndex) const; -// // Return nb of sub-entities in domains with lower index -// int getDomainSubentityShift(int domainIndex) const; // Gather graphs from all processors into one std::auto_ptr gatherGraph(const Graph* graph) const; - // Set types and number of elements of the entity to all meshes -// void gatherEntityTypesInfo(std::vector& domain_meshes, -// MED_EN::medEntityMesh entity); // Set nb of cell/cell pairs in a joint between domains void setNbCellPairs( int nb_cell_pairs, int dist_domain, int loc_domain ); diff --git a/src/MEDPartitioner/MEDPARTITIONER_ParallelTopology.cxx b/src/MEDPartitioner/MEDPARTITIONER_ParallelTopology.cxx index ef9d5bdef..94ae8218a 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_ParallelTopology.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_ParallelTopology.cxx @@ -19,12 +19,8 @@ #include #include #include -#ifndef WNT -# include -#else -# include -#endif +#include "InterpKernelHashMap.hxx" #include "MEDPARTITIONER_MESHCollection.hxx" #include "MEDPARTITIONER_Topology.hxx" #include "MEDPARTITIONER_Graph.hxx" @@ -92,8 +88,7 @@ ParallelTopology::ParallelTopology(const vector& for (int i=0; i ("<& for (int i=0; i& for (int i=0; igetNumberOfNodes(); i++) { m_node_glob_to_loc.insert(make_pair(i,make_pair(0,i))); - //m_node_loc_to_glob.insert(make_pair(make_pair(0,i+1), i+1)); m_node_loc_to_glob[0][i]=i; } m_nb_total_nodes=meshes[idomain]->getNumberOfNodes(); m_nb_nodes[0]=m_nb_total_nodes; - // meshes[idomain]->getConnectivity(MED_EN::MED_FULL_INTERLACE, MED_EN::MED_DESCENDING, MED_EN::MED_CELL, MED_EN::MED_ALL_ELEMENTS); - // int nbfaces=meshes[idomain]->getNumberOfElementsWithPoly(constituent_entity,MED_EN::MED_ALL_ELEMENTS); -// m_face_loc_to_glob[idomain].resize(nbfaces); -// for (int i=0; igetNumberOfNodes(); - hash_map > local2distant; + INTERP_KERNEL::HashMap > local2distant; m_node_loc_to_glob[idomain].resize(m_nb_nodes[idomain]); for (int icz=0; icz& { int ip = (local2distant.find(inode)->second).first; int distant = (local2distant.find(inode)->second).second; - //int global_number=m_loc_to_glob[make_pair(ip,distant)]; int global_number=m_loc_to_glob[ip][distant]; m_node_glob_to_loc.insert(make_pair(global_number,make_pair(idomain,inode))); - //m_node_loc_to_glob[make_pair(idomain,inode+1)]=global_number; m_node_loc_to_glob[idomain][inode]=global_number; } } } //using former node numbering else - {// cout << "("<"<getConnectivity(MED_EN::MED_FULL_INTERLACE, MED_EN::MED_DESCENDING, MED_EN::MED_CELL, MED_EN::MED_ALL_ELEMENTS); -// m_nb_faces[idomain]=meshes[idomain]->getNumberOfElementsWithPoly(constituent_entity,MED_EN::MED_ALL_ELEMENTS); -// MESSAGE_MED ("Nb faces domain " << idomain<getLocalDomainNumber() == idomain && -// cz[icz]->getLocalDomainNumber()>cz[icz]->getDistantDomainNumber()) -// { -// int nb_face= cz[icz]->getFaceNumber(); -// const int* face_corresp=cz[icz]->getFaceCorrespValue(); -// int distant_ip = cz[icz]->getDistantDomainNumber(); -// for (int i=0; i< nb_face; i++) -// { -// int local= face_corresp[i*2]; -// int distant = face_corresp[i*2+1]; -// local2distant.insert(make_pair(local, make_pair(distant_ip,distant))); -// } -// } -// } -// // setting mappings for all faces -// if (faceglobal[idomain]==0) -// { -// for (int iface=0; ifacesecond).first; -// int distant = (local2distant.find(iface+1)->second).second; -// //int global_number=m_loc_to_glob[make_pair(ip,distant)]; -// int global_number=m_loc_to_glob[ip][distant-1]; -// m_face_glob_to_loc.insert(make_pair(global_number,make_pair(idomain,iface+1))); -// //m_face_loc_to_glob[make_pair(idomain,iface+1)]=global_number; -// m_face_loc_to_glob[idomain][iface]=global_number; -// } -// } -// } -// //using former face numbering -// else -// { -// for (int iface=0; iface >::iterator mmiter; + typedef INTERP_KERNEL::HashMultiMap >::iterator mmiter; pair range=m_node_glob_to_loc.equal_range(node_list[i]); for (mmiter it=range.first; it !=range.second; it++) { @@ -389,7 +304,7 @@ void ParallelTopology::convertGlobalNodeListWithTwins(const int* node_list, int full_array=new int[size]; for (int i=0; i< nbnode; i++) { - typedef hash_multimap >::iterator mmiter; + typedef INTERP_KERNEL::HashMultiMap >::iterator mmiter; pair range=m_node_glob_to_loc.equal_range(node_list[i]); for (mmiter it=range.first; it !=range.second; it++) { @@ -423,7 +338,7 @@ void ParallelTopology::convertGlobalFaceListWithTwins(const int* face_list, int full_array=new int[size]; for (int i=0; i< nbface; i++) { - typedef hash_multimap >::iterator mmiter; + typedef INTERP_KERNEL::HashMultiMap >::iterator mmiter; pair range=m_face_glob_to_loc.equal_range(face_list[i]); for (mmiter it=range.first; it !=range.second; it++) { @@ -442,7 +357,7 @@ void ParallelTopology::convertGlobalCellList(const int* cell_list, int nbcell, i { for (int i=0; i< nbcell; i++) { - hash_map >::const_iterator iter = m_glob_to_loc.find(cell_list[i]); + INTERP_KERNEL::HashMap >::const_iterator iter = m_glob_to_loc.find(cell_list[i]); ip[i]=(iter->second).first; local[i]=(iter->second).second; } @@ -455,7 +370,7 @@ void ParallelTopology::convertGlobalFaceList(const int* face_list, int nbface, i { for (int i=0; i< nbface; i++) { - hash_map >::const_iterator iter = m_face_glob_to_loc.find(face_list[i]); + INTERP_KERNEL::HashMap >::const_iterator iter = m_face_glob_to_loc.find(face_list[i]); if (iter == m_face_glob_to_loc.end()) { throw MED_EXCEPTION("convertGlobalFaceList - Face not found"); @@ -477,7 +392,7 @@ void ParallelTopology::convertGlobalFaceList(const int* face_list, int nbface, i { for (int i=0; i< nbface; i++) { - typedef hash_multimap >::iterator mmiter; + typedef INTERP_KERNEL::HashMultiMap >::iterator mmiter; pair range=m_face_glob_to_loc.equal_range(face_list[i]); for (mmiter it=range.first; it !=range.second; it++) { @@ -490,439 +405,6 @@ void ParallelTopology::convertGlobalFaceList(const int* face_list, int nbface, i } -////creating node mapping -// void ParallelTopology::createNodeMapping(map& type_connectivity, -// map& present_type_numbers, -// vector& polygon_conn, -// vector& polygon_conn_index, -// vector& polyhedron_conn, -// vector& polyhedron_conn_index, -// vector& polyhedron_face_index, -// int idomain) -// { -// set local_numbers; -// int local_index=0; - -// map::const_iterator iter; -// for (iter = present_type_numbers.begin(); iter!=present_type_numbers.end();iter++) -// { -// int type=iter->first; -// int nodes_per_type= type%100; - -// if (!((type/100==m_mesh_dimension) -// ||(type==MED_EN::MED_POLYGON && m_mesh_dimension==2) -// ||(type==MED_EN::MED_POLYHEDRA && m_mesh_dimension==3))) continue; - -// if (type != MED_EN::MED_POLYGON && type != MED_EN::MED_POLYHEDRA) -// { -// for (int icell=0; icell& globNodes) -// { -// // convert global nodes to local in the given domain -// set nodes; -// set::const_iterator n = globNodes.begin(); -// for ( ; n != globNodes.end(); ++n ) -// nodes.insert( convertGlobalNode( *n, domain )); - -// const MED_EN::medConnectivity connType = MED_EN::MED_NODAL; -// const MED_EN::medEntityMesh entity = MED_EN::MED_CELL; - -// // loop on all types of cells -// const MEDMEM::MESH* mesh = new_collection.getMesh( domain ); -// int nbTypes = mesh->getNumberOfTypesWithPoly( entity ); -// MED_EN::medGeometryElement * types = mesh->getTypesWithPoly( entity ); -// for ( int t = 0; t < nbTypes; ++t ) -// { -// // get connectivity -// if ( !mesh->existConnectivityWithPoly( connType, entity )) -// continue; -// int nbCell = mesh->getNumberOfElementsWithPoly( entity, types[t] ); -// const int *conn, *index; -// switch ( types[t] ) -// { -// case MED_EN::MED_POLYGON: -// conn = mesh->getPolygonsConnectivity( connType, entity ); -// index = mesh->getPolygonsConnectivityIndex( connType, entity ); -// break; -// case MED_EN::MED_POLYHEDRA: -// conn = mesh->getPolyhedronConnectivity( connType ); -// index = mesh->getPolyhedronFacesIndex(); -// nbCell = mesh->getNumberOfPolyhedronFaces(); -// break; -// default: -// conn = mesh->getConnectivity(MED_EN::MED_FULL_INTERLACE,connType, entity, types[t]); -// index = mesh->getConnectivityIndex(connType, entity); -// } -// // find a cell containing the first of given nodes, -// // then check if the found cell contains all the given nodes -// const int firstNode = *nodes.begin(); -// for ( int i = 0; i < nbCell; ++i ) -// { -// for ( int j = index[i]-1; j < index[i+1]-1; ++j ) -// if ( conn[j] == firstNode ) -// { -// int nbSame = 0; -// for ( j = index[i]-1; j < index[i+1]-1; ++j ) -// nbSame += nodes.count( conn[j] ); -// if ( nbSame == nodes.size() ) -// return true; -// break; -// } -// } -// } -// delete [] types; -// return false; -// } - -////creating face mapping -// void ParallelTopology::createFaceMapping(const MESHCollection& initial_collection, -// const MESHCollection& new_collection) -// // map& type_list, -// // map& present_type_numbers, -// // int idomain - -// { -// // containers for the new topology -// vector new_counts(m_nb_domain,0); -// vector domain_counts(m_nb_domain,0); -// const Topology* old_topology=initial_collection.getTopology(); -// int nb_domain_old=old_topology->nbDomain(); -// int global_index=old_topology->getFaceNumber(); -// //cout << "nb faces = " << global_index << endl; -// set > > global_treated; - -// //definition of the d-1 constituent for the considered mesh dimension -// MED_EN::medEntityMesh constituent_entity; -// switch (m_mesh_dimension) -// { -// case 3: -// constituent_entity= MED_EN::MED_FACE; -// break; -// case 2: -// constituent_entity = MED_EN::MED_EDGE; -// break; -// } - -// for (int iold=0; ioldgetNumberOfElements(constituent_entity,MED_EN::MED_ALL_ELEMENTS); -// int nbtotalface = initial_collection.getMesh(iold)->getNumberOfElementsWithPoly(constituent_entity,MED_EN::MED_ALL_ELEMENTS); -// SCRUTE_MED(nbplainface); -// SCRUTE_MED(nbtotalface); -// const int* face_conn; -// const int* face_offset; -// const int* poly_conn; -// const int* poly_index; -// if (nbtotalface >0) -// { -// if (nbplainface >0) -// { -// face_conn = initial_collection.getMesh(iold)->getConnectivity(MED_EN::MED_FULL_INTERLACE, -// MED_EN::MED_NODAL,constituent_entity,MED_EN::MED_ALL_ELEMENTS); -// face_offset = initial_collection.getMesh(iold)->getConnectivityIndex(MED_EN::MED_NODAL,constituent_entity); -// } -// if (nbtotalface > nbplainface) -// { -// poly_conn = initial_collection.getMesh(iold)->getPolygonsConnectivity(MED_EN::MED_NODAL,constituent_entity); -// poly_index = initial_collection.getMesh(iold)->getPolygonsConnectivityIndex(MED_EN::MED_NODAL,constituent_entity); -// } - -// } -// else -// { -// face_conn=0; -// face_offset=0; -// } -// for (int iface=0;ifaceconvertFaceToGlobal(iold,iface+1); - -// // int inode = face_offset[iface]; -// for (int i=0; i nodes; -// int nbnodes; -// if (ifaceconvertNodeToGlobal(iold,node); -// // cout << "global node "< >::iterator mmiter; -// pair range=m_node_glob_to_loc.equal_range(global); - -// int ip; -// for (mmiter it=range.first; it !=range.second; it++) -// { -// ip=(it->second).first; -// domain_counts[ip]++; -// } -// } -// } -// else -// { -// nbnodes =poly_index[iface-nbplainface+1]- poly_index[iface-nbplainface]; -// for (int inode= poly_index[iface-nbplainface];inode < poly_index[iface-nbplainface+1]; inode++) -// { -// int node=poly_conn[inode-1]; -// // SCRUTE_MED(node); -// int global = old_topology->convertNodeToGlobal(iold,node); -// // cout << "global node "< >::iterator mmiter; -// pair range=m_node_glob_to_loc.equal_range(global); - -// int ip; -// for (mmiter it=range.first; it !=range.second; it++) -// { -// ip=(it->second).first; -// domain_counts[ip]++; -// } -// } -// } -// set::const_iterator iter_node = nodes.begin(); -// int numbers[3]; -// numbers[2]=0; // for segments -// for (int i=0; i > > ::iterator iter_triplets; -// pair > triplet = make_pair(numbers[0],make_pair(numbers[1],numbers[2])); -// iter_triplets=global_treated.find(triplet); -// if (iter_triplets==global_treated.end()) -// { -// global_treated.insert(triplet); -// // int nbnodes=face_offset[iface+1]-face_offset[iface]; -// if (global_face_number == -1) -// { -// global_index++; -// global_face_number=global_index; - -// } -// // SCRUTE_MED(nbnodes); - -// for (int inew=0;inew new_counts(m_nb_domain,0); -// vector domain_counts(m_nb_domain,0); -// const Topology* old_topology=initial_collection.getTopology(); -// int nb_domain_old=old_topology->nbDomain(); -// //int global_index=old_topology->getFaceNumber(); -// // set > > global_treated; - -// //definition of the d-1 constituent for the considered mesh dimension -// MED_EN::medEntityMesh constituent_entity; -// switch (m_mesh_dimension) -// { -// case 3: -// constituent_entity= MED_EN::MED_FACE; -// break; -// case 2: -// constituent_entity = MED_EN::MED_EDGE; -// break; -// } - -// for (int iold=0; ioldgetCellNumber(iold); - -// const int* face_conn = initial_collection.getMesh(iold)-> -// getConnectivity(MED_EN::MED_FULL_INTERLACE, -// MED_EN::MED_DESCENDING,MED_EN::MED_CELL,MED_EN::MED_ALL_ELEMENTS); -// const int* face_offset = initial_collection.getMesh(iold)-> -// getConnectivityIndex(MED_EN::MED_DESCENDING,MED_EN::MED_CELL); -// MESSAGE_MED("end of connectivity calculation"); -// set global_treated; -// for (int icell=0; icellconvertCellToGlobal(iold,icell+1); -// int inew = getCellDomainNumber(global_cell_number); - -// for (int iface = face_offset[icell]; iface < face_offset[icell+1]; iface++) -// { -// int global_face_number=old_topology->convertFaceToGlobal(iold,abs(face_conn[iface-1])); -// if (global_treated.find (global_face_number)==global_treated.end()) -// { -// new_counts[inew]++; -// m_face_glob_to_loc.insert(make_pair(global_face_number,make_pair(inew,new_counts[inew]))); - -// //m_face_loc_to_glob.insert(make_pair(make_pair(inew,new_counts[inew]),global_face_number)); -// m_face_loc_to_glob[inew].push_back(global_face_number); -// global_treated.insert(global_face_number); - -// } -// } -// } -// } - - -// for (int inew=0;inew& type_connectivity, -// map& present_type_numbers, -// int idomain, -// MED_EN::medEntityMesh entity) -// { -// int dimension; -// switch (entity) -// { -// case MED_EN::MED_CELL: -// dimension=m_mesh_dimension; -// break; -// case MED_EN::MED_FACE: -// dimension=2; -// break; -// case MED_EN::MED_EDGE: -// dimension=1; -// break; -// } - -// MED_EN::MESH_ENTITIES::const_iterator currentEntity; -// list::const_iterator iter; -// currentEntity = MED_EN::meshEntities.find(MED_EN::MED_CELL); - -// for (iter = (*currentEntity).second.begin();iter != (*currentEntity).second.end(); iter++) -// { -// MED_EN::medGeometryElement type = (*iter); -// if (type/100 != dimension) continue; -// for (int inode=0; inodegetGlobal()<<" - "<getGlobal(),make_pair(idomain,ilocal))); -// m_face_loc_to_glob[idomain].push_back(face->getGlobal()); -// ilocal++; -// } -// } -// m_nb_faces[idomain] =ilocal-1; -// } -// } - -//================================================================================ -/*! - * \brief Recreating cell and node mapping after send-reveive and fusion of domain meshes - */ -//================================================================================ - -// void ParallelTopology::recreateMappingAfterFusion(const vector& meshes) -// { -// const char* LOC = "ParallelTopology::recreateMappingAfterFusion(): "; - -// m_glob_to_loc.clear(); -// m_node_glob_to_loc.clear(); -// m_face_glob_to_loc.clear(); - -// for (int idomain=0; idomaingetCoordinateptr() ) continue; // empty domian - -// //creating cell maps - -// m_nb_cells[idomain]=meshes[idomain]->getNumberOfElementsWithPoly(MED_EN::MED_CELL, -// MED_EN::MED_ALL_ELEMENTS); -// if ( m_cell_loc_to_glob_fuse[idomain].size() != m_nb_cells[idomain] ) -// throw MED_EXCEPTION(MEDMEM::STRING(LOC)<<" invalid nb of fused cells"); - -// m_loc_to_glob[idomain].swap( m_cell_loc_to_glob_fuse[idomain] ); - -// for (int i=0; igetNumberOfNodes(); -// m_node_loc_to_glob[idomain] = ((MEDMEM::MeshFuse*)meshes[idomain])->getNodeNumbers(); -// if ( m_node_loc_to_glob[idomain].size() != m_nb_nodes[idomain] ) -// throw MED_EXCEPTION(MEDMEM::STRING(LOC)<<" invalid nb of fused nodes"); - -// // setting mappings for all nodes -// for (int inode=0; inodegetNumberOfElementsWithPoly(constituent_entity, -// MED_EN::MED_ALL_ELEMENTS); -// if ( m_face_loc_to_glob_fuse[idomain].size() != m_nb_faces[idomain] ) -// throw MED_EXCEPTION(MEDMEM::STRING(LOC)<<" invalid nb of fused faces of domain "<< idomain -// << ": expect " << m_nb_faces[idomain] -// << " but have " << m_face_loc_to_glob_fuse[idomain].size()); - -// m_face_loc_to_glob[idomain].swap( m_face_loc_to_glob_fuse[idomain] ); - -// for (int iface=0; iface #include -#include -//#include "boost/shared_ptr.hpp" +#include "InterpKernelHashMap.hxx" #include "MEDPARTITIONER_Topology.hxx" -namespace __gnu_cxx +namespace INTERP_KERNEL { - template<> struct hash< pair > + template<> struct hash< std::pair > { - size_t operator()( const pair& x ) const + size_t operator()( const std::pair& x ) const { return hash< int >()( x.first*1000000+x.second ); } }; } -using namespace std; namespace MEDPARTITIONER { class Graph; @@ -76,43 +74,9 @@ namespace MEDPARTITIONER { void convertGlobalFaceList(const int*, int , int*, int); void convertGlobalFaceListWithTwins(const int* face_list, int nbface, int*& local, int*& ip, int*& full_array,int& size); - //!creating node mapping - -// void createNodeMapping(std::map& type_connectivity, -// std::map& present_type_numbers, -// std::vector& conn, -// std::vector& conn_index, -// std::vector& polyhedron_conn, -// std::vector& polyhedron_conn_index, -// std::vector& polyhedron_face_index, -// int idomain); - - // void createFaceMapping(std::map& type_connectivity, - // std::map& present_type_numbers, - // int idomain); - -// void createFaceMapping(const MESHCollection &, const MESHCollection&); -// void createFaceMapping2ndversion(const MESHCollection &); - // //!converting node global numberings to local numberings -// void convertToLocal(std::map& type_connectivity, -// std::map& present_type_numbers, -// int idomain, -// MED_EN::medEntityMesh entity); void convertToLocal2ndVersion(int* nodes, int nbnodes, int idomain); - - - //! computing arrays with node/node correspondencies - // void computeNodeNodeCorrespondencies(int nbdomain,std::vector& ) const; - - //! computing arrays with node/node correspondencies - // void computeCellCellCorrespondencies(int nbdomain,std::vector&, const Graph*) const; - - //! retrieving Graph - // boost::shared_ptr getGraph() const; - - //!converting node local numbering to global inline int convertNodeToGlobal(int ip,int icell) const { @@ -144,29 +108,18 @@ namespace MEDPARTITIONER { { for (int i=0; isecond; } inline void convertCellToGlobal(int ip, const int* local, int n, int* global)const { for (int i=0; isecond; } inline void convertFaceToGlobal(int ip, const int* local, int n, int* global)const { - for (int i=0; isecond; - } } inline int nbDomain() const @@ -198,8 +151,8 @@ namespace MEDPARTITIONER { inline int getNodeNumber() const { if (m_node_glob_to_loc.empty()) return 0; - set keys; - for (__gnu_cxx::hash_multimap >::const_iterator iter= m_node_glob_to_loc.begin(); + std::set keys; + for (INTERP_KERNEL::HashMultiMap >::const_iterator iter= m_node_glob_to_loc.begin(); iter!=m_node_glob_to_loc.end(); iter++) { keys.insert(iter->first); @@ -210,11 +163,8 @@ namespace MEDPARTITIONER { //!retrieving list of nodes in global numbers inline void getNodeList(int idomain, int* list) const { - for (int i=0; isecond; - } } //!< retrieving cell numbers after fusing in parallel mode @@ -253,10 +203,8 @@ namespace MEDPARTITIONER { inline void getCellList(int idomain, int* list) const { for (int i=0; isecond; - } + } @@ -268,8 +216,8 @@ namespace MEDPARTITIONER { inline int getFaceNumber() const { if (m_face_glob_to_loc.empty()) return 0; - set keys; - for (__gnu_cxx::hash_multimap >::const_iterator iter= m_face_glob_to_loc.begin(); + std::set keys; + for (INTERP_KERNEL::HashMultiMap >::const_iterator iter= m_face_glob_to_loc.begin(); iter!=m_face_glob_to_loc.end(); iter++) { keys.insert(iter->first); @@ -281,12 +229,8 @@ namespace MEDPARTITIONER { //!retrieving list of faces in global numbers inline void getFaceList(int idomain, int* list) const { - for (int i=0; isecond; - } - } //! converting a global cell number to a local representation (domain + local number) @@ -297,22 +241,17 @@ namespace MEDPARTITIONER { inline int convertGlobalFace(int iglobal, int idomain) { - typedef __gnu_cxx::hash_multimap >::const_iterator MMiter; + typedef INTERP_KERNEL::HashMultiMap >::const_iterator MMiter; std::pair eq = m_face_glob_to_loc.equal_range(iglobal); - for (MMiter it=eq.first; it != eq.second; it++) - { - // SCRUTE_MED (it->second.first); - //SCRUTE_MED (idomain); - if (it->second.first == idomain) return it->second.second; - - } + for (MMiter it=eq.first; it != eq.second; it++) + if (it->second.first == idomain) return it->second.second; return -1; } inline int convertGlobalNode(int iglobal, int idomain) { - typedef __gnu_cxx::hash_multimap >::const_iterator MMiter; - pair eq = m_node_glob_to_loc.equal_range(iglobal); + typedef INTERP_KERNEL::HashMultiMap >::const_iterator MMiter; + std::pair eq = m_node_glob_to_loc.equal_range(iglobal); for (MMiter it=eq.first; it != eq.second; it++) { if (it->second.first == idomain) return it->second.second; @@ -323,21 +262,13 @@ namespace MEDPARTITIONER { inline void appendFace(int idomain, int ilocal, int iglobal) { m_face_loc_to_glob[idomain].push_back(iglobal); - m_face_glob_to_loc.insert(make_pair(iglobal,make_pair(idomain,ilocal))); + m_face_glob_to_loc.insert(std::make_pair(iglobal,std::make_pair(idomain,ilocal))); } //return max global face number int getMaxGlobalFace() const; - //!recreating a face mapping from scratch - // void recreateFaceMapping(const TGeom2FacesByDomain& face_map); - - // recreating cell and node mapping after send-reveive and fusion of domain meshes - // virtual void recreateMappingAfterFusion(const std::vector& ); - - - private: bool hasCellWithNodes( const MESHCollection&, int dom, const std::set& nodes ); @@ -345,24 +276,15 @@ namespace MEDPARTITIONER { private: //!mapping global -> local - typedef __gnu_cxx::hash_map > TGlob2DomainLoc; - TGlob2DomainLoc m_glob_to_loc; + typedef INTERP_KERNEL::HashMultiMap > TGlob2DomainLoc; - // bool is_equal_pair (pair a, pair b){ - // return (a.first==b.first && a.second==b.second); - // } - //!mapping local -> global - //map,int> m_loc_to_glob; + TGlob2DomainLoc m_glob_to_loc; - // - //__gnu_cxx::hash_map,int, __gnu_cxx::hash > > m_loc_to_glob; std::vector > m_loc_to_glob; - //!mapping global -> local - __gnu_cxx::hash_multimap > m_node_glob_to_loc; + + INTERP_KERNEL::HashMultiMap > m_node_glob_to_loc; //!mapping local -> global - // map,int> m_node_loc_to_glob; - //__gnu_cxx::hash_map,int, __gnu_cxx::hash > > m_node_loc_to_glob; std::vector > m_node_loc_to_glob; // global numbers in parallel mode @@ -371,15 +293,12 @@ namespace MEDPARTITIONER { //!mapping global -> local - typedef __gnu_cxx::hash_multimap > TGlob2LocsMap; + typedef INTERP_KERNEL::HashMultiMap > TGlob2LocsMap; TGlob2LocsMap m_face_glob_to_loc; //!mapping local -> global - //__gnu_cxx::hash_map,int, __gnu_cxx::hash > > m_face_loc_to_glob; std::vector > m_face_loc_to_glob; - //map,int> m_face_loc_to_glob; - std::vector m_nb_cells; std::vector m_nb_nodes;