Mesh utilities
The utils module of geos-mesh package contains various utilities for VTK meshes.
geos.mesh.utils.genericHelpers module
Generic VTK utilities.
- These methods include:
extraction of a surface from a given elevation
conversion from a list to vtkIdList
conversion of vtk container into iterable
- geos.mesh.utils.genericHelpers.createMultiCellMesh(cellTypes, cellPtsCoord, sharePoints=True)[source]
Create a mesh that consists of multiple cells.
Warning
The mesh is not checked for conformity.
- Parameters:
cellTypes (list[int]) – Cell type
cellPtsCoord (list[1DArray[np.float64]]) – List of cell point coordinates
sharePoints (bool) – If True, cells share points, else a new point is created for each cell vertex
- Returns:
Output mesh
- Return type:
vtkUnstructuredGrid
- geos.mesh.utils.genericHelpers.createSingleCellMesh(cellType, ptsCoord)[source]
Create a mesh that consists of a single cell.
- Parameters:
cellType (int) – cell type
ptsCoord (1DArray[np.float64]) – cell point coordinates
- Returns:
output mesh
- Return type:
vtkUnstructuredGrid
- geos.mesh.utils.genericHelpers.createVertices(cellPtsCoord, shared=True)[source]
Create vertices from cell point coordinates list.
- Parameters:
cellPtsCoord (list[npt.NDArray[np.float64]]) – list of cell point coordinates
shared (bool, optional) – If True, collocated points are merged. Defaults to True.
- Returns:
- tuple containing points and the
map of cell point ids
- Return type:
tuple[vtkPoints, list[tuple[int, …]]]
- geos.mesh.utils.genericHelpers.extractSurfaceFromElevation(mesh, elevation)[source]
Extract surface at a constant elevation from a mesh.
- Parameters:
mesh (vtkUnstructuredGrid) – input mesh
elevation (float) – elevation at which to extract the surface
- Returns:
output surface
- Return type:
vtkPolyData
- geos.mesh.utils.genericHelpers.getBounds(input)[source]
Get bounds of either single of composite data set.
- Parameters:
input (Union[vtkUnstructuredGrid, vtkMultiBlockDataSet]) – input mesh
- Returns:
- tuple containing
bounds (xmin, xmax, ymin, ymax, zmin, zmax)
- Return type:
tuple[float, float, float, float, float, float]
- geos.mesh.utils.genericHelpers.getBoundsFromPointCoords(cellPtsCoord)[source]
Compute bounding box coordinates of the list of points.
- Parameters:
cellPtsCoord (list[npt.NDArray[np.float64]]) – list of points
- Returns:
bounding box coordinates (xmin, xmax, ymin, ymax, zmin, zmax)
- Return type:
Sequence[float]
- geos.mesh.utils.genericHelpers.getMonoBlockBounds(input)[source]
Get boundary box extrema coordinates for a vtkUnstructuredGrid.
- Parameters:
input (vtkMultiBlockDataSet) – input single block mesh
- Returns:
- tuple containing
bounds (xmin, xmax, ymin, ymax, zmin, zmax)
- Return type:
tuple[float, float, float, float, float, float]
- geos.mesh.utils.genericHelpers.getMultiBlockBounds(input)[source]
Get boundary box extrema coordinates for a vtkMultiBlockDataSet.
- Parameters:
input (vtkMultiBlockDataSet) – input multiblock mesh
- Returns:
bounds.
- Return type:
tuple[float, float, float, float, float, float]
geos.mesh.utils.arrayHelpers module
ArrayHelpers module contains several utilities methods to get information on arrays in VTK datasets.
- These methods include:
array getters, with conversion into numpy array or pandas dataframe
boolean functions to check whether an array is present in the dataset
bounds getter for vtu and multiblock datasets
- geos.mesh.utils.arrayHelpers.checkValidValuesInDataSet(dataSet, attributeName, listValues, onPoints)[source]
Check if each value is valid , ie if that value is a data of the attribute in the dataset.
- Parameters:
dataSet (vtkDataSet) – The dataset mesh to check.
attributeName (str) – The name of the attribute with the data.
listValues (list[Any]) – The list of values to check.
onPoints (bool) – True if the attribute is on points, False if on cells.
- Returns:
Tuple containing the list of valid values and the list of the invalid ones.
- Return type:
tuple[list[Any], list[Any]]
- geos.mesh.utils.arrayHelpers.checkValidValuesInMultiBlock(multiBlockDataSet, attributeName, listValues, onPoints)[source]
Check if each value is valid , ie if that value is a data of the attribute in at least one dataset of the multiblock.
- Parameters:
multiBlockDataSet (vtkMultiBlockDataSet) – The multiblock dataset mesh to check.
attributeName (str) – The name of the attribute with the data.
listValues (list[Any]) – The list of values to check.
onPoints (bool) – True if the attribute is on points, False if on cells.
- Returns:
Tuple containing the list of valid values and the list of the invalid ones.
- Return type:
tuple[list[Any], list[Any]]
- geos.mesh.utils.arrayHelpers.computeCellCenterCoordinates(mesh)[source]
Get the coordinates of Cell center.
- Parameters:
mesh (vtkDataSet) – Input surface.
- Returns:
Cell center coordinates.
- Return type:
vtkPoints
- geos.mesh.utils.arrayHelpers.getArrayByName(data, name)[source]
Get the vtkDataArray corresponding to the given name.
- Parameters:
data (vtkFieldData) – Vtk field data.
name (str) – Array name.
- Returns:
The vtkDataArray associated with the name given. None if not found.
- Return type:
Optional[ vtkDataArray ]
- geos.mesh.utils.arrayHelpers.getArrayInObject(dataSet, attributeName, onPoints)[source]
Return the numpy array corresponding to input attribute name in table.
- Parameters:
dataSet (vtkDataSet) – Input dataSet.
attributeName (str) – Name of the attribute.
onPoints (bool) – True if attributes are on points, False if they are on cells.
- Returns:
The numpy array corresponding to input attribute name.
- Return type:
ArrayLike[Any]
- geos.mesh.utils.arrayHelpers.getArrayNames(data)[source]
Get the names of all arrays stored in a “vtkFieldData”, “vtkCellData” or “vtkPointData”.
- Parameters:
data (vtkFieldData) – Vtk field data.
- Returns:
The array names in the order that they are stored in the field data.
- Return type:
list[str]
- geos.mesh.utils.arrayHelpers.getAttributePieceInfo(mesh, attributeName)[source]
Get the attribute piece information.
- Two information are given:
onPoints (Union[None, bool]): True if the attribute is on points or on both pieces, False if it is on cells, None otherwise.
onBoth (bool): True if the attribute is on points and on cells, False otherwise.
- Parameters:
mesh (Union[vtkDataSet, vtkMultiBlockDataSet]) – The mesh with the attribute.
attributeName (str) – The name of the attribute.
- Returns:
The piece information of the attribute.
- Return type:
tuple[Union[None, bool], bool]
- geos.mesh.utils.arrayHelpers.getAttributeSet(mesh, onPoints)[source]
Get the set of all attributes from an mesh on points or on cells.
- Parameters:
mesh (Any) – Mesh where to find the attributes.
onPoints (bool) – True if attributes are on points, False if they are on cells.
- Returns:
Set of attribute names present in input mesh.
- Return type:
set[str]
- geos.mesh.utils.arrayHelpers.getAttributeValuesAsDF(surface, attributeNames)[source]
Get attribute values from input surface.
- Parameters:
surface (vtkPolyData) – Mesh where to get attribute values.
attributeNames (tuple[str,...]) – Tuple of attribute names to get the values.
- Returns:
DataFrame containing property names as columns.
- Return type:
pd.DataFrame
- geos.mesh.utils.arrayHelpers.getAttributesFromDataSet(dataSet, onPoints)[source]
Get the dictionary of all attributes of a vtkDataSet on points or cells.
- Parameters:
dataSet (vtkDataSet) – DataSet where to find the attributes.
onPoints (bool) – True if attributes are on points, False if they are on cells.
- Returns:
List of the names of the attributes.
- Return type:
dict[str, int]
- geos.mesh.utils.arrayHelpers.getAttributesFromMultiBlockDataSet(multiBlockDataSet, onPoints)[source]
Get the dictionary of all attributes of object on points or on cells.
- Parameters:
multiBlockDataSet (vtkMultiBlockDataSet | vtkCompositeDataSet) – multiBlockDataSet where to find the attributes.
onPoints (bool) – True if attributes are on points, False if they are on cells.
- Returns:
Dictionary of the names of the attributes as keys, and number of components as values.
- Return type:
dict[str, int]
- geos.mesh.utils.arrayHelpers.getAttributesWithNumberOfComponents(mesh, onPoints)[source]
Get the dictionary of all attributes from object on points or cells.
- Parameters:
mesh (Any) – Mesh where to find the attributes.
onPoints (bool) – True if attributes are on points, False if they are on cells.
- Returns:
Dictionary where keys are the names of the attributes and values the number of components.
- Return type:
dict[str, int]
- geos.mesh.utils.arrayHelpers.getComponentNames(mesh, attributeName, onPoints)[source]
Get the name of the components of attribute attributeName in dataSet.
- Parameters:
mesh (vtkDataSet | vtkMultiBlockDataSet | vtkCompositeDataSet | vtkDataObject) – Mesh where the attribute is.
attributeName (str) – Name of the attribute.
onPoints (bool) – True if attributes are on points, False if they are on cells.
- Returns:
Names of the components.
- Return type:
tuple[str,…]
- geos.mesh.utils.arrayHelpers.getComponentNamesDataSet(dataSet, attributeName, onPoints)[source]
Get the name of the components of attribute attributeName in dataSet.
- Parameters:
dataSet (vtkDataSet) – DataSet where the attribute is.
attributeName (str) – Name of the attribute.
onPoints (bool) – True if attributes are on points, False if they are on cells.
- Returns:
Names of the components.
- Return type:
tuple[str,…]
- geos.mesh.utils.arrayHelpers.getComponentNamesMultiBlock(multiBlockDataSet, attributeName, onPoints)[source]
Get the name of the components of attribute in MultiBlockDataSet.
- Parameters:
multiBlockDataSet (vtkMultiBlockDataSet | vtkCompositeDataSet) – DataSet where the attribute is.
attributeName (str) – Name of the attribute.
onPoints (bool) – True if attributes are on points, False if they are on cells.
- Returns:
Names of the components.
- Return type:
tuple[str,…]
- geos.mesh.utils.arrayHelpers.getCopyArrayByName(data, name)[source]
Get the copy of a vtkDataArray corresponding to the given name.
- Parameters:
data (vtkFieldData) – Vtk field data.
name (str) – Array name.
- Returns:
The copy of the vtkDataArray associated with the name given. None if not found.
- Return type:
Optional[ vtkDataArray ]
- geos.mesh.utils.arrayHelpers.getFieldType(data)[source]
Returns whether the data is “vtkFieldData”, “vtkCellData” or “vtkPointData”.
A vtk mesh can contain 3 types of field data: - vtkFieldData (parent class) - vtkCellData (inheritance of vtkFieldData) - vtkPointData (inheritance of vtkFieldData)
- Parameters:
data (vtkFieldData) – Vtk field data.
- Returns:
“vtkFieldData”, “vtkCellData” or “vtkPointData”
- Return type:
str
- geos.mesh.utils.arrayHelpers.getNumberOfComponents(mesh, attributeName, onPoints)[source]
Get the number of components of attribute attributeName in dataSet.
- Parameters:
mesh (vtkMultiBlockDataSet | vtkCompositeDataSet | vtkDataSet) – Mesh where the attribute is.
attributeName (str) – Name of the attribute.
onPoints (bool) – True if attributes are on points, False if they are on cells.
- Returns:
Number of components.
- Return type:
int
- geos.mesh.utils.arrayHelpers.getNumberOfComponentsDataSet(dataSet, attributeName, onPoints)[source]
Get the number of components of attribute attributeName in dataSet.
- Parameters:
dataSet (vtkDataSet) – DataSet where the attribute is.
attributeName (str) – Name of the attribute.
onPoints (bool) – True if attributes are on points, False if they are on cells.
- Returns:
Number of components.
- Return type:
int
- geos.mesh.utils.arrayHelpers.getNumberOfComponentsMultiBlock(multiBlockDataSet, attributeName, onPoints)[source]
Get the number of components of attribute attributeName in dataSet.
- Parameters:
multiBlockDataSet (vtkMultiBlockDataSet | vtkCompositeDataSet) – multi block data Set where the attribute is.
attributeName (str) – Name of the attribute.
onPoints (bool) – True if attributes are on points, False if they are on cells.
- Returns:
Number of components.
- Return type:
int
- geos.mesh.utils.arrayHelpers.getNumpyArrayByName(data, name, sorted=False)[source]
Get the numpy array of a given vtkDataArray found by its name.
If sorted is selected, this allows the option to reorder the values wrt GlobalIds. If not GlobalIds was found, no reordering will be perform.
- Parameters:
data (Union[vtkCellData, vtkPointData]) – Vtk field data.
name (str) – Array name to sort.
sorted (bool, optional) – Sort the output array with the help of GlobalIds. Defaults to False.
- Returns:
Sorted array.
- Return type:
Optional[ npt.NDArray ]
- geos.mesh.utils.arrayHelpers.getNumpyGlobalIdsArray(data)[source]
Get a numpy array of the GlobalIds.
- Parameters:
data (Union[ vtkCellData, vtkPointData ]) – Cell or point array.
- Returns:
The numpy array of GlobalIds.
- Return type:
Optional[ npt.NDArray[ np.int64 ] ]
- geos.mesh.utils.arrayHelpers.getVtkArrayInObject(dataSet, attributeName, onPoints)[source]
Return the array corresponding to input attribute name in table.
- Parameters:
dataSet (vtkDataSet) – Input dataSet.
attributeName (str) – Name of the attribute.
onPoints (bool) – True if attributes are on points, False if they are on cells.
- Returns:
The vtk array corresponding to input attribute name.
- Return type:
vtkDataArray
- geos.mesh.utils.arrayHelpers.getVtkArrayTypeInMultiBlock(multiBlockDataSet, attributeName, onPoints)[source]
Return VTK type of requested array from multiblock dataset input, if existing.
- Parameters:
multiBlockDataSet (vtkMultiBlockDataSet) – Input multiBlockDataSet.
attributeName (str) – Name of the attribute.
onPoints (bool) – True if attributes are on points, False if they are on cells.
- Returns:
Type of the requested vtk array if existing in input multiblock dataset.
- Return type:
int
- geos.mesh.utils.arrayHelpers.getVtkArrayTypeInObject(dataSet, attributeName, onPoints)[source]
Return VTK type of requested array from dataset input.
- Parameters:
dataSet (vtkDataSet) – Input dataSet.
attributeName (str) – Name of the attribute.
onPoints (bool) – True if attributes are on points, False if they are on cells.
- Returns:
The type of the vtk array corresponding to input attribute name.
- Return type:
int
- geos.mesh.utils.arrayHelpers.getVtkDataTypeInObject(multiBlockDataSet, attributeName, onPoints)[source]
Return VTK type of requested array from input mesh.
- Parameters:
multiBlockDataSet (Union[vtkDataSet, vtkMultiBlockDataSet]) – Input multiBlockDataSet.
attributeName (str) – Name of the attribute.
onPoints (bool) – True if attributes are on points, False if they are on cells.
- Returns:
The type of the vtk array corresponding to input attribute name.
- Return type:
int
- geos.mesh.utils.arrayHelpers.has_array(mesh, array_names)[source]
Checks if input mesh contains at least one of input data arrays.
- Parameters:
mesh (vtkUnstructuredGrid) – An unstructured mesh.
array_names (list[str]) – List of array names.
- Returns:
True if at least one array is found, else False.
- Return type:
bool
- geos.mesh.utils.arrayHelpers.isAttributeGlobal(multiBlockDataSet, attributeName, onPoints)[source]
Check if an attribute is global in the input multiBlockDataSet.
- Parameters:
multiBlockDataSet (vtkMultiBlockDataSet) – Input multiBlockDataSet.
attributeName (str) – Name of the attribute.
onPoints (bool) – True if attributes are on points, False if they are on cells.
- Returns:
True if the attribute is global, False if not.
- Return type:
bool
- geos.mesh.utils.arrayHelpers.isAttributeInObject(mesh, attributeName, onPoints)[source]
Check if an attribute is in the input object.
- Parameters:
mesh (vtkMultiBlockDataSet | vtkDataSet) – Input mesh.
attributeName (str) – Name of the attribute.
onPoints (bool) – True if attributes are on points, False if they are on cells.
- Returns:
True if the attribute is in the table, False otherwise.
- Return type:
bool
- geos.mesh.utils.arrayHelpers.isAttributeInObjectDataSet(dataSet, attributeName, onPoints)[source]
Check if an attribute is in the input object.
- Parameters:
dataSet (vtkDataSet) – Input dataSet.
attributeName (str) – Name of the attribute.
onPoints (bool) – True if attributes are on points, False if they are on cells.
- Returns:
True if the attribute is in the table, False otherwise.
- Return type:
bool
- geos.mesh.utils.arrayHelpers.isAttributeInObjectMultiBlockDataSet(multiBlockDataSet, attributeName, onPoints)[source]
Check if an attribute is in the input object.
- Parameters:
multiBlockDataSet (vtkMultiBlockDataSet) – Input multiBlockDataSet.
attributeName (str) – Name of the attribute.
onPoints (bool) – True if attributes are on points, False if they are on cells.
- Returns:
True if the attribute is in the table, False otherwise.
- Return type:
bool
geos.mesh.utils.arrayModifiers module
ArrayModifiers contains utilities to process VTK Arrays objects.
- These methods include:
filling partial VTK arrays with values (useful for block merge)
creation of new VTK array, empty or with a given data array
transfer from VTK point data to VTK cell data
- geos.mesh.utils.arrayModifiers.copyAttribute(multiBlockDataSetFrom, multiBlockDataSetTo, attributeNameFrom, attributeNameTo, onPoints=False, logger=None)[source]
Copy an attribute from a multiBlockDataSet to a similar one on the same piece.
- Parameters:
multiBlockDataSetFrom (vtkMultiBlockDataSet) – MultiBlockDataSet from which to copy the attribute.
multiBlockDataSetTo (vtkMultiBlockDataSet) – MultiBlockDataSet where to copy the attribute.
attributeNameFrom (str) – Attribute name in multiBlockDataSetFrom.
attributeNameTo (str) – Attribute name in multiBlockDataSetTo. It will be a new attribute of multiBlockDataSetTo.
onPoints (bool, optional) – True if attributes are on points, False if they are on cells. Defaults to False.
logger (Union[Logger, None], optional) – A logger to manage the output messages. Defaults to None, an internal logger is used.
- Returns:
True if copy successfully ended, False otherwise.
- Return type:
bool
- geos.mesh.utils.arrayModifiers.copyAttributeDataSet(dataSetFrom, dataSetTo, attributeNameFrom, attributeNameTo, onPoints=False, logger=None)[source]
Copy an attribute from a dataSet to a similar one on the same piece.
- Parameters:
dataSetFrom (vtkDataSet) – DataSet from which to copy the attribute.
dataSetTo (vtkDataSet) – DataSet where to copy the attribute.
attributeNameFrom (str) – Attribute name in dataSetFrom.
attributeNameTo (str) – Attribute name in dataSetTo. It will be a new attribute of dataSetTo.
onPoints (bool, optional) – True if attributes are on points, False if they are on cells. Defaults to False.
logger (Union[Logger, None], optional) – A logger to manage the output messages. Defaults to None, an internal logger is used.
- Returns:
True if copy successfully ended, False otherwise.
- Return type:
bool
- geos.mesh.utils.arrayModifiers.createAttribute(dataSet, npArray, attributeName, componentNames=(), onPoints=False, vtkDataType=None, logger=None)[source]
Create an attribute from the given numpy array.
- Parameters:
dataSet (vtkDataSet) – DataSet where to create the attribute.
npArray (NDArray[Any]) – Array that contains the values.
attributeName (str) – Name of the attribute.
componentNames (tuple[str,...], optional) – Name of the components for vectorial attributes. If one component, gives an empty tuple. Defaults to an empty tuple.
onPoints (bool, optional) – True if attributes are on points, False if they are on cells. Defaults to False.
vtkDataType (Union[int, None], optional) –
Vtk data type of the attribute to create. Defaults to None, the vtk data type is given by the type of the array.
Warning with int8, uint8 and int64 type, the corresponding vtk data type are multiples. By default: - int8 -> VTK_SIGNED_CHAR - uint8 -> VTK_UNSIGNED_CHAR - int64 -> VTK_LONG_LONG
logger (Union[Logger, None], optional) – A logger to manage the output messages. Defaults to None, an internal logger is used.
- Returns:
True if the attribute was correctly created, False if it was not created.
- Return type:
bool
- geos.mesh.utils.arrayModifiers.createCellCenterAttribute(mesh, cellCenterAttributeName)[source]
Create elementCenter attribute if it does not exist.
- Parameters:
mesh (vtkMultiBlockDataSet | vtkDataSet) – input mesh
cellCenterAttributeName (str) – Name of the attribute
- Raises:
TypeError – Raised if input mesh is not a vtkMultiBlockDataSet or a
vtkDataSet. –
- Returns:
True if calculation successfully ended, False otherwise.
- Return type:
bool
- geos.mesh.utils.arrayModifiers.createConstantAttribute(mesh, listValues, attributeName, componentNames=(), onPoints=False, vtkDataType=None, logger=None)[source]
Create a new attribute with a constant value in the mesh.
- Parameters:
mesh (Union[vtkMultiBlockDataSet, vtkDataSet]) – Mesh where to create the attribute.
listValues (list[Any]) – List of values of the attribute for each components. It is recommended to use numpy scalar type for the values.
attributeName (str) – Name of the attribute.
componentNames (tuple[str,...], optional) – Name of the components for vectorial attributes. If one component, gives an empty tuple. Defaults to an empty tuple.
onPoints (bool, optional) – True if attributes are on points, False if they are on cells. Defaults to False.
vtkDataType (Union[int, None], optional) –
Vtk data type of the attribute to create. Defaults to None, the vtk data type is given by the type of the values.
Warning with int8, uint8 and int64 type of value, the corresponding vtk data type are multiples. By default: - int8 -> VTK_SIGNED_CHAR - uint8 -> VTK_UNSIGNED_CHAR - int64 -> VTK_LONG_LONG
logger (Union[Logger, None], optional) – A logger to manage the output messages. Defaults to None, an internal logger is used.
- Returns:
True if the attribute was correctly created, False if it was not created.
- Return type:
bool
- geos.mesh.utils.arrayModifiers.createConstantAttributeDataSet(dataSet, listValues, attributeName, componentNames=(), onPoints=False, vtkDataType=None, logger=None)[source]
Create an attribute with a constant value per component in the dataSet.
- Parameters:
dataSet (vtkDataSet) – DataSet where to create the attribute.
listValues (list[Any]) – List of values of the attribute for each components. It is recommended to use numpy scalar type for the values.
attributeName (str) – Name of the attribute.
componentNames (tuple[str,...], optional) – Name of the components for vectorial attributes. If one component, gives an empty tuple. Defaults to an empty tuple.
onPoints (bool, optional) – True if attributes are on points, False if they are on cells. Defaults to False.
vtkDataType (Union[int, None], optional) –
Vtk data type of the attribute to create. Defaults to None, the vtk data type is given by the type of the values.
Warning with int8, uint8 and int64 type of value, the corresponding vtk data type are multiples. By default: - int8 -> VTK_SIGNED_CHAR - uint8 -> VTK_UNSIGNED_CHAR - int64 -> VTK_LONG_LONG
logger (Union[Logger, None], optional) – A logger to manage the output messages. Defaults to None, an internal logger is used.
- Returns:
True if the attribute was correctly created, False if it was not created.
- Return type:
bool
- geos.mesh.utils.arrayModifiers.createConstantAttributeMultiBlock(multiBlockDataSet, listValues, attributeName, componentNames=(), onPoints=False, vtkDataType=None, logger=None)[source]
Create a new attribute with a constant value per component on every block of the multiBlockDataSet.
- Parameters:
multiBlockDataSet (Union[vtkMultiBlockDataSet, vtkCompositeDataSet]) – MultiBlockDataSet where to create the attribute.
listValues (list[Any]) – List of values of the attribute for each components. It is recommended to use numpy scalar type for the values.
attributeName (str) – Name of the attribute.
componentNames (tuple[str,...], optional) – Name of the components for vectorial attributes. If one component, gives an empty tuple. Defaults to an empty tuple.
onPoints (bool, optional) – True if attributes are on points, False if they are on cells. Defaults to False.
vtkDataType (Union[int, None], optional) –
Vtk data type of the attribute to create. Defaults to None, the vtk data type is given by the type of the values.
Warning with int8, uint8 and int64 type of value, the corresponding vtk data type are multiples. By default: - int8 -> VTK_SIGNED_CHAR - uint8 -> VTK_UNSIGNED_CHAR - int64 -> VTK_LONG_LONG
logger (Union[Logger, None], optional) – A logger to manage the output messages. Defaults to None, an internal logger is used.
- Returns:
True if the attribute was correctly created, False if it was not created.
- Return type:
bool
- geos.mesh.utils.arrayModifiers.createEmptyAttribute(attributeName, componentNames, vtkDataType)[source]
Create an empty attribute.
- Parameters:
attributeName (str) – Name of the attribute
componentNames (tuple[str,...]) – Name of the components for vectorial attributes.
vtkDataType (int) – Data type.
- Returns:
The empty attribute.
- Return type:
vtkDataArray
- geos.mesh.utils.arrayModifiers.doCreateCellCenterAttribute(block, cellCenterAttributeName)[source]
Create elementCenter attribute in a vtkDataSet if it does not exist.
- Parameters:
block (vtkDataSet) – Input mesh that must be a vtkDataSet
cellCenterAttributeName (str) – Name of the attribute
- Returns:
True if calculation successfully ended, False otherwise.
- Return type:
bool
- geos.mesh.utils.arrayModifiers.fillAllPartialAttributes(multiBlockDataSet, logger=None)[source]
Fill all partial attributes of a multiBlockDataSet with the default value. All components of each attributes are filled with the same value. Depending of the type of the attribute, the default value is different 0, -1 and nan for respectively uint, int and float vtk type.
- Parameters:
multiBlockDataSet (vtkMultiBlockDataSet | vtkCompositeDataSet | vtkDataObject) – MultiBlockDataSet where to fill attributes.
logger (Union[Logger, None], optional) – A logger to manage the output messages. Defaults to None, an internal logger is used.
- Returns:
True if attributes were correctly created and filled, False if not.
- Return type:
bool
- geos.mesh.utils.arrayModifiers.fillPartialAttributes(multiBlockDataSet, attributeName, onPoints=False, listValues=None, logger=None)[source]
Fill input partial attribute of multiBlockDataSet with a constant value per component.
- Parameters:
multiBlockDataSet (vtkMultiBlockDataSet | vtkCompositeDataSet | vtkDataObject) – MultiBlockDataSet where to fill the attribute.
attributeName (str) – Attribute name.
onPoints (bool, optional) – True if attributes are on points, False if they are on cells. Defaults to False.
listValues (list[Any], optional) – List of filling value for each component. Defaults to None, the filling value is for all components: -1 for int VTK arrays. 0 for uint VTK arrays. nan for float VTK arrays.
logger (Union[Logger, None], optional) – A logger to manage the output messages. Defaults to None, an internal logger is used.
- Returns:
True if the attribute was correctly created and filled, False if not.
- Return type:
bool
- geos.mesh.utils.arrayModifiers.renameAttribute(object, attributeName, newAttributeName, onPoints)[source]
Rename an attribute.
- Parameters:
object (vtkMultiBlockDataSet) – Object where the attribute is.
attributeName (str) – Name of the attribute.
newAttributeName (str) – New name of the attribute.
onPoints (bool) – True if attributes are on points, False if they are on cells.
- Returns:
True if renaming operation successfully ended.
- Return type:
bool
geos.mesh.utils.multiblockHelpers module
Functions to explore VTK multiblock datasets.
- Methods include:
getters for blocks names and indexes
block extractor
- geos.mesh.utils.multiblockHelpers.extractBlock(multiBlockDataSet, blockIndex)[source]
Extract the block with index blockIndex from multiBlockDataSet.
- Parameters:
multiBlockDataSet (vtkMultiBlockDataSet) – multiblock dataset from which to extract the block
blockIndex (int) – block index to extract
- Returns:
extracted block
- Return type:
vtkMultiBlockDataSet
- geos.mesh.utils.multiblockHelpers.getBlockElementIndexes(multiBlockDataSet)[source]
Get a list of list that contains flat indexes of elementary blocks.
Each sublist contains the indexes of elementary blocks that belongs to a same parent node.
- Parameters:
multiBlockDataSet (Union[vtkMultiBlockDataSet, vtkCompositeDataSet]) – MultiBlockDataSet with the block indexes to get.
- Returns:
List of list of flat indexes.
- Return type:
list[list[int]]
- geos.mesh.utils.multiblockHelpers.getBlockElementIndexesFlatten(multiBlockDataSet)[source]
Get a flatten list that contains flat indexes of elementary blocks.
- Parameters:
multiBlockDataSet (Union[vtkMultiBlockDataSet, vtkCompositeDataSet]) – MultiBlockDataSet with the block flat indexes to get.
- Returns:
List of flat indexes.
- Return type:
list[int]
- geos.mesh.utils.multiblockHelpers.getBlockFromFlatIndex(multiBlockDataSet, blockIndex)[source]
Get the block with blockIndex from the vtkMultiBlockDataSet.
- Parameters:
multiBlockDataSet (Union[vtkMultiBlockDataSet, vtkCompositeDataSet]) – MultiBlockDataSet with the block to get.
blockIndex (int) – The block index og the block to get.
- Returns:
The block with the flat index if it exists, None otherwise
- Return type:
Union[None, vtkDataObject]
- geos.mesh.utils.multiblockHelpers.getBlockFromName(multiBlockDataSet, blockName)[source]
Get the block named blockName from the vtkMultiBlockDataSet.
- Parameters:
multiBlockDataSet (vtkMultiBlockDataSet | vtkCompositeDataSet) – MultiBlockDataSet with the block to get.
blockName (str) – The name of the block to get.
- Returns:
The block name blockName if it exists, None otherwise
- Return type:
Union[None, vtkDataObject]
- geos.mesh.utils.multiblockHelpers.getBlockIndexFromName(multiBlockDataSet, blockName)[source]
Get flat index of a multiBlockDataSet block with its name.
- Parameters:
multiBlockDataSet (Union[vtkMultiBlockDataSet, vtkCompositeDataSet]) – MultiBlockDataSet with the block to get the index.
blockName (str) – Name of the block to get the flat index.
- Returns:
Flat index of the block if found, -1 otherwise.
- Return type:
int
- geos.mesh.utils.multiblockHelpers.getBlockNameFromIndex(multiBlockDataSet, index)[source]
Get the name of a multiBlockDataSet block with its flat index.
- Parameters:
multiBlockDataSet (Union[vtkMultiBlockDataSet, vtkCompositeDataSet]) – MultiBlockDataSet with the block to get the name.
index (int) – Flat index of the block to get the name.
- Returns:
name of the block in the tree.
- Return type:
str
- geos.mesh.utils.multiblockHelpers.getBlockNames(multiBlockDataSet)[source]
Get the name of all blocks of the multiBlockDataSet.
- Parameters:
multiBlockDataSet (Union[vtkMultiBlockDataSet, vtkCompositeDataSet]) – MultiBlockDataSet with the block names to get.
- Returns:
list of the names of the block in the multiBlockDataSet.
- Return type:
list[str]
- geos.mesh.utils.multiblockHelpers.getElementaryCompositeBlockIndexes(multiBlockDataSet)[source]
Get indexes of composite block of the multiBlockDataSet that contains elementary blocks.
- Parameters:
multiBlockDataSet (Union[vtkMultiBlockDataSet, vtkCompositeDataSet]) – MultiBlockDataSet.
- Returns:
Dictionary that contains names as keys and flat indices as values of the parent composite blocks of elementary blocks.
- Return type:
dict[str, int]
geos.mesh.utils.multiblockModifiers module
Contains a method to merge blocks of a VTK multiblock dataset.
- geos.mesh.utils.multiblockModifiers.mergeBlocks(input, keepPartialAttributes=False)[source]
Merge all blocks of a multi block mesh.
- Parameters:
input (vtkMultiBlockDataSet | vtkCompositeDataSet) – composite object to merge blocks
keepPartialAttributes (bool) –
if True, keep partial attributes after merge.
Defaults to False.
- Returns:
merged block object
- Return type:
vtkUnstructuredGrid