[MOAB-dev] Trouble Creating AEntities

Chris Eldred chris.eldred at gmail.com
Mon Oct 14 16:55:48 CDT 2013


Tim:

I tried your code:

Range faces, edges;
result = iface->get_entities_by_dimension(0, 2, faces);
result = iface->get_adjacencies(faces, 1, true, edges, Interface::UNION);

and it didn't solve the problem.

Iulian:
My element creation code is:

//! read/create elements
ErrorCode create_elements(int nx, int ny, int num_elems, EntityHandle
start_vertex, EntityHandle &start_elem, Range &read_ents)
{
    // get the entity type being read
  EntityType ent_type = MBPOLYGON;

    // get the number of vertices per entity
  int verts_per_elem = 4;

    // Create the element sequence; passes back a pointer to the internal
storage for connectivity and the
    // starting entity handle
  EntityHandle* conn_array;
  ErrorCode result = readiface->get_element_connect( num_elems,
verts_per_elem, ent_type,1, start_elem, conn_array );
      if (MB_SUCCESS != result) return result;

    // read connectivity into conn_array directly
     for (int i=0 ; i<nx ; i++) {
    for (int j=0 ; j<ny ; j++) {
    int l = SCONV(j,ny)*nx + SCONV(i,nx) ;
    conn_array[verts_per_elem*l] = start_vertex + SCONV(j,ny)*nx +
SCONV(i,nx);
    conn_array[verts_per_elem*l+1] = start_vertex + SCONV(j,ny)*nx +
SCONV(i-1,nx);
    conn_array[verts_per_elem*l+2] = start_vertex + SCONV(j-1,ny)*nx +
SCONV(i-1,nx);
    conn_array[verts_per_elem*l+3] = start_vertex + SCONV(j-1,ny)*nx +
SCONV(i,nx);
    }}

    // notify MOAB of the new elements
  result = readiface->update_adjacencies(start_elem, num_elems,
verts_per_elem, conn_array);
  if (MB_SUCCESS != result) return result;

    // add elements to read_ents
  if (num_elems) read_ents.insert(start_elem, start_elem+num_elems-1);

  return MB_SUCCESS;
}

This does call update_adjacencies (readiface is my instance of
ReadUtilIface).

-Chris


On Mon, Oct 14, 2013 at 3:21 PM, Iulian Grindeanu <iulian at mcs.anl.gov>wrote:

> Hello,
> Did you call ReadUtil::update_adjacencies?
> If you create some elements, when you do the first adjacency call, the
> internal adjacencies are created.
> If you create more elements after the first adjacency call, you have to
> call "update_adjacencies" for the new elements created, otherwise the
> up-vertex adjacencies are not updated.
>
> This is my guess, it is hard to figure why it is not working for you with
> the limited info you sent :(
>
> Best Regards,
> Iulian
>
> ------------------------------
>
> Hey MOAB-Dev,
>
> I am having trouble creating AEntities for a simple 2D planar mesh. I
> adapted ReadTemplate.cpp to create a mesh generator and it appears to be
> working fine (vertices are all present with correct vertex-vertex and
> vertex-face adjacencies and positions, faces are all present with correct
> vertex connectivity). However, when I try to create AEntities (ie edges)
> using the following code (iface is my Core instance):
>
>   Range verts;
>   result = iface->get_entities_by_type(0, MBVERTEX, verts);
>   if (MB_SUCCESS != result) return result;
>   result = MeshTopoUtil(iface).construct_aentities(verts);
>   if (MB_SUCCESS != result) return result;
>
>   //get edge entities, by type
>   Range edges;
>   rval = iface->get_entities_by_type(0, MBEDGE, edges);
>   assert(rval == MB_SUCCESS);
>
>   cout << "Number of edges is " << edges.size() <<  endl;
>
> I get the following output:
>
> Number of edges is 0
>
> Also, attempting to get vertex-edge adjacencies or bridge adjacencies
> through edges returns null sets.
>
> Any ideas as to what is going wrong?
>
> -Chris
>
> --
> Chris Eldred
> DOE Computational Science Graduate Fellow
> Graduate Student, Atmospheric Science, Colorado State University
> B.S. Applied Computational Physics, Carnegie Mellon University, 2009
> chris.eldred at gmail.com / celdred at atmos.colostate.edu
>
>
>


-- 
Chris Eldred
DOE Computational Science Graduate Fellow
Graduate Student, Atmospheric Science, Colorado State University
B.S. Applied Computational Physics, Carnegie Mellon University, 2009
chris.eldred at gmail.com / celdred at atmos.colostate.edu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/moab-dev/attachments/20131014/d1258519/attachment.html>


More information about the moab-dev mailing list