4.1.1.9.1.12. pyfem.util.vtkUtils module

storeNodes(grid: vtkUnstructuredGrid, globdat: GlobalData) None[source]

Store node coordinates from the global data into a VTK grid.

Converts node coordinates to 3D format (padding 2D coordinates with z=0.0) and inserts them into the VTK grid’s point data.

Parameters:
  • grid – VTK grid object to store points in

  • globdat – Global data object

storeElements(grid: vtkUnstructuredGrid, globdat: GlobalData, elementGroup: str = 'All') None[source]

Store elements from the global data into a VTK grid.

Iterates through elements in the specified group and inserts them into the VTK grid with appropriate cell types based on element family and rank.

Parameters:
  • grid – VTK grid object to store cells in

  • globdat – Global data object containing element information

  • elementGroup – Name of element group to store. Defaults to “All”

storeDofField(grid: vtkUnstructuredGrid, data, globdat: GlobalData, dofTypes: List[str] | str, label: str) None[source]

Store a degree-of-freedom field as point data in the VTK grid.

Creates a VTK array containing values for specified DOF types at each node. Missing DOF types are filled with zeros.

Parameters:
  • grid – VTK grid object to add array to

  • data – Array of DOF values indexed by global DOF numbers

  • globdat – Global data object containing DOF information

  • dofTypes – List of DOF type strings (e.g., [“u”, “v”, “w”]) or single string

  • label – Name for the VTK array

storeDofFields(grid: vtkUnstructuredGrid, data, globdat: GlobalData) None[source]

Store all available DOF fields into the VTK grid.

Automatically detects and stores displacement, temperature, and phase fields if they exist in the global data.

Parameters:
  • grid – VTK grid object to add arrays to

  • data – Array of all DOF values

  • globdat – Global data object containing DOF information

storeNodeField(grid: vtkUnstructuredGrid, data, globdat: GlobalData, name: str) None[source]

Store a scalar field defined at nodes as point data in the VTK grid.

Parameters:
  • grid – VTK grid object to add array to

  • data – Array of scalar values, one per node

  • globdat – Global data object (for consistency with other functions)

  • name – Name for the VTK array

storeElementField(grid: vtkUnstructuredGrid, data, globdat: GlobalData, name: str) None[source]

Store a scalar field defined at elements as cell data in the VTK grid.

Parameters:
  • grid – VTK grid object to add array to

  • data – Array of scalar values, one per element

  • globdat – Global data object (for consistency with other functions)

  • name – Name for the VTK array

setCellNodes(cell: vtkCell, elemNodes: List[int]) None[source]

Set the node IDs for a VTK cell.

Maps the provided element node indices to the VTK cell’s point IDs.

Parameters:
  • cell – VTK cell object to set nodes for

  • elemNodes – List of node indices for the cell

insertElement(grid: vtkUnstructuredGrid, elemNodes: List[int], rank: int, family: str) None[source]

Insert an element into the VTK grid.

Routes element insertion to appropriate function based on element family (CONTINUUM, INTERFACE, SURFACE, BEAM, SHELL) and spatial rank (2D or 3D).

Parameters:
  • grid – VTK grid object to insert element into

  • elemNodes – List of node indices for the element

  • rank – Spatial dimension (2 or 3)

  • family – Element family type

Raises:

NotImplementedError – If element family or rank combination is not supported

insert2Dcontinuum(grid: vtkUnstructuredGrid, elemNodes: List[int]) None[source]

Insert a 2D continuum element into the VTK grid.

Supports 2, 3, 4, 6, 8, and 9 node elements. Higher-order elements are converted to linear elements using only corner nodes.

Parameters:
  • grid – VTK grid object to insert element into

  • elemNodes – List of node indices for the element

Raises:

NotImplementedError – If element has unsupported number of nodes

insert3Dcontinuum(grid: vtkUnstructuredGrid, elemNodes: List[int]) None[source]

Insert a 3D continuum element into the VTK grid.

Supports 4, 5, 6, 8, and 16 node elements (tetrahedra, pyramids, wedges, and hexahedra). Higher-order elements are converted to linear elements.

Parameters:
  • grid – VTK grid object to insert element into

  • elemNodes – List of node indices for the element

Raises:

NotImplementedError – If element has unsupported number of nodes

insert2Dinterface(grid: vtkUnstructuredGrid, elemNodes: List[int]) None[source]

Insert a 2D interface element into the VTK grid.

Represents interface elements as two separate line segments.

Parameters:
  • grid – VTK grid object to insert elements into

  • elemNodes – List of 4 node indices (2 nodes per side)

Raises:

NotImplementedError – If element does not have 4 nodes

insert3Dinterface(grid: vtkUnstructuredGrid, elemNodes: List[int]) None[source]

Insert a 3D interface element into the VTK grid.

Represents interface elements as two separate surfaces (triangles or quads).

Parameters:
  • grid – VTK grid object to insert elements into

  • elemNodes – List of 6 (triangular) or 8 (quadrilateral) node indices

Raises:

NotImplementedError – If element does not have 6 or 8 nodes

insert2Dsurface(grid: vtkUnstructuredGrid, elemNodes: List[int]) None[source]

Insert a 2D surface element into the VTK grid.

Parameters:
  • grid – VTK grid object to insert element into

  • elemNodes – List of 2 node indices

Raises:

NotImplementedError – If element does not have 2 nodes

insert3Dsurface(grid: vtkUnstructuredGrid, elemNodes: List[int]) None[source]

Insert a 3D surface element into the VTK grid.

Supports triangular and quadrilateral surface elements.

Parameters:
  • grid – VTK grid object to insert element into

  • elemNodes – List of 3 (triangular) or 4 (quadrilateral) node indices

Raises:

NotImplementedError – If element does not have 3 or 4 nodes

insertBeam(grid: vtkUnstructuredGrid, elemNodes: List[int]) None[source]

Insert a beam element into the VTK grid.

Supports 2-node (linear) and 3-node (quadratic) beam elements. For 3-node elements, only the end nodes are used.

Parameters:
  • grid – VTK grid object to insert element into

  • elemNodes – List of 2 or 3 node indices

Raises:

NotImplementedError – If element does not have 2 or 3 nodes

insertShell(grid: vtkUnstructuredGrid, elemNodes: List[int]) None[source]

Insert a shell element into the VTK grid.

Supports triangular and quadrilateral shell elements.

Parameters:
  • grid – VTK grid object to insert element into

  • elemNodes – List of 3 (triangular) or 4 (quadrilateral) node indices

Raises:

NotImplementedError – If element does not have 3 or 4 nodes