[MOAB-dev] IDs to index?
Grindeanu, Iulian R.
iulian at mcs.anl.gov
Wed Dec 2 11:25:00 CST 2015
the EntityHandle is a special MOAB entity, you can think of as a pointer. (it is unsigned long on linux)
first 4 bits are used for type, next are used for entity id
Range is a std-like container for those entity handles
if you convert to hex, you will see this::
(gdb) p /x 5764607523034234881
$6 = 0x5000000000000001
it means it is of type 5 (tet), and the first one in the sequence
you can use Core::id_from_handle( ) to return 1, 2, 3 in your example
You can use "iterate" methods to loop through, some examples are here
http://ftp.mcs.anl.gov/pub/fathom/moab-docs/classmoab_1_1Interface.html#ab1251d0eb25a27ea3e655d2279b3fa01
http://ftp.mcs.anl.gov/pub/fathom/moab-docs/DirectAccessNoHoles_8cpp-example.html#a17
http://ftp.mcs.anl.gov/pub/fathom/moab-docs/contents.html#twotwo
in most cases, you will have only one sequence (from 1 to the number of entities of that type)
Iulian
________________________________
From: moab-dev-bounces at mcs.anl.gov [moab-dev-bounces at mcs.anl.gov] on behalf of Nico Schlömer [nico.schloemer at gmail.com]
Sent: Wednesday, December 02, 2015 11:03 AM
To: moab-dev at mcs.anl.gov
Subject: [MOAB-dev] IDs to index?
Hi everyone,
I just checked out the elem values for some mesh,
```
// Get regions, by dimension, so we stay generic to entity type
Range elems;
rval = mb->get_entities_by_dimension(0, 3, elems);MB_CHK_ERR(rval);
cout << "Number of elements is " << elems.size() << endl;
for (size_t k = 0; k < elems.size(); k++) {
std::cout << "elems[" << k << "] = " << elems[k] << std::endl;
}
```
and get
```
elems[0] = 5764607523034234881
elems[1] = 5764607523034234882
elems[2] = 5764607523034234883
// ...
```
That came as a bit of a surprise to me since I had expected low consecutive numbers, but I guess there's no guarantee for that.
Now, I would like to store additional data per element, and I initially planned to just create a `std::vector<double>`. However, to associate the data `data[42]` with a particular `elem`, I'll have to do something else. I suppose I could use a `std::map<EntityHandle, double>` instead.
How to you typically organize this? Is there, for example, a helper method that converts an `elem` ID into something that I can use as an index into `data`?
Cheers,
Nico
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/moab-dev/attachments/20151202/b5c61244/attachment.html>
More information about the moab-dev
mailing list