Back to index

salome-med  6.5.0
Public Member Functions | Private Types | Private Member Functions | Private Attributes
MEDSPLITTER::ParallelTopology Class Reference

#include <MEDSPLITTER_ParallelTopology.hxx>

Inheritance diagram for MEDSPLITTER::ParallelTopology:
Inheritance graph
[legend]
Collaboration diagram for MEDSPLITTER::ParallelTopology:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 ParallelTopology ()
 ParallelTopology (const std::vector< MEDMEM::MESH * > &, const std::vector< MEDMEM::CONNECTZONE * > &, std::vector< int * > &, std::vector< int * > &, std::vector< int * > &)
 constructing topology according to mesh collection
 ParallelTopology (boost::shared_ptr< Graph > graph, int nbdomain, int mesh_dimension)
 constructing ParallelTopology from an old topology and a graph
 ~ParallelTopology ()
void convertGlobalNodeList (const int *, int, int *, int *)
 converts a list of global cell numbers to a distributed array with local cell numbers
void convertGlobalNodeList (const int *, int, int *, int)
 Converts a list of global node numbers on domain ip to a distributed array with local cell numbers.
void convertGlobalNodeListWithTwins (const int *face_list, int nbnode, int *&local, int *&ip, int *&full_array, int &size)
 Converts a list of global node numbers to a distributed array with local cell numbers.
void convertGlobalCellList (const int *, int, int *, int *)
 converts a list of global node numbers to a distributed array with local cell numbers
void convertGlobalFaceList (const int *, int, int *, int *)
 converts a list of global face numbers to a distributed array with local face numbers
void convertGlobalFaceList (const int *, int, int *, int)
 Converts a list of global node numbers on domain ip to a distributed array with local cell numbers.
void convertGlobalFaceListWithTwins (const int *face_list, int nbface, int *&local, int *&ip, int *&full_array, int &size)
 Converts a list of global face numbers to a distributed array with local face numbers.
void createNodeMapping (std::map< MED_EN::medGeometryElement, int * > &type_connectivity, std::map< MED_EN::medGeometryElement, int > &present_type_numbers, std::vector< int > &conn, std::vector< int > &conn_index, std::vector< int > &polyhedron_conn, std::vector< int > &polyhedron_conn_index, std::vector< int > &polyhedron_face_index, int idomain)
 creating node mapping
void createFaceMapping (const MESHCollection &, const MESHCollection &)
void createFaceMapping2ndversion (const MESHCollection &)
void convertToLocal (std::map< MED_EN::medGeometryElement, int * > &type_connectivity, std::map< MED_EN::medGeometryElement, int > &present_type_numbers, int idomain, MED_EN::medEntityMesh entity)
 converting node global numberings to local numberings
void convertToLocal2ndVersion (int *nodes, int nbnodes, int idomain)
void computeNodeNodeCorrespondencies (int nbdomain, vector< MEDMEM::MEDSKYLINEARRAY * > &) const
 computing arrays with node/node correspondencies
void computeCellCellCorrespondencies (int nbdomain, vector< MEDMEM::MEDSKYLINEARRAY * > &, const Graph *) const
 computing arrays with node/node correspondencies
int convertNodeToGlobal (int ip, int icell) const
 retrieving Graph
int convertFaceToGlobal (int ip, int iface) const
 converting face local numbering to global
int convertCellToGlobal (int ip, int icell) const
void convertNodeToGlobal (int ip, const int *local, int n, int *global) const
void convertCellToGlobal (int ip, const int *local, int n, int *global) const
void convertFaceToGlobal (int ip, const int *local, int n, int *global) const
int nbDomain () const
int nbCells () const
int nbCells (int idomain) const
int getNodeNumber (int idomain) const
 retrieving number of nodes
int getNodeNumber () const
void getNodeList (int idomain, int *list) const
 retrieving list of nodes in global numbers
std::vector< int > & getFusedCellNumbers (int idomain)
const std::vector< int > & getFusedCellNumbers (int idomain) const
 retrieving face numbers after fusing in parallel mode
std::vector< int > & getFusedFaceNumbers (int idomain)
const std::vector< int > & getFusedFaceNumbers (int idomain) const
int getCellNumber (int idomain) const
 retrieving number of nodes
int getCellDomainNumber (int global) const
void getCellList (int idomain, int *list) const
 retrieving list of nodes in global numbers
int getFaceNumber (int idomain) const
int getFaceNumber () const
void getFaceList (int idomain, int *list) const
 retrieving list of faces in global numbers
std::pair< int, int > convertGlobalCell (int iglobal) const
 converting a global cell number to a local representation (domain + local number)
int convertGlobalFace (int iglobal, int idomain)
int convertGlobalNode (int iglobal, int idomain)
void appendFace (int idomain, int ilocal, int iglobal)
 adding a face to the topology
int getMaxGlobalFace () const
 Return max global face number.
boost::shared_ptr< GraphgetGraph () const
 retrieving graph
void recreateFaceMapping (const TGeom2FacesByDomian &face_map)
 recreating a face mapping from scratch
virtual void recreateMappingAfterFusion (const std::vector< MEDMEM::MESH * > &)
 Recreating cell and node mapping after send-reveive and fusion of domain meshes.
virtual void computeNodeNodeCorrespondencies (int nbdomain, std::vector< MEDMEM::MEDSKYLINEARRAY * > &) const =0
 computing arrays with node/node correspondencies
virtual void computeCellCellCorrespondencies (int nbdomain, std::vector< MEDMEM::MEDSKYLINEARRAY * > &, const Graph *) const =0
 computing arrays with cell/cell correspondencies

Private Types

typedef INTERP_KERNEL::HashMap
< int, pair< int, int > > 
TGlob2DomainLoc
 mapping global -> local
typedef
INTERP_KERNEL::HashMultiMap
< int, pair< int, int > > 
TGlob2LocsMap
 mapping global -> local

Private Member Functions

bool hasCellWithNodes (const MESHCollection &, int dom, const std::set< int > &nodes)
 Return true if the domain mesh contains a cell based on given global nodes.

Private Attributes

TGlob2DomainLoc m_glob_to_loc
vector< vector< int > > m_loc_to_glob
 mapping local -> global
INTERP_KERNEL::HashMultiMap
< int, pair< int, int > > 
m_node_glob_to_loc
 mapping global -> local
vector< vector< int > > m_node_loc_to_glob
 mapping local -> global
vector< vector< int > > m_cell_loc_to_glob_fuse
vector< vector< int > > m_face_loc_to_glob_fuse
TGlob2LocsMap m_face_glob_to_loc
vector< vector< int > > m_face_loc_to_glob
 mapping local -> global
vector< int > m_nb_cells
vector< int > m_nb_nodes
vector< int > m_nb_faces
int m_nb_total_cells
int m_nb_total_nodes
int m_nb_total_faces
int m_nb_domain
int m_mesh_dimension
boost::shared_ptr< Graphm_graph

Detailed Description

Definition at line 45 of file MEDSPLITTER_ParallelTopology.hxx.


Member Typedef Documentation

mapping global -> local

Definition at line 350 of file MEDSPLITTER_ParallelTopology.hxx.

mapping global -> local

Definition at line 376 of file MEDSPLITTER_ParallelTopology.hxx.


Constructor & Destructor Documentation

Definition at line 44 of file MEDSPLITTER_ParallelTopology.cxx.

ParallelTopology::ParallelTopology ( const std::vector< MEDMEM::MESH * > &  meshes,
const std::vector< MEDMEM::CONNECTZONE * > &  cz,
std::vector< int * > &  cellglobal,
std::vector< int * > &  nodeglobal,
std::vector< int * > &  faceglobal 
)

constructing topology according to mesh collection

