Skip to content

Commit bbebe7d

Browse files
I wrote about uni-buffer by material
1 parent 24b5b16 commit bbebe7d

1 file changed

Lines changed: 113 additions & 5 deletions

File tree

src/docs/sphinx/blueprint_mesh.rst

Lines changed: 113 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -746,13 +746,121 @@ For element 10, we can see that the three material ids are ``1``, ``2``, and ``3
746746
Looking at the material map, we can see that ``circle_a`` is the material corresponding to material id ``1``, ``circle_b`` is the material corresponding to material id ``2``, and ``circle_c`` is the material corresponding to material id ``3``.
747747
Therefore, element 10 is split evenly between the circle materials.
748748

749-
//////
749+
Here is another example showing the basic structure:
750+
751+
.. code:: yaml
752+
753+
matset:
754+
topology: "topo"
755+
material_map:
756+
mat0: 0
757+
mat1: 1
758+
...
759+
volume_fractions: [vfs_for_elem0, vfs_for_elem1, ...]
760+
material_ids: [mats_for_elem0, mats_for_elem1, ...]
761+
sizes: [number_of_mats_in_elem0, number_of_mats_in_elem1, ...]
762+
offsets: [offsets for the sizes]
763+
indices: [indirection array into the volume_fractions and material_ids]
764+
765+
Even though volume fractions and material ids are flattened into a single buffer, they are still grouped by element, and the **o2mrelation** data tells us how to interpret the uni-buffer data.
766+
767+
Uni-Buffer Material-Dominant Material Sets
768+
===================================================
769+
770+
.. note::
771+
**Uni-buffer material-dominant** are currently unsupported in Conduit Blueprint, but it is still possible to create and reason about data in this layout. We may add support in the future as needed.
772+
773+
A **uni-buffer** material set is one that presents all of its volume fraction data in a single data buffer.
774+
A **material-dominant** material set is a material set variant wherein the volume fractions and element ids are grouped by material.
775+
It is easy to fetch information grouped by material and much harder to fetch information grouped by element in a **material-dominant** material set.
776+
In this case, the material set schema must include a volume fraction data buffer, a parallel buffer associating each volume with an element id, and an *Object* (the ``material_map``) that maps human-readable material names to unique integer material identifiers.
777+
Additionally, the top-level of this schema is an **o2mrelation** that sources from the volume fraction/element identifier buffers and targets the material topology.
778+
**Uni-buffer material-dominant** material sets are a *sparse* representation, as they only include volume fraction data for elements that have greater than 0% volume.
779+
780+
To conform to protocol, each ``matsets`` child of this type must be an *Object* that contains the following information:
781+
782+
* matsets/matset/topology: "topo"
783+
* matsets/matset/material_map: (object with integer leaves)
784+
* matsets/matset/element_ids: (integer array)
785+
* matsets/matset/volume_fractions: (floating-point array)
786+
787+
As an **o2mrelation**, the following values may also be present:
788+
789+
* matsets/matset/sizes: (integer array)
790+
* matsets/matset/offsets: (integer array)
791+
* matsets/matset/indices: (integer array)
792+
793+
.. note::
794+
It can help to think of how the data are traversed when understanding this structure. A
795+
material's size and offset can be obtained by indexing the ``sizes`` and ``offsets`` with the
796+
material index. These are used to look up a tuple of data from ``indices``. The resulting
797+
indices for the element are array indices into the ``element_ids`` and ``volume_fractions``
798+
arrays for the current material.
750799

800+
The following plot and representative ``YAML`` illustrate a simple **uni-buffer material-dominant** material set example:
751801

