[MOAB-dev] Attaching a C++ class to Mesh entities?

Vijay S. Mahadevan vijay.m at gmail.com
Fri Oct 11 11:13:05 CDT 2013


> So the question is, what is the best way to do this? And what is the best
> way to do this from within PyTAPS?  I see two basic options:
>
> 1. Somehow flatten all of the data fields into tags and store them on the
> mesh itself.

This would be optimal if you are going to traverse the elements on the
mesh like in a traditional FEM/FD sense and would need access to only
a few of the flattened fields at each entity''s computation. Accessing
all of the fields via a tag_get_data/tag_iterate at every cell can
become expensive and the nice structure in assembly computation is
lost. You could also do this for blocks of data (based on material
sets) so that you assemble patches of elements at a time with single
call to get the array of data in the local block. This should scale
well if there are many blocks and are of almost equal length. Another
advantage here is that if you wanted to view or perform checkpointing
with this data set, it comes free due to the tag persistence. But from
a visualization perspective, I would imagine you wouldn't care about
looking at say the absorption cross-section distribution in your mesh
?

> 2. Keep an external dictionary / map which is keyed by the entity and valued
> by Material objects

This would be the most optimal setting since you can directly access
any specific data field with indexing based on GLOBAL_ID of the entity
rather than traversing through each data tag individually. It would
also mean that the object hierarchy be part of the user data structure
and not persisted via MOAB. This I think is cleaner and would not
overwhelm

> Maybe there is a third option where we can store a pointer to materials as a
> tag?

AFAIK, you could possibly do this with byte arrays rather than storing
the pointer directly in which case you would just perform a cast on
the pointer to tag data and use your objects directly. When you have
ghosted elements etc, I am not entirely sure what will happen here.
Tim, perhaps a test case for using MB_TYPE_OPAQUE with serialized
objects might be useful.

Vijay

On Thu, Oct 10, 2013 at 10:26 PM, Anthony Scopatz <scopatz at gmail.com> wrote:
> Hello All,
>
> This question came up on the PyNE list recently where we are trying to
> decide how to best represent materials on a MOAB mesh.  What we have is a
> Material class, which has a rich interface that is tailored to the needs of
> nuclear engineering.  We would like to associate every entity with its own
> Material object.  These materials may change over time in the simulation.
> There are a handful of data fields on this class:
>
> composition: map<int, double>
> mass: double
> density: double
> atoms_per_mole: double
> meta: a JsonCpp instance for storing metadata
>
> So the question is, what is the best way to do this? And what is the best
> way to do this from within PyTAPS?  I see two basic options:
>
> 1. Somehow flatten all of the data fields into tags and store them on the
> mesh itself.
> 2. Keep an external dictionary / map which is keyed by the entity and valued
> by Material objects
>
> Maybe there is a third option where we can store a pointer to materials as a
> tag?  Any advice would be most appreciated!
>
> Be Well
> Anthony


More information about the moab-dev mailing list