Definition at line 48 of file MEDSPLITTER_ParallelTopology.cxx.

                                                            :m_nb_domain(meshes.size())/*,m_mesh_dimension(meshes[0]->getMeshDimension())*/
{

  int index_global=0;
  int index_node_global=0;
  int index_face_global=0;

  m_nb_cells.resize(m_nb_domain);
  m_nb_nodes.resize(m_nb_domain);
  m_nb_faces.resize(m_nb_domain);

  m_loc_to_glob.resize(m_nb_domain);
  m_node_loc_to_glob.resize(m_nb_domain);
  m_face_loc_to_glob.resize(m_nb_domain);

  MED_EN::medEntityMesh constituent_entity;

  bool parallel_mode = false;
  for (int idomain=0; !parallel_mode && idomain<m_nb_domain; idomain++)
    parallel_mode = (!meshes[idomain]);

  for (int idomain=0; idomain<m_nb_domain; idomain++)
  {
    if ( !meshes[idomain] )
      continue;
    m_mesh_dimension = meshes[idomain]->getMeshDimension();
    constituent_entity = (m_mesh_dimension == 3 ? MED_EN::MED_FACE : MED_EN::MED_EDGE );

    //creating cell maps
    m_nb_cells[idomain]=meshes[idomain]->getNumberOfElements(MED_EN::MED_CELL, MED_EN::MED_ALL_ELEMENTS);
    //              cout << "Nb cells (domain "<<idomain<<") = "<<m_nb_cells[idomain];
    m_loc_to_glob[idomain].resize(m_nb_cells[idomain]);

    if (cellglobal[idomain]==0 || parallel_mode)
    {
      MESSAGE_MED("Creating global numbering"); 
      //creating global numbering from scratch
      for (int i=0; i<m_nb_cells[idomain]; i++)
      {
        index_global++;
        m_glob_to_loc[index_global]=make_pair(idomain,i+1);
        //m_loc_to_glob[make_pair(idomain,i+1)]=index_global;
        m_loc_to_glob[idomain][i]=index_global;
        //        cout<<"glob:"<<index_global<<" --> ("<<idomain<<","<<i+1<<")"<<endl;
      }
    }
    //using global numbering coming from a previous numbering
    else
    {
      MESSAGE_MED("Using former global numbering");
      for (int i=0; i<m_nb_cells[idomain]; i++)
      {
        int global=cellglobal[idomain][i];
        m_glob_to_loc[global]=make_pair(idomain,i+1);
        //m_loc_to_glob[make_pair(idomain,i+1)]=global;
        m_loc_to_glob[idomain][i]=global;
        index_global++;
        //        cout<<"glob:"<<global<<" --> ("<<idomain<<","<<i+1<<")"<<endl;
      }
    }

    //cas sequentiel
    if (m_nb_domain==1)
    {
      m_nb_total_cells=index_global;
      m_nb_cells[0]=index_global;
      m_node_loc_to_glob[idomain].resize(meshes[idomain]->getNumberOfNodes());
      for (int i=0; i<meshes[idomain]->getNumberOfNodes(); i++)
      {
        m_node_glob_to_loc.insert(make_pair(i+1,make_pair(0,i+1)));
        //m_node_loc_to_glob.insert(make_pair(make_pair(0,i+1), i+1));
        m_node_loc_to_glob[0][i]=i+1;
      }
      m_nb_total_nodes=meshes[idomain]->getNumberOfNodes();   
      m_nb_nodes[0]=m_nb_total_nodes; 

      //                      meshes[idomain]->getConnectivity( MED_EN::MED_DESCENDING, MED_EN::MED_CELL, MED_EN::MED_ALL_ELEMENTS); 
      int nbfaces=meshes[idomain]->getNumberOfElements(constituent_entity,MED_EN::MED_ALL_ELEMENTS);
      m_face_loc_to_glob[idomain].resize(nbfaces);
      for (int i=0; i<nbfaces; i++)
      {
        m_face_glob_to_loc.insert(make_pair(i+1,make_pair(0,i+1)));
        //m_face_loc_to_glob.insert(make_pair(make_pair(0,i+1), i+1));
        m_face_loc_to_glob[0][i]=i+1;
      }
      m_nb_total_faces=nbfaces;   
      m_nb_faces[0]=nbfaces;
      MESSAGE_MED ("nb total cells "<< m_nb_total_cells);
      MESSAGE_MED("nb total nodes "<< m_nb_total_nodes);  
      MESSAGE_MED("nb total faces "<< m_nb_total_faces);  
      return;
    }

    //creating node maps
    m_nb_nodes[idomain]=meshes[idomain]->getNumberOfNodes();
    INTERP_KERNEL::HashMap <int,pair<int,int> > local2distant;
    m_node_loc_to_glob[idomain].resize(m_nb_nodes[idomain]);
    for (unsigned icz=0; icz<cz.size(); icz++)
    {
      if (cz[icz]->getLocalDomainNumber() == idomain && 
          cz[icz]->getLocalDomainNumber()>cz[icz]->getDistantDomainNumber())
      {
        int nb_node= cz[icz]->getNodeNumber();
        const int* node_corresp=cz[icz]->getNodeCorrespValue();
        int distant_ip = cz[icz]->getDistantDomainNumber();
        for (int i=0; i< nb_node; i++)
        {
          int local= node_corresp[i*2];
          int distant = node_corresp[i*2+1];
          local2distant.insert(make_pair(local, make_pair(distant_ip,distant)));    
        }
      }
    }
    // setting mappings for all nodes
    if (nodeglobal[idomain]==0)
    {
      for (int inode=0; inode<m_nb_nodes[idomain]; inode++)
      {
        if (local2distant.find(inode+1)==local2distant.end())
        {
          index_node_global++;
          m_node_glob_to_loc.insert(make_pair(index_node_global,make_pair(idomain,inode+1)));
          //m_node_loc_to_glob[make_pair(idomain,inode+1)]=index_node_global;
          m_node_loc_to_glob[idomain][inode]=index_node_global;
        }   
        else
        {
          int ip = (local2distant.find(inode+1)->second).first;
          int distant = (local2distant.find(inode+1)->second).second;
          //int global_number=m_loc_to_glob[make_pair(ip,distant)];
          int global_number=m_loc_to_glob[ip][distant-1];
          m_node_glob_to_loc.insert(make_pair(global_number,make_pair(idomain,inode+1)));
          //m_node_loc_to_glob[make_pair(idomain,inode+1)]=global_number;
          m_node_loc_to_glob[idomain][inode]=global_number;
        } 
      }
    }
    //using former node numbering
    else
    {//       cout << "("<<idomain<<","<<i+1<<")->"<<i+1<<endl;
      for (int inode=0; inode<m_nb_nodes[idomain]; inode++)
      {
        int global_number=nodeglobal[idomain][inode];
        //        cout << "global_number "<<global_number<<endl;
        m_node_glob_to_loc.insert(make_pair(global_number,make_pair(idomain,inode+1)));
        //m_node_loc_to_glob[make_pair(idomain,inode+1)]=global_number;
        m_node_loc_to_glob[idomain][inode]=global_number;
      }
    }


    //creating  dimension d-1 component mappings

    //              meshes[idomain]->getConnectivity( MED_EN::MED_DESCENDING, MED_EN::MED_CELL, MED_EN::MED_ALL_ELEMENTS); 
    m_nb_faces[idomain]=meshes[idomain]->getNumberOfElements(constituent_entity,MED_EN::MED_ALL_ELEMENTS);
    MESSAGE_MED ("Nb faces domain " << idomain<<m_nb_faces[idomain]);
    m_face_loc_to_glob[idomain].resize(m_nb_faces[idomain]);
    local2distant.clear();
    for (unsigned icz=0; icz<cz.size(); icz++)
    {
      if (cz[icz]->getLocalDomainNumber() == idomain && 
          cz[icz]->getLocalDomainNumber()>cz[icz]->getDistantDomainNumber())
      {
        int nb_face= cz[icz]->getFaceNumber();
        const int* face_corresp=cz[icz]->getFaceCorrespValue();
        int distant_ip = cz[icz]->getDistantDomainNumber();
        for (int i=0; i< nb_face; i++)
        {
          int local= face_corresp[i*2];
          int distant = face_corresp[i*2+1];
          local2distant.insert(make_pair(local, make_pair(distant_ip,distant)));    
        }
      }
    }
    // setting mappings for all faces
    if (faceglobal[idomain]==0)
    {
      for (int iface=0; iface<m_nb_faces[idomain]; iface++)
      {
        if (local2distant.find(iface+1)==local2distant.end())
        {
          index_face_global++;
          m_face_glob_to_loc.insert(make_pair(index_face_global,make_pair(idomain,iface+1)));
          //m_face_loc_to_glob[make_pair(idomain,iface+1)]=index_face_global;
          m_face_loc_to_glob[idomain][iface]=index_face_global;
        }   
        else
        {
          int ip = (local2distant.find(iface+1)->second).first;
          int distant = (local2distant.find(iface+1)->second).second;
          //int global_number=m_loc_to_glob[make_pair(ip,distant)];
          int global_number=m_loc_to_glob[ip][distant-1];
          m_face_glob_to_loc.insert(make_pair(global_number,make_pair(idomain,iface+1)));
          //m_face_loc_to_glob[make_pair(idomain,iface+1)]=global_number;
          m_face_loc_to_glob[idomain][iface]=global_number;
        } 
      }
    }
    //using former face numbering
    else
    {
      for (int iface=0; iface<m_nb_faces[idomain]; iface++)
      {
        int global_number=faceglobal[idomain][iface];
        //SCRUTE_MED(global_number);
        m_face_glob_to_loc.insert(make_pair(global_number,make_pair(idomain,iface+1)));
        //m_face_loc_to_glob[make_pair(idomain,iface+1)]=global_number;
        m_face_loc_to_glob[idomain][iface]=global_number;
      }
    }
  }

  m_nb_total_cells=index_global;
  m_nb_total_nodes=index_node_global;   
  m_nb_total_faces=index_face_global;
  SCRUTE_MED(m_nb_total_cells);
  SCRUTE_MED(m_nb_total_faces);
  SCRUTE_MED(m_nb_total_nodes);

}

