|
| 1 | +.. ## Copyright (c) 2017-2024, Lawrence Livermore National Security, LLC and |
| 2 | +.. ## other Axom Project Developers. See the top-level LICENSE file for details. |
| 3 | +.. ## |
| 4 | +.. ## SPDX-License-Identifier: (BSD-3-Clause) |
| 5 | +
|
| 6 | +****************************************************** |
| 7 | +Field Concepts |
| 8 | +****************************************************** |
| 9 | + |
| 10 | +Fields are data that are defined over a mesh, typically with one or more values |
| 11 | +per cell. Fields can be scalar, indicating 1-component per cell - or they can |
| 12 | +contain multiple components as with vector data (2+ components per cell). This |
| 13 | +section discusses important MultiMat field concepts that determine where fields |
| 14 | +live on the mesh and how their data are organized in memory. |
| 15 | + |
| 16 | +####################### |
| 17 | +Field Mapping |
| 18 | +####################### |
| 19 | + |
| 20 | +MultiMat associates materials with cells in a mesh, possibly subdividing cells. |
| 21 | +MultiMat includes the concept of field *mapping*, which is where on the mesh the |
| 22 | +field data live. Fields can be defined over the cells, which is how most simulations |
| 23 | +think about cell-centered fields. With MultiMat, fields can also be defined over |
| 24 | +the materials, allowing for compact storage of material-level data. Fields can |
| 25 | +also be defined over the cells/material pairs from the Cell-Material Relation (CMR), |
| 26 | +allowing fields to have data values for each material in a cell. |
| 27 | + |
| 28 | +.. figure:: figures/mapping.png |
| 29 | + :figwidth: 700px |
| 30 | + |
| 31 | + Diagram showing field mapping concept. |
| 32 | + |
| 33 | ++--------------------+-----------------------------------------------------------+ |
| 34 | +| FieldMapping | Meaning | |
| 35 | ++====================+===========================================================+ |
| 36 | +| PER_CELL | The field contains up to ncells * ncomponents values (for | |
| 37 | +| | dense storage) and there are ncomponents values per cell. | |
| 38 | +| | For scalars *ncomponents* is 1 so the field length is | |
| 39 | +| | ncells. | |
| 40 | ++--------------------+-----------------------------------------------------------+ |
| 41 | +| PER_MAT | The field contains nmats * ncomponents values and there | |
| 42 | +| | are ncomponents values per material. This mapping allows | |
| 43 | +| | fields to be defined over the entire material region and | |
| 44 | +| | any cell that uses the material inherits the per-material | |
| 45 | +| | field value, allowing for very compact storage of | |
| 46 | +| | material-level properties. | |
| 47 | ++--------------------+-----------------------------------------------------------+ |
| 48 | +| PER_CELL_MAT | The field contains up to ncells * nmats * ncomponents (for| |
| 49 | +| | dense storage). This mapping allows materials within a | |
| 50 | +| | cell to have their own unique values, which makes them | |
| 51 | +| | useful for tracking data at a sub-cell level. | |
| 52 | ++--------------------+-----------------------------------------------------------+ |
| 53 | + |
| 54 | +####################### |
| 55 | +Data Layout |
| 56 | +####################### |
| 57 | + |
| 58 | +Simulation codes contain a variety of algorithms that may have a preference for how |
| 59 | +data are arranged in memory to ensure good performance. MultiMat supports |
| 60 | +fields with a ``PER_CELL_MAT`` mapping and there are two ways to organize such data. |
| 61 | +Fields are said to be **Cell-Dominant** (``CELL_DOM``) if they are stored such that |
| 62 | +each cell stores all of its material data to memory before proceeding to data for |
| 63 | +the next cell. Fields are **Material-Dominant** (``MAT_DOM``) if the data for all |
| 64 | +cells that use the material is stored before proceeding to the next material. |
| 65 | +The data layout for multi-material data can be thought of as 2 nested for-loops where |
| 66 | +the outer loop is the dominant loop. For example, if iterating over materials and |
| 67 | +then cells, the data are stored using ``MAT_DOM`` layout. |
| 68 | + |
| 69 | ++--------------------+----------------------------------------------------------+ |
| 70 | +| DataLayout | Meaning | |
| 71 | ++====================+==========================================================+ |
| 72 | +| CELL_DOM | Data are stored for each cell and then for each material | |
| 73 | +| | like this *(c=cell, m=material)*: | |
| 74 | +| | | |
| 75 | +| | ``{c0m0, c0m1, c0m2, ..., c1m0, c1m1, c1m2, ...}`` | |
| 76 | ++--------------------+----------------------------------------------------------+ |
| 77 | +| MAT_DOM | Data are stored for each material and then for each cell | |
| 78 | +| | like this *(m=material, c=cell)*: | |
| 79 | +| | | |
| 80 | +| | ``{m0c0, m0c1, m0c2, m0c3, ... , m1c0, m1c1, m1c2, ...}``| |
| 81 | ++--------------------+----------------------------------------------------------+ |
| 82 | + |
| 83 | +####################### |
| 84 | +Sparsity Layout |
| 85 | +####################### |
| 86 | + |
| 87 | +Sparsity primarily concerns fields with ``PER_CELL_MAT`` mapping. When initializing |
| 88 | +the MultiMat object, the CMR indicates how materials are distributed |
| 89 | +over the mesh. It is completely acceptable for materials to skip over certain cells, |
| 90 | +which makes sense if we think about materials as a way to divide up the mesh into |
| 91 | +various regions or parts. There are ncells * nmats pairs of data that could be entered |
| 92 | +for MultiMat fields. For ``DENSE`` fields, the field must contain ncells * nmats values, |
| 93 | +with values present for cell/material pairs whether materials are present or not. |
| 94 | +This is an easy way to specify the data but it wastes memory by including extra |
| 95 | +values whose only purpose is to keep the rectangular shape of the data array. |
| 96 | + |
| 97 | +For large meshes, compressing out unnecessary values can save a lot of memory. MultiMat |
| 98 | +supports a ``SPARSE`` layout that does not include any unnecessary values. If we |
| 99 | +regard the CMR as a matrix of true/false values, a user must only provide field values |
| 100 | +for ``SPARSE`` data where the CMR contains true values. |
| 101 | + |
| 102 | + |
| 103 | +.. figure:: figures/sparsity.png |
| 104 | + :figwidth: 700px |
| 105 | + |
| 106 | + Mixed-material volume fraction field with both DENSE and SPARSE representations. |
| 107 | + |
| 108 | + |
| 109 | + |
| 110 | ++--------------------+----------------------------------------------------------+ |
| 111 | +| SparsityLayout | Meaning | |
| 112 | ++====================+==========================================================+ |
| 113 | +| DENSE | Data are provided for all ncells * nmats pairs, even if | |
| 114 | +| | there is no cell/material that is valid. | |
| 115 | ++--------------------+----------------------------------------------------------+ |
| 116 | +| SPARSE | Data are provided for only the cell/material pairs that | |
| 117 | +| | are valid according to the CMR. | |
| 118 | ++--------------------+----------------------------------------------------------+ |
0 commit comments