Multiple material IDs

60 views
Skip to first unread message

Corbin Foucart

unread,
Feb 7, 2021, 5:23:07 PM2/7/21
to deal.II User Group
Hello all,

I've read the documentation on material ID and it's not clear to me if there's a way to define more than one material ID. This could be helpful when wanting to isolate elements that correspond to the same material, but also when looking to isolate elements of different materials that might exist in a particular "layer" of the domain. 

I can see three ways to define multiple IDs per each element:
  1. Define two identical meshes and set the material IDs differently on each. This seems suboptimal because I don't really want to use up the extra memory
  2. Define functions that re-label the material IDs based on the current task at hand, at the expense of extra computation and logic
  3. Define an external vector of structs that contain the different element IDs by cell, but then it's unclear how to filter elements by MaterialIDEqualTo() without first relabeling as in (2)
Is there a standard way to do this that I'm missing? Any advice is much appreciated!

Best,
Corbin

Daniel Arndt

unread,
Feb 7, 2021, 8:06:26 PM2/7/21
to dea...@googlegroups.com
Corbin,

if you have a maximal range for either of the two material ranges you could just compute a single material ID by
material_id   = material_id1 * max_material_id2 + material_id2
material_id2 = material_id % max_material_id2
material_id1 = material_id / max_material_id2

Best,
Daniel

--
The deal.II project is located at http://www.dealii.org/
For mailing list/forum options, see https://groups.google.com/d/forum/dealii?hl=en
---
You received this message because you are subscribed to the Google Groups "deal.II User Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to dealii+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/dealii/a66dcb53-8a6b-46ce-8c29-90067829a0a3n%40googlegroups.com.

Jean-Paul Pelteret

unread,
Feb 8, 2021, 2:39:52 AM2/8/21
to dea...@googlegroups.com
Hi Corbin,

To add to Daniel's suggestion, you could also associated some generic data structures to your cell that you could store the multi-material id data in, and query it as you like. I can think of three different ways to do this:

1. Directly attach your data structure to each cell's user pointer. See the TriaAccessor::set_user_pointer() function and the other functions related to the user_pointer. Step-18 uses the cell user pointer to store quadrature point data.
2. Create a map between the CellID and your data structure, e.g. std::map<CellID, std::vector<types::material_id>>
3. In the same spirit as suggestion (2), you can use the CellDataStorage class to associate cell iterators with some generic data. Step-44 leverages this class to store quadrature point data.

I hope that this help you achieve what you're trying to do.

Best,
Jean-Paul
Reply all
Reply to author
Forward
0 new messages