Here is the call graph for this function:

ParallelTopology::ParallelTopology ( boost::shared_ptr< Graph graph,
int  nbdomain,
int  mesh_dimension 
)

constructing ParallelTopology from an old topology and a graph

Definition at line 275 of file MEDSPLITTER_ParallelTopology.cxx.

                                                                                                 :
  m_nb_domain(nb_domain),
  m_mesh_dimension(mesh_dimension),
  m_nb_cells(graph->nbVertices()),
  m_graph(graph)
{
  m_nb_cells.resize(m_nb_domain);
  m_nb_nodes.resize(m_nb_domain);
  m_nb_faces.resize(m_nb_domain);

  m_loc_to_glob.resize(m_nb_domain);
  m_node_loc_to_glob.resize(m_nb_domain);
  m_face_loc_to_glob.resize(m_nb_domain);

  // used in parallel mode only
  m_cell_loc_to_glob_fuse.resize(m_nb_domain);
  m_face_loc_to_glob_fuse.resize(m_nb_domain);

  for (int i=0; i<m_nb_domain; i++)
    m_nb_cells[i]=0;  

  const int* part = graph-> getPart();
  m_nb_total_cells= graph->nbVertices();

  for (int icell=0; icell<m_nb_total_cells; icell++)
  {
    int idomain = part[icell];
    m_nb_cells[idomain]++;
    //m_loc_to_glob[make_pair(idomain,m_nb_cells[idomain])]=icell+1;
    m_loc_to_glob[idomain].push_back(icell+1);
    m_glob_to_loc[icell+1]=make_pair(idomain,m_nb_cells[idomain]);

  }
  for (int idomain=0; idomain<m_nb_domain; idomain++)
    MESSAGE_MED("Nombre de cellules dans le domaine "<< idomain <<" : "<<m_nb_cells[idomain]); 

  SCRUTE_MED(m_nb_total_cells);

}

Definition at line 315 of file MEDSPLITTER_ParallelTopology.cxx.

{

} 

Member Function Documentation

void MEDSPLITTER::ParallelTopology::appendFace ( int  idomain,
int  ilocal,
int  iglobal 
) [inline, virtual]

adding a face to the topology

Implements MEDSPLITTER::Topology.

Definition at line 321 of file MEDSPLITTER_ParallelTopology.hxx.

    {
      m_face_loc_to_glob[idomain].push_back(iglobal);
      m_face_glob_to_loc.insert(make_pair(iglobal,make_pair(idomain,ilocal)));
    }

Here is the call graph for this function:

void ParallelTopology::computeCellCellCorrespondencies ( int  nbdomain,
vector< MEDMEM::MEDSKYLINEARRAY * > &  ,
const Graph  
) const

computing arrays with node/node correspondencies

computing arrays with cell/cell correspondencies

Parameters:
idomain- domain for which to compute correspondencies
corr- out correspondencies
graph- graph containing new cell distribution among domains
id_shift- shitf to get cell id global on this processor from id global over all procs

Definition at line 948 of file MEDSPLITTER_ParallelTopology.cxx.

{
  vector <int> sizes (m_nb_domain,0);
  vector <int*> values (m_nb_domain);
  for (int i=0; i<m_nb_domain; i++)
  {
    values[i]=0;
  }

  vector <INTERP_KERNEL::HashMultiMap<int,int> > cell_corresp;
  //TODO : remplacer int* par une map <int,int>
  //  vector<int*  > number_of_connections(m_nb_domain);
  //  vector<map<int,int> > number_of_connections;
  vector<map<int,int> > number_of_connections;
  cell_corresp.resize(m_nb_domain);
  number_of_connections.resize(m_nb_domain);
  //  for (int i=0; i<m_nb_domain; i++)
  //    {
  //      //    cell_corresp[i]=new multimap<int,int>;
  //      if (m_nb_cells[i] >0)
  //        {
  //          number_of_connections[i]=new int[m_nb_cells[idomain]];
  //          for (int j=0; j<m_nb_cells[idomain]; j++)
  //            number_of_connections[i][j]=0;
  //        }
  //    }

  const MEDMEM::MEDSKYLINEARRAY* skylinegraph = graph->getGraph();

  const int* index=skylinegraph->getIndex();
  const int* value=skylinegraph->getValue();

  TGlob2DomainLoc::const_iterator gl_do_lo_end = m_glob_to_loc.end();

  for (int icell=0; icell<m_nb_cells[idomain]; icell++)
  {
    int global= m_loc_to_glob[idomain][icell];
    for (int ii=index[global-1]-1; ii<index[global]-1; ii++)
    {
      int distant_global=value[ii];

      const pair<int,int>& local = m_glob_to_loc.find(distant_global)->second;

      if (local.first != idomain)
      {
        cell_corresp[local.first].insert(make_pair(icell+1,local.second));
        //              number_of_connections[local.first][icell]++;
        if (number_of_connections[local.first].find(icell)==number_of_connections[local.first].end())
          number_of_connections[local.first].insert(make_pair(icell,1));
        else
          number_of_connections[local.first][icell]++;

      }
    }
  }

  for (int inew=0; inew<m_nb_domain; inew++)
  {
    if (inew==idomain || number_of_connections[inew].empty()) continue;

    int* new_index=new int[m_nb_cells[idomain]+1];
    new_index[0]=1;
    for (int i=0; i<m_nb_cells[idomain]; i++)
    {

      if (number_of_connections[inew].find(i)!=number_of_connections[inew].end())
        new_index[i+1]=new_index[i]+number_of_connections[inew][i];
      else
        new_index[i+1]=new_index[i];
    }
    int* new_value;
    if (new_index[m_nb_cells[idomain]]-1 > 0)
      new_value=new int[new_index[m_nb_cells[idomain]]-1];
    else 
      new_value=0;

    int value_i=0;

    //                      INTERP_KERNEL::HashMultiMap<int,int>::iterator iter=cell_corresp[inew].begin();

    for (int i=0; i<m_nb_cells[idomain]; i++)
    {
      //          for (int j=new_index[i];j<new_index[i+1];j++,value_i++,iter++)
      //            new_value[value_i]=iter->second;

      typedef INTERP_KERNEL::HashMultiMap<int,int>::iterator mmiter;
      pair<mmiter,mmiter> range=cell_corresp[inew].equal_range(i+1);
      for (mmiter it=range.first; it!=range.second; it++)
      {
        new_value[value_i]=it->second;
        value_i++;
      }
    }
    if (value_i>0)    
    {
      corr[inew] = new MEDMEM::MEDSKYLINEARRAY(m_nb_cells[idomain], new_index[m_nb_cells[idomain]]-1, new_index,new_value,true);
    }
    else 
    {
      corr[inew]=0;
      if (new_value !=0) delete[]new_value;
      delete[]new_index;
    }   

  }

  //    for (int inew=0; inew<m_nb_domain; inew++)
  //    if (m_nb_cells[inew]>0)
  //      delete[] number_of_connections[inew];

}

Here is the call graph for this function:

virtual void MEDSPLITTER::Topology::computeCellCellCorrespondencies ( int  nbdomain,
std::vector< MEDMEM::MEDSKYLINEARRAY * > &  ,
const Graph  
) const [pure virtual, inherited]

computing arrays with cell/cell correspondencies

void ParallelTopology::computeNodeNodeCorrespondencies ( int  nbdomain,
vector< MEDMEM::MEDSKYLINEARRAY * > &   
) const

computing arrays with node/node correspondencies

Definition at line 872 of file MEDSPLITTER_ParallelTopology.cxx.

