🌐 Render

vtk_fiber

../_images/vtk_fiber.png
fibermat.utils.render.vtk_fiber(length=25.0, width=1.0, thickness=1.0, x=0.0, y=0.0, z=0.0, u=1.0, v=0.0, w=0.0, shear=1.0, tensile=inf, index=None, r_resolution=1, theta_resolution=8, z_resolution=20, **kwargs)

Export a fiber as VTK mesh using pyvista.CylinderStructured.

Parameters

lengthfloat, optional

Fiber length (mm). Default is 25 mm.

widthfloat, optional

Fiber width (mm). Default is 1 mm.

thicknessfloat, optional

Fiber thickness (mm). Default is 1 mm.

xfloat, optional

Fiber position: X-coordinate (mm). Default is 0 mm.

yfloat, optional

Fiber position: Y-coordinate (mm). Default is 0 mm.

zfloat, optional

Fiber position: Z-coordinate (mm). Default is 0 mm.

ufloat, optional

Fiber orientation: X-component. Default is 1.

vfloat, optional

Fiber orientation: Y-component. Default is 0.

wfloat, optional

Fiber orientation: Z-component. Default is 0.

shearfloat, optional

Shear modulus (MPa). Default is 1 MPa.

tensilefloat, optional

Tensile modulus (MPa). Default is ∞ MPa.

indexint, optional

Fiber label.

Returns

pyvista.StructuredGrid

VTK mesh.

Other Parameters

r_resolutionint, optional

Number of elements along the radius of the fiber. Default is 1.

theta_resolutionint, optional

Number of points on the circular face of the fiber. Default is 8.

z_resolutionint, optional

Number of points along the length of the fiber. Default is 20.

kwargs :

Additional keyword arguments ignored by the function.

Note

If index is not None, the following fields are added to the VTK mesh:
  • “fiber” : fiber index

  • “lbh” : fiber dimensions (mm)

  • “xyz” : local fiber coordinates (mm)

  • “uvw” : fiber orientation vector

  • “G” : shear modulus (MPa)

  • “E” : tensile modulus (MPa)

vtk_mat

../_images/vtk_mat.png
fibermat.utils.render.vtk_mat(mat=None, func=None, verbose=True, **kwargs)

Export a Mat object as VTK mesh.

Parameters

matpandas.DataFrame, optional

Set of fibers represented by a Mat object.

funccallable, optional

Function called for each fiber to modify the mesh or add fields. It takes as arguments the VTK mesh and the label of the fiber.

Returns

pyvista.UnstructuredGrid

VTK mesh.

Other Parameters

verbosebool, optional

If True, a progress bar is displayed. Default is True.

kwargs :

Additional keyword arguments passed to vtk_fiber() function.

Note

The following fields are added to the VTK mesh:
  • “fiber” : fiber index

  • “lbh” : fiber dimensions (mm)

  • “xyz” : local fiber coordinates (mm)

  • “uvw” : fiber orientation vector

  • “G” : shear modulus (MPa)

  • “E” : tensile modulus (MPa)

vtk_mesh

../_images/vtk_mesh.png
fibermat.utils.render.vtk_mesh(mesh=None, displacement=None, rotation=None, force=None, torque=None, verbose=True, **kwargs)

Export a Mesh object as VTK mesh.

Parameters

meshpandas.DataFrame, optional

Fiber mesh represented by a Mesh object.

Returns

pyvista.UnstructuredGrid

VTK mesh.

Other Parameters

displacementnumpy.ndarray, optional

Displacement field.

rotationnumpy.ndarray, optional

Rotation field.

forcenumpy.ndarray, optional

Load field.

torquenumpy.ndarray, optional

Torque field.

verbosebool, optional

If True, a progress bar is displayed. Default is True.

kwargs :

Additional keyword arguments passed to vtk_fiber() function.

Hint

The following fields are added to the VTK mesh:
  • “fiber” : fiber index

  • “lbh” : fiber dimensions (mm)

  • “xyz” : local fiber coordinates (mm)

  • “uvw” : fiber orientation vector

  • “G” : shear modulus (MPa)

  • “E” : tensile modulus (MPa)

If displacement is not None:
  • “displacement” : displacement field (mm)

  • “rotation” : rotation field (rad)

  • “curvature” : curvature field (1 / mm)

If force is not None:
  • “force” : force field (N)

Example

from fibermat import *

# Create a VTK fiber
vtk_fiber().plot()

# Generate a set of fibers
mat = Mat(100)
# Build the fiber network
net = Net(mat)
# Stack fibers
stack = Stack(net)
# Create the fiber mesh
mesh = Mesh(stack)

# Solve the mechanical packing problem
sol = solve(Timoshenko(mesh), packing=4)

# Create a VTK mat
vtk_mat(mat).plot()

# Create a VTK mesh
vtk_mesh(mesh).plot()

# Export as VTK
msh = vtk_mesh(
    mesh,
    sol.displacement(1),
    sol.rotation(1),
    sol.force(1),
    sol.torque(1),
)
msh.plot(scalars="force", cmap=plt.cm.twilight_shifted)
../_images/vtk_force.png