vtkConduitSource: Add state/metadata/vtk_fields node
When defining fields in a Conduit tree, it is often useful to include metadata about the fields that can be
interpreted by VTK, and utilized appropriately. To that end, we have added a new node to the Conduit tree
that can be used to store metadata about the fields in the tree. This node is called state/metadata/vtk_fields
.
Each child of the state/metadata/vtk_fields
node has a name that corresponds to a field in the tree. The number
of children of the state/metadata/vtk_fields
node should not match the number of fields
in the tree since not every
field needs to have metadata.
The current metadata that can be stored for each field is:
-
attribute_type
: It is a string and represents the attribute type of a field that, so that VTk can use an attribute array, such asGlobalIds
. The values uses are the entries ofvtkDataSetAttributes::AttributeTypes
+Ghosts
. The complete list of values is:Scalars
Vectors
Normals
TCoords
Tensors
GlobalIds
PedigreeIds
EdgeFlag
Tangents
RationalWeights
HigherOrderDegrees
ProcessIds
Ghosts
-
values_to_replace
andreplacement_values
: These two are vectors of values that be used to replace specific values in the field. This is useful when the field has some values that are not valid for VTK. For example, thevtkGhostType
array uses specific values that other ghost cell generator algorithms may not use. In this case, thevalues_to_replace
would be the values that need to be replaced, and thereplacement_values
would be the values that should replace them. The two vectors should have the same length.
Example:
conduit_cpp::Node mesh;
CreateUniformMesh(3, 3, 3, mesh);
std::vector<int> cellGhosts(8, 0);
cellGhosts[2] = 1;
conduit_cpp::Node resCellFields = mesh["fields/other_ghosts"];
resCellFields["association"] = "element";
resCellFields["topology"] = "mesh";
resCellFields["volume_dependent"] = "false";
resCellFields["values"] = cellGhosts;
std::vector<int> cellGhostValuesToReplace(1, 1);
std::vector<int> cellGhostReplacementValues(1, vtkDataSetAttributes::HIDDENCELL);
std::vector<int> cellGhostsMetaData(1, 1);
conduit_cpp::Node ghostMetaData = mesh["state/metadata/vtk_fields/other_ghosts"];
ghostMetaData["attribute_type"] = "Ghosts";
ghostMetaData["values_to_replace"] = cellGhostValuesToReplace;
ghostMetaData["replacement_values"] = cellGhostReplacementValues;
cc: @christos.tsolakis @charles.gueunet @berkgeveci @cory.quammen @acbauer.
Last issue to solve:
if we are given a node with a "GhostCells" array and "GhostPoints" arrays, we can convert it to a vtkDataObject (which includes renaming the arrays to vtkGhostType), but if we try to convert the vtkDataObject back to a conduit node we can't have both arrays present since they have the same name. My only idea to solve this issue is to convert the ghost array to yet another attribute array instead of relying on the name vtkGhostType. If you have any other ideas, let me know.