Thanks for your response. Could you please answer my first email? Do the elements have id's from 0 to the number of elements? And when we refine the mesh, the new elements will take subsequent id numbers? Basically what I want to do is to have an array of numbers of size equal to the number of elements and assign each number to each element. If I refined the mesh, I would resize this array to accommodate the new elements. Is there a more efficient way to do this in libmesh rather than just creating a vector and accessing it with an index equal to the element's id? Thanks in advance.
I realized the element id's are not from 0 to the number of elements. Because I need to have id's of elements from 0 to number of active elements, I have thought of building a vector with size equal to the max_elem_id(), iterate through the elements and assign a counter to the index corresponding to the element_id. Something like, std::vector<unsigned int> indexer; indexer.resize (mesh.max_elem_id()); unsigned int counter = 0 Now iterate through the elements and for each one: indexer[elem.id()] = counter++ Is there a better way to do this? Probably I will rebuild this indexer every time I refine the mesh. Miguel On Thu, Aug 21, 2014 at 10:38 AM, Roy Stogner <[email protected]> wrote: > > On Thu, 21 Aug 2014, Miguel Angel Salazar de Troya wrote: > > A quadrangular element can only have four neighbors? >> > > Right. > > > Say in the left side I have a refined element with just one level >> more of refinement. The neighbor I would get would be the parent >> element? The element that's at the same level than me? I will >> illustrate it: >> >> ---------------------- >> | | | | >> | | e | | >> | | | | >> |-----------| f | >> | | | | >> | | | | >> | | | | >> ---------------------- >> >> Calling >> >> for (unsigned int n_p=0; n_p<f->n_neighbors(); n_p++) >> Elem * neighbor_f = f->neighbor(n_p); >> >> will never return the element e, but it would return its parent? >> > > Right. > > > What about the other way around? If I try to get the neighbors of e, will >> I >> get f? >> > > Right. > --- > Roy > -- *Miguel Angel Salazar de Troya* Graduate Research Assistant Department of Mechanical Science and Engineering University of Illinois at Urbana-Champaign (217) 550-2360 [email protected] ------------------------------------------------------------------------------ Slashdot TV. Video for Nerds. Stuff that matters. http://tv.slashdot.org/ _______________________________________________ Libmesh-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/libmesh-users
