From: ageay Date: Wed, 14 Mar 2012 14:18:18 +0000 (+0000) Subject: Cleaning session #3. X-Git-Tag: V6_main_FINAL~792 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5a6a1ebd08208d9b81e697dc5d54ffd77914b019;p=tools%2Fmedcoupling.git Cleaning session #3. --- diff --git a/src/MEDPartitioner/MEDPARTITIONER_JointFinder.cxx b/src/MEDPartitioner/MEDPARTITIONER_JointFinder.cxx index 79a222461..e5c7c22ae 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_JointFinder.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_JointFinder.cxx @@ -26,23 +26,18 @@ #include "MEDCouplingUMesh.hxx" #include "BBTree.txx" -using namespace std; -using namespace ParaMEDMEM; -using namespace MEDPARTITIONER; - -/*! Method contributing to the distant cell graph +/*! + * Method contributing to the distant cell graph */ - -JointFinder::JointFinder(const MeshCollection& mc):_mesh_collection(mc), _topology(mc.getTopology()),_domain_selector(mc.getParaDomainSelector()) +MEDPARTITIONER::JointFinder::JointFinder(const MeshCollection& mc):_mesh_collection(mc), _topology(mc.getTopology()),_domain_selector(mc.getParaDomainSelector()) { } -JointFinder::~JointFinder() +MEDPARTITIONER::JointFinder::~JointFinder() { - //if (MyGlobals::_Is0verbose>100) cout<<"TODO ~JointFinder"<nbDomain(); _distant_node_cell.resize(nbdomain); @@ -54,15 +49,16 @@ void JointFinder::findCommonDistantNodes() } int nbproc=_domain_selector->nbProcs(); std::vector* > bbtree(nbdomain,(BBTree<3>*) 0); - std::vector rev(nbdomain,(DataArrayInt*) 0); - std::vector revIndx(nbdomain,(DataArrayInt*) 0); + std::vector rev(nbdomain,(ParaMEDMEM::DataArrayInt*) 0); + std::vector revIndx(nbdomain,(ParaMEDMEM::DataArrayInt*) 0); int meshDim; int spaceDim; //init rev and revIndx and bbtree for my domain (of me:proc n) for (int mydomain=0; mydomainisMyDomain(mydomain)) continue; + if(!_domain_selector->isMyDomain(mydomain)) + continue; const ParaMEDMEM::MEDCouplingUMesh* myMesh=_mesh_collection.getMesh(mydomain); meshDim=myMesh->getMeshDimension(); spaceDim= myMesh->getSpaceDimension(); @@ -77,7 +73,7 @@ void JointFinder::findCommonDistantNodes() bbx[2*i+1]=bbx[2*i]+2e-12; } bbtree[mydomain]=new BBTree<3> (bbx,0,0,myMesh->getNumberOfNodes(),-1e-12); - delete[] bbx; + delete [] bbx; } //send my domains to other proc an receive other domains from other proc @@ -86,25 +82,23 @@ void JointFinder::findCommonDistantNodes() for (int itarget=0; itargetisMyDomain(isource)&&_domain_selector->isMyDomain(itarget)) continue; + 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->getProcessorID(itarget); std::vector vec(spaceDim*sourceMesh->getNumberOfNodes()); - //cvw cout<<"\nproc "<<_domain_selector->rank()<<" : numberOfNodes "<getNumberOfNodes()<getCoords()->getConstPointer(),sourceMesh->getCoords()->getConstPointer()+sourceMesh->getNumberOfNodes()*spaceDim,&vec[0]); SendDoubleVec(vec,targetProc); //retrieving target data for storage in commonDistantNodes array std::vector localCorrespondency; RecvIntVec(localCorrespondency, targetProc); - //cvw cout<<"\nproc "<<_domain_selector->rank()<<" : nodeCellCorrespondency "; for (int i=0; i recvVec; RecvDoubleVec(recvVec,sourceProc); std::map commonNodes; // (local nodes, distant nodes) list - //cvw cout<<"\nproc "<<_domain_selector->rank()<<" : commonNodes "; for (int inode=0; inode<(recvVec.size()/meshDim); inode++) { double* bbox=new double[2*spaceDim]; @@ -126,12 +119,11 @@ void JointFinder::findCommonDistantNodes() } std::vector inodes; bbtree[itarget]->getIntersectingElems(bbox,inodes); - delete[] bbox; + delete [] bbox; if (inodes.size()>0) { commonNodes.insert(std::make_pair(inodes[0],inode)); - //cvw cout<<" "<second); // int globalCell=_topology->convertCellToGlobal(itarget,revPtr[icell]); nodeCellCorrespondency.push_back(globalCell); - //nodeCellCorrespondency.push_back(revPtr[icell]); //need to set at global numerotation - //cout<<"processor "<second<<" cellLoc "<rank()<<" : JointFinder SendIntVec "<<_domain_selector->rank()<decrRef(); - if (revIndx[i]!=0) revIndx[i]->decrRef(); - if (bbtree[i]!=0) delete bbtree[i]; + if (rev[i]!=0) + rev[i]->decrRef(); + if (revIndx[i]!=0) + revIndx[i]->decrRef(); + if (bbtree[i]!=0) + delete bbtree[i]; } if (MyGlobals::_Verbose>100) - std::cout<<"proc "<<_domain_selector->rank()<<" : end JointFinder::findCommonDistantNodes"<rank() << " : end JointFinder::findCommonDistantNodes" << std::endl; } -std::vector > > & JointFinder::getDistantNodeCell() +std::vector > >& MEDPARTITIONER::JointFinder::getDistantNodeCell() { return _distant_node_cell; } -std::vector > > >& JointFinder::getNodeNode() +std::vector > > >& MEDPARTITIONER::JointFinder::getNodeNode() { return _node_node; } -void JointFinder::print() +void MEDPARTITIONER::JointFinder::print() //it is for debug on small arrays under mpi 2,3 cpus { int nbdomain=_topology->nbDomain(); //MPI_Barrier(MPI_COMM_WORLD); if (MyGlobals::_Is0verbose>0) - cout<<"\nJointFinder print node-node (nn)iproc|itarget|isource|i|inodefirst-inodesecond\n\n"<< + std::cout << "\nJointFinder print node-node (nn)iproc|itarget|isource|i|inodefirst-inodesecond\n\n" << "JointFinder print distantNode=cell (nc)iproc|itarget|isource|inode=icell\n\n"; for (int isource=0; isourcerank()<rank() << itarget << "|" << isource << "|" << i << "|" << + _node_node[itarget][isource][i].first << "-" << _node_node[itarget][isource][i].second; } } - cout<rank()<<" : JointFinder _distant_node_cell itarget/isource/inode=icell"<::iterator it; for (it=_distant_node_cell[isource][itarget].begin() ; it!=_distant_node_cell[isource][itarget].end(); it++) { - cout<<" nc"<<_domain_selector->rank()<<"|"<rank() << "|" << itarget << "|" << isource << "|" << (*it).first << "=" << (*it).second; } } } - cout< #include +#include -namespace MEDPARTITIONER { +namespace MEDPARTITIONER +{ + class Topology; class MeshCollection; class ParaDomainSelector; - class Topology; + class JointFinder { public: @@ -36,13 +38,13 @@ namespace MEDPARTITIONER { void print(); std::vector > >& getDistantNodeCell(); std::vector > > >& getNodeNode(); - - std::vector > > _distant_node_cell; private: const MeshCollection& _mesh_collection; - const ParaDomainSelector* _domain_selector; - const Topology* _topology; + const ParaDomainSelector *_domain_selector; + const Topology *_topology; + std::vector > > _distant_node_cell; std::vector > > > _node_node; + }; } #endif diff --git a/src/MEDPartitioner/MEDPARTITIONER_MeshCollection.cxx b/src/MEDPartitioner/MEDPARTITIONER_MeshCollection.cxx index 7516941a5..d3baf7cb6 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_MeshCollection.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_MeshCollection.cxx @@ -47,18 +47,14 @@ #include "MEDPARTITIONER_ScotchGraph.hxx" #endif +#include #include #include #include -#include #include #include -using namespace std; -using namespace ParaMEDMEM; -using namespace MEDPARTITIONER; - -MeshCollection::MeshCollection() +MEDPARTITIONER::MeshCollection::MeshCollection() : _topology(0), _owns_topology(false), _driver(0), @@ -70,7 +66,6 @@ MeshCollection::MeshCollection() _create_empty_groups(false), _joint_finder(0) { - cout<<"coucou"< > > new2oldIds(initialCollection.getTopology()->nbDomain()); - if (MyGlobals::_Verbose>10) std::cout<<"proc "<10) + std::cout << "proc " << MyGlobals::_Rank << " : castCellMeshes" << std::endl; castCellMeshes(initialCollection, new2oldIds); //defining the name for the collection and the underlying meshes @@ -111,12 +107,12 @@ MeshCollection::MeshCollection(MeshCollection& initialCollection, //treating faces ///////////////// - if (MyGlobals::_Is0verbose) std::cout<<"treating faces"<(inewdomain,inewnode) createNodeMapping(initialCollection, nodeMapping); - //cvw std::cout<<"castMeshes"< > > new2oldFaceIds; castFaceMeshes(initialCollection, nodeMapping, new2oldFaceIds); @@ -125,10 +121,13 @@ MeshCollection::MeshCollection(MeshCollection& initialCollection, //////////////////// if (MyGlobals::_Is0verbose) - if (isParallelMode()) std::cout<<"ParallelMode on "<nbDomain()<<" Domains"<nbDomain()<<" Domains"<nbDomain() << " Domains" << std::endl; + else + std::cout << "NOT ParallelMode on " << topology->nbDomain() << " Domains" << std::endl; - if (MyGlobals::_Is0verbose>10) std::cout<<"treating cell and face families"<10) + std::cout<<"treating cell and face families"<getMesh(), @@ -139,20 +138,16 @@ MeshCollection::MeshCollection(MeshCollection& initialCollection, initialCollection.getFaceFamilyIds(), "faceFamily"); - ////////////////// //treating groups - ////////////////// - if (MyGlobals::_Is0verbose) std::cout<<"treating groups"< > >& new2oldIds) +void MEDPARTITIONER::MeshCollection::castCellMeshes(MeshCollection& initialCollection, + std::vector > >& new2oldIds) { - if (_topology==0) throw INTERP_KERNEL::Exception(LOCALIZED("Topology has not been defined on call to castCellMeshes")); + if (_topology==0) + throw INTERP_KERNEL::Exception("Topology has not been defined on call to castCellMeshes"); int nbNewDomain=_topology->nbDomain(); int nbOldDomain=initialCollection.getTopology()->nbDomain(); _mesh.resize(nbNewDomain); int rank=MyGlobals::_Rank; - //if (MyGlobals::_Verbose>10) std::cout<<"proc "< > splitMeshes; splitMeshes.resize(nbNewDomain); for (int inew=0; inewgetCellList(iold, &globalids[0]); std::vector ilocalnew(size); //local std::vector ipnew(size); //idomain old - //cvw work locally _topology->convertGlobalCellList(&globalids[0],size,&ilocalnew[0],&ipnew[0]); new2oldIds[iold].resize(nbNewDomain); @@ -208,8 +198,8 @@ void MeshCollection::castCellMeshes( &new2oldIds[iold][inew][0]+new2oldIds[iold][inew].size(), true); if (MyGlobals::_Verbose>400) - std::cout<<"proc "<getNumberOfCells()<getNumberOfCells() << std::endl; } } } @@ -220,7 +210,8 @@ void MeshCollection::castCellMeshes( for (int iold=0; ioldisMyDomain(iold) && _domain_selector->isMyDomain(inew)) continue; + 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)); @@ -232,10 +223,11 @@ void MeshCollection::castCellMeshes( } //fusing the split meshes - if (MyGlobals::_Verbose>200) std::cout<<"proc "<200) + std::cout << "proc " << rank << " : castCellMeshes fusing" << std::endl; for (int inew=0; inew meshes; + std::vector meshes; for (int i=0; i< splitMeshes[inew].size();i++) if (splitMeshes[inew][i]!=0) @@ -248,7 +240,7 @@ void MeshCollection::castCellMeshes( { _mesh[inew]=CreateEmptyMEDCouplingUMesh(); //throw INTERP_KERNEL::Exception(LOCALIZED("castCellMeshes fusing : no meshes")); - cout<<"WARNING : castCellMeshes fusing : no meshes try another number of processors"<decrRef(); } - if (MyGlobals::_Verbose>300) std::cout<<"proc "<300) + std::cout << "proc " << rank << " : castCellMeshes end fusing" << std::endl; } /*! \param initialCollection source mesh collection \param nodeMapping structure containing the correspondency between nodes in the initial collection and the node(s) in the new collection */ -void MeshCollection::createNodeMapping( MeshCollection& initialCollection, NodeMapping& nodeMapping) +void MEDPARTITIONER::MeshCollection::createNodeMapping( MeshCollection& initialCollection, NodeMapping& nodeMapping) { using std::vector; using std::make_pair; @@ -338,11 +331,7 @@ void MeshCollection::createNodeMapping( MeshCollection& initialCollection, NodeM } -//getNodeIds(meshCell, meshFace, nodeIds) -//inodeCell=nodeIds[inodeFace] -//(put the biggest mesh in One) -//if no corresponding node then inodeCell = -1 -void getNodeIds(ParaMEDMEM::MEDCouplingUMesh& meshOne, ParaMEDMEM::MEDCouplingUMesh& meshTwo, vector& nodeIds) +void getNodeIds(ParaMEDMEM::MEDCouplingUMesh& meshOne, ParaMEDMEM::MEDCouplingUMesh& meshTwo, std::vector& nodeIds) { using std::vector; if (!&meshOne || !&meshTwo) return; //empty or not existing @@ -378,9 +367,9 @@ void getNodeIds(ParaMEDMEM::MEDCouplingUMesh& meshOne, ParaMEDMEM::MEDCouplingUM creates the face meshes on the new domains from the faces on the old domain and the node mapping faces at the interface are duplicated */ -void MeshCollection::castFaceMeshes(MeshCollection& initialCollection, - const std::multimap, std::pair >& nodeMapping, - std::vector > >& new2oldIds) +void MEDPARTITIONER::MeshCollection::castFaceMeshes(MeshCollection& initialCollection, + const std::multimap, std::pair >& nodeMapping, + std::vector > >& new2oldIds) { //splitMeshes structure will contain the partition of @@ -478,7 +467,6 @@ void MeshCollection::castFaceMeshes(MeshCollection& initialCollection, } else { - //std::cout<<"one empty mesh from "<isMyDomain(iold)<<" "<< - _domain_selector->isMyDomain(inew)<isMyDomain(iold) && !_domain_selector->isMyDomain(inew)) - if (splitMeshes[inew][iold] != 0) { - //cvw std::cout<<"send NOT empty mesh "<getName()<<" "<sendMesh(*(splitMeshes[inew][iold]), _domain_selector->getProcessorID(inew)); - } - else { - //std::cout<<"send empty mesh "<sendMesh(*(empty), _domain_selector->getProcessorID(inew)); - } + if (splitMeshes[inew][iold] != 0) + { + _domain_selector->sendMesh(*(splitMeshes[inew][iold]), _domain_selector->getProcessorID(inew)); + } + else + { + _domain_selector->sendMesh(*(empty), _domain_selector->getProcessorID(inew)); + } if (!_domain_selector->isMyDomain(iold) && _domain_selector->isMyDomain(inew)) _domain_selector->recvMesh(splitMeshes[inew][iold], _domain_selector->getProcessorID(iold)); } @@ -528,9 +513,6 @@ void MeshCollection::castFaceMeshes(MeshCollection& initialCollection, { myMeshes.push_back(umesh); } - //else { - // std::cout<<"one empty mesh "<0) @@ -539,22 +521,16 @@ void MeshCollection::castFaceMeshes(MeshCollection& initialCollection, } else { - //std::cout<<"one empty meshes to merge "<setName("emptyMesh"); - //empty->setMeshDimension(3); - //empty->allocateCells(0); ParaMEDMEM::MEDCouplingUMesh *empty=CreateEmptyMEDCouplingUMesh(); meshesCastTo[inew]=empty; } - // meshesCastTo[inew]->zipCoords(); for (int iold=0; iolddecrRef(); + if (splitMeshes[inew][iold]!=0) + splitMeshes[inew][iold]->decrRef(); } - //if (MyGlobals::_Verbose>1) std::cout<<"proc "< cI; tmpMesh->getNodeIdsNearPoints(targetCoords->getConstPointer(),targetMesh.getNumberOfCells(),1e-10,c,cI); if (cI.size()!= targetMesh.getNumberOfCells()+1) - throw INTERP_KERNEL::Exception(LOCALIZED("Error in source/target projection")); + throw INTERP_KERNEL::Exception("Error in source/target projection"); for (int itargetnode=0; itargetnodedecrRef(); } -void MeshCollection::castIntField2(std::vector& meshesCastFrom, +void MEDPARTITIONER::MeshCollection::castIntField2(std::vector& meshesCastFrom, std::vector& meshesCastTo, std::vector& arrayFrom, std::string nameArrayTo) @@ -646,46 +623,45 @@ void MeshCollection::castIntField2(std::vector& m } } -void MeshCollection::remapIntField2(int inew,int iold, - const ParaMEDMEM::MEDCouplingUMesh& sourceMesh, - const ParaMEDMEM::MEDCouplingUMesh& targetMesh, - const int* fromArray, - string nameArrayTo) +void MEDPARTITIONER::MeshCollection::remapIntField2(int inew, int iold, + const ParaMEDMEM::MEDCouplingUMesh& sourceMesh, + const ParaMEDMEM::MEDCouplingUMesh& targetMesh, + const int* fromArray, + std::string nameArrayTo) //here we store ccI for next use in future call of castAllFields and remapDoubleField2 { - //cout<<"remapIntField2 "<setCoords(sourceCoords); - vector c; - vector cI; - vector ccI; //memorize intersection target<-source(inew,iold) - string str,cle; + std::vector c; + std::vector cI; + std::vector ccI; //memorize intersection target<-source(inew,iold) + std::string str,cle; str=nameArrayTo+"_toArray"; cle=Cle1ToStr(str,inew); int* toArray; int targetSize=targetMesh.getNumberOfCells(); //first time iold : create and initiate - if (_mapDataArrayInt.find(cle)==_mapDataArrayInt.end()) + if (_map_dataarray_int.find(cle)==_map_dataarray_int.end()) { - if (MyGlobals::_Is0verbose>100) cout<<"create "<100) + std::cout << "create " << cle << " size " << targetSize << std::endl; + ParaMEDMEM::DataArrayInt* p=ParaMEDMEM::DataArrayInt::New(); p->alloc(targetSize,1); p->fillWithZero(); toArray=p->getPointer(); - _mapDataArrayInt[cle]=p; + _map_dataarray_int[cle]=p; } else //other times iold: refind and complete { - toArray=_mapDataArrayInt.find(cle)->second->getPointer(); + toArray=_map_dataarray_int.find(cle)->second->getPointer(); } tmpMesh->getNodeIdsNearPoints(targetCoords->getConstPointer(),targetSize,1e-10,c,cI); if (cI.size()!=targetSize+1) - throw INTERP_KERNEL::Exception(LOCALIZED("Error in source/target projection")); + throw INTERP_KERNEL::Exception("Error in source/target projection"); for (int itargetnode=0; itargetnode700) cout<<"proc "<700) + std::cout << "proc " << MyGlobals::_Rank << " : map memorize '" << str << "'\n"; + _map_dataarray_int[str]=CreateDataArrayIntFromVector(ccI, 2); sourceCoords->decrRef(); targetCoords->decrRef(); tmpMesh->decrRef(); } -void MeshCollection::castAllFields(MeshCollection& initialCollection, string nameArrayTo) //cvwat08 +void MEDPARTITIONER::MeshCollection::castAllFields(MeshCollection& initialCollection, std::string nameArrayTo) //cvwat08 { - using std::vector; if (nameArrayTo!="cellFieldDouble") - throw INTERP_KERNEL::Exception(LOCALIZED("Error castAllField only on cellFieldDouble")); + throw INTERP_KERNEL::Exception("Error castAllField only on cellFieldDouble"); - string nameTo="typeData=6"; //resume the type of field casted + std::string nameTo="typeData=6"; //resume the type of field casted // send-recv operations int ioldMax=initialCollection.getMesh().size(); int inewMax=this->getMesh().size(); int iFieldMax=initialCollection.getFieldDescriptions().size(); - if (MyGlobals::_Verbose>10) cout<<"castAllFields with:\n"< initialCollection.getFieldDescriptions() - //getFieldDescriptions() is a string description of field coherent and tested and set BEFORE. + if (MyGlobals::_Verbose>10) + std::cout << "castAllFields with:\n" << ReprVectorOfString(initialCollection.getFieldDescriptions()) << std::endl; //see collection.prepareFieldDescriptions() for (int ifield=0; ifieldisMyDomain(iold) && !_domain_selector->isMyDomain(inew)) { int target=_domain_selector->getProcessorID(inew); - ParaMEDMEM::DataArrayDouble* field=initialCollection.getField(descriptionField,iold); //cvwat14 - //getField look for and read it if not done, and assume decrRef() in ~MeshCollection; + ParaMEDMEM::DataArrayDouble* field=initialCollection.getField(descriptionField,iold); if (MyGlobals::_Verbose>10) - std::cout<<"proc "<<_domain_selector->rank()<<" : castAllFields sendDouble"<rank() << " : castAllFields sendDouble" << std::endl; SendDataArrayDouble(field, target); } //receiving arrays from distant domains @@ -745,7 +720,7 @@ void MeshCollection::castAllFields(MeshCollection& initialCollection, string nam int source=_domain_selector->getProcessorID(iold); //receive vector if (MyGlobals::_Verbose>10) - std::cout<<"proc "<<_domain_selector->rank()<<" : castAllFields recvDouble"<rank() << " : castAllFields recvDouble" << std::endl; ParaMEDMEM::DataArrayDouble* field=RecvDataArrayDouble(source); remapDoubleField3(inew,iold,field,nameArrayTo,descriptionField); } @@ -758,68 +733,64 @@ void MeshCollection::castAllFields(MeshCollection& initialCollection, string nam for (int iold=0; ioldisMyDomain(iold) && _domain_selector->isMyDomain(inew))) { - ParaMEDMEM::DataArrayDouble* field=initialCollection.getField(descriptionField,iold); //cvwat14 + ParaMEDMEM::DataArrayDouble* field=initialCollection.getField(descriptionField,iold); remapDoubleField3(inew,iold,field,nameArrayTo,descriptionField); } } } } -void MeshCollection::remapDoubleField3(int inew, int iold, - ParaMEDMEM::DataArrayDouble* fromArray, - string nameArrayTo, - string descriptionField) +void MEDPARTITIONER::MeshCollection::remapDoubleField3(int inew, int iold, + ParaMEDMEM::DataArrayDouble* fromArray, + std::string nameArrayTo, + std::string descriptionField) //here we use 'cellFamily_ccI inew iold' set in remapIntField2 { - using std::vector; if (nameArrayTo!="cellFieldDouble") - throw INTERP_KERNEL::Exception(LOCALIZED("Error remapDoubleField3 only on cellFieldDouble")); - string cle=Cle2ToStr("cellFamily_ccI",inew,iold); + throw INTERP_KERNEL::Exception("Error remapDoubleField3 only on cellFieldDouble"); + std::string key=Cle2ToStr("cellFamily_ccI",inew,iold); - map::iterator it1; - it1=_mapDataArrayInt.find(cle); - if (it1==_mapDataArrayInt.end()) + std::map::iterator it1; + it1=_map_dataarray_int.find(key); + if (it1==_map_dataarray_int.end()) { - cerr<<"proc "<second; - if (MyGlobals::_Verbose>300) cout<<"proc "<getNbOfElems()<second; + if (MyGlobals::_Verbose>300) + std::cout << "proc " << MyGlobals::_Rank << " : remapDoubleField3 " << key << " size " << ccI->getNbOfElems() << std::endl; - int nbcell=this->getMesh()[inew]->getNumberOfCells(); //number of cell of mesh + int nbcell=this->getMesh()[inew]->getNumberOfCells(); int nbcomp=fromArray->getNumberOfComponents(); int nbPtGauss=StrToInt(ExtractFromDescription(descriptionField, "nbPtGauss=")); - //int nbk=fromArray->getNumberOfTuples(); - - //cle=reprGenericDescription(descriptionField)+" "+IntToStr(inew); - string tag="inewFieldDouble="+IntToStr(inew); - cle=descriptionField+SerializeFromString(tag); - //cout<<"descriptionField in remapDoubleField3 : "<getNbOfElems(); int fromArrayNbOfComp=fromArray->getNumberOfComponents(); int fromArrayNbOfCell=fromArrayNbOfElem/fromArrayNbOfComp/nbPtGauss; if (MyGlobals::_Verbose>1000) { - cout<<"proc "<getNumberOfTuples()<< - " nbcells "<getNumberOfComponents()<getNumberOfTuples() << + " nbcells " << fromArrayNbOfCell << + " nbComponents " << fromArray->getNumberOfComponents() << std::endl; } ParaMEDMEM::DataArrayDouble* field=0; - map::iterator it2; - it2=_mapDataArrayDouble.find(cle); - if (it2==_mapDataArrayDouble.end()) + std::map::iterator it2; + it2=_map_dataarray_double.find(key); + if (it2==_map_dataarray_double.end()) { - if (MyGlobals::_Verbose>300) cout<<"proc "<300) + std::cout << "proc "<< MyGlobals::_Rank << " : remapDoubleField3 key '" << key << "' not found and create it" << std::endl; + field=ParaMEDMEM::DataArrayDouble::New(); + _map_dataarray_double[key]=field; field->alloc(nbcell*nbPtGauss,nbcomp); field->fillWithZero(); } @@ -828,12 +799,11 @@ void MeshCollection::remapDoubleField3(int inew, int iold, field=it2->second; if (field->getNumberOfTuples()!=nbcell*nbPtGauss || field->getNumberOfComponents()!=nbcomp) { - cerr<<"proc "<getNbOfElems()<=nbcell) || (isource<0) || (isource>=fromArrayNbOfCell)) - throw INTERP_KERNEL::Exception(LOCALIZED("Error field override")); + throw INTERP_KERNEL::Exception("Error field override"); int ita=itarget*delta; int iso=isource*delta; for (int k=0; kgatherNbOf( getMesh() );*/ - // find non-empty domain mesh for ( int idomain = 0; idomain < _mesh.size(); ++idomain ) if ( _mesh[idomain] && _mesh[idomain]->getNumberOfNodes() > 0 ) @@ -1028,47 +991,39 @@ MeshCollection::MeshCollection(const std::string& filename, ParaDomainSelector& try { - //check for all proc/file compatibility of _fieldDescriptions + //check for all proc/file compatibility of _field_descriptions //*MyGlobals::_File_Names=AllgathervVectorOfString(*MyGlobals::_File_Names); - _fieldDescriptions=AllgathervVectorOfString(MyGlobals::_Field_Descriptions); //cvwat07 + _field_descriptions=AllgathervVectorOfString(MyGlobals::_Field_Descriptions); } catch(INTERP_KERNEL::Exception& e) { - cerr<<"proc "< v2=AllgathervVectorOfString(VectorizeFromMapOfStringInt(_familyInfo)); - _familyInfo=DevectorizeToMapOfStringInt(v2); + //check for all proc/file compatibility of _family_info + std::vector v2=AllgathervVectorOfString(VectorizeFromMapOfStringInt(_family_info)); + _family_info=DevectorizeToMapOfStringInt(v2); } catch(INTERP_KERNEL::Exception& e) { - cerr<<"proc "< v2=AllgathervVectorOfString( - VectorizeFromMapOfStringVectorOfString(_groupInfo)); - _groupInfo=DeleteDuplicatesInMapOfStringVectorOfString( - DevectorizeToMapOfStringVectorOfString(v2)); + //check for all proc/file compatibility of _group_info + std::vector v2=AllgathervVectorOfString(VectorizeFromMapOfStringVectorOfString(_group_info)); + _group_info=DeleteDuplicatesInMapOfStringVectorOfString(DevectorizeToMapOfStringVectorOfString(v2)); } catch(INTERP_KERNEL::Exception& e) { - cerr<<"proc "< _meshes=MEDLoader::GetMeshNames(filename); - //std::vector< std::string > _fields=MEDLoader::GetAllFieldNamesOnMesh(filename,meshname[0]); - //cout<<"number of fields "<<_fields.size()<getNumberOfNodes() > 0 ) _i_non_empty_mesh = 0; } -MeshCollection::~MeshCollection() +MEDPARTITIONER::MeshCollection::~MeshCollection() { for (int i=0; i<_mesh.size();i++) if (_mesh[i]!=0) _mesh[i]->decrRef(); - for (int i=0; i<_cellFamilyIds.size();i++) - if (_cellFamilyIds[i]!=0) _cellFamilyIds[i]->decrRef(); + for (int i=0; i<_cell_family_ids.size();i++) + if (_cell_family_ids[i]!=0) + _cell_family_ids[i]->decrRef(); - for (int i=0; i<_faceMesh.size();i++) - if (_faceMesh[i]!=0) _faceMesh[i]->decrRef(); + for (int i=0; i<_face_mesh.size();i++) + if (_face_mesh[i]!=0) + _face_mesh[i]->decrRef(); - for (int i=0; i<_faceFamilyIds.size();i++) - if (_faceFamilyIds[i]!=0) _faceFamilyIds[i]->decrRef(); + for (int i=0; i<_face_family_ids.size();i++) + if (_face_family_ids[i]!=0) + _face_family_ids[i]->decrRef(); - for (map::iterator it=_mapDataArrayInt.begin() ; it!=_mapDataArrayInt.end(); it++ ) - if ((*it).second!=0) (*it).second->decrRef(); + for (std::map::iterator it=_map_dataarray_int.begin() ; it!=_map_dataarray_int.end(); it++ ) + if ((*it).second!=0) + (*it).second->decrRef(); - for (map::iterator it=_mapDataArrayDouble.begin() ; it!=_mapDataArrayDouble.end(); it++ ) - if ((*it).second!=0) (*it).second->decrRef(); + for (std::map::iterator it=_map_dataarray_double.begin() ; it!=_map_dataarray_double.end(); it++ ) + if ((*it).second!=0) + (*it).second->decrRef(); - if (_driver !=0) {delete _driver; _driver=0;} - if (_topology!=0 && _owns_topology) {delete _topology; _topology=0;} + delete _driver; + if (_topology!=0 && _owns_topology) + delete _topology; - if (_joint_finder!=0) {delete _joint_finder; _joint_finder=0;} + delete _joint_finder; } /*! constructing the MESH collection from a file @@ -1138,23 +1100,20 @@ MeshCollection::~MeshCollection() * \param filename name of the master file that will contain the list of the MED files * */ -void MeshCollection::write(const std::string& filename) +void MEDPARTITIONER::MeshCollection::write(const std::string& filename) { //building the connect zones necessary for writing joints // if (_topology->nbDomain()>1) // buildConnectZones(); //suppresses link with driver so that it can be changed for writing - if (_driver!=0) delete _driver; + delete _driver; _driver=0; - - //char filenamechar[256]; - // strcpy(filenamechar,filename.c_str()); retrieveDriver()->write (filename.c_str(), _domain_selector); } /*! creates or gets the link to the collection driver */ -MeshCollectionDriver* MeshCollection::retrieveDriver() +MEDPARTITIONER::MeshCollectionDriver* MEDPARTITIONER::MeshCollection::retrieveDriver() { if (_driver==0) { @@ -1167,7 +1126,7 @@ MeshCollectionDriver* MeshCollection::retrieveDriver() _driver=new MeshCollectionMedAsciiDriver(this); break; default: - throw INTERP_KERNEL::Exception(LOCALIZED("Unrecognized driver")); + throw INTERP_KERNEL::Exception("Unrecognized driver"); } } return _driver; @@ -1177,43 +1136,54 @@ MeshCollectionDriver* MeshCollection::retrieveDriver() /*! gets an existing driver * */ -MeshCollectionDriver* MeshCollection::getDriver() const { +MEDPARTITIONER::MeshCollectionDriver* MEDPARTITIONER::MeshCollection::getDriver() const +{ return _driver; } -// /*! retrieves the mesh dimension*/ -int MeshCollection::getMeshDimension() const { +/*! + * retrieves the mesh dimension +*/ +int MEDPARTITIONER::MeshCollection::getMeshDimension() const +{ return _i_non_empty_mesh < 0 ? -1 : _mesh[_i_non_empty_mesh]->getMeshDimension(); } -std::vector& MeshCollection::getMesh() { +std::vector& MEDPARTITIONER::MeshCollection::getMesh() +{ return _mesh; } -std::vector& MeshCollection::getFaceMesh() { - return _faceMesh; +std::vector& MEDPARTITIONER::MeshCollection::getFaceMesh() +{ + return _face_mesh; } -ParaMEDMEM::MEDCouplingUMesh* MeshCollection::getMesh(int idomain) const { +ParaMEDMEM::MEDCouplingUMesh* MEDPARTITIONER::MeshCollection::getMesh(int idomain) const +{ return _mesh[idomain]; } -ParaMEDMEM::MEDCouplingUMesh* MeshCollection::getFaceMesh(int idomain) { - return _faceMesh[idomain]; +ParaMEDMEM::MEDCouplingUMesh* MEDPARTITIONER::MeshCollection::getFaceMesh(int idomain) +{ + return _face_mesh[idomain]; } -std::vector& MeshCollection::getCZ() { +std::vector& MEDPARTITIONER::MeshCollection::getCZ() +{ return _connect_zones; } -Topology* MeshCollection::getTopology() const { +MEDPARTITIONER::Topology* MEDPARTITIONER::MeshCollection::getTopology() const +{ return _topology; } -void MeshCollection::setTopology(Topology* topo) { +void MEDPARTITIONER::MeshCollection::setTopology(Topology* topo) +{ if (_topology!=0) { - throw INTERP_KERNEL::Exception(LOCALIZED("topology is already set")); + throw INTERP_KERNEL::Exception("topology is already set"); } else _topology = topo; @@ -1225,18 +1195,18 @@ void MeshCollection::setTopology(Topology* topo) { * \param edgeweight returns the pointer to the table that contains the edgeweights * (only used if indivisible regions are required) */ -void MeshCollection::buildCellGraph(MEDPARTITIONER::SkyLineArray* & array, int *& edgeweights ) //cvwat09 +void MEDPARTITIONER::MeshCollection::buildCellGraph(MEDPARTITIONER::SkyLineArray* & array, int *& edgeweights ) { using std::multimap; using std::vector; using std::make_pair; using std::pair; - multimap< int, int > node2cell; - multimap< int, int > cell2cell; - multimap< int, int > cell2node; + std::multimap< int, int > node2cell; + std::multimap< int, int > cell2cell; + std::multimap< int, int > cell2node; - vector > > commonDistantNodes; + std::vector > > commonDistantNodes; int nbdomain=_topology->nbDomain(); if (isParallelMode()) { @@ -1250,58 +1220,41 @@ void MeshCollection::buildCellGraph(MEDPARTITIONER::SkyLineArray* & array, int * //looking for reverse nodal connectivity i global numbering for (int idomain=0; idomainisMyDomain(idomain)) continue; - - /*obsolete - int offsetCell=0, offsetNode=0; - if (isParallelMode()) - { - offsetCell=_domain_selector->getDomainCellShift(idomain); - offsetNode=_domain_selector->getDomainNodeShift(idomain); - }*/ + if (isParallelMode() && !_domain_selector->isMyDomain(idomain)) + continue; ParaMEDMEM::DataArrayInt* index=ParaMEDMEM::DataArrayInt::New(); ParaMEDMEM::DataArrayInt* revConn=ParaMEDMEM::DataArrayInt::New(); int nbNodes=_mesh[idomain]->getNumberOfNodes(); - //cout<<"proc "<getReverseNodalConnectivity(revConn,index); //problem saturation over 1 000 000 nodes for 1 proc - if (MyGlobals::_Verbose>100) cout<<"proc "<100) + std::cout << "proc " << MyGlobals::_Rank << " getReverseNodalConnectivity done on " << nbNodes << " nodes" << std::endl; int* index_ptr=index->getPointer(); int* revConnPtr=revConn->getPointer(); - //if (MyGlobals::_Verbose>100) cout<<"proc "<convertNodeToGlobal(idomain,i); int globalCell=_topology->convertCellToGlobal(idomain,revConnPtr[icell]); node2cell.insert(make_pair(globalNode, globalCell)); - //cvw cout<<" "<decrRef(); index->decrRef(); - //vector > > dNC=getDistantNodeCell() for (int iother=0; iother::iterator it; int isource=idomain; int itarget=iother; - for (it=_joint_finder->_distant_node_cell[isource][itarget].begin(); - it!=_joint_finder->_distant_node_cell[isource][itarget].end(); it++) + for (it=_joint_finder->getDistantNodeCell()[isource][itarget].begin(); + it!=_joint_finder->getDistantNodeCell()[isource][itarget].end(); it++) { int globalNode=_topology->convertNodeToGlobal(idomain,(*it).first); int globalCell=(*it).second; node2cell.insert(make_pair(globalNode, globalCell)); - //cout<<"processor "<100) cout<<"proc "<nbNodes()<100) + std::cout<< "proc " << MyGlobals::_Rank << " creating graph arcs on nbNodes " << _topology->nbNodes() << std::endl; for (int inode=0; inode<_topology->nbNodes(); inode++) //on all nodes { typedef multimap::const_iterator MI; @@ -1344,15 +1298,15 @@ void MeshCollection::buildCellGraph(MEDPARTITIONER::SkyLineArray* & array, int * if (nbcn>=3) //cvw TODO if 2d cells set at 2 cell2cell.insert(make_pair(cell1->second,cell2->second)); //note here there is some global numerotation of cell which come from other domain (not mydomain) - //cout<<" "<second<<"!"<second; //cvw } } } } - if (MyGlobals::_Verbose>100) cout<<"proc "<100) + std::cout << "proc " << MyGlobals::_Rank << " create skylinearray" << std::endl; //filling up index and value to create skylinearray structure - vector index,value; + std::vector index,value; index.push_back(0); int idep=0; @@ -1367,10 +1321,8 @@ void MeshCollection::buildCellGraph(MEDPARTITIONER::SkyLineArray* & array, int * multimap::iterator it; pair::iterator,multimap::iterator> ret; ret=cell2cell.equal_range(globalCell); - //cout<<" "<100) { - std::cout<<"\nproc "<<_domain_selector->rank()<<" : end MeshCollection::buildCellGraph "<< - index.size()-1<<" "<rank() << " : end MeshCollection::buildCellGraph " << + index.size()-1 << " " << value.size() << std::endl; if (index.size()>1) { - for (int i=0; i<10; ++i) cout<10) cout<<"proc "<10) + std::cout << "proc " << MyGlobals::_Rank << " : MeshCollection::createPartition : Building cell graph" << std::endl; - if (nbdomain <1) throw INTERP_KERNEL::Exception(LOCALIZED("Number of subdomains must be > 0")); + if (nbdomain <1) + throw INTERP_KERNEL::Exception("Number of subdomains must be > 0"); MEDPARTITIONER::SkyLineArray* array=0; int* edgeweights=0; - - //cout<<"Building cell graph... "; - // if ( _domain_selector ) - // buildCellGraphParallel(array,edgeweights); - // else - buildCellGraph(array,edgeweights); //cvwat09 + buildCellGraph(array,edgeweights); //MPI_Barrier(MPI_COMM_WORLD); - //cout<<"proc "<10) cout<<"METISGraph"<10) + std::cout << "METISGraph" << std::endl; + cellGraph=new METISGraph(array,edgeweights); #else throw INTERP_KERNEL::Exception(LOCALIZED("METIS Graph is not available. Check your products, please.")); #endif break; case Graph::SCOTCH: #ifdef MED_ENABLE_SCOTCH - if (MyGlobals::_Verbose>10) cout<<"SCOTCHGraph"<10) + std::cout << "SCOTCHGraph" << std::endl; + cellGraph=new SCOTCHGraph(array,edgeweights); #else throw INTERP_KERNEL::Exception(LOCALIZED("SCOTCH Graph is not available. Check your products, please.")); #endif @@ -1466,18 +1413,19 @@ Topology* MeshCollection::createPartition(int nbdomain, //cvwat06 if (user_vertices_weights!=0) cellGraph->setVerticesWeights(user_vertices_weights); - if (MyGlobals::_Is0verbose>10) cout<<"partitioning graph on "<partGraph(nbdomain, options_string, _domain_selector); //cvwat10 + if (MyGlobals::_Is0verbose>10) + std::cout << "partitioning graph on " << nbdomain << " domains" << std::endl; + cellGraph->partGraph(nbdomain, options_string, _domain_selector); - if (MyGlobals::_Is0verbose>10) cout<<"building new topology"<10) + std::cout << "building new topology" << std::endl; //cellGraph is a shared pointer Topology* topology=new ParallelTopology (cellGraph, getTopology(), nbdomain, getMeshDimension()); - //cleaning - if (edgeweights!=0) delete[] edgeweights; - // if (array!=0) delete array; + delete [] edgeweights; delete cellGraph; - if (MyGlobals::_Verbose>11) cout<<"proc "<11) + std::cout << "proc " << MyGlobals::_Rank << " : end MeshCollection::createPartition" << std::endl; return topology; } @@ -1487,23 +1435,21 @@ Topology* MeshCollection::createPartition(int nbdomain, //cvwat06 * * returns a topology based on the new partition */ -Topology* MeshCollection::createPartition(const int* partition) +MEDPARTITIONER::Topology* MEDPARTITIONER::MeshCollection::createPartition(const int* partition) { - using std::set; - MEDPARTITIONER::SkyLineArray* array=0; int* edgeweights=0; buildCellGraph(array,edgeweights); Graph* cellGraph; - set domains; + std::set domains; for (int i=0; i<_topology->nbCells(); i++) { domains.insert(partition[i]); } int nbdomain=domains.size(); - cellGraph=(Graph*)(new UserGraph(array, partition, _topology->nbCells())); + cellGraph=new UserGraph(array, partition, _topology->nbCells()); //cellGraph is a shared pointer Topology* topology = new ParallelTopology (cellGraph, getTopology(), nbdomain, getMeshDimension()); @@ -1513,7 +1459,7 @@ Topology* MeshCollection::createPartition(const int* partition) return topology; } -void MeshCollection::setDomainNames(const std::string& name) +void MEDPARTITIONER::MeshCollection::setDomainNames(const std::string& name) { for (int i=0; i<_topology->nbDomain(); i++) { @@ -1524,161 +1470,151 @@ void MeshCollection::setDomainNames(const std::string& name) } } -ParaMEDMEM::DataArrayDouble* MeshCollection::getField(std::string descriptionField, int iold) +ParaMEDMEM::DataArrayDouble *MEDPARTITIONER::MeshCollection::getField(std::string descriptionField, int iold) //getField look for and read it if not done, and assume decrRef() in ~MeshCollection; //something like MEDCouplingFieldDouble *f2=MEDLoader::ReadFieldCell(name.c_str(),f1->getMesh()->getName(),0,f1->getName(),0,1); { int rank=MyGlobals::_Rank; - string tag="ioldFieldDouble="+IntToStr(iold); - string descriptionIold=descriptionField+SerializeFromString(tag); - if (_mapDataArrayDouble.find(descriptionIold)!=_mapDataArrayDouble.end()) + std::string tag="ioldFieldDouble="+IntToStr(iold); + std::string descriptionIold=descriptionField+SerializeFromString(tag); + if (_map_dataarray_double.find(descriptionIold)!=_map_dataarray_double.end()) { - if (MyGlobals::_Verbose>300) cout<<"proc "<reprZip()<300) + std::cout << "proc " << rank << " : YET READ getField : " << descriptionIold << std::endl; + ParaMEDMEM::DataArrayDouble* res=_map_dataarray_double[descriptionIold]; return res; } - if (MyGlobals::_Verbose>200) cout<<"proc "<200) + std::cout << "proc " << rank << " : TO BE READ getField : " << descriptionIold << std::endl; + std::string description, fileName, meshName, fieldName; int idomain, typeField, DT, IT, entity; idomain=iold; fileName=MyGlobals::_File_Names[iold]; if (MyGlobals::_Verbose>10) - cout<<"proc "<getArray(); + ParaMEDMEM::DataArrayDouble* res=f2->getArray(); //to know names of components - vector browse=BrowseFieldDouble(f2); - //done yet - //double time=f2->getTime(IT,DT); - //browse.push_back("time="+DoubleToStr(time)); - string localFieldInformation=descriptionIold+SerializeFromVectorOfString(browse); - if (MyGlobals::_Verbose>10) cout<<"proc "< browse=BrowseFieldDouble(f2); + std::string localFieldInformation=descriptionIold+SerializeFromVectorOfString(browse); + if (MyGlobals::_Verbose>10) + std::cout << "proc " << MyGlobals::_Rank << " : localFieldInformation : " << localFieldInformation << std::endl; MyGlobals::_General_Informations.push_back(localFieldInformation); - res->incrRef(); //free field, keep res + res->incrRef(); f2->decrRef(); - _mapDataArrayDouble[descriptionIold]=res; - - //duplicate it! because f2->decRef!! - //DataArrayDouble* res=f2->getArray()->deepCpy(); - //f2->decrRef(); - //cout<reprZip()< r2; + std::vector r2; //from allgatherv then vector(procs) of serialised vector(fields) of vector(description) data - for (int i=0; i<_fieldDescriptions.size(); i++) + for (int i=0; i<_field_descriptions.size(); i++) { - vector r1=DeserializeToVectorOfString(_fieldDescriptions[i]); - for (int i=0; i r1=DeserializeToVectorOfString(_field_descriptions[i]); + for (int i=0; i& inodesFace,vector< int >& inodesCell) +bool isFaceOncell(std::vector< int >& inodesFace, std::vector< int >& inodesCell) { int ires=0; int nbok=inodesFace.size(); for (int i=0; inbDomain(); inew++) { if (isParallelMode() && _domain_selector->isMyDomain(inew)) { if (MyGlobals::_Verbose>200) - std::cout<<"proc "<getNumberOfCells()<getNumberOfCells() << std::endl; ParaMEDMEM::MEDCouplingUMesh* mcel=_mesh[inew]; - ParaMEDMEM::MEDCouplingUMesh* mfac=_faceMesh[inew]; + ParaMEDMEM::MEDCouplingUMesh* mfac=_face_mesh[inew]; //to have cellnode=f(facenode)... inodeCell=nodeIds[inodeFace] - vector nodeIds; - //cout<<"proc "< nodeIds; getNodeIds(*mcel, *mfac, nodeIds); - if (nodeIds.size()==0) continue; //one empty mesh nothing to do + if (nodeIds.size()==0) + continue; //one empty mesh nothing to do - DataArrayInt *revNodalCel=DataArrayInt::New(); - DataArrayInt *revNodalIndxCel=DataArrayInt::New(); + ParaMEDMEM::DataArrayInt *revNodalCel=ParaMEDMEM::DataArrayInt::New(); + ParaMEDMEM::DataArrayInt *revNodalIndxCel=ParaMEDMEM::DataArrayInt::New(); mcel->getReverseNodalConnectivity(revNodalCel,revNodalIndxCel); int *revC=revNodalCel->getPointer(); int *revIndxC=revNodalIndxCel->getPointer(); - vector< int > faceOnCell; - vector< int > faceNotOnCell; + std::vector< int > faceOnCell; + std::vector< int > faceNotOnCell; int nbface=mfac->getNumberOfCells(); for (int iface=0; iface inodesFace; + std::vector< int > inodesFace; mfac->getNodeIdsOfCell(iface, inodesFace); int nbnodFace=inodesFace.size(); //set inodesFace in mcel for (int i=0; i inodesCell; + std::vector< int > inodesCell; mcel->getNodeIdsOfCell(icel, inodesCell); ok=isFaceOncell(inodesFace, inodesCell); if (ok) break; @@ -1686,79 +1622,23 @@ void MeshCollection::filterFaceOnCell() if (ok) { faceOnCell.push_back(iface); - //if (MyGlobals::_Is0verbose) cout<<"face on cell "<decrRef(); revNodalIndxCel->decrRef(); - string cle; - cle=Cle1ToStr("filterFaceOnCell",inew); - _mapDataArrayInt[cle]=CreateDataArrayIntFromVector(faceOnCell); - cle=Cle1ToStr("filterNotFaceOnCell",inew); - _mapDataArrayInt[cle]=CreateDataArrayIntFromVector(faceNotOnCell); - - /*ParaMEDMEM::DataArrayInt* index=ParaMEDMEM::DataArrayInt::New(); - ParaMEDMEM::DataArrayInt* revConn=ParaMEDMEM::DataArrayInt::New(); - _mesh[idomain]->getReverseNodalConnectivity(revConn,index); - int* index_ptr=index->getPointer();*/ - - /*if (MyGlobals::_Is0verbose) - { - cout<<"proc "<nbDomain(); inew++) - { - if (isParallelMode() && _domain_selector->isMyDomain(inew)) - { - if (MyGlobals::_Verbose>1) std::cout<<"proc "<getNumberOfCells()<buildDescendingConnectivity(desc,descIndx,revDesc,revDescIndx); - revDesc->decrRef(); - desc->decrRef(); - descIndx->decrRef(); - int nbOfCells=meshDM1->getNumberOfCells(); - const int *revDescIndxC=revDescIndx->getConstPointer(); - std::vector boundaryCells; - for(int i=0; idecrRef(); - bool keepCoords=true; - MEDCouplingUMesh *ret=(MEDCouplingUMesh *)meshDM1->buildPartOfMySelf(&boundaryCells[0],&boundaryCells[0]+boundaryCells.size(),keepCoords); - meshDM1->decrRef(); - //don't know what to do with result yet.. - //_faceMesh[inew]->decrRef(); - //_faceMesh[inew]=ret; - } - } -} -*/ - diff --git a/src/MEDPartitioner/MEDPARTITIONER_MeshCollection.hxx b/src/MEDPartitioner/MEDPARTITIONER_MeshCollection.hxx index 569c04566..9e754b89f 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_MeshCollection.hxx +++ b/src/MEDPartitioner/MEDPARTITIONER_MeshCollection.hxx @@ -25,8 +25,8 @@ #include "MEDCouplingUMesh.hxx" -#include #include +#include #include namespace ParaMEDMEM @@ -67,9 +67,9 @@ namespace MEDPARTITIONER void write(const std::string& filename); //getting the driver - MeshCollectionDriver* retrieveDriver(); - MeshCollectionDriver* getDriver() const; - void setDriverType(MEDPARTITIONER::DriverType type) {_driver_type=type;} + MeshCollectionDriver *retrieveDriver(); + MeshCollectionDriver *getDriver() const; + void setDriverType(MEDPARTITIONER::DriverType type) { _driver_type=type; } //creation of the cell graph void buildCellGraph(MEDPARTITIONER::SkyLineArray* & array,int *& edgeweights ); @@ -81,7 +81,7 @@ namespace MEDPARTITIONER Topology* createPartition(const int* partition); //getting mesh dimension - int getMeshDimension() const ; + int getMeshDimension() const; //getting a reference to mesh vector std::vector& getMesh(); std::vector& getFaceMesh(); @@ -91,17 +91,17 @@ namespace MEDPARTITIONER ParaMEDMEM::MEDCouplingUMesh* getFaceMesh(int idomain); std::vector& getGroupMeshes(int idomain); - std::vector& getCellFamilyIds() {return _cellFamilyIds;} - std::vector& getFaceFamilyIds() {return _faceFamilyIds;} + std::vector& getCellFamilyIds() { return _cell_family_ids; } + std::vector& getFaceFamilyIds() { return _face_family_ids; } - std::map& getMapDataArrayInt() {return _mapDataArrayInt;} - std::map& getMapDataArrayDouble() {return _mapDataArrayDouble;} + std::map& getMapDataArrayInt() { return _map_dataarray_int; } + std::map& getMapDataArrayDouble() { return _map_dataarray_double; } - std::map& getFamilyInfo() {return _familyInfo;} - std::map >& getGroupInfo() {return _groupInfo;} + std::map& getFamilyInfo() { return _family_info; } + std::map >& getGroupInfo() { return _group_info; } ParaMEDMEM::DataArrayDouble* getField(std::string descriptionField, int iold); - std::vector& getFieldDescriptions() {return _fieldDescriptions;} + std::vector& getFieldDescriptions() { return _field_descriptions; } void prepareFieldDescriptions(); void filterFaceOnCell(); @@ -110,19 +110,19 @@ namespace MEDPARTITIONER //getting a pointer to topology Topology* getTopology() const ; - ParaDomainSelector* getParaDomainSelector() const{return _domain_selector;} + ParaDomainSelector* getParaDomainSelector() const { return _domain_selector; } //setting a new topology void setTopology(Topology* topology); //getting/setting the name of the global mesh (as opposed //to the name of a subdomain \a nn, which is name_nn) - std::string getName() const {return _name;} - void setName(const std::string& name){_name=name;} + std::string getName() const { return _name; } + void setName(const std::string& name) { _name=name; } void setDomainNames(const std::string& name); //getting/setting the description of the global mesh - std::string getDescription() const {return _description;} - void setDescription(const std::string& name) { _description=name;} + std::string getDescription() const { return _description; } + void setDescription(const std::string& name) { _description=name; } //creates the node mapping between an old collection and the present one void createNodeMapping(MeshCollection& initialCollection, @@ -177,7 +177,7 @@ namespace MEDPARTITIONER //links to meshes std::vector _mesh; - std::vector _faceMesh; + std::vector _face_mesh; //index of a non empty mesh within _mesh (in parallel mode all of meshes can be empty) int _i_non_empty_mesh; @@ -186,20 +186,20 @@ namespace MEDPARTITIONER std::vector _connect_zones; //family ids storages - std::vector _cellFamilyIds; - std::vector _faceFamilyIds; + std::vector _cell_family_ids; + std::vector _face_family_ids; //DataArrayInt* storages - std::map _mapDataArrayInt; + std::map _map_dataarray_int; //DataArrayDouble* storages - std::map _mapDataArrayDouble; + std::map _map_dataarray_double; //fields to be partitioned - std::vector _fieldDescriptions; + std::vector _field_descriptions; //group family conversion - std::map _familyInfo; - std::map > _groupInfo; + std::map _family_info; + std::map > _group_info; //list of groups that are not to be splitted std::vector _indivisible_regions; diff --git a/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionDriver.cxx b/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionDriver.cxx index e82ed7284..0a770e75c 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionDriver.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionDriver.cxx @@ -28,26 +28,23 @@ #include "MEDLoader.hxx" #include "MEDFileMesh.hxx" -#include -#include #include #include -#include +#include +#include #include +#include #include #include #include #include -#include - -extern "C" { +extern "C" +{ #include "med.h" } -using namespace std; -using namespace ParaMEDMEM; using namespace MEDPARTITIONER; MeshCollectionDriver::MeshCollectionDriver(MeshCollection* collection):_collection(collection) @@ -61,9 +58,9 @@ MeshCollectionDriver::MeshCollectionDriver(MeshCollection* collection):_collecti * */ int MeshCollectionDriver::readSeq(const char* filename, const char* meshname) { - cout<<"readSeq"<& cellglobal, //cvwat03 - vector& faceglobal, - vector& nodeglobal, int idomain) +void MeshCollectionDriver::readSubdomain(std::vector& cellglobal, + std::vector& faceglobal, + std::vector& nodeglobal, int idomain) { - string meshname=MyGlobals::_Mesh_Names[idomain]; - string file=MyGlobals::_File_Names[idomain]; - //cout << "Reading "< nonEmpty=mfm->getNonEmptyLevels(); + std::vector nonEmpty=mfm->getNonEmptyLevels(); try { @@ -120,7 +116,7 @@ void MeshCollectionDriver::readSubdomain(vector& cellglobal, //cvwat03 ParaMEDMEM::DataArrayInt* empty=ParaMEDMEM::DataArrayInt::New(); empty->alloc(0,1); (_collection->getCellFamilyIds())[idomain]=empty; - cout<<"\nNO Level0Mesh (Cells)\n"; + std::cout << "\nNO Level0Mesh (Cells)\n"; } try { @@ -133,7 +129,7 @@ void MeshCollectionDriver::readSubdomain(vector& cellglobal, //cvwat03 } else { - throw "no faces"; + throw INTERP_KERNEL::Exception("no faces"); } } catch(...) @@ -141,7 +137,8 @@ void MeshCollectionDriver::readSubdomain(vector& cellglobal, //cvwat03 (_collection->getFaceMesh())[idomain]=CreateEmptyMEDCouplingUMesh(); // or 0 if you want test; ParaMEDMEM::DataArrayInt* empty=ParaMEDMEM::DataArrayInt::New(); (_collection->getFaceFamilyIds())[idomain]=empty; - if (MyGlobals::_Verbose>10) cout<<"proc "<10) + std::cout << "proc " << MyGlobals::_Rank << " : NO LevelM1Mesh (Faces)\n"; } //reading groups @@ -150,12 +147,12 @@ void MeshCollectionDriver::readSubdomain(vector& cellglobal, //cvwat03 mfm->decrRef(); - vector localInformation; - string str; + std::vector localInformation; + std::string str; localInformation.push_back(str+"ioldDomain="+IntToStr(idomain)); localInformation.push_back(str+"meshName="+meshname); MyGlobals::_General_Informations.push_back(SerializeFromVectorOfString(localInformation)); - vector localFields=BrowseAllFieldsOnMesh(file, meshname, idomain); //cvwat07 + std::vector localFields=BrowseAllFieldsOnMesh(file, meshname, idomain); if (localFields.size()>0) MyGlobals::_Field_Descriptions.push_back(SerializeFromVectorOfString(localFields)); } @@ -163,12 +160,11 @@ void MeshCollectionDriver::readSubdomain(vector& cellglobal, //cvwat03 void MeshCollectionDriver::readSubdomain(int idomain) { - string meshname=MyGlobals::_Mesh_Names[idomain]; - string file=MyGlobals::_File_Names[idomain]; - //cout << "Reading "< nonEmpty=mfm->getNonEmptyLevels(); + std::vector nonEmpty=mfm->getNonEmptyLevels(); try { @@ -183,7 +179,7 @@ void MeshCollectionDriver::readSubdomain(int idomain) ParaMEDMEM::DataArrayInt* empty=ParaMEDMEM::DataArrayInt::New(); empty->alloc(0,1); (_collection->getCellFamilyIds())[idomain]=empty; - cout<<"\nNO Level0Mesh (Cells)\n"; + std::cout<<"\nNO Level0Mesh (Cells)\n"; } try { @@ -196,7 +192,7 @@ void MeshCollectionDriver::readSubdomain(int idomain) } else { - throw "no faces"; + throw INTERP_KERNEL::Exception("no faces"); } } catch(...) @@ -204,7 +200,8 @@ void MeshCollectionDriver::readSubdomain(int idomain) (_collection->getFaceMesh())[idomain]=CreateEmptyMEDCouplingUMesh(); // or 0 if you want test; ParaMEDMEM::DataArrayInt* empty=ParaMEDMEM::DataArrayInt::New(); (_collection->getFaceFamilyIds())[idomain]=empty; - if (MyGlobals::_Verbose>10) cout<<"proc "<10) + std::cout << "proc " << MyGlobals::_Rank << " : NO LevelM1Mesh (Faces)\n"; } //reading groups @@ -213,38 +210,36 @@ void MeshCollectionDriver::readSubdomain(int idomain) mfm->decrRef(); - vector localInformation; - string str; + std::vector localInformation; + std::string str; localInformation.push_back(str+"ioldDomain="+IntToStr(idomain)); localInformation.push_back(str+"meshName="+meshname); MyGlobals::_General_Informations.push_back(SerializeFromVectorOfString(localInformation)); - vector localFields=BrowseAllFieldsOnMesh(file, meshname, idomain); //cvwat07 + std::vector localFields=BrowseAllFieldsOnMesh(file, meshname, idomain); if (localFields.size()>0) MyGlobals::_Field_Descriptions.push_back(SerializeFromVectorOfString(localFields)); } -void MeshCollectionDriver::writeMedFile(int idomain, const string& distfilename) +void MeshCollectionDriver::writeMedFile(int idomain, const std::string& distfilename) const { - vector meshes; + std::vector meshes; ParaMEDMEM::MEDCouplingUMesh* cellMesh=_collection->getMesh(idomain); ParaMEDMEM::MEDCouplingUMesh* faceMesh=_collection->getFaceMesh(idomain); ParaMEDMEM::MEDCouplingUMesh* faceMeshFilter=0; - string finalMeshName=ExtractFromDescription(MyGlobals::_General_Informations[0], "finalMeshName="); - string cleFilter=Cle1ToStr("filterFaceOnCell",idomain); - DataArrayInt* filter=0; + std::string finalMeshName=ExtractFromDescription(MyGlobals::_General_Informations[0], "finalMeshName="); + std::string cleFilter=Cle1ToStr("filterFaceOnCell",idomain); + ParaMEDMEM::DataArrayInt* filter=0; if (_collection->getMapDataArrayInt().find(cleFilter)!=_collection->getMapDataArrayInt().end()) { filter=_collection->getMapDataArrayInt().find(cleFilter)->second; int* index=filter->getPointer(); - faceMeshFilter=(MEDCouplingUMesh *) faceMesh->buildPartOfMySelf(index,index+filter->getNbOfElems(),true); + faceMeshFilter=(ParaMEDMEM::MEDCouplingUMesh *) faceMesh->buildPartOfMySelf(index,index+filter->getNbOfElems(),true); faceMesh=faceMeshFilter; } cellMesh->setName(finalMeshName.c_str()); meshes.push_back(cellMesh); - //cellMesh->zipCoords(); - //faceMesh->zipCoords(); faceMesh->checkCoherency(); if (faceMesh->getNumberOfCells()>0) @@ -253,62 +248,18 @@ void MeshCollectionDriver::writeMedFile(int idomain, const string& distfilename) meshes.push_back(faceMesh); } - /*do not work - ParaMEDMEM::MEDFileUMesh* mfm2=ParaMEDMEM::MEDFileUMesh::New(); - MEDFileUMesh* mfm2 = static_cast(cellMesh->getMeshes()->getMeshAtPos(0)); - MEDFileUMesh* mfm2 = ParaMEDMEM::MEDFileUMesh::New(cellMesh); - string fname="FUM_"+distfilename; - mfm2->setMeshAtLevel(0, cellMesh ); - mfm2->setMeshAtLevel(-1, faceMesh ); - mfm2->write(fname.c_str(),0); - mfm2->decrRef(); - */ - ParaMEDMEM::MEDCouplingUMesh* boundaryMesh=0; - //ParaMEDMEM::MEDCouplingUMesh* boundaryMesh1=0; - //ParaMEDMEM::MEDCouplingUMesh* finalboundaryMesh=0; if (MyGlobals::_Creates_Boundary_Faces>0) { //try to write Boundary meshes bool keepCoords=false; //TODO or true - boundaryMesh=(MEDCouplingUMesh *) cellMesh->buildBoundaryMesh(keepCoords); + boundaryMesh=(ParaMEDMEM::MEDCouplingUMesh *) cellMesh->buildBoundaryMesh(keepCoords); boundaryMesh->setName("boundaryMesh"); - //cout<<"boundaryMesh "<getNumberOfCells()<checkCoherency(); - //boundaryMesh->tryToShareSameCoordsPermute(*cellMesh, 1e-10); - //meshes.push_back(boundaryMesh); - //string boundary="boundary_"+distfilename; - - /*try to find joint do no work - int rang=MyGlobals::_Rank; - if (rang==1) (_collection->getParaDomainSelector())->sendMesh(*(boundaryMesh),0); - if (rang==0) - { - (_collection->getParaDomainSelector())->recvMesh(boundaryMesh1,1); - //vector meshes; - //vector corr; - //meshes.push_back(boundaryMesh); - //meshes.push_back(boundaryMesh1); - //need share the same coords - //boundaryMesh1->tryToShareSameCoordsPermute(*boundaryMesh, 1e-10); - //finalboundaryMesh=MEDCouplingUMesh::FuseUMeshesOnSameCoords(meshes,2, corr); - //boundaryMesh=finalboundaryMesh; - - boundaryMesh->zipCoords(); - boundaryMesh1->zipCoords(); - finalboundaryMesh=MEDCouplingUMesh::MergeUMeshes(boundaryMesh,boundaryMesh1); - DataArrayInt* commonNodes=0; - commonNodes=finalboundaryMesh->zipCoordsTraducer(); - boundaryMesh=finalboundaryMesh; - cout<<"zipcoords"<repr()<decrRef(); - + if (faceMeshFilter!=0) + faceMeshFilter->decrRef(); if (boundaryMesh!=0) { @@ -316,122 +267,91 @@ void MeshCollectionDriver::writeMedFile(int idomain, const string& distfilename) MEDLoader::WriteUMesh(distfilename.c_str(), boundaryMesh, false); boundaryMesh->decrRef(); } - - //cout<<"familyInfo :\n"<getFamilyInfo())<getGroupInfo())<getMesh(idomain)->getName()); - - /*example of adding new family - (_collection->getFamilyInfo())["FaceNotOnCell"]=-500; - vector FaceNotOnCell; - FaceNotOnCell.push_back("FaceNotOnCell"); - (_collection->getGroupInfo())["FaceNotOnCell"]=FaceNotOnCell; - */ mfm->setFamilyInfo(_collection->getFamilyInfo()); mfm->setGroupInfo(_collection->getGroupInfo()); - //without filter mfm->setFamilyFieldArr(-1,(_collection->getFaceFamilyIds())[idomain]); - - string cle=Cle1ToStr("faceFamily_toArray",idomain); - if (_collection->getMapDataArrayInt().find(cle)!=_collection->getMapDataArrayInt().end()) + std::string key=Cle1ToStr("faceFamily_toArray",idomain); + if (_collection->getMapDataArrayInt().find(key)!=_collection->getMapDataArrayInt().end()) { - DataArrayInt* fam=_collection->getMapDataArrayInt().find(cle)->second; - DataArrayInt* famFilter=0; + ParaMEDMEM::DataArrayInt *fam=_collection->getMapDataArrayInt().find(key)->second; + ParaMEDMEM::DataArrayInt *famFilter=0; if (filter!=0) { int* index=filter->getPointer(); int nbTuples=filter->getNbOfElems(); //not the good one...buildPartOfMySelf do not exist for DataArray //Filter=fam->renumberAndReduce(index, filter->getNbOfElems()); - famFilter=DataArrayInt::New(); + famFilter=ParaMEDMEM::DataArrayInt::New(); famFilter->alloc(nbTuples,1); int* pfamFilter=famFilter->getPointer(); int* pfam=fam->getPointer(); - for (int i=0; isetFamilyFieldArr(-1,fam); famFilter->decrRef(); } - //cout<<"proc "<setFamilyFieldArr(-1,fam); - //if (famFilter!=0) famFilter->decrRef(); - } - - /*example visualisation of filter - if (_collection->getMapDataArrayInt().find(cle)!=_collection->getMapDataArrayInt().end()) - { - DataArrayInt* fam=_collection->getMapDataArrayInt().find(cle)->second; - string cle2=Cle1ToStr("filterNotFaceOnCell",idomain); - if (_collection->getMapDataArrayInt().find(cle2)!=_collection->getMapDataArrayInt().end()) - { - DataArrayInt* filter=_collection->getMapDataArrayInt().find(cle2)->second; - int* index=filter->getPointer(); - int* pfam=fam->getPointer(); - for (int i=0; igetNbOfElems(); i++) pfam[index[i]]=-500; - } - mfm->setFamilyFieldArr(-1,fam); - //mfm->setFamilyFieldArr(-1,_collection->getMapDataArrayInt().find(cle)->second); } - */ - cle=Cle1ToStr("cellFamily_toArray",idomain); - if (_collection->getMapDataArrayInt().find(cle)!=_collection->getMapDataArrayInt().end()) - mfm->setFamilyFieldArr(0,_collection->getMapDataArrayInt().find(cle)->second); + key=Cle1ToStr("cellFamily_toArray",idomain); + if (_collection->getMapDataArrayInt().find(key)!=_collection->getMapDataArrayInt().end()) + mfm->setFamilyFieldArr(0,_collection->getMapDataArrayInt().find(key)->second); mfm->write(distfilename.c_str(),0); - cle="/inewFieldDouble="+IntToStr(idomain)+"/"; + key="/inewFieldDouble="+IntToStr(idomain)+"/"; - map::iterator it; + std::map::iterator it; int nbfFieldFound=0; for (it=_collection->getMapDataArrayDouble().begin() ; it!=_collection->getMapDataArrayDouble().end(); it++) { - string desc=(*it).first; - size_t found=desc.find(cle); - if (found==string::npos) continue; - if (MyGlobals::_Verbose>20) cout<<"proc "<20) + std::cout << "proc " << MyGlobals::_Rank << " : write field " << desc << std::endl; + std::string meshName, fieldName; int typeField, DT, IT, entity; FieldShortDescriptionToData(desc, fieldName, typeField, entity, DT, IT); double time=StrToDouble(ExtractFromDescription(desc, "time=")); int typeData=StrToInt(ExtractFromDescription(desc, "typeData=")); - //int nbPtGauss=StrToInt(ExtractFromDescription(desc, "nbPtGauss=")); - string entityName=ExtractFromDescription(desc, "entityName="); - MEDCouplingFieldDouble* field=0; + std::string entityName=ExtractFromDescription(desc, "entityName="); + ParaMEDMEM::MEDCouplingFieldDouble* field=0; if (typeData!=6) { - cout<<"WARNING : writeMedFile : typeData "<setName(fieldName.c_str()); field->setMesh(mfm->getLevel0Mesh(false)); - DataArrayDouble* da=(*it).second; + ParaMEDMEM::DataArrayDouble *da=(*it).second; //get information for components etc.. - vector r1; + std::vector r1; r1=SelectTagsInVectorOfString(MyGlobals::_General_Informations,"fieldName="+fieldName); r1=SelectTagsInVectorOfString(r1,"typeField="+IntToStr(typeField)); r1=SelectTagsInVectorOfString(r1,"DT="+IntToStr(DT)); r1=SelectTagsInVectorOfString(r1,"IT="+IntToStr(IT)); //not saved in file? field->setDescription(ExtractFromDescription(r1[0], "fieldDescription=").c_str()); int nbc=StrToInt(ExtractFromDescription(r1[0], "nbComponents=")); - //double time=StrToDouble(ExtractFromDescription(r1[0], "time=")); if (nbc==da->getNumberOfComponents()) { for (int i=0; igetNumberOfComponents()<getNumberOfComponents() << std::endl; } field->setArray(da); @@ -448,20 +368,16 @@ void MeshCollectionDriver::writeMedFile(int idomain, const string& distfilename) try { MEDLoader::WriteField(distfilename.c_str(),field,false); - //if entityName=="MED_NODE_ELEMENT" - //AN INTERP_KERNEL::EXCEPTION HAS BEEN THROWN : Not implemented other profile fitting from already written mesh for fields than on NODES and on CELLS.********** - //modification MEDLoader.cxx done } catch(INTERP_KERNEL::Exception& e) { //cout trying rewrite all data, only one field defined - string tmp,newName=distfilename; + std::string tmp,newName=distfilename; tmp+="_"+fieldName+"_"+IntToStr(nbfFieldFound)+".med"; newName.replace(newName.find(".med"),4,tmp); - cout<<"WARNING : writeMedFile : new file name with only one field :"<decrRef(); } diff --git a/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionDriver.hxx b/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionDriver.hxx index 5ff51849f..bebac0d91 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionDriver.hxx +++ b/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionDriver.hxx @@ -34,20 +34,17 @@ namespace MEDPARTITIONER { public: MeshCollectionDriver(MeshCollection*); - virtual ~MeshCollectionDriver() - { - } + virtual ~MeshCollectionDriver() { } virtual int read(const char*, ParaDomainSelector* sel=0) = 0; int readSeq(const char*,const char*); - virtual void write(const char*, ParaDomainSelector* sel=0) = 0; - + virtual void write(const char*, ParaDomainSelector* sel=0) const = 0; protected: void readSubdomain(std::vector& cellglobal, std::vector& faceglobal, std::vector& nodeglobal, int idomain); void readSubdomain(int idomain); - void writeMedFile(int idomain, const std::string& distfilename); - + void writeMedFile(int idomain, const std::string& distfilename) const; + protected: MeshCollection* _collection; }; } diff --git a/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedAsciiDriver.cxx b/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedAsciiDriver.cxx index 5a60695fb..57ea4f540 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedAsciiDriver.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedAsciiDriver.cxx @@ -27,22 +27,19 @@ #include "MEDCouplingUMesh.hxx" #include "MEDLoader.hxx" -#include -#include #include #include -#include +#include +#include #include +#include #include #include #include #include -#include - using namespace MEDPARTITIONER; -using namespace std; MeshCollectionMedAsciiDriver::MeshCollectionMedAsciiDriver(MeshCollection* collection):MeshCollectionDriver(collection) { @@ -58,16 +55,17 @@ MeshCollectionMedAsciiDriver::MeshCollectionMedAsciiDriver(MeshCollection* colle int MeshCollectionMedAsciiDriver::read(const char* filename, ParaDomainSelector* domainSelector) { //distributed meshes - vector cellglobal; - vector nodeglobal; - vector faceglobal; + std::vector cellglobal; + std::vector nodeglobal; + std::vector faceglobal; int nbdomain; //reading ascii master file try { - ifstream asciiinput(filename); - if (!asciiinput) throw INTERP_KERNEL::Exception(LOCALIZED("Master ASCII File does not exist")); + std::ifstream asciiinput(filename); + if (!asciiinput) + throw INTERP_KERNEL::Exception("Master ASCII File does not exist"); char charbuffer[512]; asciiinput.getline(charbuffer,512); @@ -78,8 +76,6 @@ int MeshCollectionMedAsciiDriver::read(const char* filename, ParaDomainSelector* //reading number of domains nbdomain=atoi(charbuffer); - //cout << "nb domain "<>nbdomain; MyGlobals::_File_Names.resize(nbdomain); MyGlobals::_Mesh_Names.resize(nbdomain); (_collection->getMesh()).resize(nbdomain); @@ -87,13 +83,13 @@ int MeshCollectionMedAsciiDriver::read(const char* filename, ParaDomainSelector* nodeglobal.resize(nbdomain); faceglobal.resize(nbdomain); - if (nbdomain == 0) throw INTERP_KERNEL::Exception(LOCALIZED("Empty ASCII master file")); + if (nbdomain == 0) + throw INTERP_KERNEL::Exception("Empty ASCII master file"); for (int i=0; iisMyDomain(i)) readSubdomain(cellglobal,faceglobal,nodeglobal, i); @@ -115,19 +111,18 @@ int MeshCollectionMedAsciiDriver::read(const char* filename, ParaDomainSelector* } //of try catch(...) { - throw INTERP_KERNEL::Exception(LOCALIZED("I/O error reading parallel MED file")); + throw INTERP_KERNEL::Exception("I/O error reading parallel MED file"); } //creation of topology from mesh and connect zones - ParallelTopology* aPT = new ParallelTopology - ((_collection->getMesh()), (_collection->getCZ()), cellglobal, nodeglobal, faceglobal); + ParallelTopology* aPT = new ParallelTopology((_collection->getMesh()), (_collection->getCZ()), cellglobal, nodeglobal, faceglobal); _collection->setTopology(aPT); for (int i=0; igetMesh().size(); - vector filenames; + std::vector filenames; filenames.resize(nbdomains); //loop on the domains for (int idomain=0; idomainrank() == 0 ) { - ofstream file(filename); - file << "#MED Fichier V 2.3"<<" "<getMesh().size()<<" "<getMesh().size() << " " << std::endl; for (int idomain=0; idomaingetName() <<" "<< idomain+1 << " " << (_collection->getMesh())[idomain]->getName() << " localhost " - << filenames[idomain] << " "< -#include #include #include +#include +#include #include -#include #include #include +#include #include #include #include #include -#include - using namespace MEDPARTITIONER; -using namespace std; /*!\class MeshCollectionMedXmlDriver * @@ -85,13 +82,13 @@ int MeshCollectionMedXmlDriver::read(const char* filename, ParaDomainSelector* d xmlDocPtr master_doc=xmlParseFile(filename); if (!master_doc) - throw INTERP_KERNEL::Exception(LOCALIZED("Xml Master File does not exist or is not compliant with Xml scheme")); + throw INTERP_KERNEL::Exception("Xml Master File does not exist or is not compliant with Xml scheme"); //number of domains xmlXPathContextPtr xpathCtx = xmlXPathNewContext(master_doc); xmlXPathObjectPtr xpathObj = xmlXPathEvalExpression(BAD_CAST "//splitting/subdomain", xpathCtx); if (xpathObj==0 || xpathObj->nodesetval->nodeNr ==0) - throw INTERP_KERNEL::Exception(LOCALIZED("Xml Master File does not contain /MED/splitting/subdomain node")); + throw INTERP_KERNEL::Exception("Xml Master File does not contain /MED/splitting/subdomain node"); //as subdomain has only one property which is "number" //it suffices to take the content of its first child @@ -102,7 +99,7 @@ int MeshCollectionMedXmlDriver::read(const char* filename, ParaDomainSelector* d xmlXPathFreeObject(xpathObj); xpathObj = xmlXPathEvalExpression(BAD_CAST "//content/mesh", xpathCtx); if (xpathObj==0 || xpathObj->nodesetval->nodeNr ==0) - throw INTERP_KERNEL::Exception(LOCALIZED("Xml Master File does not contain /MED/content/mesh node")); + throw INTERP_KERNEL::Exception("Xml Master File does not contain /MED/content/mesh node"); _collection->setName( (const char*)xpathObj->nodesetval->nodeTab[0]->properties->children->content); //cout << "nb domain " << nbdomain << endl; @@ -118,29 +115,29 @@ int MeshCollectionMedXmlDriver::read(const char* filename, ParaDomainSelector* d xmlXPathFreeObject(xpathObj); xpathObj = xmlXPathEvalExpression(BAD_CAST filechar, xpathCtx); if (xpathObj==0 || xpathObj->nodesetval->nodeNr ==0) - throw INTERP_KERNEL::Exception(LOCALIZED("Xml Master File does not contain /MED/files/subfile nodes")); + throw INTERP_KERNEL::Exception("Xml Master File does not contain /MED/files/subfile nodes"); int nbfiles = xpathObj->nodesetval ->nodeNr; for (int i=0; inodesetval ==0) - throw INTERP_KERNEL::Exception(LOCALIZED("Error retrieving a file name from subfile of Xml Master File")); + throw INTERP_KERNEL::Exception("Error retrieving a file name from subfile of Xml Master File"); MyGlobals::_File_Names[i]=(const char*)xpathObjfilename->nodesetval->nodeTab[0]->children->content; //reading the local mesh names - ostringstream mesh_search_string; + std::ostringstream mesh_search_string; mesh_search_string<<"//mapping/mesh/chunk[@subdomain=\""<nodesetval ==0) - throw INTERP_KERNEL::Exception(LOCALIZED("Error retrieving mesh name from chunk of Xml Master File")); + throw INTERP_KERNEL::Exception("Error retrieving mesh name from chunk of Xml Master File"); MyGlobals::_Mesh_Names[i]=(const char*)xpathMeshObj->nodesetval->nodeTab[0]->children->content; if ( !domainSelector || domainSelector->isMyDomain(i)) @@ -157,7 +154,7 @@ int MeshCollectionMedXmlDriver::read(const char* filename, ParaDomainSelector* d } //of try catch(...) { - throw INTERP_KERNEL::Exception(LOCALIZED("I/O error reading parallel MED file")); + throw INTERP_KERNEL::Exception("I/O error reading parallel MED file"); } @@ -179,7 +176,7 @@ int MeshCollectionMedXmlDriver::read(const char* filename, ParaDomainSelector* d * with the connect zones being written as joints * \param filename name of the Xml file containing the meshes description */ -void MeshCollectionMedXmlDriver::write(const char* filename, ParaDomainSelector* domainSelector) +void MeshCollectionMedXmlDriver::write(const char* filename, ParaDomainSelector* domainSelector) const { xmlDocPtr master_doc = 0; xmlNodePtr root_node = 0, node, node2; @@ -235,22 +232,23 @@ void MeshCollectionMedXmlDriver::write(const char* filename, ParaDomainSelector* int nbdomains= _collection->getMesh().size(); //loop on the domains - string finalMeshName=ExtractFromDescription(MyGlobals::_General_Informations[0], "finalMeshName="); + std::string finalMeshName=ExtractFromDescription(MyGlobals::_General_Informations[0], "finalMeshName="); for (int idomain=nbdomains-1; idomain>=0;idomain--) { - string distfilename; - ostringstream suffix; + std::string distfilename; + std::ostringstream suffix; suffix<isMyDomain( idomain ) ) { - if ( (_collection->getMesh())[idomain]->getNumberOfCells()==0 ) continue; //empty domain + if ( (_collection->getMesh())[idomain]->getNumberOfCells()==0 ) + continue; //empty domain if (MyGlobals::_Verbose>1) - cout<<"proc "<rank()<<" : writeMedFile "<getMesh())[idomain]->getNumberOfCells()<<" cells" - << " "<<(_collection->getFaceMesh())[idomain]->getNumberOfCells()<<" faces" - << " "<<(_collection->getMesh())[idomain]->getNumberOfNodes()<<" nodes"<rank() << " : writeMedFile " << distfilename + << " "<< (_collection->getMesh())[idomain]->getNumberOfCells() << " cells" + << " " << (_collection->getFaceMesh())[idomain]->getNumberOfCells() << " faces" + << " " << (_collection->getMesh())[idomain]->getNumberOfNodes()<<" nodes" << std::endl; writeMedFile(idomain,distfilename); } @@ -273,9 +271,8 @@ void MeshCollectionMedXmlDriver::write(const char* filename, ParaDomainSelector* //create the ascii description file if (domainSelector->rank()==0) { - string myfile(filename); + std::string myfile(filename); myfile.append(".xml"); - _master_filename=myfile; if ( !domainSelector || domainSelector->rank() == 0 ) xmlSaveFormatFileEnc(myfile.c_str(), master_doc, "UTF-8", 1); } diff --git a/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedXmlDriver.hxx b/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedXmlDriver.hxx index 61b4c90f7..2b269960e 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedXmlDriver.hxx +++ b/src/MEDPartitioner/MEDPARTITIONER_MeshCollectionMedXmlDriver.hxx @@ -29,11 +29,9 @@ namespace MEDPARTITIONER { public: MeshCollectionMedXmlDriver(MeshCollection*); - virtual ~MeshCollectionMedXmlDriver() - { - } + virtual ~MeshCollectionMedXmlDriver() { } int read(const char*, ParaDomainSelector* sel=0); - void write(const char*, ParaDomainSelector* sel=0); + void write(const char*, ParaDomainSelector* sel=0) const; private : std::string _master_filename; }; diff --git a/src/MEDPartitioner/MEDPARTITIONER_MetisGraph.cxx b/src/MEDPartitioner/MEDPARTITIONER_MetisGraph.cxx index fe07e8ad4..b08a31561 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_MetisGraph.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_MetisGraph.cxx @@ -37,7 +37,6 @@ extern "C" } #endif -using namespace ParaMEDMEM; using namespace MEDPARTITIONER; METISGraph::METISGraph():Graph() @@ -169,7 +168,7 @@ void METISGraph::partGraph(int ndomain, catch(...) { //shit ParMETIS "Error! Key -2 not found!" not catched... - throw INTERP_KERNEL::Exception(LOCALIZED("Problem in ParMETIS_PartKway")); + throw INTERP_KERNEL::Exception("Problem in ParMETIS_PartKway"); } if (n<8 && nparts==3) { @@ -177,7 +176,7 @@ void METISGraph::partGraph(int ndomain, partition[i]=i%3; } #else - throw INTERP_KERNEL::Exception(LOCALIZED("ParMETIS is not available. Check your products, please.")); + throw INTERP_KERNEL::Exception("ParMETIS is not available. Check your products, please."); #endif } else @@ -192,7 +191,7 @@ void METISGraph::partGraph(int ndomain, METIS_PartGraphKway(&n, xadj, adjncy, vwgt, adjwgt, &wgtflag, &base, &nparts, options, &edgecut, partition); #else - throw INTERP_KERNEL::Exception(LOCALIZED("METIS is not available. Check your products, please.")); + throw INTERP_KERNEL::Exception("METIS is not available. Check your products, please."); #endif } } diff --git a/src/MEDPartitioner/MEDPARTITIONER_ParaDomainSelector.cxx b/src/MEDPartitioner/MEDPARTITIONER_ParaDomainSelector.cxx index 0ba2eb254..3c6cf0563 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_ParaDomainSelector.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_ParaDomainSelector.cxx @@ -30,17 +30,10 @@ #include #endif -#ifndef WIN32 -#include -#endif - -using namespace std; -using namespace MEDPARTITIONER; - /*! * \brief Constructor. Find out my rank and world size */ -ParaDomainSelector::ParaDomainSelector(bool mesure_memory) +MEDPARTITIONER::ParaDomainSelector::ParaDomainSelector(bool mesure_memory) :_rank(0),_world_size(1), _nb_result_domains(-1), _mesure_memory(mesure_memory), _init_time(0.0), _init_memory(0), _max_memory(0) { @@ -52,14 +45,14 @@ ParaDomainSelector::ParaDomainSelector(bool mesure_memory) evaluateMemory(); } -ParaDomainSelector::~ParaDomainSelector() +MEDPARTITIONER::ParaDomainSelector::~ParaDomainSelector() { } /*! * \brief Return true if is running on different hosts */ -bool ParaDomainSelector::isOnDifferentHosts() const +bool MEDPARTITIONER::ParaDomainSelector::isOnDifferentHosts() const { evaluateMemory(); if ( _world_size < 2 ) return false; @@ -78,16 +71,14 @@ bool ParaDomainSelector::isOnDifferentHosts() const (void*)&name_there[0], MPI_MAX_PROCESSOR_NAME, MPI_CHAR, prev_proc, tag, MPI_COMM_WORLD, &status); - //cout<<"proc "<& domain_meshes) +void MEDPARTITIONER::ParaDomainSelector::gatherNbOf(const std::vector& domain_meshes) { evaluateMemory(); // get nb of elems of each domain mesh int nb_domains=domain_meshes.size(); - //cout<<"proc "< nb_elems(nb_domains*2, 0); //NumberOfCells & NumberOfNodes + std::vector nb_elems(nb_domains*2, 0); //NumberOfCells & NumberOfNodes for (int i=0; i& nb_elems[i*2+1] = domain_meshes[i]->getNumberOfNodes(); } // receive nb of elems from other procs - vector all_nb_elems( nb_domains*2 ); + std::vector all_nb_elems( nb_domains*2 ); #ifdef HAVE_MPI2 MPI_Allreduce((void*)&nb_elems[0], (void*)&all_nb_elems[0], nb_domains*2, MPI_INT, MPI_SUM, MPI_COMM_WORLD); @@ -148,13 +138,13 @@ void ParaDomainSelector::gatherNbOf(const vector& } if (MyGlobals::_Is0verbose>10) - cout<<"totalNbCells "<& cell_shift_by_domain=_cell_shift_by_domain; - vector& node_shift_by_domain=_node_shift_by_domain; - vector& face_shift_by_domain=_face_shift_by_domain; + std::vector& cell_shift_by_domain=_cell_shift_by_domain; + std::vector& node_shift_by_domain=_node_shift_by_domain; + std::vector& face_shift_by_domain=_face_shift_by_domain; - vector< int > ordered_nbs_cell, ordered_nbs_node, domain_order(nb_domains); + std::vector< int > ordered_nbs_cell, ordered_nbs_node, domain_order(nb_domains); ordered_nbs_cell.push_back(0); ordered_nbs_node.push_back(0); for (int iproc=0; iproc& if (MyGlobals::_Is0verbose>300) { - cout<<"proc "<& if (MyGlobals::_Is0verbose>200) { - cout<<"proc "<& * The result array is to be used as the first arg of ParMETIS_V3_PartKway() and * is freed by ParaDomainSelector. */ -int* ParaDomainSelector::getProcVtxdist() const +int *MEDPARTITIONER::ParaDomainSelector::getProcVtxdist() const { evaluateMemory(); - if (_nb_vert_of_procs.empty()) throw INTERP_KERNEL::Exception(LOCALIZED("_nb_vert_of_procs not set")); + if (_nb_vert_of_procs.empty()) + throw INTERP_KERNEL::Exception("_nb_vert_of_procs not set"); return (int*) & _nb_vert_of_procs[0]; } @@ -228,17 +222,19 @@ int* ParaDomainSelector::getProcVtxdist() const * gatherNbOf() must be called before. * Result added to local id on given domain gives id in the whole distributed mesh */ -int ParaDomainSelector::getDomainCellShift(int domainIndex) const +int MEDPARTITIONER::ParaDomainSelector::getDomainCellShift(int domainIndex) const { evaluateMemory(); - if (_cell_shift_by_domain.empty()) throw INTERP_KERNEL::Exception(LOCALIZED("_cell_shift_by_domain not set")); + if (_cell_shift_by_domain.empty()) + throw INTERP_KERNEL::Exception("_cell_shift_by_domain not set"); return _cell_shift_by_domain[domainIndex]; } -int ParaDomainSelector::getDomainNodeShift(int domainIndex) const +int MEDPARTITIONER::ParaDomainSelector::getDomainNodeShift(int domainIndex) const { evaluateMemory(); - if (_node_shift_by_domain.empty()) throw INTERP_KERNEL::Exception(LOCALIZED("_node_shift_by_domain not set")); + if (_node_shift_by_domain.empty()) + throw INTERP_KERNEL::Exception("_node_shift_by_domain not set"); return _node_shift_by_domain[domainIndex]; } @@ -248,18 +244,18 @@ int ParaDomainSelector::getDomainNodeShift(int domainIndex) const * gatherNbOf() must be called before. * Result added to global id on this processor gives id in the whole distributed mesh */ -int ParaDomainSelector::getProcNodeShift() const +int MEDPARTITIONER::ParaDomainSelector::getProcNodeShift() const { evaluateMemory(); - if (_nb_vert_of_procs.empty()) throw INTERP_KERNEL::Exception(LOCALIZED("_nb_vert_of_procs not set")); - //cout<<"_nb_vert_of_procs "<<_nb_vert_of_procs[0]<<" "<<_nb_vert_of_procs[1]< ParaDomainSelector::gatherGraph(const Graph* graph) const +std::auto_ptr MEDPARTITIONER::ParaDomainSelector::gatherGraph(const Graph* graph) const { Graph* glob_graph = 0; @@ -270,14 +266,14 @@ auto_ptr ParaDomainSelector::gatherGraph(const Graph* graph) const // Gather indices // --------------- - vector index_size_of_proc( nbProcs() ); // index sizes - 1 + std::vector index_size_of_proc( nbProcs() ); // index sizes - 1 for ( int i = 1; i < _nb_vert_of_procs.size(); ++i ) index_size_of_proc[i-1] = _nb_vert_of_procs[ i ] - _nb_vert_of_procs[ i-1 ]; int index_size = 1 + _cell_shift_by_domain.back(); - int* graph_index = new int[ index_size ]; - const int* index = graph->getGraph()->getIndex(); - int* proc_index_displacement = (int*) & _nb_vert_of_procs[0]; + int *graph_index = new int[ index_size ]; + const int *index = graph->getGraph()->getIndex(); + int *proc_index_displacement = (int*) & _nb_vert_of_procs[0]; MPI_Allgatherv((void*) (index+1), // send local index except first 0 (or 1) index_size_of_proc[_rank], // index size on this proc @@ -290,7 +286,7 @@ auto_ptr ParaDomainSelector::gatherGraph(const Graph* graph) const graph_index[0] = index[0]; // it is not overwritten thanks to proc_index_displacement[0]==1 // get sizes of graph values on each proc by the got indices of graphs - vector< int > value_size_of_proc( nbProcs() ), proc_value_displacement(1,0); + std::vector< int > value_size_of_proc( nbProcs() ), proc_value_displacement(1,0); for ( int i = 0; i < nbProcs(); ++i ) { if ( index_size_of_proc[i] > 0 ) @@ -313,8 +309,8 @@ auto_ptr ParaDomainSelector::gatherGraph(const Graph* graph) const // -------------- int value_size = graph_index[ index_size-1 ] - graph_index[ 0 ]; - int* graph_value = new int[ value_size ]; - const int* value = graph->getGraph()->getValue(); + int *graph_value = new int[ value_size ]; + const int *value = graph->getGraph()->getValue(); MPI_Allgatherv((void*) value, // send local value value_size_of_proc[_rank], // value size on this proc @@ -356,14 +352,14 @@ auto_ptr ParaDomainSelector::gatherGraph(const Graph* graph) const #endif // HAVE_MPI2 - return auto_ptr( glob_graph ); + return std::auto_ptr( glob_graph ); } /*! * \brief Set nb of cell/cell pairs in a joint between domains */ -void ParaDomainSelector::setNbCellPairs( int nb_cell_pairs, int dist_domain, int loc_domain ) +void MEDPARTITIONER::ParaDomainSelector::setNbCellPairs( int nb_cell_pairs, int dist_domain, int loc_domain ) { // This method is needed for further computing global numbers of faces in joint. // Store if both domains are on this proc else on one of procs only @@ -384,7 +380,7 @@ void ParaDomainSelector::setNbCellPairs( int nb_cell_pairs, int dist_domain, int */ //================================================================================ -int ParaDomainSelector::getNbCellPairs( int dist_domain, int loc_domain ) const +int MEDPARTITIONER::ParaDomainSelector::getNbCellPairs( int dist_domain, int loc_domain ) const { evaluateMemory(); @@ -398,13 +394,13 @@ int ParaDomainSelector::getNbCellPairs( int dist_domain, int loc_domain ) const */ //================================================================================ -void ParaDomainSelector::gatherNbCellPairs() +void MEDPARTITIONER::ParaDomainSelector::gatherNbCellPairs() { if ( _nb_cell_pairs_by_joint.empty() ) _nb_cell_pairs_by_joint.resize( _nb_result_domains*(_nb_result_domains+1), 0); evaluateMemory(); - vector< int > send_buf = _nb_cell_pairs_by_joint; + std::vector< int > send_buf = _nb_cell_pairs_by_joint; #ifdef HAVE_MPI2 MPI_Allreduce((void*)&send_buf[0], (void*)&_nb_cell_pairs_by_joint[0], @@ -415,7 +411,7 @@ void ParaDomainSelector::gatherNbCellPairs() // namely that each joint is treated on one proc only for ( int j = 0; j < _nb_cell_pairs_by_joint.size(); ++j ) if ( _nb_cell_pairs_by_joint[j] != send_buf[j] && send_buf[j]>0 ) - throw INTERP_KERNEL::Exception(LOCALIZED("invalid nb of cell pairs")); + throw INTERP_KERNEL::Exception("invalid nb of cell pairs"); } //================================================================================ @@ -424,7 +420,7 @@ void ParaDomainSelector::gatherNbCellPairs() */ //================================================================================ -int ParaDomainSelector::getFisrtGlobalIdOfSubentity( int loc_domain, int dist_domain ) const +int MEDPARTITIONER::ParaDomainSelector::getFisrtGlobalIdOfSubentity( int loc_domain, int dist_domain ) const { // total_nb_faces includes faces existing before creation of joint faces // (got in gatherNbOf( MED_FACE )). @@ -434,7 +430,7 @@ int ParaDomainSelector::getFisrtGlobalIdOfSubentity( int loc_domain, int dist_do int id = total_nb_faces + 1; if ( _nb_cell_pairs_by_joint.empty() ) - throw INTERP_KERNEL::Exception(LOCALIZED("gatherNbCellPairs() must be called before")); + throw INTERP_KERNEL::Exception("gatherNbCellPairs() must be called before"); int joint_id = jointId( loc_domain, dist_domain ); for ( int j = 0; j < joint_id; ++j ) id += _nb_cell_pairs_by_joint[ j ]; @@ -448,8 +444,8 @@ int ParaDomainSelector::getFisrtGlobalIdOfSubentity( int loc_domain, int dist_do */ //================================================================================ -int* ParaDomainSelector::exchangeSubentityIds( int loc_domain, int dist_domain, - const vector& loc_ids_here ) const +int *MEDPARTITIONER::ParaDomainSelector::exchangeSubentityIds( int loc_domain, int dist_domain, + const std::vector& loc_ids_here ) const { int* loc_ids_dist = new int[ loc_ids_here.size()]; int dest = getProcessorID( dist_domain ); @@ -471,14 +467,14 @@ int* ParaDomainSelector::exchangeSubentityIds( int loc_domain, int dist_domain, */ //================================================================================ -int ParaDomainSelector::jointId( int local_domain, int distant_domain ) const +int MEDPARTITIONER::ParaDomainSelector::jointId( int local_domain, int distant_domain ) const { evaluateMemory(); if (_nb_result_domains < 0) - throw INTERP_KERNEL::Exception(LOCALIZED("setNbDomains() must be called before")); + throw INTERP_KERNEL::Exception("setNbDomains() must be called before"); if ( local_domain < distant_domain ) - swap( local_domain, distant_domain ); + std::swap( local_domain, distant_domain ); return local_domain * _nb_result_domains + distant_domain; } @@ -489,7 +485,7 @@ int ParaDomainSelector::jointId( int local_domain, int distant_domain ) const */ //================================================================================ -double ParaDomainSelector::getPassedTime() const +double MEDPARTITIONER::ParaDomainSelector::getPassedTime() const { #ifdef HAVE_MPI2 return MPI_Wtime() - _init_time; @@ -498,54 +494,28 @@ double ParaDomainSelector::getPassedTime() const #endif } -/*! - * \brief Evaluate current memory usage and return the maximal one in KB - */ -int ParaDomainSelector::evaluateMemory() const -{ - if ( _mesure_memory ) - { - int used_memory = 0; -#ifndef WIN32 - struct sysinfo si; - int err = sysinfo( &si ); - if ( !err ) - used_memory = - (( si.totalram - si.freeram + si.totalswap - si.freeswap ) * si.mem_unit ) / 1024; -#endif - if ( used_memory > _max_memory ) - ((ParaDomainSelector*) this)->_max_memory = used_memory; - - if ( !_init_memory ) - ((ParaDomainSelector*) this)->_init_memory = used_memory; - } - 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 +void MEDPARTITIONER::ParaDomainSelector::sendMesh(const ParaMEDMEM::MEDCouplingUMesh& mesh, int target) const { - if (MyGlobals::_Verbose>600) cout<<"proc "<<_rank<<" : sendMesh '"<600) + std::cout << "proc " << _rank << " : sendMesh '" << mesh.getName() << "' size " << mesh.getNumberOfCells() << " to " << target << std::endl; // First stage : sending sizes // ------------------------------ - vector tinyInfoLocal; - vector tinyInfoLocalS; - vector tinyInfoLocalD; + std::vector tinyInfoLocal; + std::vector tinyInfoLocalS; + std::vector tinyInfoLocalD; //Getting tiny info of local mesh to allow the distant proc to initialize and allocate //the transmitted mesh. mesh.getTinySerializationInformation(tinyInfoLocalD,tinyInfoLocal,tinyInfoLocalS); - //cout<<"sendMesh getTinySerializationInformation "<getNbOfElems(); //cvw if empty be 1! + nbLocalElems=v1Local->getNbOfElems(); // if empty be 1! ptLocal=v1Local->getPointer(); } -#ifdef HAVE_MPI2 +#ifdef HAVE_MPI2 MPI_Send(ptLocal, nbLocalElems, MPI_INT, target, 1111, MPI_COMM_WORLD); #endif int nbLocalElems2=0; double *ptLocal2=0; - if(v2Local) //cvw if empty be 0! + if(v2Local) //if empty be 0! { nbLocalElems2=v2Local->getNbOfElems(); ptLocal2=v2Local->getPointer(); @@ -578,11 +548,6 @@ void ParaDomainSelector::sendMesh(const ParaMEDMEM::MEDCouplingUMesh& mesh, int if(v1Local) v1Local->decrRef(); if(v2Local) v2Local->decrRef(); } - else - { - //cout<<"sendMesh empty Mesh cvw3344 "< tinyInfoDistant; - vector tinyInfoLocalS; - vector tinyInfoDistantD(1); + std::vector tinyInfoDistant; + std::vector tinyInfoLocalS; + std::vector tinyInfoDistantD(1); //Getting tiny info of local mesh to allow the distant proc to initialize and allocate //the transmitted mesh. #ifdef HAVE_MPI2 @@ -612,7 +577,6 @@ void ParaDomainSelector::recvMesh(ParaMEDMEM::MEDCouplingUMesh*& mesh, int sourc #endif //there was tinyInfoLocal.push_back(mesh.getNumberOfCells()); int NumberOfCells=tinyInfoDistant[tinyVecSize-1]; - //cout<<"recvMesh NumberOfCells "<0) { ParaMEDMEM::DataArrayInt *v1Distant=ParaMEDMEM::DataArrayInt::New(); @@ -654,6 +618,33 @@ void ParaDomainSelector::recvMesh(ParaMEDMEM::MEDCouplingUMesh*& mesh, int sourc { mesh=CreateEmptyMEDCouplingUMesh(); } - if (MyGlobals::_Verbose>600) cout<<"proc "<<_rank<<" : recvMesh '"<getName()<<"' size "<getNumberOfCells()<<" from "<600) + std::cout << "proc " << _rank << " : recvMesh '" << mesh->getName() << "' size " << mesh->getNumberOfCells() << " from " << source << std::endl; } +#ifndef WIN32 +#include +#endif + +/*! + * \brief Evaluate current memory usage and return the maximal one in KB + */ +int MEDPARTITIONER::ParaDomainSelector::evaluateMemory() const +{ + if ( _mesure_memory ) + { + int used_memory = 0; +#ifndef WIN32 + struct sysinfo si; + int err = sysinfo( &si ); + if ( !err ) + used_memory = (( si.totalram - si.freeram + si.totalswap - si.freeswap ) * si.mem_unit ) / 1024; +#endif + if ( used_memory > _max_memory ) + ((ParaDomainSelector*) this)->_max_memory = used_memory; + + if ( !_init_memory ) + ((ParaDomainSelector*) this)->_init_memory = used_memory; + } + return _max_memory - _init_memory; +} diff --git a/src/MEDPartitioner/MEDPARTITIONER_ParaDomainSelector.hxx b/src/MEDPartitioner/MEDPARTITIONER_ParaDomainSelector.hxx index f49583294..0d1953415 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_ParaDomainSelector.hxx +++ b/src/MEDPartitioner/MEDPARTITIONER_ParaDomainSelector.hxx @@ -30,7 +30,6 @@ namespace ParaMEDMEM class MEDCouplingUMesh; } - namespace MEDPARTITIONER { class Graph; @@ -41,9 +40,7 @@ namespace MEDPARTITIONER */ class MEDPARTITIONER_EXPORT ParaDomainSelector { - public: - ParaDomainSelector(bool mesure_memory=false); ~ParaDomainSelector(); @@ -102,9 +99,9 @@ namespace MEDPARTITIONER void sendMesh(const ParaMEDMEM::MEDCouplingUMesh& mesh, int target) const; void recvMesh(ParaMEDMEM::MEDCouplingUMesh*& mesh, int source) const; - private: - int _rank, _world_size; //my rank and nb of processors + int _rank; //my rank + int _world_size; //nb of processors int _nb_result_domains; //required nb of domains std::vector< int > _nb_cell_pairs_by_joint; @@ -114,8 +111,9 @@ namespace MEDPARTITIONER std::vector< int > _face_shift_by_domain; double _init_time; - bool _mesure_memory; - int _init_memory, _max_memory; + bool _mesure_memory; + int _init_memory; + int _max_memory; }; } #endif diff --git a/src/MEDPartitioner/MEDPARTITIONER_ParallelTopology.cxx b/src/MEDPartitioner/MEDPARTITIONER_ParallelTopology.cxx index 1c4a67c15..bca8b4b89 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_ParallelTopology.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_ParallelTopology.cxx @@ -37,21 +37,21 @@ #endif using namespace MEDPARTITIONER; -using namespace std; ParallelTopology::ParallelTopology():_nb_domain(0),_mesh_dimension(0) { } //constructing topology according to mesh collection without global numerotation (use setGlobalNumerotation later) -ParallelTopology::ParallelTopology(const vector& meshes) +ParallelTopology::ParallelTopology(const std::vector& meshes) { _nb_domain=meshes.size(); _nb_cells.resize(_nb_domain); _nb_nodes.resize(_nb_domain); // _nb_faces.resize(_nb_domain); - if (MyGlobals::_Is0verbose>100) cout<<"new ParallelTopology\n"; + if (MyGlobals::_Is0verbose>100) + std::cout << "new ParallelTopology\n"; _loc_to_glob.resize(0); //precaution, need gatherNbOf() setGlobalNumerotation() _node_loc_to_glob.resize(0); //precaution, need gatherNbOf() setGlobalNumerotation() //_face_loc_to_glob.resize(_nb_domain); @@ -60,7 +60,8 @@ ParallelTopology::ParallelTopology(const vector& for (int idomain=0; !parallel_mode && idomain<_nb_domain; idomain++) parallel_mode = (!meshes[idomain]); - if (MyGlobals::_Is0verbose>20 && !parallel_mode) cout<<"WARNING : ParallelTopology contructor without parallel_mode"<20 && !parallel_mode) + std::cout << "WARNING : ParallelTopology contructor without parallel_mode" << std::endl; for (int idomain=0; idomain<_nb_domain; idomain++) { if ( !meshes[idomain] ) continue; @@ -71,7 +72,7 @@ ParallelTopology::ParallelTopology(const vector& else { if (_mesh_dimension!=meshes[idomain]->getMeshDimension()) - throw INTERP_KERNEL::Exception(LOCALIZED("meshes dimensions incompatible")); + throw INTERP_KERNEL::Exception("meshes dimensions incompatible"); } _nb_cells[idomain]=meshes[idomain]->getNumberOfCells(); _nb_nodes[idomain]=meshes[idomain]->getNumberOfNodes(); @@ -82,14 +83,16 @@ ParallelTopology::ParallelTopology(const vector& //constructing _loc_to_glob etc by default, needs gatherNbOf() done void ParallelTopology::setGlobalNumerotationDefault(ParaDomainSelector* domainSelector) { - if (MyGlobals::_Is0verbose>100) cout<<"setGlobalNumerotationDefault on "<<_nb_domain<<" domains\n"; - if (_loc_to_glob.size()!=0) throw INTERP_KERNEL::Exception(LOCALIZED("a global numerotation is done yet")); + if (MyGlobals::_Is0verbose>100) + std::cout<< "setGlobalNumerotationDefault on " << _nb_domain << " domains\n"; + if (_loc_to_glob.size()!=0) throw INTERP_KERNEL::Exception("a global numerotation is done yet"); _loc_to_glob.resize(_nb_domain); _node_loc_to_glob.resize(_nb_domain); //warning because _nb_cells[idomain] is 0 if not my domain(s) //we set loc_to_glob etc.. only for my domain(s) - if (MyGlobals::_Is0verbose>500) cout<<"(c)idomain|ilocalCell|iglobalCell"<500) + std::cout << "(c)idomain|ilocalCell|iglobalCell" << std::endl; for (int idomain=0; idomain<_nb_domain; idomain++) { _loc_to_glob[idomain].resize(_nb_cells[idomain]); @@ -97,15 +100,16 @@ void ParallelTopology::setGlobalNumerotationDefault(ParaDomainSelector* domainSe for (int i=0; i<_nb_cells[idomain]; i++) { int global=domainCellShift+i ; - _glob_to_loc.insert(make_pair(global,make_pair(idomain,i))); + _glob_to_loc.insert(std::make_pair(global,std::make_pair(idomain,i))); _loc_to_glob[idomain][i]=global; - if (MyGlobals::_Verbose>500) cout<<"c"<500) + std::cout << "c" << idomain << "|" << i << "|" << global << " "; } } if (MyGlobals::_Verbose>500) MPI_Barrier(MPI_COMM_WORLD); - if (MyGlobals::_Is0verbose>500) cout<500) std::cout << std::endl; - if (MyGlobals::_Is0verbose>500) cout<<"(n)idomain|ilocalNode|iglobalNode"<500) std::cout << "(n)idomain|ilocalNode|iglobalNode" << std::endl; for (int idomain=0; idomain<_nb_domain; idomain++) { _node_loc_to_glob[idomain].resize(_nb_nodes[idomain]); @@ -113,26 +117,28 @@ void ParallelTopology::setGlobalNumerotationDefault(ParaDomainSelector* domainSe for (int i=0; i<_nb_nodes[idomain]; i++) { int global=domainNodeShift+i ; - _node_glob_to_loc.insert(make_pair(global,make_pair(idomain,i))); + _node_glob_to_loc.insert(std::make_pair(global,std::make_pair(idomain,i))); _node_loc_to_glob[idomain][i]=global; - if (MyGlobals::_Verbose>500) cout<<"n"<500) + std::cout << "n" << idomain << "|" << i << "|" << global << " "; } } if (MyGlobals::_Verbose>500) MPI_Barrier(MPI_COMM_WORLD); - if (MyGlobals::_Is0verbose>500) cout<500) std::cout << std::endl; _nb_total_cells=domainSelector->getNbTotalCells(); _nb_total_nodes=domainSelector->getNbTotalNodes(); _nb_total_faces=domainSelector->getNbTotalFaces(); - if (MyGlobals::_Is0verbose>200) cout<<"globalNumerotation default done meshDimension "<<_mesh_dimension<<" nbTotalCells "<<_nb_total_cells<<" nbTotalNodes "<<_nb_total_nodes<200) + std::cout << "globalNumerotation default done meshDimension " << _mesh_dimension << " nbTotalCells " << _nb_total_cells << " nbTotalNodes " << _nb_total_nodes << std::endl; } //constructing topology according to mesh collection -ParallelTopology::ParallelTopology(const vector& meshes, - const vector& cz, - vector& cellglobal, - vector& nodeglobal, - vector& faceglobal) +ParallelTopology::ParallelTopology(const std::vector& meshes, + const std::vector& cz, + std::vector& cellglobal, + std::vector& nodeglobal, + std::vector& faceglobal) { _nb_domain=meshes.size(); int index_global=0; @@ -168,9 +174,8 @@ ParallelTopology::ParallelTopology(const vector& for (int i=0; i<_nb_cells[idomain]; i++) { int global=i ;//cellDomainShift+i; - _glob_to_loc.insert(make_pair(global,make_pair(idomain,i))); + _glob_to_loc.insert(std::make_pair(global,std::make_pair(idomain,i))); _loc_to_glob[idomain][i]=global; - //cvw cout<& for (int i=0; i<_nb_cells[idomain]; i++) { int global=cellglobal[idomain][i]; - _glob_to_loc.insert(make_pair(global,make_pair(idomain,i))); + _glob_to_loc.insert(std::make_pair(global,std::make_pair(idomain,i))); //_loc_to_glob[make_pair(idomain,i+1)]=global; _loc_to_glob[idomain][i]=global; index_global++; - // cout<<"glob:"< ("<& _node_loc_to_glob[idomain].resize(meshes[idomain]->getNumberOfNodes()); for (int i=0; igetNumberOfNodes(); i++) { - _node_glob_to_loc.insert(make_pair(i,make_pair(0,i))); + _node_glob_to_loc.insert(std::make_pair(i,std::make_pair(0,i))); _node_loc_to_glob[0][i]=i; } _nb_total_nodes=meshes[idomain]->getNumberOfNodes(); @@ -206,7 +210,7 @@ ParallelTopology::ParallelTopology(const vector& //creating node maps _nb_nodes[idomain]=meshes[idomain]->getNumberOfNodes(); - INTERP_KERNEL::HashMap > local2distant; + INTERP_KERNEL::HashMap > local2distant; _node_loc_to_glob[idomain].resize(_nb_nodes[idomain]); for (int icz=0; icz& { int local= node_corresp[i*2]; int distant = node_corresp[i*2+1]; - local2distant.insert(make_pair(local, make_pair(distant_ip,distant))); + local2distant.insert(std::make_pair(local, std::make_pair(distant_ip,distant))); } } } @@ -232,7 +236,7 @@ ParallelTopology::ParallelTopology(const vector& if (local2distant.find(inode)==local2distant.end()) { index_node_global++; - _node_glob_to_loc.insert(make_pair(index_node_global,make_pair(idomain,inode))); + _node_glob_to_loc.insert(std::make_pair(index_node_global,std::make_pair(idomain,inode))); //_node_loc_to_glob[make_pair(idomain,inode+1)]=index_node_global; _node_loc_to_glob[idomain][inode]=index_node_global; } @@ -241,7 +245,7 @@ ParallelTopology::ParallelTopology(const vector& int ip = (local2distant.find(inode)->second).first; int distant = (local2distant.find(inode)->second).second; int global_number=_loc_to_glob[ip][distant]; - _node_glob_to_loc.insert(make_pair(global_number,make_pair(idomain,inode))); + _node_glob_to_loc.insert(std::make_pair(global_number,std::make_pair(idomain,inode))); _node_loc_to_glob[idomain][inode]=global_number; } } @@ -252,7 +256,7 @@ ParallelTopology::ParallelTopology(const vector& for (int inode=0; inode<_nb_nodes[idomain]; inode++) { int global_number=nodeglobal[idomain][inode]; - _node_glob_to_loc.insert(make_pair(global_number,make_pair(idomain,inode))); + _node_glob_to_loc.insert(std::make_pair(global_number,std::make_pair(idomain,inode))); _node_loc_to_glob[idomain][inode]=global_number; } } @@ -273,8 +277,8 @@ ParallelTopology::ParallelTopology(Graph* graph, Topology* oldTopology, int nb_d _mesh_dimension=mesh_dimension; if (MyGlobals::_Verbose>200) - cout<<"proc "<nbDomain()<<" newNbDomain "<<_nb_domain<nbDomain() << " newNbDomain " << _nb_domain << std::endl; _nb_cells.resize(_nb_domain,0); _nb_nodes.resize(_nb_domain,0); _nb_faces.resize(_nb_domain,0); @@ -286,7 +290,7 @@ ParallelTopology::ParallelTopology(Graph* graph, Topology* oldTopology, int nb_d const int* part=graph->getPart(); //all cells for this proc (may be more domains) _nb_total_cells=graph->nbVertices(); //all cells for this proc (may be more domains) if (MyGlobals::_Verbose>300) - cout<<"proc "<nbDomain(); iold++) @@ -303,13 +307,13 @@ ParallelTopology::ParallelTopology(Graph* graph, Topology* oldTopology, int nb_d icellProc++; int iGlobalCell=globalids[icell]; _loc_to_glob[idomain].push_back(iGlobalCell); - _glob_to_loc.insert(make_pair(iGlobalCell, make_pair(idomain, _nb_cells[idomain]))); + _glob_to_loc.insert(std::make_pair(iGlobalCell, std::make_pair(idomain, _nb_cells[idomain]))); } } if (MyGlobals::_Verbose>300) for (int idomain=0; idomain<_nb_domain; idomain++) - cout<<"proc "< local_node = _node_glob_to_loc.find(node_list[i])->second; + std::pair local_node = _node_glob_to_loc.find(node_list[i])->second; ip[i]=local_node.first; local[i]=local_node.second; } @@ -344,12 +348,12 @@ void ParallelTopology::convertGlobalNodeList(const int* node_list, int nbnode, i void ParallelTopology::convertGlobalNodeList(const int* node_list, int nbnode, int* local, int ip) { if (_node_glob_to_loc.empty()) - throw INTERP_KERNEL::Exception(LOCALIZED("Node mapping has not yet been built")); + throw INTERP_KERNEL::Exception("Node mapping has not yet been built"); for (int i=0; i< nbnode; i++) { - typedef INTERP_KERNEL::HashMultiMap >::iterator mmiter; - pair range=_node_glob_to_loc.equal_range(node_list[i]); + typedef INTERP_KERNEL::HashMultiMap >::iterator mmiter; + std::pair range=_node_glob_to_loc.equal_range(node_list[i]); for (mmiter it=range.first; it !=range.second; it++) { int ipfound=(it->second).first; @@ -368,14 +372,12 @@ void ParallelTopology::convertGlobalNodeList(const int* node_list, int nbnode, i void ParallelTopology::convertGlobalNodeListWithTwins(const int* node_list, int nbnode, int*& local, int*& ip,int*& full_array, int& size) { if (_node_glob_to_loc.empty()) - throw INTERP_KERNEL::Exception(LOCALIZED("Node mapping has not yet been built")); + throw INTERP_KERNEL::Exception("Node mapping has not yet been built"); size=0; for (int i=0; i< nbnode; i++) { int count= _node_glob_to_loc.count(node_list[i]); - // if (count > 1) - // cout << "noeud " << node_list[i]<< " doublon d'ordre " << count< >::iterator mmiter; - pair range=_node_glob_to_loc.equal_range(node_list[i]); + typedef INTERP_KERNEL::HashMultiMap >::iterator mmiter; + std::pair range=_node_glob_to_loc.equal_range(node_list[i]); for (mmiter it=range.first; it !=range.second; it++) { ip[index]=(it->second).first; @@ -418,8 +420,8 @@ void ParallelTopology::convertGlobalFaceListWithTwins(const int* face_list, int full_array=new int[size]; for (int i=0; i< nbface; i++) { - typedef INTERP_KERNEL::HashMultiMap >::iterator mmiter; - pair range=_face_glob_to_loc.equal_range(face_list[i]); + typedef INTERP_KERNEL::HashMultiMap >::iterator mmiter; + std::pair range=_face_glob_to_loc.equal_range(face_list[i]); for (mmiter it=range.first; it !=range.second; it++) { ip[index]=(it->second).first; @@ -437,18 +439,16 @@ void ParallelTopology::convertGlobalCellList(const int* cell_list, int nbcell, i { for (int i=0; i >::const_iterator iter = _glob_to_loc.find(cell_list[i]); - INTERP_KERNEL::HashMap >::const_iterator iter = _glob_to_loc.find(cell_list[i]); + INTERP_KERNEL::HashMap >::const_iterator iter = _glob_to_loc.find(cell_list[i]); if (iter == _glob_to_loc.end()) { - cerr<<"proc "<second).first; //no domain local[i]=(iter->second).second; //no local cell - //cout<<"proc "< >::const_iterator iter = _face_glob_to_loc.find(face_list[i]); + INTERP_KERNEL::HashMap >::const_iterator iter = _face_glob_to_loc.find(face_list[i]); if (iter == _face_glob_to_loc.end()) { - throw INTERP_KERNEL::Exception(LOCALIZED("ParallelTopology::convertGlobalFaceList : Face not found")); + throw INTERP_KERNEL::Exception("ParallelTopology::convertGlobalFaceList : Face not found"); } ip[i]=(iter->second).first; local[i]=(iter->second).second; - // cout << " in convertGlobalFAceList face global "< ("< >::iterator mmiter; - pair range=_face_glob_to_loc.equal_range(face_list[i]); + typedef INTERP_KERNEL::HashMultiMap >::iterator mmiter; + std::pair range=_face_glob_to_loc.equal_range(face_list[i]); for (mmiter it=range.first; it !=range.second; it++) { int ipfound=(it->second).first; @@ -503,8 +502,8 @@ void ParallelTopology::convertToLocal2ndVersion(int* nodes, int nbnodes, int ido { // cout <<" inode :"< -using namespace MEDPARTITIONER; - -SkyLineArray::SkyLineArray() +MEDPARTITIONER::SkyLineArray::SkyLineArray() { } -SkyLineArray::SkyLineArray(const SkyLineArray &myArray) +MEDPARTITIONER::SkyLineArray::SkyLineArray(const SkyLineArray &myArray) { _index=myArray._index; _value=myArray._value; } -SkyLineArray::~SkyLineArray() +MEDPARTITIONER::SkyLineArray::~SkyLineArray() { } -SkyLineArray::SkyLineArray(const std::vector& index, const std::vector& value) +MEDPARTITIONER::SkyLineArray::SkyLineArray(const std::vector& index, const std::vector& value) { _value=value; _index=index; diff --git a/src/MEDPartitioner/MEDPARTITIONER_SkyLineArray.hxx b/src/MEDPartitioner/MEDPARTITIONER_SkyLineArray.hxx index ff765d88a..e0b9707ff 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_SkyLineArray.hxx +++ b/src/MEDPartitioner/MEDPARTITIONER_SkyLineArray.hxx @@ -28,35 +28,20 @@ namespace MEDPARTITIONER { class MEDPARTITIONER_EXPORT SkyLineArray { - private : + private: std::vector _index; std::vector _value; - - public : - SkyLineArray(); //if used SkyLineArray will keep empty + public: + /*! if used SkyLineArray will keep empty */ + SkyLineArray(); SkyLineArray( const SkyLineArray &myArray ); SkyLineArray( const std::vector& index, const std::vector& value ); ~SkyLineArray(); - inline int getNumberOf() const - { - return _index.size()-1; - } - - inline int getLength() const - { - return _value.size() ; - } - - inline const int* getIndex() const - { - return (const int*)(&_index[0]) ; - } - - inline const int* getValue() const - { - return (const int*)(&_value[0]) ; - } + int getNumberOf() const { return _index.size()-1; } + int getLength() const { return _value.size() ; } + const int* getIndex() const { return (const int*)(&_index[0]); } + const int* getValue() const { return (const int*)(&_value[0]); } }; } # endif diff --git a/src/MEDPartitioner/MEDPARTITIONER_Topology.hxx b/src/MEDPartitioner/MEDPARTITIONER_Topology.hxx index d934643e4..2253ce1cb 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_Topology.hxx +++ b/src/MEDPartitioner/MEDPARTITIONER_Topology.hxx @@ -20,94 +20,90 @@ #ifndef __MEDPARTITIONER_TOPOLOGY_HXX__ #define __MEDPARTITIONER_TOPOLOGY_HXX__ -#include #include +#include -namespace MEDPARTITIONER +namespace ParaMEDMEM { - class ConnectZone; - class SkyLineArray; -} -namespace ParaMEDMEM { class MEDCouplingUMesh; } -namespace MEDPARTITIONER { +namespace MEDPARTITIONER +{ class Graph; + class ConnectZone; + class SkyLineArray; class MeshCollection; class MEDPARTITIONER_FaceModel; class Topology { public: - Topology() - { - } - Topology(std::vector, std::vector) - { - } - virtual ~Topology() - { - } + Topology() { } + Topology(std::vector, std::vector) { } + virtual ~Topology() { } - //converts a list of global cell numbers - //to a distributed array with local cell numbers - virtual void convertGlobalNodeList(const int* list, int nb, int* local, int*ip) = 0; - virtual void convertGlobalNodeList(const int* list, int nb, int* local, int ip) = 0; + /*! converts a list of global cell numbers + * to a distributed array with local cell numbers + */ + virtual void convertGlobalNodeList(const int *list, int nb, int *local, int*ip) = 0; + virtual void convertGlobalNodeList(const int *list, int nb, int *local, int ip) = 0; //converts a list of global node numbers - //to a distributed array with local cell numbers - virtual void convertGlobalCellList(const int*list , int nb, int* local, int*ip) = 0; + /*! to a distributed array with local cell numbers */ + virtual void convertGlobalCellList(const int*list , int nb, int *local, int*ip) = 0; - //converts a list of global face numbers - //to a distributed array with local face numbers - virtual void convertGlobalFaceList(const int*list , int nb, int* local, int*ip) = 0; + /*! converts a list of global face numbers + * to a distributed array with local face numbers + */ + virtual void convertGlobalFaceList(const int*list , int nb, int* local, int*ip) = 0; virtual void convertGlobalFaceList(const int*list , int nb, int* local, int ip) = 0; - virtual void convertGlobalFaceListWithTwins(const int* face_list, int nbface, int*& local, int*& ip, int*& full_array, int& size) = 0; - virtual void convertGlobalNodeListWithTwins(const int* face_list, int nbnode, int*& local, int*& ip, int*& full_array, int& size) = 0; - //number of doamins + virtual void convertGlobalFaceListWithTwins(const int *face_list, int nbface, int*& local, int*& ip, int*& full_array, int& size) = 0; + virtual void convertGlobalNodeListWithTwins(const int *face_list, int nbnode, int*& local, int*& ip, int*& full_array, int& size) = 0; + /*! number of doamins */ virtual int nbDomain() const = 0; - //number of cells + /*! number of cells */ virtual int nbCells() const = 0; - //number of nodes + /*! number of nodes */ virtual int nbNodes() const = 0; - //number of cells on a specific domain + /*! number of cells on a specific domain */ virtual int nbCells(int idomain) const = 0; - //converting node global numberings to local numberings + /*! converting node global numberings to local numberings */ virtual void convertToLocal2ndVersion(int*,int,int) = 0; virtual int convertNodeToGlobal(int ip,int icell) const = 0; virtual int convertFaceToGlobal(int ip,int icell) const = 0; virtual int convertCellToGlobal(int ip,int icell) const = 0; - virtual void convertNodeToGlobal(int ip,const int* local, int n, int* global) const = 0 ; - virtual void convertCellToGlobal(int ip,const int* local, int n, int* global) const = 0 ; - virtual void convertFaceToGlobal(int ip,const int* local, int n, int* global) const = 0 ; - //retrieving number of nodes + virtual void convertNodeToGlobal(int ip,const int *local, int n, int *global) const = 0; + virtual void convertCellToGlobal(int ip,const int *local, int n, int *global) const = 0; + virtual void convertFaceToGlobal(int ip,const int *local, int n, int *global) const = 0; + /*! retrieving number of nodes */ virtual int getNodeNumber(int idomain) const = 0; virtual int getNodeNumber() const = 0; - //retrieving list of nodes - virtual void getNodeList(int idomain, int* list) const = 0; + /*! retrieving list of nodes */ + virtual void getNodeList(int idomain, int *list) const = 0; virtual std::vector & getFusedCellNumbers(int idomain) = 0; virtual const std::vector & getFusedCellNumbers(int idomain) const = 0; virtual std::vector & getFusedFaceNumbers(int idomain) = 0; virtual const std::vector & getFusedFaceNumbers(int idomain) const = 0; - //retrieving number of nodes + /*! retrieving number of nodes */ virtual int getCellNumber(int idomain) const = 0; - //retrieving list of nodes - virtual void getCellList(int idomain, int* list) const = 0; - //retrieving number of faces + /*! retrieving list of nodes */ + virtual void getCellList(int idomain, int *list) const = 0; + /*! retrieving number of faces */ virtual int getFaceNumber(int idomain) const = 0; - virtual int getFaceNumber()const = 0; - //retrieving list of nodes - virtual void getFaceList(int idomain, int* list) const = 0; - //adding a face to the mapping + virtual int getFaceNumber() const = 0; + /*! retrieving list of nodes */ + virtual void getFaceList(int idomain, int *list) const = 0; + /*! adding a face to the mapping */ virtual void appendFace(int idomain, int ilocal, int iglobal) = 0; - //return max global face number + /*! returns max global face number */ virtual int getMaxGlobalFace() const = 0; - //converting a global cell number to a local representation + /*! converting a global cell number to a local representation */ virtual std::pair convertGlobalCell(int iglobal) const = 0; - //converting a global face number to a local representation + /*! converting a global face number to a local representation */ virtual int convertGlobalFace(int iglobal, int idomain) = 0; - //converting a global node number to a local representation + /*! converting a global node number to a local representation */ virtual int convertGlobalNode(int iglobal, int idomain) = 0; }; } + #endif diff --git a/src/MEDPartitioner/MEDPARTITIONER_UserGraph.cxx b/src/MEDPartitioner/MEDPARTITIONER_UserGraph.cxx index 80d558a8a..203a496a6 100644 --- a/src/MEDPartitioner/MEDPARTITIONER_UserGraph.cxx +++ b/src/MEDPartitioner/MEDPARTITIONER_UserGraph.cxx @@ -30,7 +30,7 @@ using namespace MEDPARTITIONER; * (domain numbers range from 0 to ndomain-1 * \param n number of cells in the mesh */ -UserGraph::UserGraph(MEDPARTITIONER::SkyLineArray* array, const int* partition, int n):Graph(array,0) +UserGraph::UserGraph(MEDPARTITIONER::SkyLineArray *array, const int *partition, int n):Graph(array,0) { std::vector index(n+1),value(n); @@ -52,6 +52,6 @@ UserGraph::~UserGraph() void UserGraph::partGraph(int ndomain, const std::string& options, ParaDomainSelector* sel) { - std::cerr<<"MEDPARTITIONER::UserGraph::partGraph() should not have to be used"< #endif -using namespace std; -using namespace ParaMEDMEM; using namespace MEDPARTITIONER; int MEDPARTITIONER::MyGlobals::_Verbose=0; int MEDPARTITIONER::MyGlobals::_Is0verbose=0; -int MEDPARTITIONER::MyGlobals::_Rank=(-1); -int MEDPARTITIONER::MyGlobals::_World_Size=(-1); +int MEDPARTITIONER::MyGlobals::_Rank=-1; +int MEDPARTITIONER::MyGlobals::_World_Size=-1; int MEDPARTITIONER::MyGlobals::_Randomize=0; int MEDPARTITIONER::MyGlobals::_Atomize=0; int MEDPARTITIONER::MyGlobals::_Creates_Boundary_Faces=0; -vector MEDPARTITIONER::MyGlobals::_File_Names; -vector MEDPARTITIONER::MyGlobals::_Mesh_Names; -vector MEDPARTITIONER::MyGlobals::_Field_Descriptions; -vector MEDPARTITIONER::MyGlobals::_General_Informations; +std::vector MEDPARTITIONER::MyGlobals::_File_Names; +std::vector MEDPARTITIONER::MyGlobals::_Mesh_Names; +std::vector MEDPARTITIONER::MyGlobals::_Field_Descriptions; +std::vector MEDPARTITIONER::MyGlobals::_General_Informations; std::string MEDPARTITIONER::Trim(const std::string& s,const std::string& drop) { - string r=s; + std::string r(s); r.erase(r.find_last_not_of(drop)+1); return r.erase(0,r.find_first_not_of(drop)); } std::string MEDPARTITIONER::IntToStr(const int i) { - ostringstream oss; - oss<>res; + std::istringstream iss(s); + iss >> res; return res; } double MEDPARTITIONER::StrToDouble(const std::string& s) { double res; - istringstream iss(s); - iss>>res; + std::istringstream iss(s); + iss >> res; return res; } -bool MEDPARTITIONER::TestArg(const char *arg, const char *argExpected, string& argValue) +bool MEDPARTITIONER::TestArg(const char *arg, const char *argExpected, std::string& argValue) { argValue=""; int i; for (i=0; i MEDPARTITIONER::CreateRandomSize(const int size) { - vector res(size); - for (int i=0; i res(size); + for (int i=0; i MEDPARTITIONER::CreateRandomSize(const int size) res[ii]=res[i]; res[i]=tmp; } - //cout<<"CreateRandomSize "<& ran, vector& vx, vector& va) -//randomize a xadj and adjncy, renumbering vertices belong rand. -//work only on one processor!!!! +/*! + * randomize a xadj and adjncy, renumbering vertices belong rand. Works only on one processor!!!! + */ +void MEDPARTITIONER::RandomizeAdj(int* xadj, int* adjncy, std::vector& ran, std::vector& vx, std::vector& va) { if (MyGlobals::_World_Size>1) { - cerr<<"MEDPARTITIONER::RandomizeAdj only works on one proc!"< invran(size); - for (int i=0; i invran(size); + for (int i=0; i& ran, int lgj=xadj[ir+1]-ii; for (int j=0; j r=CreateRandomSize(size); - vector vx,va; + std::vector r=CreateRandomSize(size); + std::vector vx,va; RandomizeAdj(&xadj[0],&adjncy[0],r,vx,va); - for (int i=0; i& vec) +std::string MEDPARTITIONER::ReprVectorOfString(const std::vector& vec) { - if (vec.size()==0) return string(" NONE\n"); - ostringstream oss; - for (vector::const_iterator i=vec.begin(); i!=vec.end(); ++i) - oss<<" -> '"<<*i<<"'"<::const_iterator i=vec.begin(); i!=vec.end(); ++i) + oss << " -> '" << *i << "'" << std::endl; return oss.str(); } std::string MEDPARTITIONER::ReprVectorOfString(const std::vector& vec, const std::string separator) { - if (vec.size()==0) return string(" NONE\n"); - ostringstream oss; - for (vector::const_iterator i=vec.begin(); i!=vec.end(); ++i) - oss<::const_iterator i=vec.begin(); i!=vec.end(); ++i) + oss << separator << *i; return oss.str(); } std::string MEDPARTITIONER::ReprMapOfStringInt(const std::map& mymap) { - if (mymap.size()==0) return string(" NONE\n"); - ostringstream oss; - for (map::const_iterator i=mymap.begin(); i!=mymap.end(); ++i) - oss<<" -> ["<<(*i).first<<"]="<<(*i).second<::const_iterator i=mymap.begin(); i!=mymap.end(); ++i) + oss << " -> [" << (*i).first << "]=" << (*i).second << std::endl; return oss.str(); } std::string MEDPARTITIONER::ReprMapOfStringVectorOfString(const std::map< std::string,std::vector >& mymap) { - if (mymap.size()==0) return string(" NONE\n"); - ostringstream oss; - for (map< string,vector >::const_iterator i=mymap.begin(); i!=mymap.end(); ++i) - oss<<" -> ["<<(*i).first<<"]="< >::const_iterator i=mymap.begin(); i!=mymap.end(); ++i) + oss << " -> [" << (*i).first << "]=" << std::endl << ReprVectorOfString((*i).second) << std::endl; return oss.str(); } std::string MEDPARTITIONER::ReprFieldDescriptions(const std::vector& vec, const std::string separator) { - if (vec.size()==0) return string(" NONE\n"); - ostringstream oss; - for (vector::const_iterator i=vec.begin(); i!=vec.end(); ++i) + if (vec.size()==0) + return std::string(" NONE\n"); + std::ostringstream oss; + for (std::vector::const_iterator i=vec.begin(); i!=vec.end(); ++i) { - oss<<" ->"; - oss<"; + oss << ReprVectorOfString(DeserializeToVectorOfString(*i), separator) << std::endl; } return oss.str(); } +/*! + * a string "hello" gives a string " 5/hello/" + * serialized_FromVectorOfString_string+SerializeFromString("toto") is + * equivalent to vector.push_back("toto") on serialized_FromVectorOfString_string + */ std::string MEDPARTITIONER::SerializeFromString(const std::string& s) -//a string "hello" gives a string " 5/hello/" -//serialized_FromVectorOfString_string+SerializeFromString("toto") is -//equivalent to vector.push_back("toto") on serialized_FromVectorOfString_string { - ostringstream oss; - oss<& vec) -//a vector of string gives a string { - ostringstream oss; - for (vector::const_iterator i=vec.begin(); i!=vec.end(); ++i) - oss<::const_iterator i=vec.begin(); i!=vec.end(); ++i) + oss<< std::setw(5) << (*i).size() << "/" << *i << "/"; return oss.str(); } +/*! + * a string gives a vector of string + */ std::vector MEDPARTITIONER::DeserializeToVectorOfString(const std::string& str) -//a string gives a vector of string { - //vector res=new vector; - vector res; - size_t pos=0; - size_t posmax=str.size(); - if (posmax==0) return res; //empty vector - size_t length; + std::vector res; + std::size_t pos=0; + std::size_t posmax=str.size(); + if (posmax==0) + return res; //empty vector + std::size_t length; while (pos < posmax-6) //setw(5)+" " { - istringstream iss(str.substr(pos,5)); - iss>>length; - //cout<<"length "<> length; if ((str[pos+5]!='/') || (str[pos+6+length]!='/')) { - cerr<<"Error on string '"< MEDPARTITIONER::DeserializeToVectorOfString(const std:: std::string MEDPARTITIONER::EraseTagSerialized(const std::string& fromStr, const std::string& tag) { - vector vec=DeserializeToVectorOfString(fromStr); - vector res; + std::vector vec=DeserializeToVectorOfString(fromStr); + std::vector res; for (int i=0; i MEDPARTITIONER::VectorizeFromMapOfStringInt(const std::map& mymap) -//elements first and second of map give one elements in result vector of string -//converting formatted the int second as firsts characters ending at first slash { - vector res; - for (map::const_iterator i=mymap.begin(); i!=mymap.end(); ++i) + std::vector res; + for (std::map::const_iterator i=mymap.begin(); i!=mymap.end(); ++i) { - ostringstream oss; - oss<<(*i).second<<"/"<<(*i).first; + std::ostringstream oss; + oss << (*i).second << "/" << (*i).first; res.push_back(oss.str()); } return res; } +/* + * if existing identicals (first,second) in vector no problem, else Exception + */ std::map MEDPARTITIONER::DevectorizeToMapOfStringInt(const std::vector& vec) -//if existing identicals (first,second) in vector no problem, else Exception { - map res; - for (vector::const_iterator i=vec.begin(); i!=vec.end(); ++i) + std::map res; + for (std::vector::const_iterator i=vec.begin(); i!=vec.end(); ++i) { - size_t pos=0; - size_t posmax=(*i).size(); - size_t found=(*i).find('/'); //first slash - if ((found==string::npos) || (found<1)) - throw INTERP_KERNEL::Exception(LOCALIZED("Error aIntNumber/anyString is expected")); + std::size_t pos=0; + std::size_t posmax=(*i).size(); + std::size_t found=(*i).find('/'); //first slash + if ((found==std::string::npos) || (found<1)) + throw INTERP_KERNEL::Exception("Error aIntNumber/anyString is expected"); int second; - istringstream iss((*i).substr(pos,found)); - iss>>second; - string first=(*i).substr(pos+found+1,posmax-found); - map::iterator it=res.find(first); + std::istringstream iss((*i).substr(pos,found)); + iss >> second; + std::string first=(*i).substr(pos+found+1,posmax-found); + std::map::iterator it=res.find(first); if (it!=res.end()) if ((*it).second!=second) - throw INTERP_KERNEL::Exception(LOCALIZED("Error not the same map value")); + throw INTERP_KERNEL::Exception("Error not the same map value"); res[first]=second; } return res; } +/*! + * elements first and second of map give one elements in result vector of string + * adding key map and length of second vector as first string in each serialized vector + * one serialized vector per key map + */ std::vector MEDPARTITIONER::VectorizeFromMapOfStringVectorOfString(const std::map< std::string,std::vector >& mymap) -//elements first and second of map give one elements in result vector of string -//adding key map and length of second vector as first string in each serialized vector -//one serialized vector per key map { - vector res; - for (map< string,vector >::const_iterator i=mymap.begin(); i!=mymap.end(); ++i) + std::vector res; + for (std::map< std::string,std::vector >::const_iterator i=mymap.begin(); i!=mymap.end(); ++i) { - vector vs=(*i).second; //a vector of string; - ostringstream oss; - oss<<"Keymap/"<<(*i).first<<"/"<<(*i).second.size(); + std::vector vs=(*i).second; //a vector of string; + std::ostringstream oss; + oss << "Keymap/" << (*i).first << "/" << (*i).second.size(); vs.insert(vs.begin(), oss.str()); res.push_back(SerializeFromVectorOfString(vs)); } return res; } +/*! + * if existing identicals keymap in vector no problem + * duplicates in second vector + */ std::map< std::string,std::vector > MEDPARTITIONER::DevectorizeToMapOfStringVectorOfString(const std::vector& vec) -//if existing identicals keymap in vector no problem -//duplicates in second vector { - map< string,vector > res; - for (vector::const_iterator i=vec.begin(); i!=vec.end(); ++i) + std::map< std::string,std::vector > res; + for (std::vector::const_iterator i=vec.begin(); i!=vec.end(); ++i) { - vector vs=DeserializeToVectorOfString(*i); + std::vector vs=DeserializeToVectorOfString(*i); - string enTete=vs[0]; - size_t posmax=enTete.size(); - size_t foundKey=enTete.find("Keymap/"); - size_t foundSizeVector=enTete.find_last_of('/'); - if ((foundKey==string::npos) || (foundKey!=0) || ((foundKey+7)>=foundSizeVector)) - throw INTERP_KERNEL::Exception(LOCALIZED("Error Keymap/anyString/aIntNumber is expected")); + std::string enTete=vs[0]; + std::size_t posmax=enTete.size(); + std::size_t foundKey=enTete.find("Keymap/"); + std::size_t foundSizeVector=enTete.find_last_of('/'); + if ((foundKey==std::string::npos) || (foundKey!=0) || ((foundKey+7)>=foundSizeVector)) + throw INTERP_KERNEL::Exception("Error Keymap/anyString/aIntNumber is expected"); int sizeVector; - istringstream iss(enTete.substr(foundSizeVector+1,posmax-foundSizeVector)); - iss>>sizeVector; - string keymap=enTete.substr(foundKey+7,foundSizeVector-foundKey-7); - //cout< MEDPARTITIONER::RecvVectorOfString(const int source) - //non conseille, interblocages, utiliser sendAndReceive - { - throw INTERP_KERNEL::Exception(LOCALIZED("use SendAndReceiveVectorOfString please.")); - int recSize=0; - int tag=111000; - MPI_Status status; - MPI_Recv(&recSize, 1, MPI_INT, source, tag, MPI_COMM_WORLD, &status); - string recData(recSize,'x'); - MPI_Recv((void*)recData.data(), recSize, MPI_CHAR, 1, tag+100, MPI_COMM_WORLD, &status); - //cout<<"proc "< MEDPARTITIONER::SendAndReceiveVectorOfString(const std::vector& vec, const int source, const int target) -//not optimized but suffisant -//return empty vector if i am not target { int rank=MyGlobals::_Rank; - - /*for test - ostringstream oss; - oss<<"sendAndReceive from "< res; + std::vector res; return res; //empty one for other proc } +/*! + * strings NO need all same size!!!! + */ std::vector MEDPARTITIONER::AllgathervVectorOfString(const std::vector& vec) -//strings NO need all same size!!!! { int world_size=MyGlobals::_World_Size; - string str=SerializeFromVectorOfString(vec); - - /*for test - int rank=MyGlobals::_Rank; - ostringstream oss; - oss<<"allgatherv from "< indexes(world_size); + std::vector indexes(world_size); int size=str.length(); MPI_Allgather(&size, 1, MPI_INT, &indexes[0], 1, MPI_INT, MPI_COMM_WORLD); - /*{ - ostringstream oss; - for (int i=0; i disp(1,0); + std::vector< int > disp(1,0); for (int i=0; i deserial=DeserializeToVectorOfString(recData); + std::vector deserial=DeserializeToVectorOfString(recData); if (MyGlobals::_Verbose>1000) { - cout<<"proc "<& vec, const int source, const int target) //TODO - std::string MEDPARTITIONER::Cle1ToStr(const std::string& s, const int inew) { - ostringstream oss; - oss<>inew; + std::size_t posmax=key.size(); + std::size_t found=key.find(' '); + if ((found==std::string::npos) || (found<1)) + throw INTERP_KERNEL::Exception("Error 'aStringWithoutWhitespace aInt' is expected"); + s=key.substr(0,found); + std::istringstream iss(key.substr(found,posmax-found)); + iss >> inew; } std::string MEDPARTITIONER::Cle2ToStr(const std::string& s, const int inew, const int iold) { - ostringstream oss; - oss<>inew>>iold; + std::size_t posmax=key.size(); + std::size_t found=key.find(' '); + if ((found==std::string::npos) || (found<1)) + throw INTERP_KERNEL::Exception("Error 'aStringWithoutWhitespace aInt aInt' is expected"); + s=key.substr(0,found); + std::istringstream iss(key.substr(found,posmax-found)); + iss >> inew >> iold; } std::string MEDPARTITIONER::ExtractFromDescription(const std::string& description,const std::string& tag) { - size_t found=description.find(tag); - if ((found==string::npos) || (found<1)) + std::size_t found=description.find(tag); + if ((found==std::string::npos) || (found<1)) { - cerr<<"ERROR : not found '"<alloc(v.size()/nbComponents,nbComponents); std::copy(v.begin(),v.end(),p->getPointer()); return p; @@ -626,55 +591,23 @@ ParaMEDMEM::DataArrayInt* MEDPARTITIONER::CreateDataArrayIntFromVector(const std ParaMEDMEM::DataArrayDouble* MEDPARTITIONER::CreateDataArrayDoubleFromVector(const std::vector& v) { - ParaMEDMEM::DataArrayDouble* p=DataArrayDouble::New(); + ParaMEDMEM::DataArrayDouble* p=ParaMEDMEM::DataArrayDouble::New(); p->alloc(v.size(),1); std::copy(v.begin(),v.end(),p->getPointer()); return p; } -std::vector MEDPARTITIONER::BrowseFieldDouble(const MEDCouplingFieldDouble* fd) -//quick almost human readable information on a field double - -/* - example done by fd->simpleRepr() : - FieldDouble with name : "VectorFieldOnCells" - Description of field is : "" - FieldDouble space discretization is : P0 - FieldDouble time discretization is : One time label. Time is defined by iteration=0 order=1 and time=2. - Time unit is : "" - FieldDouble nature of field is : NoNature - FieldDouble default array has 3 components and 30000 tuples. - FieldDouble default array has following info on components : "vx" "vy" "vz" - Mesh support information : - __________________________ - Unstructured mesh with name : "testMesh" - Description of mesh : "" - Time attached to the mesh [unit] : 0 [] - Iteration : -1 Order : -1 - Mesh dimension : 3 - Space dimension : 3 - Info attached on space dimension : "" "" "" - Number of nodes : 33201 - Number of cells : 30000 - Cell types present : NORM_HEXA8 -*/ - +/*! + */ +std::vector MEDPARTITIONER::BrowseFieldDouble(const ParaMEDMEM::MEDCouplingFieldDouble* fd) { - vector res; - //res.push_back("fieldName="); res.back()+=fd->getName(); - //not saved in file? res.push_back("fieldDescription="); res.back()+=fd->getDescription(); - //ret << "FieldDouble space discretization is : " << _type->getStringRepr() << "\n"; - //ret << "FieldDouble time discretization is : " << _time_discr->getStringRepr() << "\n"; - //ret << "FieldDouble nature of field is : " << MEDCouplingNatureOfField::getRepr(_nature) << "\n"; + std::vector res; if (fd->getArray()) { int nb=fd->getArray()->getNumberOfComponents(); res.push_back("nbComponents="); res.back()+=IntToStr(nb); - //ret << "FieldDouble default array has " << nbOfCompo << " components and " << getArray()->getNumberOfTuples() << " tuples.\n"; - //ret << "FieldDouble default array has following info on components : "; for (int i=0; igetInfoOnComponent(i) << "\" "; res.push_back("componentInfo"); res.back()+=IntToStr(i)+"="+fd->getArray()->getInfoOnComponent(i); } @@ -686,28 +619,31 @@ std::vector MEDPARTITIONER::BrowseFieldDouble(const MEDCouplingFiel return res; } +/*! + * quick almost human readable information on all fields in a .med file + */ std::vector MEDPARTITIONER::BrowseAllFields(const std::string& myfile) -//quick almost human readable information on all fields in a .med file { - vector res; - vector meshNames=MEDLoader::GetMeshNames(myfile.c_str()); + std::vector res; + std::vector meshNames=MEDLoader::GetMeshNames(myfile.c_str()); for (int i=0; i fieldNames= + std::vector fieldNames= MEDLoader::GetAllFieldNamesOnMesh(myfile.c_str(),meshNames[i].c_str()); for (int j = 0; j < fieldNames.size(); j++) { - vector< ParaMEDMEM::TypeOfField > typeFields= + std::vector< ParaMEDMEM::TypeOfField > typeFields= MEDLoader::GetTypesOfField(myfile.c_str(), meshNames[i].c_str(), fieldNames[j].c_str()); for (int k = 0; k < typeFields.size(); k++) { - vector< pair< int, int > > its= + std::vector< std::pair< int, int > > its= MEDLoader::GetFieldIterations(typeFields[k], myfile.c_str(), meshNames[i].c_str(), fieldNames[j].c_str()); - if (MyGlobals::_Is0verbose>100) cout<<"fieldName "<100) + std::cout<< "fieldName " << fieldNames[j] << " typeField " << typeFields[k] << " its.size() " << its.size() << std::endl; for (int m = 0; m < its.size(); m++) { - vector resi; + std::vector resi; resi.push_back("fileName="); resi.back()+=myfile; resi.push_back("meshName="); resi.back()+=meshNames[i]; resi.push_back("fieldName="); resi.back()+=fieldNames[j]; @@ -799,10 +735,11 @@ std::vector MEDPARTITIONER::GetInfosOfField(const char *fileName, c //"MED_UNDEF_ENTITY_TYPE" }; - vector res; + std::vector res; med_idt fid=MEDfileOpen(fileName,MED_ACC_RDONLY); med_int nbFields=MEDnField(fid); - if (MyGlobals::_Verbose>20) cout<<"on filename "<20) + std::cout << "on filename " << fileName << " nbOfField " << nbFields << std::endl; // med_field_type typcha; med_int numdt=0,numo=0; @@ -819,15 +756,15 @@ std::vector MEDPARTITIONER::GetInfosOfField(const char *fileName, c INTERP_KERNEL::AutoPtr dt_unit=new char[MED_LNAME_SIZE+1]; med_int nbPdt; MEDfieldInfo(fid,i,nomcha,maa_ass,&localmesh,&typcha,comp,unit,dt_unit,&nbPdt); - string curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1); - string curMeshName=MEDLoaderBase::buildStringFromFortran(maa_ass,MED_NAME_SIZE+1); + std::string curFieldName=MEDLoaderBase::buildStringFromFortran(nomcha,MED_NAME_SIZE+1); + std::string curMeshName=MEDLoaderBase::buildStringFromFortran(maa_ass,MED_NAME_SIZE+1); for (int k=1; k<=nbPdt; k++) { MEDfieldComputingStepInfo(fid,nomcha,k,&numdt,&numo,&dt); if (MyGlobals::_Verbose>20) - cout<<"on filename "< MEDPARTITIONER::GetInfosOfField(const char *fileName, c char pflname[MED_NAME_SIZE+1]=""; char locname[MED_NAME_SIZE+1]=""; med_int nbofprofile=MEDfieldnProfile(fid,nomcha,numdt,numo,enttype,GEOMTYPE[j],pflname,locname); - - /* - med_proto.h firefox file:///export/home/.../med-3.0.3/doc/html.dox/index.html - MEDfieldnValueWithProfileByName(const med_idt fid, const char * const fieldname,const med_int numdt,const med_int numit, - const med_entity_type entitype, const med_geometry_type geotype, const char * const profilename, - const med_storage_mode storagemode,med_int * const profilesize, - char * const localizationname, med_int * const nbofintegrationpoint); - - MEDfieldnValueWithProfile(const med_idt fid, const char * const fieldname,const med_int numdt,const med_int numit, - const med_entity_type entitype, const med_geometry_type geotype, - const int profileit, - const med_storage_mode storagemode,char * const profilename ,med_int * const profilesize, - char * const localizationname, med_int * const nbofintegrationpoint); - */ int profileit=1; if (enttype==MED_NODE) { @@ -861,15 +784,15 @@ std::vector MEDPARTITIONER::GetInfosOfField(const char *fileName, c if (nbOfVal>0) { if (MyGlobals::_Verbose>20) - cout<<"on filename "< resi; + std::cout << "on filename " << fileName << " entity " << enttype << " nbOfVal with " << + nbofprofile << " profile(s) for geomType (AUCUN) nbOfVal " << + nbOfVal << " profilName '" << pflname << "' profileSize " << profilesize << " nbPtGauss " << nbi << std::endl; + std::vector resi; resi.push_back("idomain="); resi.back()+=IntToStr(idomain); resi.push_back("fileName="); resi.back()+=fileName; resi.push_back("meshName="); resi.back()+=curMeshName; resi.push_back("fieldName="); resi.back()+=curFieldName; - resi.push_back("typeField="); resi.back()+=IntToStr((int)ON_NODES); + resi.push_back("typeField="); resi.back()+=IntToStr((int)ParaMEDMEM::ON_NODES); resi.push_back("typeData="); resi.back()+=IntToStr((int)typcha); //6 for double? resi.push_back("nbComponent="); resi.back()+=IntToStr((int)ncomp); resi.push_back("DT="); resi.back()+=IntToStr((int)numdt); @@ -893,15 +816,17 @@ std::vector MEDPARTITIONER::GetInfosOfField(const char *fileName, c if (nbOfVal>0) { if (MyGlobals::_Verbose>20) - cout<<"on filename "< resi; + std::vector resi; resi.push_back("idomain="); resi.back()+=IntToStr(idomain); resi.push_back("fileName="); resi.back()+=fileName; resi.push_back("meshName="); resi.back()+=curMeshName; @@ -922,8 +847,8 @@ std::vector MEDPARTITIONER::GetInfosOfField(const char *fileName, c resi.push_back("nbPtGauss="); resi.back()+=IntToStr((int)nbi); if (typeField==(-1)) { - cout<<"WARNING : unknown typeField for entity type "< MEDPARTITIONER::GetInfosOfField(const char *fileName, c delete [] maa_ass; delete [] nomcha; MEDfileClose(fid); - if (MyGlobals::_Verbose>10) cout<<"detected fields:\n"<10) + std::cout << "detected fields:\n" << ReprVectorOfString(res) << std::endl; return res; } +/*! + * quick almost human readable information on all fields on a mesh in a .med file + */ std::vector MEDPARTITIONER::BrowseAllFieldsOnMesh(const std::string& myfile, const std::string& mymesh, const int idomain) -//quick almost human readable information on all fields on a mesh in a .med file { - vector res=GetInfosOfField(myfile.c_str(),mymesh.c_str(),idomain); + std::vector res=GetInfosOfField(myfile.c_str(),mymesh.c_str(),idomain); return res; - - /*obsolete do no work on GetTypesOfField ON_GAUSS_NE - vector res; - vector meshNames; - meshNames.push_back(mymesh); - - for (int i=0; i fieldNames= - MEDLoader::GetAllFieldNamesOnMesh(myfile.c_str(),meshNames[i].c_str()); - for (int j=0; j typeFields= - MEDLoader::GetTypesOfField(myfile.c_str(), meshNames[i].c_str(), fieldNames[j].c_str()); - //if (MyGlobals::_Is0verbose>100) cout<<"fieldName "< > its; - its=MEDLoader::GetFieldIterations(typeFields[k], myfile.c_str(), meshNames[i].c_str(), fieldNames[j].c_str()); - //if (typeFields[k]==ON_GAUSS_NE) its.push_back(make_pair(5,6)); - if (MyGlobals::_Is0verbose>100) cout<<"fieldName "< resi; - resi.push_back("idomain="); resi.back()+=IntToStr(idomain); - resi.push_back("fileName="); resi.back()+=myfile; - resi.push_back("meshName="); resi.back()+=meshNames[i]; - resi.push_back("fieldName="); resi.back()+=fieldNames[j]; - resi.push_back("typeField="); resi.back()+=IntToStr((int)typeFields[k]); - resi.push_back("DT="); resi.back()+=IntToStr((int)its[m].first); - resi.push_back("IT="); resi.back()+=IntToStr((int)its[m].second); - //cout<<"BrowseAllFieldsOnMesh add "<& vec, const int tar int tag = 111002; int size=vec.size(); if (MyGlobals::_Verbose>1000) - cout<<"proc "< SendDoubleVec "< SendDoubleVec " << size << std::endl; #ifdef HAVE_MPI2 MPI_Send(&size, 1, MPI_INT, target, tag, MPI_COMM_WORLD); MPI_Send(const_cast(&vec[0]), size, MPI_DOUBLE, target, tag+100, MPI_COMM_WORLD); @@ -1021,8 +906,8 @@ std::vector* MEDPARTITIONER::RecvDoubleVec(const int source) MPI_Status status; MPI_Recv(&size, 1, MPI_INT, source, tag, MPI_COMM_WORLD, &status); if (MyGlobals::_Verbose>1000) - cout<<"proc "<* vec=new vector; + std::cout << "proc " << MyGlobals::_Rank << " : <-- RecvDoubleVec " << size << std::endl; + std::vector* vec=new std::vector; vec->resize(size); MPI_Recv(&vec[0], size, MPI_DOUBLE, source, tag+100, MPI_COMM_WORLD, &status); #endif @@ -1037,7 +922,7 @@ void MEDPARTITIONER::RecvDoubleVec(std::vector& vec, const int source) MPI_Status status; MPI_Recv(&size, 1, MPI_INT, source, tag, MPI_COMM_WORLD, &status); if (MyGlobals::_Verbose>1000) - cout<<"proc "<& vec, const int target) int tag = 111003; int size=vec.size(); if (MyGlobals::_Verbose>1000) - cout<<"proc "< SendIntVec "< SendIntVec " << size << std::endl; #ifdef HAVE_MPI2 MPI_Send(&size, 1, MPI_INT, target, tag, MPI_COMM_WORLD); MPI_Send(const_cast(&vec[0]), size,MPI_INT, target, tag+100, MPI_COMM_WORLD); @@ -1064,16 +949,16 @@ void MEDPARTITIONER::SendIntVec(const std::vector& vec, const int target) \param vec vector that is filled \param source processor id of the incoming messages */ -std::vector* MEDPARTITIONER::RecvIntVec(const int source) +std::vector *MEDPARTITIONER::RecvIntVec(const int source) { int tag = 111003; int size; #ifdef HAVE_MPI2 MPI_Status status; MPI_Recv(&size, 1, MPI_INT, source, tag, MPI_COMM_WORLD, &status); - if (MyGlobals::_Verbose>1000) - cout<<"proc "<* vec=new vector; + if (MyGlobals::_Verbose>1000) + std::cout << "proc " << MyGlobals::_Rank << " : <-- RecvIntVec " << size << std::endl; + std::vector *vec=new std::vector; vec->resize(size); MPI_Recv(&vec[0], size, MPI_INT, source, tag+100, MPI_COMM_WORLD, &status); #endif @@ -1088,7 +973,7 @@ void MEDPARTITIONER::RecvIntVec(std::vector& vec, const int source) MPI_Status status; MPI_Recv(&size, 1, MPI_INT, source, tag, MPI_COMM_WORLD, &status); if (MyGlobals::_Verbose>1000) - cout<<"proc "<& vec, const int source) \param da dataArray to be sent \param target processor id of the target */ -void MEDPARTITIONER::SendDataArrayInt(const ParaMEDMEM::DataArrayInt* da, const int target) +void MEDPARTITIONER::SendDataArrayInt(const ParaMEDMEM::DataArrayInt *da, const int target) { - if (da==0) throw INTERP_KERNEL::Exception(LOCALIZED("Problem send DataArrayInt* NULL")); + if (da==0) + throw INTERP_KERNEL::Exception("Problem send DataArrayInt* NULL"); int tag = 111004; int size[3]; size[0]=da->getNbOfElems(); size[1]=da->getNumberOfTuples(); size[2]=da->getNumberOfComponents(); if (MyGlobals::_Verbose>1000) - cout<<"proc "< SendDataArrayInt "< SendDataArrayInt " << size[0] << std::endl; #ifdef HAVE_MPI2 MPI_Send(&size, 3, MPI_INT, target, tag, MPI_COMM_WORLD); - const int * p=da->getConstPointer(); + const int *p=da->getConstPointer(); MPI_Send(const_cast(&p[0]), size[0] ,MPI_INT, target, tag+100, MPI_COMM_WORLD); #endif } @@ -1122,7 +1008,7 @@ void MEDPARTITIONER::SendDataArrayInt(const ParaMEDMEM::DataArrayInt* da, const \param da dataArrayInt that is filled \param source processor id of the incoming messages */ -ParaMEDMEM::DataArrayInt* MEDPARTITIONER::RecvDataArrayInt(const int source) +ParaMEDMEM::DataArrayInt *MEDPARTITIONER::RecvDataArrayInt(const int source) { int tag = 111004; int size[3]; @@ -1130,12 +1016,12 @@ ParaMEDMEM::DataArrayInt* MEDPARTITIONER::RecvDataArrayInt(const int source) MPI_Status status; MPI_Recv(size, 3, MPI_INT, source, tag, MPI_COMM_WORLD, &status); if (MyGlobals::_Verbose>1000) - cout<<"proc "<alloc(size[1],size[2]); - int * p=da->getPointer(); + int *p=da->getPointer(); MPI_Recv(const_cast(&p[0]), size[0], MPI_INT, source, tag+100, MPI_COMM_WORLD, &status); #endif return da; @@ -1147,19 +1033,20 @@ ParaMEDMEM::DataArrayInt* MEDPARTITIONER::RecvDataArrayInt(const int source) \param da dataArray to be sent \param target processor id of the target */ -void MEDPARTITIONER::SendDataArrayDouble(const ParaMEDMEM::DataArrayDouble* da, const int target) +void MEDPARTITIONER::SendDataArrayDouble(const ParaMEDMEM::DataArrayDouble *da, const int target) { - if (da==0) throw INTERP_KERNEL::Exception(LOCALIZED("Problem send DataArrayDouble* NULL")); + if (da==0) + throw INTERP_KERNEL::Exception("Problem send DataArrayDouble* NULL"); int tag = 111005; int size[3]; size[0]=da->getNbOfElems(); size[1]=da->getNumberOfTuples(); size[2]=da->getNumberOfComponents(); if (MyGlobals::_Verbose>1000) - cout<<"proc "< SendDataArrayDouble "< SendDataArrayDouble " << size[0] << std::endl; #ifdef HAVE_MPI2 MPI_Send(&size, 3, MPI_INT, target, tag, MPI_COMM_WORLD); - const double * p=da->getConstPointer(); + const double *p=da->getConstPointer(); MPI_Send(const_cast(&p[0]), size[0] ,MPI_DOUBLE, target, tag+100, MPI_COMM_WORLD); #endif } @@ -1177,19 +1064,21 @@ ParaMEDMEM::DataArrayDouble* MEDPARTITIONER::RecvDataArrayDouble(const int sourc MPI_Status status; MPI_Recv(size, 3, MPI_INT, source, tag, MPI_COMM_WORLD, &status); if (MyGlobals::_Verbose>1000) - cout<<"proc "<alloc(size[1],size[2]); - double * p=da->getPointer(); + double *p=da->getPointer(); MPI_Recv(const_cast(&p[0]), size[0], MPI_DOUBLE, source, tag+100, MPI_COMM_WORLD, &status); #endif return da; } +/*! + * create empty MEDCouplingUMesh* dim 3 + */ ParaMEDMEM::MEDCouplingUMesh* MEDPARTITIONER::CreateEmptyMEDCouplingUMesh() -//create empty MEDCouplingUMesh* dim 3 { ParaMEDMEM::MEDCouplingUMesh* umesh=ParaMEDMEM::MEDCouplingUMesh::New(); umesh->setMeshDimension(3); @@ -1208,9 +1097,9 @@ void MEDPARTITIONER::TestVectorOfStringMpi() { int rank=MyGlobals::_Rank; int world_size=MyGlobals::_World_Size; - vector myVector; - ostringstream oss; - oss<<"hello from "< myVector; + std::ostringstream oss; + oss << "hello from " << std::setw(5) << rank << " " << std::string(rank+1,'n') << " next is an empty one"; myVector.push_back(oss.str()); myVector.push_back(""); @@ -1219,71 +1108,65 @@ void MEDPARTITIONER::TestVectorOfStringMpi() if (rank==0) { - /* - string s0=SerializeFromVectorOfString(myVector); - cout<<"s0 is : a string '"< v0=DeserializeToVectorOfString(s0); - cout<<"v0 is : a vector of size "< res=DeserializeToVectorOfString(s0); + std::string s0=SerializeFromVectorOfString(myVector); + std::vector res=DeserializeToVectorOfString(s0); if (res.size()!=myVector.size()) - throw INTERP_KERNEL::Exception(LOCALIZED("Problem in (de)serialise VectorOfString incoherent sizes")); + throw INTERP_KERNEL::Exception("Problem in (de)serialise VectorOfString incoherent sizes"); for (int i=0; i res=SendAndReceiveVectorOfString(myVector, i, j); + std::vector res=SendAndReceiveVectorOfString(myVector, i, j); if ((rank==j) && MyGlobals::_Verbose>20) - cout<<"proc "< res=AllgathervVectorOfString(myVector); + std::vector res=AllgathervVectorOfString(myVector); //sometimes for test res=AllgathervVectorOfString(myVector); res=AllgathervVectorOfString(myVector); if (rank==0 && MyGlobals::_Verbose>20) - cout<<"proc "< myMap; + std::map myMap; myMap["one"]=1; myMap["two"]=22; //a bug myMap["three"]=3; @@ -1291,36 +1174,31 @@ void MEDPARTITIONER::TestMapOfStringIntMpi() if (rank==0) { - vector v2=VectorizeFromMapOfStringInt(myMap); - /* - cout<<"v2 is : a vector of size "< m3=DevectorizeToMapOfStringInt(v2); + std::vector v2=VectorizeFromMapOfStringInt(myMap); + std::map m3=DevectorizeToMapOfStringInt(v2); if (ReprMapOfStringInt(m3)!=ReprMapOfStringInt(myMap)) - throw INTERP_KERNEL::Exception(LOCALIZED("Problem in (de)vectorize MapOfStringInt")); + throw INTERP_KERNEL::Exception("Problem in (de)vectorize MapOfStringInt"); } - vector v2=AllgathervVectorOfString(VectorizeFromMapOfStringInt(myMap)); + std::vector v2=AllgathervVectorOfString(VectorizeFromMapOfStringInt(myMap)); if (rank==0 && MyGlobals::_Verbose>20) { - cout<<"v2 is : a vector of size "< m2=DevectorizeToMapOfStringInt(v2); - cout<<"m2 is : a map of size "< m2=DevectorizeToMapOfStringInt(v2); + std::cout << "m2 is : a map of size " << m2.size() << std::endl; + std::cout << ReprMapOfStringInt(m2) << std::endl; } - if (MyGlobals::_Verbose) cout<<"proc "< myVector; - ostringstream oss; - oss<<"hello from "< myVector; + std::ostringstream oss; + oss << "hello from " << std::setw(5) << MyGlobals::_Rank << " " << std::string(rank+1,'n') << " next is an empty one"; myVector.push_back(oss.str()); myVector.push_back(""); myVector.push_back("next is an singleton"); @@ -1328,36 +1206,37 @@ void MEDPARTITIONER::TestMapOfStringVectorOfStringMpi() if (rank==0) { - map< string,vector > m2; + std::map< std::string,std::vector > m2; m2["first key"]=myVector; m2["second key"]=myVector; - vector v2=VectorizeFromMapOfStringVectorOfString(m2); - map< string,vector > m3=DevectorizeToMapOfStringVectorOfString(v2); + std::vector v2=VectorizeFromMapOfStringVectorOfString(m2); + std::map< std::string,std::vector > m3=DevectorizeToMapOfStringVectorOfString(v2); if (rank==0 && MyGlobals::_Verbose>20) - cout<<"m2 is : a MapOfStringVectorOfString of size "< > m4; + std::map< std::string,std::vector > m4; m4["1rst key"]=myVector; m4["2snd key"]=myVector; - vector v4=AllgathervVectorOfString(VectorizeFromMapOfStringVectorOfString(m4)); + std::vector v4=AllgathervVectorOfString(VectorizeFromMapOfStringVectorOfString(m4)); if (rank==0 && MyGlobals::_Verbose>20) { - map< string,vector > m5=DevectorizeToMapOfStringVectorOfString(v4); - map< string,vector > m6=DeleteDuplicatesInMapOfStringVectorOfString(m5); - cout<<"m5 is : a map of size "< > m5=DevectorizeToMapOfStringVectorOfString(v4); + std::map< std::string,std::vector > m6=DeleteDuplicatesInMapOfStringVectorOfString(m5); + std::cout<< "m5 is : a map of size "<alloc(nbOfTuples,numberOfComponents); - vector vals; + std::vector vals; for (int j=0; jgetPointer()); - if (rank==0) SendDataArrayInt(send, 1); - if (rank==1) recv=RecvDataArrayInt(0); + if (rank==0) + SendDataArrayInt(send, 1); + if (rank==1) + recv=RecvDataArrayInt(0); if (rank==1 && MyGlobals::_Verbose>20) { - cout<repr()<repr()<repr() << std::endl; + std::cout << recv->repr() << std::endl; } if (rank==1) { if (send->repr()!=recv->repr()) - throw INTERP_KERNEL::Exception(LOCALIZED("Problem in send&recv DataArrayInt")); + throw INTERP_KERNEL::Exception("Problem in send&recv DataArrayInt"); } send->decrRef(); - if (rank==1) recv->decrRef(); + if (rank==1) + recv->decrRef(); } //double { @@ -1396,7 +1278,7 @@ void MEDPARTITIONER::TestDataArrayMpi() int nbOfTuples=5; int numberOfComponents=3; send->alloc(nbOfTuples,numberOfComponents); - vector vals; + std::vector vals; for (int j=0; jgetPointer()); @@ -1404,32 +1286,33 @@ void MEDPARTITIONER::TestDataArrayMpi() if (rank==1) recv=RecvDataArrayDouble(0); if (rank==1 && MyGlobals::_Verbose>20) { - cout<repr()<repr()<repr() << std::endl; + std::cout << recv->repr() << std::endl; } if (rank==1) { if (send->repr()!=recv->repr()) - throw INTERP_KERNEL::Exception(LOCALIZED("Problem in send&recv DataArrayDouble")); + throw INTERP_KERNEL::Exception("Problem in send&recv DataArrayDouble"); } send->decrRef(); if (rank==1) recv->decrRef(); } - if (MyGlobals::_Verbose) cout<<"proc "< x, y; + int rank=MyGlobals::_Rank; + std::vector x, y; int tag=111111; MPI_Request requete0, requete1; MPI_Status statut; int ok=0; - string res; - if (rang==0) + std::string res; + if (rank==0) { x.resize(taille); MPI_Ssend_init(&x[0], taille, MPI_INT, 1, tag, MPI_COMM_WORLD , &requete0); @@ -1446,7 +1329,7 @@ void MEDPARTITIONER::TestPersistantMpi0To1(int taille, int nb) } MPI_Request_free(&requete0); } - else if (rang == 1) + else if (rank == 1) { y.resize(taille); MPI_Recv_init(&y[0], taille, MPI_INT, 0, tag, MPI_COMM_WORLD , &requete1); @@ -1468,43 +1351,46 @@ void MEDPARTITIONER::TestPersistantMpi0To1(int taille, int nb) if (nb==taille) ok++; if (MyGlobals::_Verbose>9) { - res="0K"; if (nb!=taille) res="KO"; - cout<1) - cout<<"resultat "<=wsize) next=0; - vector x, y; + befo=rank-1; if (befo<0) befo=wsize-1; + next=rank+1; if (next>=wsize) next=0; + std::vector x, y; tagbefo=111111+befo; - tagnext=111111+rang; + tagnext=111111+rank; MPI_Request requete0, requete1; MPI_Status statut1, statut2; int ok=0; - string res; - //cout<<"ini|"< cela peut prendre du temps MPI_Start(&requete0); //Reception du gros message --> cela peut prendre du temps @@ -1514,7 +1400,6 @@ void MEDPARTITIONER::TestPersistantMpiRing(int taille, int nb) //... //Traitement sequentiel independant de "y" //... - //cout<<"dsr|"<9) { - res="0K"+IntToStr(rang); if (nb!=taille) res="KO"+IntToStr(rang); - cout<1) - cout<<"resultat proc "<=rangMax) couleur=MPI_UNDEFINED; - cout<<"coul|"<=rankMax) + color=MPI_UNDEFINED; //MPI_Comm_dup (MPI_COMM_WORLD, &newcomm) ; - MPI_Comm_split(MPI_COMM_WORLD, couleur, rang, &newcomm); + MPI_Comm_split(MPI_COMM_WORLD, color, rank, &newcomm); int befo, next, wsize, tagbefo, tagnext; - wsize=rangMax; - if (wsize>MyGlobals::_World_Size) wsize=MyGlobals::_World_Size; - befo=rang-1; if (befo<0) befo=wsize-1; - next=rang+1; if (next>=wsize) next=0; - vector x, y; + wsize=rankMax; + if (wsize>MyGlobals::_World_Size) + wsize=MyGlobals::_World_Size; + befo=rank-1; + if (befo<0) + befo=wsize-1; + next=rank+1; + if (next>=wsize) + next=0; + std::vector x, y; tagbefo=111111+befo; - tagnext=111111+rang; + tagnext=111111+rank; MPI_Request requete0, requete1; MPI_Status statut1, statut2; int ok=0; - string res; + std::string res; - //cout<<"ini|"< cela peut prendre du temps + for (int i=0; i time consuming MPI_Start(&requete0); - //Reception du gros message --> cela peut prendre du temps - for (int i=0; i time consuming + for (int i=0; i9) { - res="0K"+IntToStr(rang); if (nb!=taille) res="KO"+IntToStr(rang); - cout<1) - cout<<"resultat proc "< #include -#ifdef LOCALIZED -#undef LOCALIZED -#endif - -#if defined(_DEBUG_) || defined(_DEBUG) -//only for debug # define LOCALIZED(message) #message , __FILE__ , __FUNCTION__ , __LINE__ -# define LOCALIZED(message) #message , __FUNCTION__ , __LINE__ -#else -# define LOCALIZED(message) #message -#endif +//# define LOCALIZED(message) #message , __FILE__ , __FUNCTION__ , __LINE__ namespace MEDPARTITIONER { @@ -83,11 +74,11 @@ namespace MEDPARTITIONER void FieldShortDescriptionToData(const std::string& description, std::string& fieldName, int& typeField, int& entity, int& DT, int& IT); - ParaMEDMEM::DataArrayInt* CreateDataArrayIntFromVector(const std::vector& v); - ParaMEDMEM::DataArrayInt* CreateDataArrayIntFromVector(const std::vector& v, const int nbComponents); - ParaMEDMEM::DataArrayDouble* CreateDataArrayDoubleFromVector(const std::vector& v); + ParaMEDMEM::DataArrayInt *CreateDataArrayIntFromVector(const std::vector& v); + ParaMEDMEM::DataArrayInt *CreateDataArrayIntFromVector(const std::vector& v, const int nbComponents); + ParaMEDMEM::DataArrayDouble *CreateDataArrayDoubleFromVector(const std::vector& v); - //non conseille, interblocages, utiliser sendAndReceive + //not adviced, interblocking, use sendAndReceive //void SendVectorOfString(const std::vector& vec, const int target); //std::vector RecvVectorOfString(const int source); //TODO void sendRecvVectorOfString(const std::vector& vec, const int source, const int target); @@ -100,7 +91,7 @@ namespace MEDPARTITIONER std::vector GetInfosOfField(const char *fileName, const char *meshName, const int idomain ); void SendDoubleVec(const std::vector& vec, const int target); - std::vector* RecvDoubleVec(const int source); + std::vector *RecvDoubleVec(const int source); void RecvDoubleVec(std::vector& vec, const int source); void SendIntVec(const std::vector& vec, const int target); @@ -108,11 +99,11 @@ namespace MEDPARTITIONER void RecvIntVec(std::vector& vec, const int source); void SendDataArrayInt(const ParaMEDMEM::DataArrayInt* da, const int target); - ParaMEDMEM::DataArrayInt* RecvDataArrayInt(const int source); + ParaMEDMEM::DataArrayInt *RecvDataArrayInt(const int source); void SendDataArrayDouble(const ParaMEDMEM::DataArrayDouble* da, const int target); - ParaMEDMEM::DataArrayDouble* RecvDataArrayDouble(const int source); + ParaMEDMEM::DataArrayDouble *RecvDataArrayDouble(const int source); - ParaMEDMEM::MEDCouplingUMesh* CreateEmptyMEDCouplingUMesh(); + ParaMEDMEM::MEDCouplingUMesh *CreateEmptyMEDCouplingUMesh(); void TestVectorOfStringMpi(); void TestMapOfStringIntMpi(); @@ -124,18 +115,19 @@ namespace MEDPARTITIONER class MyGlobals { - public : static int _Verbose; //0 to 1000 over 200 is debug - public : static int _Rank; - public : static int _World_Size; - public : static int _Randomize; - public : static int _Atomize; - public : static int _Creates_Boundary_Faces; - public : static int _Is0verbose; //trace cout if rank 0 and verbose - public : static std::vector _File_Names; //on [iold] - public : static std::vector _Mesh_Names; //on [iold] - public : static std::vector _Field_Descriptions; - //used for descriptions of components of fields for example... - public : static std::vector _General_Informations; + public : + static int _Verbose; //0 to 1000 over 200 is debug + static int _Rank; + static int _World_Size; + static int _Randomize; + static int _Atomize; + static int _Creates_Boundary_Faces; + static int _Is0verbose; //trace cout if rank 0 and verbose + static std::vector _File_Names; //on [iold] + static std::vector _Mesh_Names; //on [iold] + static std::vector _Field_Descriptions; + /*! used for descriptions of components of fields for example...*/ + static std::vector _General_Informations; }; } #endif