752-
uni-buffer material-dominant
753-
- spec
754-
- example
755-
- unsupported
802+
.. figure:: venn_matsets.png
803+
:width: 600px
804+
:align: center
805+
806+
A plot of a 3x3 ``venn``'s material boundaries with meshlines and element ids shown. Cyan represents the ``background``, red represents ``circle_a``, green represents ``circle_b``, and blue represents ``circle_c``.
807+
808+
.. code:: yaml
809+
810+
matset:
811+
topology: "topo"
812+
material_map:
813+
circle_a: 1
814+
circle_b: 2
815+
circle_c: 3
816+
background: 0
817+
volume_fractions: [1.0, 0.333333333333333, 1.0, 0.5, 0.333333333333333, 1.0, 0.5, 1.0, 1.0, 0.333333333333333, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
818+
element_ids: [9, 10, 13, 14, 10, 11, 14, 15, 6, 10, 0, 1, 2, 3, 4, 5, 7, 8, 12]
819+
sizes: [4, 4, 2, 9]
820+
offsets: [0, 4, 8, 10]
821+
indices: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18]
822+
823+
Again, **uni-buffer material-dominant** material sets are sparsely organized by material.
824+
We can use information from the **o2mrelation** to understand the ``volume_fractions`` and ``element_ids`` arrays.
825+
Let's say we want to know the element ids and volume fractions for the first material.
826+
The first material is the first material to appear in the material map, so our first (0th) material is ``circle_a``.
827+
First, we examine the **o2mrelation** arrays. We see that our size is ``4``, meaning there are four elements containing this material.
828+
Our offset is ``0``, meaning our starting index into the ``indices`` array is zero.
829+
The 0th entry in ``indices`` is also ``0``, meaning that the 0th values in both the ``volume_fractions`` and ``element_ids`` arrays correspond to data for the first material (``circle_a``).
830+
If indices are not present, then we use the ``sizes`` and ``offsets`` information to get the starting index directly into the ``volume_fractions`` and ``element_ids`` arrays.
831+
If ``sizes`` and ``offsets`` are not present, then it is assumed that all sizes are ``1`` and ``offsets`` is a trivial prefix sum.
832+
For ``circle_a``, we see that the element ids are ``9``, ``10``, ``13``, and ``14``, and the volume fractions are ``1.0``, ``0.333333333333333``, ``1.0``, and ``0.5``.
833+
That means that ``circle_a`` is present in element ``9`` with a volume fraction of ``1.0``, present in element ``10`` with a volume fraction of ``0.333333333333333``, present in element ``13`` with a volume fraction of ``1.0``, and present in element ``14`` with a volume fraction of ``0.5``.
834+
835+
If we want to know the element ids and volume fractions for the third material, we first go to the third index in the ``sizes`` and ``offsets`` arrays.
836+
The third material is the third material to appear in the material map, so our third (0th) material is ``circle_c``.
837+
We can see that the size is ``2``, meaning there are two elements containing this material.
838+
Our offset is ``8``, meaning our starting index into the ``indices`` array is eight.
839+
The 8th entry in ``indices`` is ``8``, meaning that the 8th values in both the ``volume_fractions`` and ``element_ids`` arrays correspond to data for the third material (``circle_c``).
840+
If indices are not present, then we use the ``sizes`` and ``offsets`` information to get the starting index directly into the ``volume_fractions`` and ``element_ids`` arrays.
841+
If ``sizes`` and ``offsets`` are not present, then it is assumed that all sizes are ``1`` and ``offsets`` is a trivial prefix sum.
842+
For ``circle_c``, we see that the element ids are ``6`` and ``10``, and the volume fractions are ``1.0`` and ``0.333333333333333``.
843+
That means that ``circle_c`` is present in element ``6`` with a volume fraction of ``1.0``, present in element ``10`` with a volume fraction of ``0.333333333333333``.
844+
845+
Here is another example showing the basic structure:
846+
847+
.. code:: yaml
848+
849+
matset:
850+
topology: "topo"
851+
material_map:
852+
mat0: 0
853+
mat1: 1
854+
...
855+
volume_fractions: [vfs_for_mat0, vfs_for_mat1, ...]
856+
element_ids: [elems_for_mat0, elems_for_mat1, ...]
857+
sizes: [number_of_elems_mat0_is_in, number_of_elems_mat1_is_in, ...]
858+
offsets: [offsets for the sizes]
859+
indices: [indirection array into the volume_fractions and element_ids]
860+
861+
Even though volume fractions and element ids are flattened into a single buffer, they are still grouped by material, and the **o2mrelation** data tells us how to interpret the uni-buffer data.
862+
863+
//////
756864

757865
how do I know what I am?
758866

0 commit comments

Comments
 (0)