[MOAB-dev] how to store adjacencies informations?

Lorenzo Alessio Botti ihabiamx at yahoo.it
Thu May 12 04:35:29 CDT 2011


Hi all,
I plan to use MOAB to implement discontinuous Galerkin discretizations.
Since these formulation are base on fluxes I need to know the cell neighbors at assembly time.

I found two ways of computing adjacencies (I'm working with a 3D mesh)

1) iterate over cells without building interior faces

  result = instance.get_entities_by_dimension(0, 3, ents);
  for (moab::Range::iterator it = ents.begin(); it != ents.end(); it++)
  {
    EntityHandle ent = *it;
    std::vector<EntityHandle> conn;
    result = instance.get_connectivity(&ent, 1, conn);

    short int num_sub_ent = CN::NumSubEntities(instance.type_from_handle(ent), 2);
    EntityHandle bridge_verts[MAX_SUB_ENTITIES];
    int bridge_indices[MAX_SUB_ENTITIES];

    Range side_neighbors;
    for (unsigned int i = 0; i < num_sub_ent; i++)
    { 
      side_neighbors.clear();
      int num_sub_verts = CN::VerticesPerEntity( CN::SubEntityType(instance.type_from_handle(ent), 2, i ) );
    
      CN::SubEntityVertexIndices(instance.type_from_handle(ent) , 2, i, bridge_indices );
      for (int j = 0; j < num_sub_verts; ++j)
        bridge_verts[j]= conn[bridge_indices[j]];

      result = instance.get_adjacencies(&bridge_verts[0], num_sub_verts, 3, true, side_neighbors);
    }
  }


2) Compute interior faces and iterate over them  

     result = instance.get_entities_by_dimension(0, 3, ents);
     Range interior_tris;
     result = instance.get_adjacencies(ents, 2, true, interior_tris, Interface::UNION);

    Range side_neighbors;
    for (unsigned int n_tris = 0; n_tris < interior_tris.size(); n_tris++)
    {
      side_neighbors.clear();  
      EntityHandle entity = interior_tris[n_tris];
      result = instance.get_adjacencies(&entity, 1, 3, false, side_neighbors);
    }


First question.
Are there better options?

Second point.
Clearly in both cases get_adjacencies is the time consuming operation...
I would like to know if there is an easy and supported way to add adjacencies to handles once they have been computed.
I tried   

result = instance.add_adjacencies(ent, side_neighbors, true);

to add element to element connectivity in (1) but it fails.
Do I have to tag neighbors to handles?

Thanks for help
Lorenzo 




More information about the moab-dev mailing list