{
  vector <int> sizes (m_nb_domain,0);
  vector <int*> values (m_nb_domain);
  for (int i=0; i<m_nb_domain; i++)
  {
    values[i]=0;
  }

  for (int inode=0; inode<m_nb_nodes[idomain]; inode++)
  {
    //int global = (m_node_loc_to_glob.find(make_pair(idomain,inode+1)))->second;
    int global = m_node_loc_to_glob[idomain][inode];
    typedef INTERP_KERNEL::HashMultiMap<int,pair<int,int> >::const_iterator mm;
    pair<mm,mm> range = m_node_glob_to_loc.equal_range(global);
    for (mm it=range.first; it !=range.second; it++)
    {
      int id = (it->second).first;
      if (id !=idomain)
      {
        sizes[id]++;
      }
    }
  }

  for (int ip=0; ip<m_nb_domain; ip++)
  {
    if (sizes[ip]>0)
      values[ip]=new int[2*sizes[ip]];
    sizes[ip]=0;
  }


  for (int inode=0; inode<m_nb_nodes[idomain]; inode++)
  {
    //int global = (m_node_loc_to_glob.find(make_pair(idomain,inode+1)))->second;
    int global = m_node_loc_to_glob[idomain][inode];
    typedef INTERP_KERNEL::HashMultiMap<int,pair<int,int> >::const_iterator mm;
    pair<mm,mm> range = m_node_glob_to_loc.equal_range(global);
    for (mm it=range.first; it !=range.second; it++)
    {
      int id = (it->second).first;
      if (id !=idomain)
      {
        values[id][sizes[id]*2]=inode+1;
        values[id][sizes[id]*2+1]=(it->second).second;
        sizes[id]++;
      }
    }
  }

  for (int i=0; i< m_nb_domain; i++)
  {
    if (sizes[i]!=0)
    {
      int* index = new int[sizes[i]+1];
      for (int j=0; j<sizes[i]+1; j++)
        index[j]=j+1;
      corr[i]=new MEDMEM::MEDSKYLINEARRAY(sizes[i],2*sizes[i],index,values[i]);
      delete[] index;
      delete[] values[i];
    }
  }
}

Here is the call graph for this function:

virtual void MEDSPLITTER::Topology::computeNodeNodeCorrespondencies ( int  nbdomain,
std::vector< MEDMEM::MEDSKYLINEARRAY * > &   
) const [pure virtual, inherited]

computing arrays with node/node correspondencies

int MEDSPLITTER::ParallelTopology::convertCellToGlobal ( int  ip,
int  icell 
) const [inline, virtual]

Implements MEDSPLITTER::Topology.

Definition at line 132 of file MEDSPLITTER_ParallelTopology.hxx.

    {
      //     if (m_loc_to_glob.find(make_pair(ip,icell))==m_loc_to_glob.end())
      //       return -1;
      //     else
      //return m_loc_to_glob.find(make_pair(ip,icell))->second;
      return m_loc_to_glob[ip][icell-1];
    }
void MEDSPLITTER::ParallelTopology::convertCellToGlobal ( int  ip,
const int *  local,
int  n,
int *  global 
) const [inline, virtual]

Implements MEDSPLITTER::Topology.

Definition at line 149 of file MEDSPLITTER_ParallelTopology.hxx.

    {
      for (int i=0; i<n; i++)
        global[i]=m_loc_to_glob[ip][local[i]-1];  
      //global[i]=m_loc_to_glob.find(make_pair(ip,local[i]))->second;
    }
int MEDSPLITTER::ParallelTopology::convertFaceToGlobal ( int  ip,
int  iface 
) const [inline, virtual]

converting face local numbering to global

Implements MEDSPLITTER::Topology.

Definition at line 122 of file MEDSPLITTER_ParallelTopology.hxx.

    {
      //     if (m_face_loc_to_glob.find(make_pair(ip,icell))==m_face_loc_to_glob.end())
      //       return -1;
      //     else
      //return m_face_loc_to_glob.find(make_pair(ip,icell))->second;
      return m_face_loc_to_glob[ip][iface-1];
    }
void MEDSPLITTER::ParallelTopology::convertFaceToGlobal ( int  ip,
const int *  local,
int  n,
int *  global 
) const [inline, virtual]

Implements MEDSPLITTER::Topology.

Definition at line 156 of file MEDSPLITTER_ParallelTopology.hxx.

    {
      for (int i=0; i<n; i++)
      {
        global[i]=m_face_loc_to_glob[ip][local[i]-1];
        //          if (m_face_loc_to_glob.find(make_pair(ip,local[i]))==m_face_loc_to_glob.end())
        //            {
        //              cout << "problem : face # "<< local[i] << " of processor "<< ip<< " was not found in mapping loc2glob"<<endl; 
        //              global[i]=-1;
        //            }
        //          else
        //            global[i]=m_face_loc_to_glob.find(make_pair(ip,local[i]))->second;
      }
    }
std::pair<int,int> MEDSPLITTER::ParallelTopology::convertGlobalCell ( int  iglobal) const [inline, virtual]

converting a global cell number to a local representation (domain + local number)

Implements MEDSPLITTER::Topology.

Definition at line 291 of file MEDSPLITTER_ParallelTopology.hxx.

    {
      return m_glob_to_loc.find(iglobal)->second;
    }

Here is the call graph for this function:

void ParallelTopology::convertGlobalCellList ( const int *  cell_list,
int  nbcell,
int *  local,
int *  ip 
) [virtual]

converts a list of global node numbers to a distributed array with local cell numbers

converts a list of global cell numbers to a distributed array with local cell numbers

Implements MEDSPLITTER::Topology.

Definition at line 437 of file MEDSPLITTER_ParallelTopology.cxx.

{
  for (int i=0; i< nbcell; i++)
  {
    INTERP_KERNEL::HashMap<int, pair<int,int> >::const_iterator iter = m_glob_to_loc.find(cell_list[i]);
    ip[i]=(iter->second).first;
    local[i]=(iter->second).second;
  }
}

Here is the call graph for this function:

int MEDSPLITTER::ParallelTopology::convertGlobalFace ( int  iglobal,
int  idomain 
) [inline, virtual]

Implements MEDSPLITTER::Topology.

Definition at line 296 of file MEDSPLITTER_ParallelTopology.hxx.

    {
      typedef INTERP_KERNEL::HashMultiMap<int, pair<int,int> >::const_iterator MMiter;
      pair<MMiter,MMiter> eq = m_face_glob_to_loc.equal_range(iglobal);
      for (MMiter it=eq.first; it != eq.second; it++)
      {
        SCRUTE_MED (it->second.first);
        SCRUTE_MED (idomain);
        if (it->second.first == idomain) return it->second.second;

      }
      return -1;
    }

Here is the call graph for this function:

void ParallelTopology::convertGlobalFaceList ( const int *  face_list,
int  nbface,
int *  local,
int *  ip 
) [virtual]

converts a list of global face numbers to a distributed array with local face numbers

Converts a list of global face numbers to a distributed array with local face numbers.

Implements MEDSPLITTER::Topology.

Definition at line 450 of file MEDSPLITTER_ParallelTopology.cxx.

{
  for (int i=0; i< nbface; i++)
  {
    INTERP_KERNEL::HashMap<int, pair<int,int> >::const_iterator iter = m_face_glob_to_loc.find(face_list[i]);
    if (iter == m_face_glob_to_loc.end())
    {
      throw MED_EXCEPTION("convertGlobalFaceList - Face  not found");
    }
    ip[i]=(iter->second).first;
    local[i]=(iter->second).second;
    //    cout << " in convertGlobalFAceList face global "<<face_list[i]<<" -> ("<<ip[i]<<","<<local[i]<<")"<<endl;
  }
}

Here is the call graph for this function:

void ParallelTopology::convertGlobalFaceList ( const int *  face_list,
int  nbface,
int *  local,
int  ip 
) [virtual]

Converts a list of global node numbers on domain ip to a distributed array with local cell numbers.

If a node in the list is represented on several domains, only the value with domain ip is returned

Implements MEDSPLITTER::Topology.

Definition at line 472 of file MEDSPLITTER_ParallelTopology.cxx.

{
  for (int i=0; i< nbface; i++)
  {
    typedef INTERP_KERNEL::HashMultiMap<int,pair<int,int> >::iterator mmiter;
    pair<mmiter,mmiter> range=m_face_glob_to_loc.equal_range(face_list[i]);
    for (mmiter it=range.first; it !=range.second; it++)
    { 
      int ipfound=(it->second).first;
      if (ipfound==ip)
        local[i]=(it->second).second; 

    }
  }
} 

Here is the call graph for this function:

void ParallelTopology::convertGlobalFaceListWithTwins ( const int *  face_list,
int  nbface,
int *&  local,
int *&  ip,
int *&  full_array,
int &  size 
) [virtual]

Converts a list of global face numbers to a distributed array with local face numbers.

If a face in the list is represented on several domains, all the values are put in the array

Implements MEDSPLITTER::Topology.

Definition at line 407 of file MEDSPLITTER_ParallelTopology.cxx.

