Back to index

salome-med  6.5.0
Public Member Functions | Private Attributes
MEDPARTITIONER::JointFinder Class Reference

#include <MEDPARTITIONER_JointFinder.hxx>

Collaboration diagram for MEDPARTITIONER::JointFinder:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 JointFinder (const MeshCollection &mc)
 Method contributing to the distant cell graph.
 ~JointFinder ()
void findCommonDistantNodes ()
void print ()
std::vector< std::vector
< std::multimap< int, int > > > & 
getDistantNodeCell ()
std::vector< std::vector
< std::vector< std::pair< int,
int > > > > & 
getNodeNode ()

Private Attributes

const MeshCollection & _mesh_collection
const ParaDomainSelector * _domain_selector
const Topology_topology
std::vector< std::vector
< std::multimap< int, int > > > 
_distant_node_cell
std::vector< std::vector
< std::vector< std::pair< int,
int > > > > 
_node_node

Detailed Description

Definition at line 32 of file MEDPARTITIONER_JointFinder.hxx.


Constructor & Destructor Documentation

MEDPARTITIONER::JointFinder::JointFinder ( const MeshCollection &  mc)

Method contributing to the distant cell graph.

Definition at line 32 of file MEDPARTITIONER_JointFinder.cxx.

                                                              :_mesh_collection(mc),_domain_selector(mc.getParaDomainSelector()),_topology(mc.getTopology())
{
}

Definition at line 36 of file MEDPARTITIONER_JointFinder.cxx.

{
}

Member Function Documentation

Definition at line 40 of file MEDPARTITIONER_JointFinder.cxx.

{
  int nbdomain=_topology->nbDomain();
  _distant_node_cell.resize(nbdomain);
  _node_node.resize(nbdomain);
  for (int i=0; i<nbdomain; i++) 
    {
      _distant_node_cell[i].resize(nbdomain);
      _node_node[i].resize(nbdomain);
    }
  int nbproc=_domain_selector->nbProcs();
  std::vector<BBTree<3>* > bbtree(nbdomain,(BBTree<3>*) 0);
  std::vector<double* > bbxi(nbdomain,(double*) 0);
  std::vector<ParaMEDMEM::DataArrayInt*> rev(nbdomain,(ParaMEDMEM::DataArrayInt*) 0);
  std::vector<ParaMEDMEM::DataArrayInt*> revIndx(nbdomain,(ParaMEDMEM::DataArrayInt*) 0);
  int meshDim=-1;
  int spaceDim=-1;
  
  //init rev and revIndx and bbtree for my domain (of me:proc n)
  for (int mydomain=0; mydomain<nbdomain; mydomain++)
    {
      if(!_domain_selector->isMyDomain(mydomain))
        continue;
      const ParaMEDMEM::MEDCouplingUMesh* myMesh=_mesh_collection.getMesh(mydomain);
      meshDim = myMesh->getMeshDimension();
      spaceDim= myMesh->getSpaceDimension();
      rev[mydomain] = ParaMEDMEM::DataArrayInt::New();
      revIndx[mydomain] = ParaMEDMEM::DataArrayInt::New();
      myMesh->getReverseNodalConnectivity(rev[mydomain],revIndx[mydomain]);
      double* bbx=new double[2*spaceDim*myMesh->getNumberOfNodes()];
      for (int i=0; i<myMesh->getNumberOfNodes()*spaceDim; i++)
        {
          const double* coords=myMesh->getCoords()->getConstPointer();
          bbx[2*i]=(coords[i])-1e-12;
          bbx[2*i+1]=bbx[2*i]+2e-12;
        }
      bbtree[mydomain]=new BBTree<3> (bbx,0,0,myMesh->getNumberOfNodes(),-1e-12);
      //keep bbx because need it in getIntersectingElems
      //no delete [] bbx yet
      bbxi[mydomain]=bbx;
    }
  
  //send my domains to other proc an receive other domains from other proc
  for (int isource=0; isource<nbdomain; isource++)
    {
      for (int itarget=0; itarget<nbdomain; itarget++)
        {
          const ParaMEDMEM::MEDCouplingUMesh* sourceMesh=_mesh_collection.getMesh(isource);
          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<double> vec(spaceDim*sourceMesh->getNumberOfNodes());
              std::copy(sourceMesh->getCoords()->getConstPointer(),sourceMesh->getCoords()->getConstPointer()+sourceMesh->getNumberOfNodes()*spaceDim,&vec[0]);
              SendDoubleVec(vec,targetProc);
    
              //retrieving target data for storage in commonDistantNodes array
              std::vector<int> localCorrespondency;
              RecvIntVec(localCorrespondency, targetProc);
              for (std::size_t i=0; i<localCorrespondency.size()/2; i++)
                {
                  _distant_node_cell[isource][itarget].insert(std::make_pair(localCorrespondency[2*i],localCorrespondency[2*i+1]));
                }
    
            }

          if (_domain_selector->isMyDomain(itarget))
            {
              //receiving data from source proc
              int sourceProc = isource%nbproc;
              std::vector<double> recvVec;
              RecvDoubleVec(recvVec,sourceProc);
              std::map<int,int> commonNodes; // (local nodes, distant nodes) list
              for (int inode=0; inode<(recvVec.size()/spaceDim); inode++)
                {
                  double* bbox=new double[2*spaceDim];
                  for (int i=0; i<spaceDim; i++)
                    {
                      bbox[2*i]=recvVec[inode*spaceDim+i]-1e-12;
                      bbox[2*i+1]=bbox[2*i]+2e-12;
                    }
                  std::vector<int> inodes;
                  bbtree[itarget]->getIntersectingElems(bbox,inodes);
                  delete [] bbox;
      
                  if (inodes.size()>0) 
                    {
                      commonNodes.insert(std::make_pair(inodes[0],inode));
                    }
          
                }
              std::vector<int> nodeCellCorrespondency;
              for (std::map<int,int>::iterator iter=commonNodes.begin(); iter!=commonNodes.end(); iter++)
                {
                  _node_node[itarget][isource].push_back(std::make_pair(iter->first, iter->second));//storing node pairs in a vector
                  const int* revIndxPtr=revIndx[itarget]->getConstPointer();
                  const int* revPtr=rev[itarget]->getConstPointer();
                  for (int icell=revIndxPtr[iter->first]; icell<revIndxPtr[iter->first+1]; icell++)
                    {
                      nodeCellCorrespondency.push_back(iter->second); //
                      int globalCell=_topology->convertCellToGlobal(itarget,revPtr[icell]);
                      nodeCellCorrespondency.push_back(globalCell);
                    }
                }
              SendIntVec(nodeCellCorrespondency, sourceProc); //itarget proc send to other (otherLocalNode-itargetGlobalCell)
            }
        }
    }
    
  //free  rev(nbdomain) revIndx(nbdomain) bbtree(nbdomain) bbxi(nbdomain)
  for (int i=0; i<nbdomain; i++)
    {
      if (rev[i]!=0)
        rev[i]->decrRef();
      if (revIndx[i]!=0)
        revIndx[i]->decrRef();
      if (bbtree[i]!=0)
        delete bbtree[i];
      if (bbxi[i]!=0)
        delete [] bbxi[i];
    }

  if (MyGlobals::_Verbose>100) 
    std::cout << "proc " << _domain_selector->rank() << " : end JointFinder::findCommonDistantNodes" << std::endl;
}

