On Tue, 19 Aug 2014, Miguel Angel Salazar de Troya wrote:

> 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?

It depends.  IIRC renumbering is on by default, and after renumbering
takes place (e.g. in the Mesh construction or the EquationSystems
reinit) then all the ids will be sequential.  But in user code it's
possible to turn renumbering off and in library code (even with
renumbering) it's possible to catch the mesh in a state after
refinement has occurred but before renumbering has.

> 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?

The safest thing to do in this case is usually to create an
ExplicitSystem, attach it to your EquationSystems, and give it
variables corresponding to the data you want to store; e.g. for one
Number per Elem you'd give it a zeroth order monomial variable.

That way your data gets parallelized and ghosted properly (although
it's easy to serialize too if you insist), gets distributed to child
elements automatically upon refinement, gets homogenized upon
coarsening, and gets renumbered if/when the Mesh does.

If your needs differ from that (e.g. you want data attached to parent
elements and child elements at the same time) you might try a
unordered_map indexed by unique_id().  The unique_id() numbering isn't
contiguous (hence the map rather than vector) but isn't changed except
when an Elem is destroyed and recreated.
---
Roy

------------------------------------------------------------------------------
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

Reply via email to