{
  size=0;
  for (int i=0; i< nbface; i++)
  {
    //int count = m_face_glob_to_loc.count(face_list[i]);
    //if (count >1) MESSAGE_MED("face en doublon "<<face_list[i]);
    size+= m_face_glob_to_loc.count(face_list[i]);
  }
  int index=0;
  ip=new int[size];
  local=new int[size];
  full_array=new int[size];
  for (int i=0; i< nbface; i++)
  {
    typedef INTERP_KERNEL::HashMultiMap<int,pair<int,int> >::iterator mmiter;
    pair<mmiter,mmiter> range=m_face_glob_to_loc.equal_range(face_list[i]);
    for (mmiter it=range.first; it !=range.second; it++)
    { 
      ip[index]=(it->second).first;
      local[index]=(it->second).second;
      full_array[index]=face_list[i];
      index++;
    }

  }
}

Here is the call graph for this function:

int MEDSPLITTER::ParallelTopology::convertGlobalNode ( int  iglobal,
int  idomain 
) [inline, virtual]

Implements MEDSPLITTER::Topology.

Definition at line 310 of file MEDSPLITTER_ParallelTopology.hxx.

    {
      typedef INTERP_KERNEL::HashMultiMap<int, pair<int,int> >::const_iterator MMiter;
      pair<MMiter,MMiter> eq = m_node_glob_to_loc.equal_range(iglobal);
      for (MMiter it=eq.first; it != eq.second; it++)
      {
        if (it->second.first == idomain) return it->second.second;
      }
      return -1;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void ParallelTopology::convertGlobalNodeList ( const int *  node_list,
int  nbnode,
int *  local,
int *  ip 
) [virtual]

converts a list of global cell numbers to a distributed array with local cell numbers

Converts a list of global node numbers to a distributed array with local cell numbers.

If a node in the list is represented on several domains, only the first value is returned

Implements MEDSPLITTER::Topology.

Definition at line 326 of file MEDSPLITTER_ParallelTopology.cxx.

{
  if (m_node_glob_to_loc.empty()) 
    throw MEDMEM::MEDEXCEPTION("convertGlobalNodeList - Node mapping has not yet been built");
  for (int i=0; i< nbnode; i++)
  {
    pair<int,int> local_node = m_node_glob_to_loc.find(node_list[i])->second;
    ip[i]=local_node.first;
    local[i]=local_node.second;
  }
}

Here is the call graph for this function:

void ParallelTopology::convertGlobalNodeList ( const int *  node_list,
int  nbnode,
int *  local,
int  ip 
) [virtual]

Converts a list of global node numbers on domain ip to a distributed array with local cell numbers.

If a node in the list is represented on several domains, only the value with domain ip is returned

Implements MEDSPLITTER::Topology.

Definition at line 345 of file MEDSPLITTER_ParallelTopology.cxx.

{
  if (m_node_glob_to_loc.empty()) 
    throw MEDMEM::MEDEXCEPTION("convertGlobalNodeList - Node mapping has not yet been built");

  for (int i=0; i< nbnode; i++)
  {
    typedef INTERP_KERNEL::HashMultiMap<int,pair<int,int> >::iterator mmiter;
    pair<mmiter,mmiter> range=m_node_glob_to_loc.equal_range(node_list[i]);
    for (mmiter it=range.first; it !=range.second; it++)
    { 
      int ipfound=(it->second).first;
      if (ipfound==ip)
        local[i]=(it->second).second;
    }
  }
} 

Here is the call graph for this function:

void ParallelTopology::convertGlobalNodeListWithTwins ( const int *  node_list,
int  nbnode,
int *&  local,
int *&  ip,
int *&  full_array,
int &  size 
) [virtual]

Converts a list of global node numbers to a distributed array with local cell numbers.

If a node in the list is represented on several domains, all the values are put in the array

Implements MEDSPLITTER::Topology.

Definition at line 369 of file MEDSPLITTER_ParallelTopology.cxx.

{
  if (m_node_glob_to_loc.empty()) 
    throw MEDMEM::MEDEXCEPTION("convertGlobalNodeList - Node mapping has not yet been built");

  size=0;
  for (int i=0; i< nbnode; i++)
  {
    int count= m_node_glob_to_loc.count(node_list[i]);
    //      if (count > 1) 
    //        cout << "noeud " << node_list[i]<< " doublon d'ordre " << count<<endl;
    size+=count;
  }
  int index=0;
  ip=new int[size];
  local=new int[size];
  full_array=new int[size];
  for (int i=0; i< nbnode; i++)
  {
    typedef INTERP_KERNEL::HashMultiMap<int,pair<int,int> >::iterator mmiter;
    pair<mmiter,mmiter> range=m_node_glob_to_loc.equal_range(node_list[i]);
    for (mmiter it=range.first; it !=range.second; it++)
    { 
      ip[index]=(it->second).first;
      local[index]=(it->second).second;
      full_array [index]=node_list[i];
      index++;
    }

  }
}

Here is the call graph for this function:

int MEDSPLITTER::ParallelTopology::convertNodeToGlobal ( int  ip,
int  icell 
) const [inline, virtual]

retrieving Graph

converting node local numbering to global

Implements MEDSPLITTER::Topology.

Definition at line 115 of file MEDSPLITTER_ParallelTopology.hxx.

    {
      //return m_node_loc_to_glob.find(make_pair(ip,icell))->second;
      return icell < 1 ? icell : m_node_loc_to_glob[ip][icell-1];
    }

Here is the caller graph for this function:

void MEDSPLITTER::ParallelTopology::convertNodeToGlobal ( int  ip,
const int *  local,
int  n,
int *  global 
) const [inline, virtual]

Implements MEDSPLITTER::Topology.

Definition at line 141 of file MEDSPLITTER_ParallelTopology.hxx.

    {
      for (int i=0; i<n; i++)
        //global[i]=m_node_loc_to_glob[ip][local[i]-1];
        global[i]=convertNodeToGlobal(ip,local[i]);
      //global[i]=m_node_loc_to_glob.find(make_pair(ip,local[i]))->second;
    }

Here is the call graph for this function:

void ParallelTopology::convertToLocal ( std::map< MED_EN::medGeometryElement, int * > &  type_connectivity,
std::map< MED_EN::medGeometryElement, int > &  present_type_numbers,
int  idomain,
MED_EN::medEntityMesh  entity 
) [virtual]

converting node global numberings to local numberings

Implements MEDSPLITTER::Topology.

Definition at line 807 of file MEDSPLITTER_ParallelTopology.cxx.

{
  int dimension;
  switch (entity)
  {
  case MED_EN::MED_CELL:
    dimension=m_mesh_dimension;
    break;
  case MED_EN::MED_FACE:
    dimension=2;
    break;
  case MED_EN::MED_EDGE:
    dimension=1;
    break;
  } 

  MED_EN::MESH_ENTITIES::const_iterator currentEntity;
  list<MED_EN::medGeometryElement>::const_iterator iter;
  currentEntity  = MED_EN::meshEntities.find(MED_EN::MED_CELL);

  for (iter = (*currentEntity).second.begin();iter != (*currentEntity).second.end(); iter++)
  {
    MED_EN::medGeometryElement type = (*iter);
    if (type/100 != dimension) continue;
    for (int inode=0; inode<present_type_numbers[type]*(type%100); inode++)
    {
      //      cout <<" inode :"<<inode<< " global = "<<type_connectivity[type][inode];
      int global = type_connectivity[type][inode];
      typedef INTERP_KERNEL::HashMultiMap<int,pair<int,int> >::iterator mmiter;
      pair<mmiter,mmiter> range=m_node_glob_to_loc.equal_range(global);
      for (mmiter it=range.first; it !=range.second; it++)
      {
        if ((it->second).first==idomain)
          type_connectivity[type][inode]=(it->second).second;
      }
      //      cout << " local = " <<type_connectivity[type][inode]<<endl;
    }

  }
}

Here is the call graph for this function:

void ParallelTopology::convertToLocal2ndVersion ( int *  nodes,
int  nbnodes,
int  idomain 
) [virtual]

Implements MEDSPLITTER::Topology.

Definition at line 854 of file MEDSPLITTER_ParallelTopology.cxx.

{
  for (int inode=0; inode<nbnodes; inode++)
  {
    //      cout <<" inode :"<<inode<< " global = "<<type_connectivity[type][inode];
    int global = nodes[inode];
    typedef INTERP_KERNEL::HashMultiMap<int,pair<int,int> >::iterator mmiter;
    pair<mmiter,mmiter> range=m_node_glob_to_loc.equal_range(global);
    for (mmiter it=range.first; it !=range.second; it++)
    {
      if ((it->second).first==idomain)
        nodes[inode]=(it->second).second;
    }        
  }
}

Here is the call graph for this function:

void ParallelTopology::createFaceMapping ( const MESHCollection initial_collection,
const MESHCollection new_collection 
) [virtual]

Implements MEDSPLITTER::Topology.

Definition at line 618 of file MEDSPLITTER_ParallelTopology.cxx.

{
  // containers for the new topology
  vector<int> new_counts(m_nb_domain,0);
  vector<int> domain_counts(m_nb_domain,0);
  const Topology* old_topology=initial_collection.getTopology();
  int nb_domain_old=old_topology->nbDomain();
  int global_index=old_topology->getFaceNumber();
  //cout << "nb faces = " << global_index << endl;
  set <pair<int, pair<int,int> > > global_treated;

  //definition of the d-1 constituent for the considered mesh dimension
  MED_EN::medEntityMesh constituent_entity;
  switch (m_mesh_dimension)
  {
  case 3:
    constituent_entity= MED_EN::MED_FACE;
    break;
  case 2:
    constituent_entity = MED_EN::MED_EDGE;
    break;
  }

  for (int iold=0; iold<nb_domain_old;iold++)
  {
    if ( !initial_collection.getMesh(iold) ) continue;
    int nbtotalface = initial_collection.getMesh(iold)->getNumberOfElements(constituent_entity,MED_EN::MED_ALL_ELEMENTS);
    SCRUTE_MED(nbtotalface);
    const int* face_conn = 0;
    const int* face_offset = 0;
    if (nbtotalface >0)
    {
      face_conn = initial_collection.getMesh(iold)->getConnectivity(
                                                                    MED_EN::MED_NODAL,constituent_entity,MED_EN::MED_ALL_ELEMENTS);
      face_offset = initial_collection.getMesh(iold)->getConnectivityIndex(MED_EN::MED_NODAL,constituent_entity);
    }
    for (int iface=0;iface<nbtotalface; iface++)
    {
      int global_face_number = old_topology->convertFaceToGlobal(iold,iface+1);

      //      int inode = face_offset[iface];
      for (int i=0; i<m_nb_domain; i++) domain_counts[i]=0;
      set <int> nodes;
      int nbnodes;
      {
        nbnodes=face_offset[iface+1]-face_offset[iface];
        for (int inode= face_offset[iface];inode < face_offset[iface+1]; inode++)
        {
          int node=face_conn[inode-1];

          int global = old_topology->convertNodeToGlobal(iold,node);
          //        cout << "global node "<<global<<"ip "<<iold<< "noeud"<<node<<endl;
          nodes.insert(global);
          typedef INTERP_KERNEL::HashMultiMap<int,pair<int,int> >::iterator mmiter;
          pair<mmiter,mmiter> range=m_node_glob_to_loc.equal_range(global);

          int ip;
          for (mmiter it=range.first; it !=range.second; it++)
          { 
            ip=(it->second).first;
            domain_counts[ip]++;
          }
        }
      }

      set<int>::const_iterator iter_node = nodes.begin();
      int numbers[3];
      numbers[2]=0; // for segments
      for (int i=0; i<nbnodes; i++)
      {
        numbers[i]=*iter_node;
        iter_node++;
      }
      set <pair<int, pair<int,int> > > ::iterator iter_triplets;
      pair<int, pair<int,int> > triplet = make_pair(numbers[0],make_pair(numbers[1],numbers[2]));
      iter_triplets=global_treated.find(triplet);
      if (iter_triplets==global_treated.end())
      {
        global_treated.insert(triplet);
        //  int nbnodes=face_offset[iface+1]-face_offset[iface];
        if (global_face_number == -1) 
        {
          global_index++;
          global_face_number=global_index;

        }
        //  SCRUTE_MED(nbnodes);

        for (int inew=0;inew<m_nb_domain;inew++)
        {
          //     SCRUTE_MED(domain_counts[inew]);
          if(domain_counts[inew]==nbnodes)
          {
            if ( !hasCellWithNodes( new_collection, inew, nodes ))
              continue; // 0020861: EDF 1387 MED: Result of medsplitter gives standalone triangles

            new_counts[inew]++;
            m_face_glob_to_loc.insert(make_pair(global_face_number,make_pair(inew,new_counts[inew])));
            //m_face_loc_to_glob.insert(make_pair(make_pair(inew,new_counts[inew]),global_face_number));
            m_face_loc_to_glob[inew].push_back(global_face_number);
          }
        }
        //cout << "global_face_number = " << global_face_number << endl;
      }
    }
  }

  for (int inew=0;inew<m_nb_domain;inew++)
  {
    m_nb_faces[inew]=new_counts[inew];
    MESSAGE_MED(" Nb faces ["<<inew<<"]="<<m_nb_faces[inew]);
  }
  MESSAGE_MED(" total number of faces"<<getFaceNumber());
}

Here is the call graph for this function:

void ParallelTopology::createFaceMapping2ndversion ( const MESHCollection initial_collection)

Definition at line 739 of file MEDSPLITTER_ParallelTopology.cxx.

{
  // containers for the new topology
  vector<int> new_counts(m_nb_domain,0);
  vector<int> domain_counts(m_nb_domain,0);
  const Topology* old_topology=initial_collection.getTopology();
  int nb_domain_old=old_topology->nbDomain();
  //int global_index=old_topology->getFaceNumber();
  //  set <pair<int, pair<int,int> > > global_treated;

  //definition of the d-1 constituent for the considered mesh dimension
  MED_EN::medEntityMesh constituent_entity;
  switch (m_mesh_dimension)
  {
  case 3:
    constituent_entity= MED_EN::MED_FACE;
    break;
  case 2:
    constituent_entity = MED_EN::MED_EDGE;
    break;
  }

  for (int iold=0; iold<nb_domain_old;iold++)
  {
    int nbcell=old_topology->getCellNumber(iold);

    const int* face_conn = initial_collection.getMesh(iold)->
      getConnectivity(MED_EN::MED_DESCENDING,MED_EN::MED_CELL,MED_EN::MED_ALL_ELEMENTS);
    const int* face_offset = initial_collection.getMesh(iold)->
      getConnectivityIndex(MED_EN::MED_DESCENDING,MED_EN::MED_CELL);
    MESSAGE_MED("end of connectivity calculation");
    set<int> global_treated;
    for (int icell=0; icell<nbcell; icell++)
    {
      int global_cell_number=old_topology->convertCellToGlobal(iold,icell+1);
      int inew = getCellDomainNumber(global_cell_number);

      for (int iface = face_offset[icell]; iface < face_offset[icell+1]; iface++)
      {
        int global_face_number=old_topology->convertFaceToGlobal(iold,abs(face_conn[iface-1]));
        if (global_treated.find (global_face_number)==global_treated.end())
        {
          new_counts[inew]++;
          m_face_glob_to_loc.insert(make_pair(global_face_number,make_pair(inew,new_counts[inew])));

          //m_face_loc_to_glob.insert(make_pair(make_pair(inew,new_counts[inew]),global_face_number));
          m_face_loc_to_glob[inew].push_back(global_face_number);
          global_treated.insert(global_face_number);

        }
      }
    }
  }


  for (int inew=0;inew<m_nb_domain;inew++)
  {
    m_nb_faces[inew]=new_counts[inew];
    //  cout << " Nb faces ["<<inew<<"]="<<m_nb_faces[inew]<<endl;
  }
  MESSAGE_MED(" total number of faces"<<getFaceNumber());
}

Here is the call graph for this function:

void ParallelTopology::createNodeMapping ( std::map< MED_EN::medGeometryElement, int * > &  type_connectivity,
std::map< MED_EN::medGeometryElement, int > &  present_type_numbers,
std::vector< int > &  conn,
std::vector< int > &  conn_index,
std::vector< int > &  polyhedron_conn,
std::vector< int > &  polyhedron_conn_index,
std::vector< int > &  polyhedron_face_index,
int  idomain 
) [virtual]

creating node mapping

Implements MEDSPLITTER::Topology.

Definition at line 490 of file MEDSPLITTER_ParallelTopology.cxx.

{
  set<int> local_numbers;
  int local_index=0;

  map<MED_EN::medGeometryElement,int>::const_iterator iter;
  for (iter = present_type_numbers.begin(); iter!=present_type_numbers.end();iter++)
  {
    int type=iter->first;
    int nodes_per_type= type%100;

    if (!((type/100==m_mesh_dimension)
          ||(type==MED_EN::MED_POLYGON && m_mesh_dimension==2)
          ||(type==MED_EN::MED_POLYHEDRA && m_mesh_dimension==3))) continue;

    if (type != MED_EN::MED_POLYGON && type != MED_EN::MED_POLYHEDRA)
    {
      for (int icell=0; icell<present_type_numbers[type]; icell++)
      {
        for (int inode=0; inode<nodes_per_type; inode++)
        {
          int global=type_connectivity[type][icell*nodes_per_type+inode];
          if(local_numbers.find(global)==local_numbers.end())
          {
            local_index++;
            local_numbers.insert(global);
            //m_node_loc_to_glob.insert(make_pair(make_pair(idomain,local_index),global));
            m_node_loc_to_glob[idomain].push_back(global);
            m_node_glob_to_loc.insert(make_pair(global,make_pair(idomain,local_index)));
            //          cout << "node : global ="<<global<<" local =("<<idomain<<","<<local_index<<")"<<endl;         
          }
        }

      }
    }
    else if (type== MED_EN::MED_POLYGON)
    {
      for ( unsigned i = 0; i < polygon_conn.size(); ++i )
      {
        int global=polygon_conn[i];
        if(local_numbers.find(global)==local_numbers.end())
        {
          local_index++;
          local_numbers.insert(global);
          m_node_loc_to_glob[idomain].push_back(global);
          m_node_glob_to_loc.insert(make_pair(global,make_pair(idomain,local_index)));
        }
      }
    }
    else if (type==MED_EN::MED_POLYHEDRA)
    {
      for ( unsigned i = 0; i < polyhedron_conn.size(); ++i )
      {
        int global=polyhedron_conn[i];
        if(local_numbers.find(global)==local_numbers.end())
        {
          local_index++;
          local_numbers.insert(global);
          m_node_loc_to_glob[idomain].push_back(global);
          m_node_glob_to_loc.insert(make_pair(global,make_pair(idomain,local_index)));
        }
      }
    }

  }
  m_nb_nodes[idomain]=local_index;
}

Here is the call graph for this function:

int MEDSPLITTER::ParallelTopology::getCellDomainNumber ( int  global) const [inline]

Definition at line 245 of file MEDSPLITTER_ParallelTopology.hxx.

    {
      return (m_glob_to_loc.find(global)->second).first;
    }

Here is the call graph for this function:

Here is the caller graph for this function:

void MEDSPLITTER::ParallelTopology::getCellList ( int  idomain,
int *  list 
) const [inline, virtual]

retrieving list of nodes in global numbers

Implements MEDSPLITTER::Topology.

Definition at line 251 of file MEDSPLITTER_ParallelTopology.hxx.

    {
      for (int i=0; i<m_nb_cells[idomain];i++)
      {
        list[i]=m_loc_to_glob[idomain][i];
        //list[i]=(m_loc_to_glob.find(make_pair(idomain,i+1)))->second;
      }

    }
int MEDSPLITTER::ParallelTopology::getCellNumber ( int  idomain) const [inline, virtual]

retrieving number of nodes

Implements MEDSPLITTER::Topology.

Definition at line 240 of file MEDSPLITTER_ParallelTopology.hxx.

    {
      return m_nb_cells[idomain];
    }
void MEDSPLITTER::ParallelTopology::getFaceList ( int  idomain,
int *  list 
) const [inline, virtual]

retrieving list of faces in global numbers

Implements MEDSPLITTER::Topology.

Definition at line 280 of file MEDSPLITTER_ParallelTopology.hxx.

    {
      for (int i=0; i<m_nb_faces[idomain];i++)
      {
        list[i]=m_face_loc_to_glob[idomain][i];
        //list[i]=(m_face_loc_to_glob.find(make_pair(idomain,i+1)))->second;
      }

    }
int MEDSPLITTER::ParallelTopology::getFaceNumber ( int  idomain) const [inline, virtual]

Implements MEDSPLITTER::Topology.

Definition at line 261 of file MEDSPLITTER_ParallelTopology.hxx.

    {
      return m_nb_faces[idomain];
    }
int MEDSPLITTER::ParallelTopology::getFaceNumber ( ) const [inline, virtual]

Implements MEDSPLITTER::Topology.

Definition at line 266 of file MEDSPLITTER_ParallelTopology.hxx.

    {
      if (m_face_glob_to_loc.empty()) return 0;
      set <int> keys;
      for (INTERP_KERNEL::HashMultiMap<int, pair<int,int> >::const_iterator iter= m_face_glob_to_loc.begin();
           iter!=m_face_glob_to_loc.end();
           iter++) {
        keys.insert(iter->first);
      }
      return keys.size();
    }

Here is the call graph for this function:

Here is the caller graph for this function:

std::vector<int>& MEDSPLITTER::ParallelTopology::getFusedCellNumbers ( int  idomain) [inline, virtual]

Implements MEDSPLITTER::Topology.

Definition at line 219 of file MEDSPLITTER_ParallelTopology.hxx.

    {
      return m_cell_loc_to_glob_fuse[idomain];
    }
const std::vector<int>& MEDSPLITTER::ParallelTopology::getFusedCellNumbers ( int  idomain) const [inline, virtual]

retrieving face numbers after fusing in parallel mode

Implements MEDSPLITTER::Topology.

Definition at line 223 of file MEDSPLITTER_ParallelTopology.hxx.

std::vector<int>& MEDSPLITTER::ParallelTopology::getFusedFaceNumbers ( int  idomain) [inline, virtual]

Implements MEDSPLITTER::Topology.

Definition at line 229 of file MEDSPLITTER_ParallelTopology.hxx.

    {
      return m_face_loc_to_glob_fuse[idomain];
    }
const std::vector<int>& MEDSPLITTER::ParallelTopology::getFusedFaceNumbers ( int  idomain) const [inline, virtual]

Implements MEDSPLITTER::Topology.

Definition at line 233 of file MEDSPLITTER_ParallelTopology.hxx.

    {
      return m_face_loc_to_glob_fuse[idomain];
    }
boost::shared_ptr<Graph> MEDSPLITTER::ParallelTopology::getGraph ( ) const [inline, virtual]

retrieving graph

Implements MEDSPLITTER::Topology.

Definition at line 330 of file MEDSPLITTER_ParallelTopology.hxx.

    {
      return m_graph;
    }
int ParallelTopology::getMaxGlobalFace ( ) const [virtual]

Return max global face number.

Implements MEDSPLITTER::Topology.

Definition at line 1066 of file MEDSPLITTER_ParallelTopology.cxx.

{
  int max = 0;
  TGlob2LocsMap::const_iterator g_l_l = m_face_glob_to_loc.begin();
  for ( ; g_l_l != m_face_glob_to_loc.end(); ++g_l_l )
    if ( g_l_l->first > max )
      max = g_l_l->first;
  return max;
}

Here is the call graph for this function:

void MEDSPLITTER::ParallelTopology::getNodeList ( int  idomain,
int *  list 
) const [inline, virtual]

retrieving list of nodes in global numbers

retrieving cell numbers after fusing in parallel mode

Implements MEDSPLITTER::Topology.

Definition at line 209 of file MEDSPLITTER_ParallelTopology.hxx.

int MEDSPLITTER::ParallelTopology::getNodeNumber ( int  idomain) const [inline, virtual]

retrieving number of nodes

Implements MEDSPLITTER::Topology.

Definition at line 191 of file MEDSPLITTER_ParallelTopology.hxx.

    {
      return m_nb_nodes[idomain];
    }
int MEDSPLITTER::ParallelTopology::getNodeNumber ( ) const [inline, virtual]

Implements MEDSPLITTER::Topology.

Definition at line 196 of file MEDSPLITTER_ParallelTopology.hxx.

    {
      if (m_node_glob_to_loc.empty()) return 0;
      set <int> keys;
      for (INTERP_KERNEL::HashMultiMap<int, pair<int,int> >::const_iterator iter= m_node_glob_to_loc.begin();
           iter!=m_node_glob_to_loc.end();
           iter++) {
        keys.insert(iter->first);
      }
      return keys.size();
    }

Here is the call graph for this function:

bool ParallelTopology::hasCellWithNodes ( const MESHCollection new_collection,
int  dom,
const std::set< int > &  nodes 
) [private]

Return true if the domain mesh contains a cell based on given global nodes.

Definition at line 571 of file MEDSPLITTER_ParallelTopology.cxx.

{
  // convert global nodes to local in the given domain
  set<int> nodes;
  set<int>::const_iterator n = globNodes.begin();
  for ( ; n != globNodes.end(); ++n )
    nodes.insert( convertGlobalNode( *n, domain ));

  const MED_EN::medConnectivity connType = MED_EN::MED_NODAL;
  const MED_EN::medEntityMesh   entity   = MED_EN::MED_CELL;

  // loop on all types of cells
  const MEDMEM::MESH* mesh = new_collection.getMesh( domain );
  int nbTypes = mesh->getNumberOfTypes( entity );
  const MED_EN::medGeometryElement * types = mesh->getTypes( entity );
  for ( int t = 0; t < nbTypes; ++t )
  {
    // get connectivity
    if ( !mesh->existConnectivity( connType, entity ))
      continue;
    int nbCell = mesh->getNumberOfElements( entity, types[t] );
    const int *conn, *index;
    conn  = mesh->getConnectivity(connType, entity, types[t]);
    index = mesh->getConnectivityIndex(connType, entity);
    // find a cell containing the first of given nodes,
    // then check if the found cell contains all the given nodes
    const int firstNode = *nodes.begin();
    for ( int i = 0; i < nbCell; ++i )
    {
      for ( int j = index[i]-1; j < index[i+1]-1; ++j )
        if ( conn[j] == firstNode )
        {
          unsigned nbSame = 0;
          for ( j = index[i]-1; j < index[i+1]-1; ++j )
            nbSame += nodes.count( conn[j] );
          if ( nbSame == nodes.size() )
            return true;
          break;
        }
    }
  }
  return false;
}

Here is the call graph for this function:

Here is the caller graph for this function:

int MEDSPLITTER::ParallelTopology::nbCells ( ) const [inline, virtual]

Implements MEDSPLITTER::Topology.

Definition at line 176 of file MEDSPLITTER_ParallelTopology.hxx.

    {
      return m_nb_total_cells;
    }
int MEDSPLITTER::ParallelTopology::nbCells ( int  idomain) const [inline, virtual]

Implements MEDSPLITTER::Topology.

Definition at line 182 of file MEDSPLITTER_ParallelTopology.hxx.

    {
      return m_nb_cells[idomain];
    }
int MEDSPLITTER::ParallelTopology::nbDomain ( ) const [inline, virtual]

Implements MEDSPLITTER::Topology.

Definition at line 171 of file MEDSPLITTER_ParallelTopology.hxx.

    {
      return m_nb_domain;
    }
void ParallelTopology::recreateFaceMapping ( const TGeom2FacesByDomian face_map) [virtual]

recreating a face mapping from scratch

Implements MEDSPLITTER::Topology.

Definition at line 1076 of file MEDSPLITTER_ParallelTopology.cxx.

{
  m_face_glob_to_loc.clear();
  for (int i=0; i<m_nb_domain;i++)
    m_face_loc_to_glob[i].clear();

  for (int idomain=0; idomain<m_nb_domain; idomain++)
  {
    int ilocal=1;
    TGeom2Faces::const_iterator iter = face_map[idomain].begin();
    for (; iter != face_map[idomain].end(); iter++)
    {
      for (unsigned i=0; i< (iter->second).size(); i++)
      {
        MEDSPLITTER_FaceModel* face = (iter->second)[i];
        //cout << "global :"<<face->getGlobal()<<" - "<<ilocal<<endl;
        m_face_glob_to_loc.insert(make_pair(face->getGlobal(),make_pair(idomain,ilocal)));
        m_face_loc_to_glob[idomain].push_back(face->getGlobal());
        ilocal++;
      }
    }
    m_nb_faces[idomain] =ilocal-1;
  }
}

Here is the call graph for this function:

void ParallelTopology::recreateMappingAfterFusion ( const std::vector< MEDMEM::MESH * > &  meshes) [virtual]

Recreating cell and node mapping after send-reveive and fusion of domain meshes.

Implements MEDSPLITTER::Topology.

Definition at line 1107 of file MEDSPLITTER_ParallelTopology.cxx.

{
  const char* LOC = "ParallelTopology::recreateMappingAfterFusion(): ";

  m_glob_to_loc.clear();
  m_node_glob_to_loc.clear();
  m_face_glob_to_loc.clear();

  for (int idomain=0; idomain<m_nb_domain; idomain++)
  {
    m_nb_cells[idomain] = m_nb_nodes[idomain] = m_nb_faces[idomain] = 0;
    m_loc_to_glob[idomain].clear();
    m_node_loc_to_glob[idomain].clear();
    m_face_loc_to_glob[idomain].clear();
    
    if ( !meshes[idomain]->getCoordinateptr() ) continue; // empty domian

    //creating cell maps

    m_nb_cells[idomain]=meshes[idomain]->getNumberOfElements(MED_EN::MED_CELL,
                                                             MED_EN::MED_ALL_ELEMENTS);
    if ( m_cell_loc_to_glob_fuse[idomain].size() != m_nb_cells[idomain] )
      throw MED_EXCEPTION(MEDMEM::STRING(LOC)<<" invalid nb of fused cells");

    m_loc_to_glob[idomain].swap( m_cell_loc_to_glob_fuse[idomain] );

    for (int i=0; i<m_nb_cells[idomain]; i++)
    {
      int global=m_loc_to_glob[idomain][i];
      m_glob_to_loc[global]=make_pair(idomain,i+1);
    }

    //creating node maps

    m_nb_nodes[idomain]=meshes[idomain]->getNumberOfNodes();
    m_node_loc_to_glob[idomain] = ((MEDMEM::MeshFuse*)meshes[idomain])->getNodeNumbers();
    if ( m_node_loc_to_glob[idomain].size() != m_nb_nodes[idomain] )
      throw MED_EXCEPTION(MEDMEM::STRING(LOC)<<" invalid nb of fused nodes");

    // setting mappings for all nodes
    for (int inode=0; inode<m_nb_nodes[idomain]; inode++)
    {
      int global_number=m_node_loc_to_glob[idomain][inode];
      m_node_glob_to_loc.insert(make_pair(global_number,make_pair(idomain,inode+1)));
    }


    //creating dimension d-1 component mappings

    MED_EN::medEntityMesh constituent_entity =
      (m_mesh_dimension == 3 ? MED_EN::MED_FACE : MED_EN::MED_EDGE );
    m_nb_faces[idomain] = meshes[idomain]->getNumberOfElements(constituent_entity,
                                                               MED_EN::MED_ALL_ELEMENTS);
    if ( m_face_loc_to_glob_fuse[idomain].size() != m_nb_faces[idomain] )
      throw MED_EXCEPTION(MEDMEM::STRING(LOC)<<" invalid nb of fused faces of domain "<< idomain
                          << ": expect " << m_nb_faces[idomain]
                          << " but have " << m_face_loc_to_glob_fuse[idomain].size());

    m_face_loc_to_glob[idomain].swap( m_face_loc_to_glob_fuse[idomain] );

    for (int iface=0; iface<m_nb_faces[idomain]; iface++)
    {
      int global_number=m_face_loc_to_glob[idomain][iface];
      m_face_glob_to_loc.insert(make_pair(global_number,make_pair(idomain,iface+1)));
    }
  }

}

Here is the call graph for this function:


Member Data Documentation

Definition at line 371 of file MEDSPLITTER_ParallelTopology.hxx.

Definition at line 377 of file MEDSPLITTER_ParallelTopology.hxx.

vector<vector <int> > MEDSPLITTER::ParallelTopology::m_face_loc_to_glob [private]

mapping local -> global

Definition at line 381 of file MEDSPLITTER_ParallelTopology.hxx.

Definition at line 372 of file MEDSPLITTER_ParallelTopology.hxx.

Definition at line 351 of file MEDSPLITTER_ParallelTopology.hxx.

boost::shared_ptr<Graph> MEDSPLITTER::ParallelTopology::m_graph [private]

Definition at line 401 of file MEDSPLITTER_ParallelTopology.hxx.

vector<vector<int> > MEDSPLITTER::ParallelTopology::m_loc_to_glob [private]

mapping local -> global

Definition at line 361 of file MEDSPLITTER_ParallelTopology.hxx.

Definition at line 399 of file MEDSPLITTER_ParallelTopology.hxx.

Definition at line 385 of file MEDSPLITTER_ParallelTopology.hxx.

Definition at line 397 of file MEDSPLITTER_ParallelTopology.hxx.

Definition at line 389 of file MEDSPLITTER_ParallelTopology.hxx.

Definition at line 387 of file MEDSPLITTER_ParallelTopology.hxx.

Definition at line 391 of file MEDSPLITTER_ParallelTopology.hxx.

Definition at line 395 of file MEDSPLITTER_ParallelTopology.hxx.

Definition at line 393 of file MEDSPLITTER_ParallelTopology.hxx.

mapping global -> local

Definition at line 363 of file MEDSPLITTER_ParallelTopology.hxx.

vector<vector <int> > MEDSPLITTER::ParallelTopology::m_node_loc_to_glob [private]

mapping local -> global

Definition at line 368 of file MEDSPLITTER_ParallelTopology.hxx.


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