Here is the call graph for this function:

std::vector< std::vector< std::multimap< int, int > > > & MEDPARTITIONER::JointFinder::getDistantNodeCell ( )

Definition at line 169 of file MEDPARTITIONER_JointFinder.cxx.

{
  return _distant_node_cell;
}
std::vector< std::vector< std::vector< std::pair< int, int > > > > & MEDPARTITIONER::JointFinder::getNodeNode ( )

Definition at line 174 of file MEDPARTITIONER_JointFinder.cxx.

{
  return _node_node;
}

Definition at line 179 of file MEDPARTITIONER_JointFinder.cxx.

{
  int nbdomain=_topology->nbDomain();
  //MPI_Barrier(MPI_COMM_WORLD);
  if (MyGlobals::_Is0verbose>0) 
    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; isource<nbdomain; isource++)
    {
      for (int itarget=0; itarget<nbdomain; itarget++)
        {
          for (std::size_t i=0; i<_node_node[itarget][isource].size(); i++)
            std::cout << " nn" << _domain_selector->rank() << itarget << "|" << isource << "|" << i << "|" <<
              _node_node[itarget][isource][i].first << "-" <<
              _node_node[itarget][isource][i].second;
        }
    }
  std::cout<<std::endl;
  //MPI_Barrier(MPI_COMM_WORLD);
  for (int isource=0; isource<nbdomain; isource++)
    {
      for (int itarget=0; itarget<nbdomain; itarget++)
        {
          std::multimap<int,int>::iterator it;
          for (it=_distant_node_cell[isource][itarget].begin() ; it!=_distant_node_cell[isource][itarget].end(); it++)
            {
              std::cout << " nc" << _domain_selector->rank() << "|" << itarget << "|" << isource << "|" << (*it).first << "=" << (*it).second;
            }
        }
    }
  std::cout << std::endl;
  //MPI_Barrier(MPI_COMM_WORLD);
}

Member Data Documentation

std::vector<std::vector<std::multimap<int,int> > > MEDPARTITIONER::JointFinder::_distant_node_cell [private]

Definition at line 45 of file MEDPARTITIONER_JointFinder.hxx.

const ParaDomainSelector* MEDPARTITIONER::JointFinder::_domain_selector [private]

Definition at line 43 of file MEDPARTITIONER_JointFinder.hxx.

const MeshCollection& MEDPARTITIONER::JointFinder::_mesh_collection [private]

Definition at line 42 of file MEDPARTITIONER_JointFinder.hxx.

std::vector<std::vector<std::vector<std::pair<int,int> > > > MEDPARTITIONER::JointFinder::_node_node [private]

Definition at line 46 of file MEDPARTITIONER_JointFinder.hxx.

Definition at line 44 of file MEDPARTITIONER_JointFinder.hxx.


The documentation for this class was generated from the following files: