#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"
#include <string>
#include <limits>
-#ifndef WNT
-# include <ext/hash_map>
-#else
-# include <hash_map>
-#endif
#include <set>
#include <iostream>
using namespace std;
#endif
-//template inclusion
-//#include "MEDPARTITIONER_MESHCollection.txx"
MESHCollection::MESHCollection()
: _topology(0),
std::vector<std::vector<std::vector<int> > > 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());
std::vector<std::vector<std::vector<int> > > 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; inew<topology->nbDomain();inew++)
{
_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);
///////////////////////
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"<<iold<<" inew "<<inew<<" "<<splitMeshes[inew][iold]->getNumberOfCells()<<std::endl;
-
- }
+
if (_domain_selector->isMyDomain(inew))
- {
- _domain_selector->recvMesh(splitMeshes[inew][iold],_domain_selector->getProcessorID(iold));
- std::cout<<"recv iold"<<iold<<" inew "<<inew<<std::endl;
- }
+ _domain_selector->recvMesh(splitMeshes[inew][iold],_domain_selector->getProcessorID(iold));
+
}
}
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"<<meshes.size()<<std::endl;
if (!isParallelMode()||_domain_selector->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 "<<inew<<" "<<_mesh[inew]->getNumberOfCells()<<" cells"<<
- _mesh[inew]->getNumberOfNodes()<<" nodes"<<endl;
}
for (int i=0; i< splitMeshes[inew].size();i++)
if (splitMeshes[inew][i]!=0) splitMeshes[inew][i]->decrRef();
{
// std::map<pair<double,pair<double, double> >, int > nodeClassifier;
int nvertices=initialCollection.getMesh(iold)->getNumberOfNodes();
- cout <<"nvertices "<<nvertices<<endl;
bbox=new double[nvertices*6];
ParaMEDMEM::DataArrayDouble* coords = initialCollection.getMesh(iold)->getCoords();
double* coordsPtr=coords->getPointer();
- for (int i=0; i<nvertices;i++)
- cout<<"coords old "<<coordsPtr[3*i]<<" "<<coordsPtr[3*i+1]<<" "<<coordsPtr[3*i+2]<<endl;
for (int i=0; i<nvertices*3;i++)
{
for (int inew=0; inew<_topology->nbDomain(); inew++)
{
//sending meshes for parallel computation
- if (isParallelMode() && _domain_selector->isMyDomain(inew) && !_domain_selector->isMyDomain(iold))
- {
- std::cout<<"sendTo"<<_domain_selector->getProcessorID(iold)<<std::endl;
+ if (isParallelMode() && _domain_selector->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) <<std::endl;
_domain_selector->recvMesh(mesh, _domain_selector->getProcessorID(inew));
ParaMEDMEM::DataArrayDouble* coords = mesh->getCoords();
for (int inode=0; inode<mesh->getNumberOfNodes();inode++)
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)))
{
{
double* coordsPtr=coords->getPointer()+inode*3;
- cout<<"coords new "<<coordsPtr[0]<<" "<<coordsPtr[1]<<" "<<coordsPtr[2]<<endl;
std::vector<int> elems;
tree->getElementsAroundPoint(coordsPtr,elems);
- if (elems.size()==0) {cout<<"warning " <<inode<< endl;continue;}
+ if (elems.size()==0) continue;
nodeMapping.insert(make_pair(make_pair(iold,elems[0]),make_pair(inew,inode)));
- cout << "inode :" <<inode<<" ("<<iold<<","<<elems[0]<<")-->("<<inew<<","<<inode<<")"<<endl;
}
}
}
+ if (!isParallelMode() || (_domain_selector->isMyDomain(iold)))
+ {
+ delete tree;
+ delete[] bbox;
+ }
}
- std::cout<<"NodeMapping size"<<nodeMapping.size()<<std::endl;
}
for (int iold=0; iold<meshesCastFrom.size();iold++)
{
if (isParallelMode() && !_domain_selector->isMyDomain(iold)) continue;
- cout <<"-----------MESH OLD "<<iold<<"-----------"<<endl;
- cout <<meshesCastFrom[iold]->advancedRepr();
new2oldIds[iold].resize(newSize);
for (int ielem=0;ielem<meshesCastFrom[iold]->getNumberOfCells();ielem++)
{
meshesCastFrom[iold]->getNodeIdsOfCell(ielem,nodes);
map <int,int> faces;
- // cout<<"----------------"<<endl;
+
//analysis of element ielem
+ //counters are set for the element
+ //for each source node, the mapping is interrogated and the domain counters
+ //are incremented for each target node
+ //the face is considered as going to target domains if the counter of the domain
+ //is equal to the number of nodes
for (int inode=0;inode<nodes.size();inode++)
{
typedef multimap<pair<int,int>,pair<int,int> >::const_iterator MI;
int mynode=nodes[inode];
- if (mynode <0 || mynode > 1000000000) exit(1);
+
pair <MI,MI> myRange = nodeMapping.equal_range(make_pair(iold,mynode));
- // cout << iold <<" " <<nodes[inode]<<endl;
for (MI iter=myRange.first; iter!=myRange.second; iter++)
{
int inew=iter->second.first;
faces[inew]=1;
else
faces[inew]++;
- // cout<<"idomain" << iter->second.first<<" facemapping "<<faces[iter->second.first]<<endl;
}
}
//creating the splitMeshes from the face ids
for (int inew=0;inew<_topology->nbDomain();inew++)
{
- cout<<"nb faces - iold "<<iold<<" inew "<<inew<<" : "<<new2oldIds[iold][inew].size()<<endl;
splitMeshes[inew][iold]=(ParaMEDMEM::MEDCouplingUMesh*)(meshesCastFrom[iold]->buildPartOfMySelf(&new2oldIds[iold][inew][0],&new2oldIds[iold][inew][0]+new2oldIds[iold][inew].size(),true));
- cout << "split face Meshes "<<inew<<" "<<iold<<splitMeshes[inew][iold]->advancedRepr();
+ splitMeshes[inew][iold]->zipCoords();
}
}
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<ParaMEDMEM::MEDCouplingUMesh*>& meshesCastFrom,std::vector<ParaMEDMEM::MEDCouplingUMesh*>& meshesCastTo, std::vector<ParaMEDMEM::DataArrayInt*>& arrayFrom, std::vector<ParaMEDMEM::DataArrayInt*>& arrayTo, std::vector< std::vector< std::vector<int> > >& new2oldMapping)
+void MESHCollection::castIntField(std::vector<ParaMEDMEM::MEDCouplingUMesh*>& meshesCastFrom,std::vector<ParaMEDMEM::MEDCouplingUMesh*>& meshesCastTo, std::vector<ParaMEDMEM::DataArrayInt*>& arrayFrom, std::vector<ParaMEDMEM::DataArrayInt*>& arrayTo)
{
vector<vector<const ParaMEDMEM::DataArrayInt*> > splitIds;
splitIds.resize(meshesCastTo.size());
//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();
vector<int>sendIds(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<int> 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());
}
}
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);
+ vector<int>c;
+ vector<int> 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; itargetnode<targetMesh.getNumberOfCells();itargetnode++)
+ {
+ if (cI[itargetnode]==cI[itargetnode+1]) continue;
+ int isourcenode=c[cI[itargetnode]];
+ toArray[itargetnode]=fromArray[isourcenode];
+ }
+ sourceCoords->decrRef();
+ 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
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;}
}
void MESHCollection::write(const string& filename)
{
//building the connect zones necessary for writing joints
- cout<<"Building Connect Zones"<<endl;
// if (_topology->nbDomain()>1)
// buildConnectZones();
- cout <<"End of connect zones building"<<endl;
//suppresses link with driver so that it can be changed for writing
if (_driver!=0)delete _driver;
_driver=0;
if (revConn->getPointer()[i]<min) min=revConn->getPointer()[i];
if (revConn->getPointer()[i]>max) max=revConn->getPointer()[i];
}
- cout <<"min:"<<min<<" max:"<<max<<endl;
int* globalNodeIds=new int[_mesh[idomain]->getNumberOfNodes()];
_topology->getNodeList(idomain,globalNodeIds);
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<int,int>::iterator iter;
for (iter=commonDistantNodes[idomain][mydomain].begin();iter!=commonDistantNodes[idomain][mydomain].end();iter++)
{
int icell=iter->second;
node2cell.insert(make_pair(globalNodeIds[ilocnode],icell+offset));
- // cout<<"pair "<<globalNodeIds[ilocnode]<<" "<<icell+offset<<" "<<offset<<endl;
}
// }
}
mincell=0;
maxcell=_topology->nbCells();
}
- cout<<"mincell"<<mincell<<" maxcell "<<maxcell<<endl;
for (int inode=0; inode<_topology->nbNodes();inode++)
{
typedef multimap<int,int>::const_iterator MI;
cout<< "end of graph creation"<<endl;
}
-// /*! Method contributing to the distant cell graph
-// */
-// void MESHCollection::findCommonDistantNodes(vector<vector<multimap<int,int> > >& commonDistantNodes)
-// {
-// int nbdomain=_topology->nbDomain();
-// commonDistantNodes.resize(nbdomain);
-// for (int i=0; i<nbdomain;i++) commonDistantNodes[i].resize(nbdomain);
-// int nbproc=_domain_selector->nbProcs();
-// vector<BBTree<3>* > bbtree(nbdomain);
-// vector<ParaMEDMEM::DataArrayInt*> rev(nbdomain);
-// vector<ParaMEDMEM::DataArrayInt*>revIndx(nbdomain);
-// int meshDim;
-// int spaceDim;
-
-// for (int mydomain=0;mydomain<nbdomain;mydomain++)
-// {
-// if(! _domain_selector->isMyDomain(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;isource<nbdomain;isource++)
-// for (int itarget=0;itarget<nbdomain;itarget++)
-// {
-
-// if (_domain_selector->isMyDomain(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<double> 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<int> localCorrespondency;
-// _domain_selector->recvIntVec(localCorrespondency, targetProc);
-// cout<<"size "<<localCorrespondency.size()<<endl;
-// for (int i=0; i<localCorrespondency.size()/2;i++)
-// commonDistantNodes[isource][itarget].insert(make_pair(localCorrespondency[2*i],localCorrespondency[2*i+1]));
-
-// }
-// if (_domain_selector->isMyDomain(itarget))
-// {
-// //receiving data from source proc
-// int sourceProc = isource%nbproc;
-// std::vector<double> recvVec;
-// _domain_selector->recvDoubleVec(recvVec,sourceProc);
-// std::map<int,int> 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<spaceDim;i++)
-// {
-// bbox[2*i]=recvVec[inode*spaceDim+i]-1e-12;
-// bbox[2*i+1]=bbox[2*i]+2e-12;
-// }
-// vector<int> inodes;
-// bbtree[itarget]->getIntersectingElems(bbox,inodes);
-// delete[] bbox;
-
-// if (inodes.size()>0) commonNodes.insert(make_pair(inodes[0],inode));
-// }
-// std::vector<int> nodeCellCorrespondency;
-// for (map<int,int>::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];icell<revIndxPtr[iter->first+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
*
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";
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<MEDMEM::MEDSKYLINEARRAY*> node_node_correspondency;
-// node_node_correspondency.resize(_topology->nbDomain());
-
-// cout << "Computing node/node corresp"<<endl;
-
-// _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 node/node corresp"<<endl;
-
-// vector<MEDMEM::MEDSKYLINEARRAY*> 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<int>& loc_face_ids, int idomain, int idistant)
-// {
-// MEDMEM::MESHING* meshing = dynamic_cast<MEDMEM::MESHING*> (_mesh[idomain]);
-// MED_EN::medEntityMesh constituent_entity = getSubEntity();
-
-// MEDMEM::STRING jointname("joint_");
-// jointname<<idistant+1;
-
-// MEDMEM::GROUP * tmp_grp = new GROUP, * joint_group = tmp_grp;
-// // try to find already present group with such a name
-// // vector<MEDMEM::GROUP*> 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<MEDMEM::GROUP*> 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<MED_EN::medGeometryElement, vector<int> > joint_types;
-
-// int nbfaces = loc_face_ids.size();
-// for (int i=0; i<nbfaces; i++)
-// {
-// MED_EN::medGeometryElement type = meshing->getElementType(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<MED_EN::medGeometryElement, vector<int> >::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 <map <MED_EN::medGeometryElement, vector<MEDPARTITIONER_FaceModel*> > > face_map(_topology->nbDomain());
-// map< pair<int,int>, MEDMEM::MEDSKYLINEARRAY*> cell_corresp_here;
-
-// MED_EN::medEntityMesh constituent_entity = getSubEntity();
-
-// if ( isParallelMode() )
-// {
-// buildConnectZonesBetweenProcs(face_map, cell_corresp_here);
-// }
-
-// cout << "Computing node/node corresp"<<endl;
-
-// //Creating nodes
-// for (int idomain=0; idomain<_topology->nbDomain(); idomain++)
-// {
-
-// // constructing node/node correspondencies
-// vector<MEDMEM::MEDSKYLINEARRAY*> 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"<<endl;
-
-// //creating faces if required
-// if (_subdomain_boundary_creates)
-// {
-// int global_face_id = _topology->getFaceNumber()+1;
-// //int global_face_id = _topology->getMaxGlobalFace()+1;
-
-// map <pair<int,int>, vector<int> > 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 <int> nb_added_groups( _topology->nbDomain(), 0 );
-
-// for (int idomain=0; idomain<_topology->nbDomain(); idomain++)
-// {
-// vector<MEDMEM::MEDSKYLINEARRAY*> 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; ilocal<nbcells; ilocal++)
-// {
-// for (int icelldistant = index[ilocal]; icelldistant < index[ilocal+1]; icelldistant++)
-// {
-// int distant_id = value[icelldistant-1];
-// MEDPARTITIONER_FaceModel* face = getCommonFace(idomain,ilocal+1,idistant,distant_id,global_face_id);
-// face_map[idomain][face->getType()].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<medGeometryElement> types;
-// vector <int> nb_elems;
-// vector <int*> conn;
-
-// MEDMEM::MESHING* meshing = dynamic_cast<MEDMEM::MESHING*> (_mesh[idomain]);
-// if ( !meshing->getConnectivityptr() )
-// continue; // no cells in idomain
-
-// for (map <medGeometryElement, vector<MEDPARTITIONER_FaceModel*> >::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; ielem<nb_elem_in_type; ielem++)
-// {
-// for (int inode=0; inode<nb_node_per_type; inode++)
-// connectivity[ielem*nb_node_per_type+inode]=(*(iter->second)[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; itype<nbtypes; itype++)
-// {
-// meshing->setConnectivity(conn[itype], constituent_entity, types[itype]);
-// delete[]conn[itype];
-// }
-// for (int idistant =0; idistant<_topology->nbDomain(); idistant++)
-// {
-// map <pair<int,int>, vector<int> >::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<int> 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<nbtotalfaces+1;i++)
-// index[i]=0;
-// int*value=new int[nbfaces];
-
-// map<int,int> faces;
-// vector<int> local_faces( nbfaces );
-// for (int iface=0; iface<nbfaces; iface++)
-// {
-// int iglobal = (iter->second)[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<int,int>::const_iterator iter=faces.begin();
-// iter != faces.end();
-// iter++)
-// {
-// index[iter->first]=1;
-// value[iloc++]=iter->second;
-// }
-
-// for (int i=0; i<nbtotalfaces;i++)
-// index[i+1]+=index[i];
-// bool shallowcopy=true;
-// MEDMEM::MEDSKYLINEARRAY* skarray=new MEDMEM::MEDSKYLINEARRAY(nbtotalfaces,nbfaces,index,value,shallowcopy);
-
-// if (cz!=0)
-// cz->setEntityCorresp(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 <medGeometryElement, vector<MEDPARTITIONER_FaceModel*> >::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"<<endl;
-
-// //Creating cell/cell correspondencies
-// for (int idomain=0;idomain<_topology->nbDomain();idomain++)
-// {
-// vector<MEDMEM::MEDSKYLINEARRAY*> 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<int,int>, MEDMEM::MEDSKYLINEARRAY*> & cell_cell_correspondency_here)
-// {
-// using namespace MED_EN;
-
-// // graph over all procs
-// auto_ptr<Graph> 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 <list<int> > 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 <string, set<int> > group_map;
-// for (int idomain=0; idomain < old_collection._topology->nbDomain(); idomain++)
-// {
-// if ( !old_collection.getMesh(idomain) ) continue;
-// for (int igroup=0; igroup<old_collection.getMesh(idomain)->getNumberOfGroups(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 <int> igroupold(old_collection._topology->nbDomain(),0);
-// map<string,set<int> >::const_iterator iter=group_map.begin();
-
-// for (int igroup=0; igroup<nbgroups; igroup++)
-// {
-// vector <const MEDMEM::SUPPORT*> 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<int>::iterator iter=group_map[group_name].begin(); iter!=group_map[group_name].end(); iter++)
-// // cout << *iter<<" ";
-// // cout <<endl;
-// if (group_map[group_name].find(idomain)==group_map[group_name].end()) continue;
-
-// //retrieves the group igroup on domain idomain
-// MEDMEM::GROUP* group = (old_collection.getMesh(idomain)->getGroups(entities[ientity]))[igroupold[idomain]];
-// old_supports[idomain] = static_cast<const MEDMEM::SUPPORT*> (group);
-// igroupold[idomain]++;
-// }
-
-// vector <MEDMEM::GROUP*>new_groups(_topology->nbDomain());
-// vector <MEDMEM::SUPPORT*> new_supports(_topology->nbDomain());
-// for (int i=0; i<_topology->nbDomain(); i++)
-// {
-// new_groups[i]=new MEDMEM::GROUP();
-// new_supports[i]=static_cast<MEDMEM::SUPPORT*>(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<MEDMEM::MESHING*> (_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<const MEDMEM::SUPPORT*>& old_support, vector<MEDMEM::SUPPORT*>& new_support)
-// {
-
-// if (old_collection._topology->nbDomain() != old_support.size())
-// {
-// throw MED_EXCEPTION(STRING("Error : wrong call to MESHCollection::castSupport"));
-// }
-// vector <list<int> > 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 <string> 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<nbelem;i++)
-// list_of_elems[i]=i+1;
-// }
-// else
-// list_of_elems = const_cast<int*> (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; i<nbelem; i++)
-// // cell_arrays[ip[i]][local[i]]=id;
-// {
-// // cout <<"(glob,ip,iloc)/nbelem"<<array[i]<<" "<<ip[i]<<" "<<local[i]<<"/"<<nbelem<<endl;
-// element_array[ip[i]].push_back(local[i]);
-// }
-// break;
-// case MED_EN::MED_FACE :
-// case MED_EN::MED_EDGE :
-// old_collection.getTopology()->convertFaceToGlobal(idomain,list_of_elems,nbelem,array);
-// _topology->convertGlobalFaceListWithTwins(array,nbelem,local,ip,full_array,size);
-// for (int i=0; i<size; i++)
-// element_array[ip[i]].push_back(local[i]);
-// delete[] full_array;
-// break;
-// case MED_EN::MED_NODE :
-// old_collection.getTopology()->convertNodeToGlobal(idomain,list_of_elems,nbelem,array);
-// _topology->convertGlobalNodeListWithTwins(array,nbelem,local,ip,full_array,size);
-// for (int i=0; i<size; i++)
-// element_array[ip[i]].push_back(local[i]);
-// delete[] full_array;
-// break;
-
-// }
-// delete[] ip;
-// delete[] local;
-// delete[] array;
-
-// if (support->isOnAllElements()) 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<ParaMEDMEM::TypeOfField> fieldTypes =MEDLoader::GetTypesOfField(fileName, fieldName,meshName);
-
-// }
-
-// void MESHCollection::castAllFields(const MESHCollection& initial_collection)
-// {
-// vector <string> field_names;
-// vector <int> iternumber;
-// vector <int> ordernumber;
-// vector <int> types;
-
-// string filename=initial_collection.getDriver()->getFilename();
-// field_names=MEDLoader::GetAllFieldNames(filename.c_str());
-
-// readFileStruct(field_names,iternumber,ordernumber,types);
-
-// for (int i=0; i<field_names.size(); i++)
-// {
-// char field_char[80];
-// strcpy(field_char,field_names[i].c_str());
-
-// castFieldDouble(initial_collection, field_char, iternumber[i], ordernumber[i]);
-// }
-// }
-
-// //! \param initial_collection mesh collection before the redistribution stage
-// //! \param idomain domain number on the new collection
-// //! \param entity dimension of the treated nodes (0 : cell, 1 : face in 3d, edge in 2d, 2: edge in 3d)
-// void MESHCollection::createNodalConnectivity(const MESHCollection& initial_collection,int idomain, int entity)
-// {
-
-
-// int dimension=0;
-// int nb_elems=0;
-// ParaMEDMEM::MEDCouplingUMesh* mesh_builder = m_mesh[idomain];
-
-// //creating arrays for storing global numbers and cell types
-// switch (entity)
-// {
-// case MED_EN::MED_CELL:
-// dimension=initial_collection.getMeshDimension();
-// nb_elems=m_topology->getCellNumber(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 "<<endl;
-// //retrieving global id list
-// switch (entity)
-// {
-// case MED_EN::MED_CELL:
-// m_topology->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"<<endl;
-// //vector containing the number of cells per type
-// type_numbers.clear();
-// for (int icell=0; icell<nb_elems; icell++)
-// {
-// map<MED_EN::medGeometryElement,int>::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"<<type_numbers[304]<<endl;
-// int nb_present_types=type_numbers.size();
-
-// //setting the list of cells for each type
-// map<MED_EN::medGeometryElement,int> index;
-
-// map<MED_EN::medGeometryElement,int*> type_cell_list;
-
-// MED_EN::MESH_ENTITIES::const_iterator currentEntity;
-// std::map<MED_EN::medGeometryElement,int>::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 :"<<type<<" nb:"<<type_numbers[type]<<endl;
-// }
-
-// for (int icell=0; icell<nb_elems; icell++)
-// {
-// type_cell_list[cell_type_list[icell]][index[cell_type_list[icell]]++]=list[icell];
-// }
-
-// delete[]list;
-// delete[]cell_type_list;
-
-// //setting the list of present ypes
-// int* present_type_numbers=new int[nb_present_types];
-// MED_EN::medGeometryElement* type_array = new MED_EN::medGeometryElement[nb_present_types];
-// MESSAGE_MED("Nb de types presents "<<nb_present_types);
-// int itype=0;
-// for (iter = type_numbers.begin();iter != type_numbers.end(); iter++)
-// {
-// MED_EN::medGeometryElement type = iter->first;
-// if (!isDimensionOK(type,dimension)) continue;
-
-// type_array[itype]=type;
-
-// present_type_numbers[itype]=type_numbers[type];
-
-// MESSAGE_MED("Nombre d'elements de type "<<type<<" : "<<type_numbers[type]);
-// itype++;
-// }
-
-// //retrieving connectivity in global numbering for each typeinitial_collection.getMesh(iold)->get
-// map<MED_EN::medGeometryElement,int*> type_connectivity;
-// vector<int> polygon_conn;
-// vector<int> polygon_conn_index;
-// vector<int> polyhedron_conn;
-// vector<int> polyhedron_conn_index;
-// vector<int> 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 <<" : "<<nbnode);
-
-// double* coordinates=new double[initial_collection.getSpaceDimension()*nbnode];
-// int* node_list=new int[nbnode];
-// m_topology->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<MED_EN::medGeometryElement, vector<MEDPARTITIONER_FaceModel*> >& 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<int*> (_mesh[idomain]->getConnectivity(MED_EN::MED_FULL_INTERLACE,MED_EN::MED_NODAL,constituent_entity, MED_EN::MED_ALL_ELEMENTS));
-// for (int itype=0; itype<nbtypes; itype++)
-// {
-// for (int iface=global_numbering[itype]; iface<global_numbering[itype+1]; iface++)
-// {
-// MEDPARTITIONER_FaceModel* face_model = new MEDPARTITIONER_FaceModel();
-// MED_EN::medGeometryElement type = types[itype];
-// face_model->setType(type);
-// int nbnodes = type%100;
-// face_model->setNbNodes(nbnodes);
-// face_model->setGlobal(_topology->convertFaceToGlobal(idomain,iface));
-// for (int i=0; i<nbnodes; i++)
-// {
-// (*face_model)[i]=*conn++;
-// }
-// face_map[type].push_back(face_model);
-// }
-// }
-// }
-
-// /*! retrieves the face that is common to two cells located on two different processors
-// *
-// * \param ip1 domain id for cell 1
-// * \param ilocal1 cell id for cell 1
-// * \param ip2 domain id for cell 2
-// * \param ilocal2 cell id for cell 2
-// * \param face_index global index for the newly created face
-// */
-// MEDPARTITIONER_FaceModel* MESHCollection::getCommonFace(int ip1,int ilocal1,int ip2,int ilocal2,int face_index)
-// {
-// MED_EN::medGeometryElement type1 = _mesh[ip1]->getElementType(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<int> nodes1, nodes1_local;
-// vector<int> nodes2;
-// for (int i= conn_index1[ilocal1-1]; i<conn_index1[ilocal1]; i++)
-// {
-// nodes1.push_back(_topology->convertNodeToGlobal(ip1,*(conn1+i-1)));
-// nodes1_local.push_back( conn1[i-1] );
-// }
-// for (int i= conn_index2[ilocal2-1]; i<conn_index2[ilocal2]; i++)
-// nodes2.push_back(_topology->convertNodeToGlobal(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<nbfaces)
-// {
-// //SCRUTE_MED (iface);
-// int nbnodes= types[iface]%100;
-// const int* nodes = celltype1.getNodesConstituent(1,iface+1);
-// int common_nodes=0;
-// for (int i=0; i<nbnodes;i++)
-// {
-// for (int i2=0; i2<nb_nodes2; i2++)
-// {
-// if (nodes1[nodes[i]-1]==nodes2[i2]) common_nodes++;
-// }
-// }
-// if (common_nodes>=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; i<nbnodes; i++)
-// (*face_model)[i]=nodes1_local[faces[iface][i]-1];
-
-// return face_model;
-// }
void MESHCollection::setDomainNames(const std::string& name)
{
for (int i=0; i<_topology->nbDomain(); i++)
//creates faces on the new collection
void castMeshes(std::vector<ParaMEDMEM::MEDCouplingUMesh*>& meshCastFrom,std::vector<ParaMEDMEM::MEDCouplingUMesh*>& meshCastTo, MESHCollection& initialCollection,const std::multimap<std::pair<int,int>,std::pair<int,int> >& nodeMapping, std::vector<std::vector<std::vector<int> > >& old2newIds);
-
- //!transfers families from an old MESHCollection to new mesh
- // void castFamilies(const MESHCollection& old_collection);
-
- //void castSupport(const MESHCollection& old_collection, std::vector<const MEDMEM::SUPPORT*>& old_support, std::vector<MEDMEM::SUPPORT*>& 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 <std::map <MED_EN::medGeometryElement, std::vector<MEDPARTITIONER_FaceModel*> > > &, map< pair<int,int>, MEDPARTITIONER::MEDSKYLINEARRAY*> & local_cell_cell_correspondency);
-
-// void addJointGroup(const std::vector<int>&, 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<ParaMEDMEM::MEDCouplingUMesh*>& meshesCastFrom,std::vector<ParaMEDMEM::MEDCouplingUMesh*>& meshesCastTo, std::vector<ParaMEDMEM::DataArrayInt*>& arrayFrom, std::vector<ParaMEDMEM::DataArrayInt*>& arrayTo, std::vector<std::vector< std::vector<int> > > & old2newMapping);
+ void castIntField(std::vector<ParaMEDMEM::MEDCouplingUMesh*>& meshesCastFrom,std::vector<ParaMEDMEM::MEDCouplingUMesh*>& meshesCastTo, std::vector<ParaMEDMEM::DataArrayInt*>& arrayFrom, std::vector<ParaMEDMEM::DataArrayInt*>& arrayTo);
void findCommonDistantNodes(std::vector<std::vector<std::multimap<int,int> > >& commonDistantNodes);
- // template <class T>
- // void castFields(const MESHCollection& old_collection, const string& fieldname, int itnumber, int ordernumber);
-
- // void getFaces(int idomain, std::map<MED_EN::medGeometryElement, std::vector<MEDPARTITIONER_FaceModel*> >&);
-
-// MEDPARTITIONER_FaceModel* getCommonFace(int ip1,int ilocal1,int ip2,int ilocal2,int face_index);
-// template<class TID2CONN>
-// 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;
vector<int*>& faceglobal,
vector<int*>& 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]<<endl;
- //(_collection->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);
_collection->getGroupInfo()=mfm->getGroupInfo();
cout <<"End of Read"<<endl;
- //reading MEDPARTITIONER::CONNECTZONEs NODE/NODE and CELL/CELL
- // med_idt fid = MEDouvrir(file,MED_LECTURE);
- // med_int njoint = MEDnJoint(fid, meshname);
- // for (int ijoint=0; ijoint<njoint; ijoint++)
- // {
- // int distant;
- // char joint_description[MED_TAILLE_DESC+1];
- // char name[MED_TAILLE_NOM+1];
- // char name_distant[MED_TAILLE_NOM+1];
-
- // int ncorr = MEDjointInfo(fid,meshname, ijoint+1, name,
- // joint_description,
- // &distant, name_distant);
-
- // for (int ic=0; ic<ncorr; ic++)
- // {
- // med_entite_maillage cor_typent_local;
- // med_geometrie_element cor_typgeo_local;
- // med_entite_maillage cor_typent_dist;
- // med_geometrie_element cor_typgeo_dist;
-
-
- // int ncouples;
- // ncouples = MEDjointTypeCorres(fid, meshname, name, ic+1,
- // &cor_typent_local, &cor_typgeo_local,
- // &cor_typent_dist, &cor_typgeo_dist
- // );
- // int* node_corresp=new int[ncouples];
- // if (cor_typent_local == MED_NOEUD && cor_typent_dist == MED_NOEUD)
- // {
-
- // MEDjointLire(fid, meshname, name,
- // node_corresp,ncouples,
- // cor_typent_local, cor_typgeo_local,
- // cor_typent_dist, cor_typgeo_dist
- // );
- // }
- // //constructing the connect zone and adding it to the connect zone list
- // MEDPARTITIONER::CONNECTZONE* cz = new MEDPARTITIONER::CONNECTZONE();
- // cz->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 "<<endl;
-
-// /////////////////////////////////////////
-// //writing node/node correspondency
-// /////////////////////////////////////////
-// int nbnodes=(_collection->getCZ())[icz]->getNodeNumber();
-// int* node_corresp=const_cast<int*>((_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 (idomain<idistant)
-// // jointSort(node_corresp, nbnodes, true);
-// // else
-// // jointSort(node_corresp, nbnodes, false);
-
-// error=
-// MEDjointEcr(fid, mesh_name, joint_name, node_corresp, nbnodes,
-// MED_NOEUD, MED_POINT1,MED_NOEUD, MED_POINT1);
-// if (error==-1) cout << "erreur creation de joint "<<endl;
-
-// //writing cell/cell joint
-// // writeElementJoint(MED_EN::MED_CELL, icz, idomain, idistant, mesh_name,joint_name,fid);
-// //writing face/face joint
-// // if (_collection->getSubdomainBoundaryCreates())
-// // {
-// // 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<const ParaMEDMEM::MEDCouplingUMesh*> meshes;
+ ParaMEDMEM::MEDCouplingUMesh* cellMesh=_collection->getMesh(idomain);
+ ParaMEDMEM::MEDCouplingUMesh*faceMesh =_collection->getFaceMesh(idomain);
-
-// MEDfermer(fid);
- std::cout<<"End of writing"<<std::endl;
-
+ meshes.push_back(cellMesh);
+ // faceMesh->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);
}
#define MEDPARTITIONER_MESHCOLLECTIONDRIVER_HXX_
#include "MEDPARTITIONER.hxx"
+#include <string>
namespace MEDPARTITIONER
{
void readSubdomain(vector<int*>& cellglobal,
vector<int*>& faceglobal,
vector<int*>& 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,
// Author : Edward AGAPOV (eap)
#include "MEDCouplingUMesh.hxx"
-#include "MEDMEM_Exception.hxx"
+
#include "MEDPARTITIONER_ParaDomainSelector.hxx"
#include "MEDPARTITIONER_UserGraph.hxx"
-//#include "MEDPARTITIONER_JointExchangeData.hxx"
-
-//#include <MEDMEM_Meshing.hxx>
-#include <MEDMEM_DriversDef.hxx>
-#include <iostream>
#include <numeric>
#ifdef HAVE_MPI2
//================================================================================
int ParaDomainSelector::gatherNbOf(
- //MED_EN::medEntityMesh entity,
const vector<ParaMEDMEM::MEDCouplingUMesh*>& domain_meshes)
{
evaluateMemory();
*/
//================================================================================
-#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
return auto_ptr<Graph>( 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<ParaMEDMEM::MEDCouplingUMesh*>& domain_meshes,
-// MED_EN::medEntityMesh entity)
-// {
-// const list<medGeometryElement> & 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<int> 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<medGeometryElement>::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<medGeometryElement>::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();
-// }
//================================================================================
/*!
// 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<int> 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
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 )
{
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();
-// }
//================================================================================
/*!
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
{
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
{
MPI_Recv(ptDist2, nbDistElem, MPI_DOUBLE,source, 1110, MPI_COMM_WORLD, &status);
#endif
//
- //mesh=dynamic_cast<ParaMEDMEM::MEDCouplingUMesh*> (distant_mesh_tmp);
//finish unserialization
mesh->unserialization(tinyInfoDistantD,tinyInfoDistant,v1Distant,v2Distant,unusedTinyDistantSts);
- std::cout<<"mesh size on recv"<<mesh->getNumberOfCells()<<std::endl;
- //
+
if(v1Distant)
v1Distant->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<double>& vec, int target)const
{
int size=vec.size();
MPI_Send(const_cast<double*>(&vec[0]), size,MPI_DOUBLE, target, 1212, MPI_COMM_WORLD);
#endif
}
+/*! Receives messages from proc \a source to fill vector<int> 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<double>& vec, int source)const
{
int size;
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<int>& vec, int target)const
{
int size=vec.size();
MPI_Send(const_cast<int*>(&vec[0]), size,MPI_INT, target, 1212, MPI_COMM_WORLD);
#endif
}
+/*! Receives messages from proc \a source to fill vector<int> 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<int>& vec, int source)const
{
int size;
// 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<Graph> gatherGraph(const Graph* graph) const;
- // Set types and number of elements of the entity to all meshes
-// void gatherEntityTypesInfo(std::vector<ParaMEDMEM::MEDCouplingUMesh*>& 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 );
#include <set>
#include <map>
#include <vector>
-#ifndef WNT
-# include <ext/hash_map>
-#else
-# include <hash_map>
-#endif
+#include "InterpKernelHashMap.hxx"
#include "MEDPARTITIONER_MESHCollection.hxx"
#include "MEDPARTITIONER_Topology.hxx"
#include "MEDPARTITIONER_Graph.hxx"
for (int i=0; i<m_nb_cells[idomain]; i++)
{
- m_glob_to_loc[index_global]=make_pair(idomain,i);
- //m_loc_to_glob[make_pair(idomain,i+1)]=index_global;
+ m_glob_to_loc.insert(make_pair(index_global,make_pair(idomain,i+1)));
m_loc_to_glob[idomain][i]=index_global;
// cout<<"glob:"<<index_global<<" --> ("<<idomain<<","<<i+1<<")"<<endl;
index_global++;
for (int i=0; i<m_nb_cells[idomain]; i++)
{
int global=cellglobal[idomain][i];
- m_glob_to_loc[global]=make_pair(idomain,i);
+ m_glob_to_loc.insert(make_pair(global,make_pair(idomain,i)));
//m_loc_to_glob[make_pair(idomain,i+1)]=global;
m_loc_to_glob[idomain][i]=global;
index_global++;
for (int i=0; i<meshes[idomain]->getNumberOfNodes(); 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; i<nbfaces; i++)
-// {
-// m_face_glob_to_loc.insert(make_pair(i+1,make_pair(0,i+1)));
-// //m_face_loc_to_glob.insert(make_pair(make_pair(0,i+1), i+1));
-// m_face_loc_to_glob[0][i]=i+1;
-// }
-// m_nb_total_faces=nbfaces;
-// m_nb_faces[0]=nbfaces;
MESSAGE_MED ("nb total cells "<< m_nb_total_cells);
MESSAGE_MED("nb total nodes "<< m_nb_total_nodes);
- // MESSAGE_MED("nb total faces "<< m_nb_total_faces);
return;
}
//creating node maps
m_nb_nodes[idomain]=meshes[idomain]->getNumberOfNodes();
- hash_map <int,pair<int,int> > local2distant;
+ INTERP_KERNEL::HashMap <int,pair<int,int> > local2distant;
m_node_loc_to_glob[idomain].resize(m_nb_nodes[idomain]);
for (int icz=0; icz<cz.size(); 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 << "("<<idomain<<","<<i+1<<")->"<<i+1<<endl;
+ {
for (int inode=0; inode<m_nb_nodes[idomain]; inode++)
{
int global_number=nodeglobal[idomain][inode];
- // cout << "global_number "<<global_number<<endl;
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;
}
}
-
-
- //creating dimension d-1 component mappings
-
- // meshes[idomain]->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<<m_nb_faces[idomain]);
-// m_face_loc_to_glob[idomain].resize(m_nb_faces[idomain]);
-// local2distant.clear();
-// for (int icz=0; icz<cz.size(); icz++)
-// {
-// if (cz[icz]->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; iface<m_nb_faces[idomain]; iface++)
-// {
-// if (local2distant.find(iface+1)==local2distant.end())
-// {
-// index_face_global++;
-// m_face_glob_to_loc.insert(make_pair(index_face_global,make_pair(idomain,iface+1)));
-// //m_face_loc_to_glob[make_pair(idomain,iface+1)]=index_face_global;
-// m_face_loc_to_glob[idomain][iface]=index_face_global;
-// }
-// else
-// {
-// int ip = (local2distant.find(iface+1)->second).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<m_nb_faces[idomain]; iface++)
-// {
-// int global_number=faceglobal[idomain][iface];
-// //cout << "dom: "<< idomain << " read glob face " << global_number << endl;
-// //SCRUTE_MED(global_number);
-// 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;
-// }
-// }
-
}
m_nb_total_cells=index_global;
m_nb_cells[idomain]++;
//m_loc_to_glob[make_pair(idomain,m_nb_cells[idomain])]=icell+1;
m_loc_to_glob[idomain].push_back(icell);
- m_glob_to_loc[icell]=make_pair(idomain,m_nb_cells[idomain]);
+ m_glob_to_loc.insert(make_pair(icell,make_pair(idomain,m_nb_cells[idomain])));
}
for (int idomain=0; idomain<m_nb_domain; idomain++)
for (int i=0; i< nbnode; i++)
{
- typedef hash_multimap<int,pair<int,int> >::iterator mmiter;
+ typedef INTERP_KERNEL::HashMultiMap<int,pair<int,int> >::iterator mmiter;
pair<mmiter,mmiter> range=m_node_glob_to_loc.equal_range(node_list[i]);
for (mmiter it=range.first; it !=range.second; it++)
{
full_array=new int[size];
for (int i=0; i< nbnode; i++)
{
- typedef hash_multimap<int,pair<int,int> >::iterator mmiter;
+ typedef INTERP_KERNEL::HashMultiMap<int,pair<int,int> >::iterator mmiter;
pair<mmiter,mmiter> range=m_node_glob_to_loc.equal_range(node_list[i]);
for (mmiter it=range.first; it !=range.second; it++)
{
full_array=new int[size];
for (int i=0; i< nbface; i++)
{
- typedef hash_multimap<int,pair<int,int> >::iterator mmiter;
+ typedef INTERP_KERNEL::HashMultiMap<int,pair<int,int> >::iterator mmiter;
pair<mmiter,mmiter> range=m_face_glob_to_loc.equal_range(face_list[i]);
for (mmiter it=range.first; it !=range.second; it++)
{
{
for (int i=0; i< nbcell; i++)
{
- hash_map<int, pair<int,int> >::const_iterator iter = m_glob_to_loc.find(cell_list[i]);
+ INTERP_KERNEL::HashMap<int, pair<int,int> >::const_iterator iter = m_glob_to_loc.find(cell_list[i]);
ip[i]=(iter->second).first;
local[i]=(iter->second).second;
}
{
for (int i=0; i< nbface; i++)
{
- hash_map<int, pair<int,int> >::const_iterator iter = m_face_glob_to_loc.find(face_list[i]);
+ INTERP_KERNEL::HashMap<int, pair<int,int> >::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");
{
for (int i=0; i< nbface; i++)
{
- typedef hash_multimap<int,pair<int,int> >::iterator mmiter;
+ typedef INTERP_KERNEL::HashMultiMap<int,pair<int,int> >::iterator mmiter;
pair<mmiter,mmiter> range=m_face_glob_to_loc.equal_range(face_list[i]);
for (mmiter it=range.first; it !=range.second; it++)
{
}
-////creating node mapping
-// void ParallelTopology::createNodeMapping(map<MED_EN::medGeometryElement,int*>& type_connectivity,
-// map<MED_EN::medGeometryElement,int>& present_type_numbers,
-// vector<int>& polygon_conn,
-// vector<int>& polygon_conn_index,
-// vector<int>& polyhedron_conn,
-// vector<int>& polyhedron_conn_index,
-// vector<int>& polyhedron_face_index,
-// int idomain)
-// {
-// set<int> local_numbers;
-// int local_index=0;
-
-// map<MED_EN::medGeometryElement,int>::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<present_type_numbers[type]; icell++)
-// {
-// for (int inode=0; inode<nodes_per_type; inode++)
-// {
-// int global=type_connectivity[type][icell*nodes_per_type+inode];
-// if(local_numbers.find(global)==local_numbers.end())
-// {
-// local_index++;
-// local_numbers.insert(global);
-// //m_node_loc_to_glob.insert(make_pair(make_pair(idomain,local_index),global));
-// m_node_loc_to_glob[idomain].push_back(global);
-// m_node_glob_to_loc.insert(make_pair(global,make_pair(idomain,local_index)));
-// // cout << "node : global ="<<global<<" local =("<<idomain<<","<<local_index<<")"<<endl;
-// }
-// }
-
-// }
-// }
-// else if (type== MED_EN::MED_POLYGON)
-// {
-// for (int icell=0; icell<polygon_conn_index.size()-1; icell++)
-// {
-// for (int inode=polygon_conn_index[icell]; inode<polygon_conn_index[icell+1]; inode++)
-// {
-// int global=polygon_conn[inode-1];
-// if(local_numbers.find(global)==local_numbers.end())
-// {
-// local_index++;
-// local_numbers.insert(global);
-// //m_node_loc_to_glob.insert(make_pair(make_pair(idomain,local_index),global));
-// m_node_loc_to_glob[idomain].push_back(global);
-// m_node_glob_to_loc.insert(make_pair(global,make_pair(idomain,local_index)));
-// // cout << "node : global ="<<global<<" local =("<<idomain<<","<<local_index<<")"<<endl;
-// }
-// }
-
-// }
-// }
-// else if (type==MED_EN::MED_POLYHEDRA)
-// {
-// for (int icell=0; icell<polyhedron_conn_index.size()-1; icell++)
-// {
-// for (int iface = polyhedron_conn_index[icell];
-// iface < polyhedron_conn_index[icell+1];
-// iface++)
-// for (int inode=polyhedron_face_index[iface-1];
-// inode<polyhedron_face_index[iface]; inode++)
-// {
-// int global=polyhedron_conn[inode-1];
-// if(local_numbers.find(global)==local_numbers.end())
-// {
-// local_index++;
-// local_numbers.insert(global);
-// //m_node_loc_to_glob.insert(make_pair(make_pair(idomain,local_index),global));
-// m_node_loc_to_glob[idomain].push_back(global);
-// m_node_glob_to_loc.insert(make_pair(global,make_pair(idomain,local_index)));
-// // cout << "node : global ="<<global<<" local =("<<idomain<<","<<local_index<<")"<<endl;
-// }
-// }
-
-
-// }
-// }
-
-// }
-// m_nb_nodes[idomain]=local_index;
-// }
-
-//================================================================================
-/*!
- * \brief Return true if the domain mesh contains a cell based on given global nodes
- */
-//================================================================================
-
-// bool ParallelTopology::hasCellWithNodes( const MESHCollection& new_collection,
-// int domain,
-// const set<int>& globNodes)
-// {
-// // convert global nodes to local in the given domain
-// set<int> nodes;
-// set<int>::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<MED_EN::medGeometryElement,int*>& type_list,
-// // map<MED_EN::medGeometryElement,int>& present_type_numbers,
-// // int idomain
-
-// {
-// // containers for the new topology
-// vector<int> new_counts(m_nb_domain,0);
-// vector<int> 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 <pair<int, pair<int,int> > > 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; iold<nb_domain_old;iold++)
-// {
-// if ( !initial_collection.getMesh(iold) ) continue;
-// int nbplainface = initial_collection.getMesh(iold)->getNumberOfElements(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;iface<nbtotalface; iface++)
-// {
-// int global_face_number = old_topology->convertFaceToGlobal(iold,iface+1);
-
-// // int inode = face_offset[iface];
-// for (int i=0; i<m_nb_domain; i++) domain_counts[i]=0;
-// set <int> nodes;
-// int nbnodes;
-// if (iface<nbplainface)
-// {
-// nbnodes=face_offset[iface+1]-face_offset[iface];
-// for (int inode= face_offset[iface];inode < face_offset[iface+1]; inode++)
-// {
-// int node=face_conn[inode-1];
-
-// int global = old_topology->convertNodeToGlobal(iold,node);
-// // cout << "global node "<<global<<"ip "<<iold<< "noeud"<<node<<endl;
-// nodes.insert(global);
-// typedef hash_multimap<int,pair<int,int> >::iterator mmiter;
-// pair<mmiter,mmiter> 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 "<<global<<"ip "<<iold<< "noeud"<<node<<endl;
-// // SCRUTE_MED(global);
-// nodes.insert(global);
-// typedef hash_multimap<int,pair<int,int> >::iterator mmiter;
-// pair<mmiter,mmiter> 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<int>::const_iterator iter_node = nodes.begin();
-// int numbers[3];
-// numbers[2]=0; // for segments
-// for (int i=0; i<nbnodes; i++)
-// {
-// numbers[i]=*iter_node;
-// iter_node++;
-// }
-// set <pair<int, pair<int,int> > > ::iterator iter_triplets;
-// pair<int, pair<int,int> > 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<m_nb_domain;inew++)
-// {
-// // SCRUTE_MED(domain_counts[inew]);
-// if(domain_counts[inew]==nbnodes)
-// {
-// if ( !hasCellWithNodes( new_collection, inew, nodes ))
-// continue; // 0020861: EDF 1387 MED: Result of medsplitter gives standalone triangles
-
-// 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);
-// }
-// }
-// //cout << "global_face_number = " << global_face_number << endl;
-// }
-// }
-// }
-
-// for (int inew=0;inew<m_nb_domain;inew++)
-// {
-// m_nb_faces[inew]=new_counts[inew];
-// MESSAGE_MED(" Nb faces ["<<inew<<"]="<<m_nb_faces[inew]);
-// }
-// MESSAGE_MED(" total number of faces"<<getFaceNumber());
-// }
-
-////creating node mapping
-// void ParallelTopology::createFaceMapping2ndversion(const MESHCollection& initial_collection)
-
-// {
-// // containers for the new topology
-// vector<int> new_counts(m_nb_domain,0);
-// vector<int> 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 <pair<int, pair<int,int> > > 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; iold<nb_domain_old;iold++)
-// {
-// int nbcell=old_topology->getCellNumber(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<int> global_treated;
-// for (int icell=0; icell<nbcell; icell++)
-// {
-// int global_cell_number=old_topology->convertCellToGlobal(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<m_nb_domain;inew++)
-// {
-// m_nb_faces[inew]=new_counts[inew];
-// // cout << " Nb faces ["<<inew<<"]="<<m_nb_faces[inew]<<endl;
-// }
-// MESSAGE_MED(" total number of faces"<<getFaceNumber());
-// }
-
-
-//replacing a table of global numbering with a table with local numberings
-// type_connectivity contains global connectivity for each type in input
-// type_connectivity contains local connectivity for each type in output
-// void ParallelTopology::convertToLocal(map<MED_EN::medGeometryElement,int*>& type_connectivity,
-// map<MED_EN::medGeometryElement,int>& 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<MED_EN::medGeometryElement>::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; inode<present_type_numbers[type]*(type%100); inode++)
-// {
-// // cout <<" inode :"<<inode<< " global = "<<type_connectivity[type][inode];
-// int global = type_connectivity[type][inode];
-// typedef hash_multimap<int,pair<int,int> >::iterator mmiter;
-// pair<mmiter,mmiter> range=m_node_glob_to_loc.equal_range(global);
-// for (mmiter it=range.first; it !=range.second; it++)
-// {
-// if ((it->second).first==idomain)
-// type_connectivity[type][inode]=(it->second).second;
-// }
-// // cout << " local = " <<type_connectivity[type][inode]<<endl;
-// }
-
-// }
-// }
//replacing a table of global numbering with a table with local numberings
// type_connectivity contains global connectivity for each type in input
{
// cout <<" inode :"<<inode<< " global = "<<type_connectivity[type][inode];
int global = nodes[inode];
- typedef hash_multimap<int,pair<int,int> >::iterator mmiter;
+ typedef INTERP_KERNEL::HashMultiMap<int,pair<int,int> >::iterator mmiter;
pair<mmiter,mmiter> range=m_node_glob_to_loc.equal_range(global);
for (mmiter it=range.first; it !=range.second; it++)
{
}
-//! computing arrays with node/node correspondencies
-// void ParallelTopology::computeNodeNodeCorrespondencies(int idomain, vector<MEDMEM::MEDSKYLINEARRAY*>& corr) const
-// {
-// vector <int> sizes (m_nb_domain,0);
-// vector <int*> values (m_nb_domain);
-// for (int i=0; i<m_nb_domain; i++)
-// {
-// values[i]=0;
-// }
-
-// for (int inode=0; inode<m_nb_nodes[idomain]; inode++)
-// {
-// //int global = (m_node_loc_to_glob.find(make_pair(idomain,inode+1)))->second;
-// int global = m_node_loc_to_glob[idomain][inode];
-// typedef hash_multimap<int,pair<int,int> >::const_iterator mm;
-// pair<mm,mm> range = m_node_glob_to_loc.equal_range(global);
-// for (mm it=range.first; it !=range.second; it++)
-// {
-// int id = (it->second).first;
-// if (id !=idomain)
-// {
-// sizes[id]++;
-// }
-// }
-// }
-
-// for (int ip=0; ip<m_nb_domain; ip++)
-// {
-// if (sizes[ip]>0)
-// values[ip]=new int[2*sizes[ip]];
-// sizes[ip]=0;
-// }
-
-
-// for (int inode=0; inode<m_nb_nodes[idomain]; inode++)
-// {
-// //int global = (m_node_loc_to_glob.find(make_pair(idomain,inode+1)))->second;
-// int global = m_node_loc_to_glob[idomain][inode];
-// typedef hash_multimap<int,pair<int,int> >::const_iterator mm;
-// pair<mm,mm> range = m_node_glob_to_loc.equal_range(global);
-// for (mm it=range.first; it !=range.second; it++)
-// {
-// int id = (it->second).first;
-// if (id !=idomain)
-// {
-// values[id][sizes[id]*2]=inode+1;
-// values[id][sizes[id]*2+1]=(it->second).second;
-// sizes[id]++;
-// }
-// }
-// }
-
-// for (int i=0; i< m_nb_domain; i++)
-// {
-// if (sizes[i]!=0)
-// {
-// int* index = new int[sizes[i]+1];
-// for (int j=0; j<sizes[i]+1; j++)
-// index[j]=j+1;
-// corr[i]=new MEDMEM::MEDSKYLINEARRAY(sizes[i],2*sizes[i],index,values[i]);
-// delete[] index;
-// delete[] values[i];
-// }
-// }
-// }
-
-//================================================================================
-/*!
- * \brief computing arrays with cell/cell correspondencies
- * \param idomain - domain for which to compute correspondencies
- * \param corr - out correspondencies
- * \param graph - graph containing new cell distribution among domains
- * \param id_shift - shitf to get cell id global on this processor from id global
- * over all procs
- */
-//================================================================================
-
-// void ParallelTopology::computeCellCellCorrespondencies(int idomain, vector<MEDMEM::MEDSKYLINEARRAY*>& corr, const Graph* graph) const
-// {
-// vector <int> sizes (m_nb_domain,0);
-// vector <int*> values (m_nb_domain);
-// for (int i=0; i<m_nb_domain; i++)
-// {
-// values[i]=0;
-// }
-
-// vector <hash_multimap<int,int> > cell_corresp;
-// //TODO : remplacer int* par une map <int,int>
-// // vector<int* > number_of_connections(m_nb_domain);
-// // vector<map<int,int> > number_of_connections;
-// vector<map<int,int> > number_of_connections;
-// cell_corresp.resize(m_nb_domain);
-// number_of_connections.resize(m_nb_domain);
-// // for (int i=0; i<m_nb_domain; i++)
-// // {
-// // // cell_corresp[i]=new multimap<int,int>;
-// // if (m_nb_cells[i] >0)
-// // {
-// // number_of_connections[i]=new int[m_nb_cells[idomain]];
-// // for (int j=0; j<m_nb_cells[idomain]; j++)
-// // number_of_connections[i][j]=0;
-// // }
-// // }
-
-// const MEDMEM::MEDSKYLINEARRAY* skylinegraph = graph->getGraph();
-
-// const int* index=skylinegraph->getIndex();
-// const int* value=skylinegraph->getValue();
-
-// TGlob2DomainLoc::const_iterator gl_do_lo_end = m_glob_to_loc.end();
-
-// for (int icell=0; icell<m_nb_cells[idomain]; icell++)
-// {
-// int global= m_loc_to_glob[idomain][icell];
-// for (int ii=index[global-1]-1; ii<index[global]-1; ii++)
-// {
-// int distant_global=value[ii];
-
-// const pair<int,int>& local = m_glob_to_loc.find(distant_global)->second;
-
-// if (local.first != idomain)
-// {
-// cell_corresp[local.first].insert(make_pair(icell+1,local.second));
-// // number_of_connections[local.first][icell]++;
-// if (number_of_connections[local.first].find(icell)==number_of_connections[local.first].end())
-// number_of_connections[local.first].insert(make_pair(icell,1));
-// else
-// number_of_connections[local.first][icell]++;
-
-// }
-// }
-// }
-
-// for (int inew=0; inew<m_nb_domain; inew++)
-// {
-// if (inew==idomain || number_of_connections[inew].empty()) continue;
-
-// int* new_index=new int[m_nb_cells[idomain]+1];
-// new_index[0]=1;
-// for (int i=0; i<m_nb_cells[idomain]; i++)
-// {
-
-// if (number_of_connections[inew].find(i)!=number_of_connections[inew].end())
-// new_index[i+1]=new_index[i]+number_of_connections[inew][i];
-// else
-// new_index[i+1]=new_index[i];
-// }
-// int* new_value;
-// if (new_index[m_nb_cells[idomain]]-1 > 0)
-// new_value=new int[new_index[m_nb_cells[idomain]]-1];
-// else
-// new_value=0;
-
-// int value_i=0;
-
-// // hash_multimap<int,int>::iterator iter=cell_corresp[inew].begin();
-
-// for (int i=0; i<m_nb_cells[idomain]; i++)
-// {
-// // for (int j=new_index[i];j<new_index[i+1];j++,value_i++,iter++)
-// // new_value[value_i]=iter->second;
-
-// typedef hash_multimap<int,int>::iterator mmiter;
-// pair<mmiter,mmiter> range=cell_corresp[inew].equal_range(i+1);
-// for (mmiter it=range.first; it!=range.second; it++)
-// {
-// new_value[value_i]=it->second;
-// value_i++;
-// }
-// }
-// if (value_i>0)
-// {
-// corr[inew] = new MEDMEM::MEDSKYLINEARRAY(m_nb_cells[idomain], new_index[m_nb_cells[idomain]]-1, new_index,new_value,true);
-// }
-// else
-// {
-// corr[inew]=0;
-// if (new_value !=0) delete[]new_value;
-// delete[]new_index;
-// }
-
-// }
-
- // for (int inew=0; inew<m_nb_domain; inew++)
- // if (m_nb_cells[inew]>0)
- // delete[] number_of_connections[inew];
-
-//}
-
//================================================================================
/*!
* \brief Return max global face number
return max;
}
-// void ParallelTopology::recreateFaceMapping(const TGeom2FacesByDomian& face_map)
-// {
-// m_face_glob_to_loc.clear();
-// for (int i=0; i<m_nb_domain;i++)
-// m_face_loc_to_glob[i].clear();
-
-// for (int idomain=0; idomain<m_nb_domain; idomain++)
-// {
-// int ilocal=1;
-// TGeom2Faces::const_iterator iter = face_map[idomain].begin();
-// for (; iter != face_map[idomain].end(); iter++)
-// {
-// for (int i=0; i< (iter->second).size(); i++)
-// {
-// MEDPARTITIONER_FaceModel* face = (iter->second)[i];
-// //cout << "global :"<<face->getGlobal()<<" - "<<ilocal<<endl;
-// m_face_glob_to_loc.insert(make_pair(face->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<MEDMEM::MESH*>& 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; idomain<m_nb_domain; idomain++)
-// {
-// m_nb_cells[idomain] = m_nb_nodes[idomain] = m_nb_faces[idomain] = 0;
-// m_loc_to_glob[idomain].clear();
-// m_node_loc_to_glob[idomain].clear();
-// m_face_loc_to_glob[idomain].clear();
-
-// if ( !meshes[idomain]->getCoordinateptr() ) 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; i<m_nb_cells[idomain]; i++)
-// {
-// int global=m_loc_to_glob[idomain][i];
-// m_glob_to_loc[global]=make_pair(idomain,i+1);
-// }
-
-// //creating node maps
-
-// m_nb_nodes[idomain]=meshes[idomain]->getNumberOfNodes();
-// 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; inode<m_nb_nodes[idomain]; inode++)
-// {
-// int global_number=m_node_loc_to_glob[idomain][inode];
-// m_node_glob_to_loc.insert(make_pair(global_number,make_pair(idomain,inode+1)));
-// }
-
-
-// //creating dimension d-1 component mappings
-
-// MED_EN::medEntityMesh constituent_entity =
-// (m_mesh_dimension == 3 ? MED_EN::MED_FACE : MED_EN::MED_EDGE );
-// m_nb_faces[idomain] = meshes[idomain]->getNumberOfElementsWithPoly(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<m_nb_faces[idomain]; iface++)
-// {
-// int global_number=m_face_loc_to_glob[idomain][iface];
-// m_face_glob_to_loc.insert(make_pair(global_number,make_pair(idomain,iface+1)));
-// }
-// }
-
-//}
#include <set>
#include <vector>
-#include <ext/hash_map>
-//#include "boost/shared_ptr.hpp"
+#include "InterpKernelHashMap.hxx"
#include "MEDPARTITIONER_Topology.hxx"
-namespace __gnu_cxx
+namespace INTERP_KERNEL
{
- template<> struct hash< pair<int,int> >
+ template<> struct hash< std::pair<int,int> >
{
- size_t operator()( const pair<int,int>& x ) const
+ size_t operator()( const std::pair<int,int>& x ) const
{
return hash< int >()( x.first*1000000+x.second );
}
};
}
-using namespace std;
namespace MEDPARTITIONER {
class Graph;
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<MED_EN::medGeometryElement,int*>& type_connectivity,
-// std::map<MED_EN::medGeometryElement,int>& present_type_numbers,
-// std::vector<int>& conn,
-// std::vector<int>& conn_index,
-// std::vector<int>& polyhedron_conn,
-// std::vector<int>& polyhedron_conn_index,
-// std::vector<int>& polyhedron_face_index,
-// int idomain);
-
- // void createFaceMapping(std::map<MED_EN::medGeometryElement,int*>& type_connectivity,
- // std::map<MED_EN::medGeometryElement,int>& 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<MED_EN::medGeometryElement,int*>& type_connectivity,
-// std::map<MED_EN::medGeometryElement,int>& 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<MEDPARTITIONER::MEDSKYLINEARRAY*>& ) const;
-
- //! computing arrays with node/node correspondencies
- // void computeCellCellCorrespondencies(int nbdomain,std::vector<MEDPARTITIONER::MEDSKYLINEARRAY*>&, const Graph*) const;
-
- //! retrieving Graph
- // boost::shared_ptr<Graph> getGraph() const;
-
-
//!converting node local numbering to global
inline int convertNodeToGlobal(int ip,int icell) const
{
{
for (int i=0; i<n; i++)
global[i]=m_node_loc_to_glob[ip][local[i]];
- //global[i]=m_node_loc_to_glob.find(make_pair(ip,local[i]))->second;
}
inline void convertCellToGlobal(int ip, const int* local, int n, int* global)const
{
for (int i=0; i<n; i++)
global[i]=m_loc_to_glob[ip][local[i]];
- //global[i]=m_loc_to_glob.find(make_pair(ip,local[i]))->second;
}
inline void convertFaceToGlobal(int ip, const int* local, int n, int* global)const
{
- for (int i=0; i<n; i++)
- {
+ for (int i=0; i<n; i++)
global[i]=m_face_loc_to_glob[ip][local[i]];
- // if (m_face_loc_to_glob.find(make_pair(ip,local[i]))==m_face_loc_to_glob.end())
- // {
- // cout << "problem : face # "<< local[i] << " of processor "<< ip<< " was not found in mapping loc2glob"<<endl;
- // global[i]=-1;
- // }
- // else
- // global[i]=m_face_loc_to_glob.find(make_pair(ip,local[i]))->second;
- }
}
inline int nbDomain() const
inline int getNodeNumber() const
{
if (m_node_glob_to_loc.empty()) return 0;
- set <int> keys;
- for (__gnu_cxx::hash_multimap<int, pair<int,int> >::const_iterator iter= m_node_glob_to_loc.begin();
+ std::set <int> keys;
+ for (INTERP_KERNEL::HashMultiMap<int, std::pair<int,int> >::const_iterator iter= m_node_glob_to_loc.begin();
iter!=m_node_glob_to_loc.end();
iter++) {
keys.insert(iter->first);
//!retrieving list of nodes in global numbers
inline void getNodeList(int idomain, int* list) const
{
- for (int i=0; i<m_nb_nodes[idomain];i++)
- {
+ for (int i=0; i<m_nb_nodes[idomain];i++)
list[i]=m_node_loc_to_glob[idomain][i];
- //list[i]=(m_node_loc_to_glob.find(make_pair(idomain,i+1)))->second;
- }
}
//!< retrieving cell numbers after fusing in parallel mode
inline void getCellList(int idomain, int* list) const
{
for (int i=0; i<m_nb_cells[idomain];i++)
- {
list[i]=m_loc_to_glob[idomain][i];
- //list[i]=(m_loc_to_glob.find(make_pair(idomain,i+1)))->second;
- }
+
}
inline int getFaceNumber() const
{
if (m_face_glob_to_loc.empty()) return 0;
- set <int> keys;
- for (__gnu_cxx::hash_multimap<int, pair<int,int> >::const_iterator iter= m_face_glob_to_loc.begin();
+ std::set <int> keys;
+ for (INTERP_KERNEL::HashMultiMap<int, std::pair<int,int> >::const_iterator iter= m_face_glob_to_loc.begin();
iter!=m_face_glob_to_loc.end();
iter++) {
keys.insert(iter->first);
//!retrieving list of faces in global numbers
inline void getFaceList(int idomain, int* list) const
{
- for (int i=0; i<m_nb_faces[idomain];i++)
- {
+ for (int i=0; i<m_nb_faces[idomain];i++)
list[i]=m_face_loc_to_glob[idomain][i];
- //list[i]=(m_face_loc_to_glob.find(make_pair(idomain,i+1)))->second;
- }
-
}
//! converting a global cell number to a local representation (domain + local number)
inline int convertGlobalFace(int iglobal, int idomain)
{
- typedef __gnu_cxx::hash_multimap<int, pair<int,int> >::const_iterator MMiter;
+ typedef INTERP_KERNEL::HashMultiMap<int, std::pair<int,int> >::const_iterator MMiter;
std::pair<MMiter,MMiter> 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<int, pair<int,int> >::const_iterator MMiter;
- pair<MMiter,MMiter> eq = m_node_glob_to_loc.equal_range(iglobal);
+ typedef INTERP_KERNEL::HashMultiMap<int, std::pair<int,int> >::const_iterator MMiter;
+ std::pair<MMiter,MMiter> 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;
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<ParaMEDMEM::MEDCouplingUMesh*>& );
-
-
-
private:
bool hasCellWithNodes( const MESHCollection&, int dom, const std::set<int>& nodes );
private:
//!mapping global -> local
- typedef __gnu_cxx::hash_map<int,std::pair<int,int> > TGlob2DomainLoc;
- TGlob2DomainLoc m_glob_to_loc;
+ typedef INTERP_KERNEL::HashMultiMap<int,std::pair<int,int> > TGlob2DomainLoc;
- // bool is_equal_pair (pair<int,int> a, pair<int,int> b){
- // return (a.first==b.first && a.second==b.second);
- // }
- //!mapping local -> global
- //map<pair<int,int>,int> m_loc_to_glob;
+ TGlob2DomainLoc m_glob_to_loc;
- //
- //__gnu_cxx::hash_map<pair<int,int>,int, __gnu_cxx::hash<pair<int,int> > > m_loc_to_glob;
std::vector<std::vector<int> > m_loc_to_glob;
- //!mapping global -> local
- __gnu_cxx::hash_multimap<int,std::pair<int,int> > m_node_glob_to_loc;
+
+ INTERP_KERNEL::HashMultiMap<int,std::pair<int,int> > m_node_glob_to_loc;
//!mapping local -> global
- // map<pair<int,int>,int> m_node_loc_to_glob;
- //__gnu_cxx::hash_map<pair<int,int>,int, __gnu_cxx::hash<pair<int,int> > > m_node_loc_to_glob;
std::vector<std::vector <int> > m_node_loc_to_glob;
// global numbers in parallel mode
//!mapping global -> local
- typedef __gnu_cxx::hash_multimap<int,std::pair<int,int> > TGlob2LocsMap;
+ typedef INTERP_KERNEL::HashMultiMap<int,std::pair<int,int> > TGlob2LocsMap;
TGlob2LocsMap m_face_glob_to_loc;
//!mapping local -> global
- //__gnu_cxx::hash_map<pair<int,int>,int, __gnu_cxx::hash<pair<int,int> > > m_face_loc_to_glob;
std::vector<std::vector <int> > m_face_loc_to_glob;
- //map<pair<int,int>,int> m_face_loc_to_glob;
-
std::vector<int> m_nb_cells;
std::vector<int> m_nb_nodes;