Post processing of Simulation result

I am using Modulus (-release_22.09) and trying to do Structural Analysis, I have read the input geometry in .stl file format.
I have used VoxelInferencer as well as VTKUniformGrid, still I am not able to see my point cloud data in image based data for visualisation using Paraview.
(When I have used Modulsu library, (modulus.geometry.primitives_3d) to define the geometry (reference example available with Modulus (example name: Bracket)); and used these VoxelInferencer & VTKUniformGrid class, I am able to convert my point cloud data to meshed/image file)
I am getting point cloud data which can be confirmed with attached screen shot.

my code for VoxelInferencer is shown below :
# Voxel interface
# add inferencer data
def mask_fn(x, y, z):
sdf = interior_mesh.sdf({“x”: x, “y”: y, “z”: z}, {})
return sdf[“sdf”] < 0

voxel_inferencer = VoxelInferencer(
    bounds=[[-2, 2], [-2, 2], [-2, 2]],
    npoints=[256, 128, 256],
    nodes=nodes,
    output_names=["u", "v", "w", "sigma_xy", "sigma_xz", "sigma_zz"],
    export_map={"U": ["u", "v", "w"], "sigma_xx": ["sigma_xy"], "sigma_xz": ["sigma_xy"], "sigma_zz": ["sigma_zz"]},
    mask_fn=mask_fn,
    requires_grad=False,
    batch_size=10000,
)
domain.add_inferencer(voxel_inferencer, "grid_infeStl143")

May you please suggest where I am doing wrong and the right way to do this.

Hi @IamARP

Can you check to see if some other VTI file can be viewed correctly in Paraview? For example, does the example in the post-processing section of the user guide work?

from modulus.domain.inferencer  import VoxelInferencer

# Define mask function, should be a callable with parameters being the variables
mask_fn = lambda x, y: x**2 + y**2 > 0.001

voxel_inferencer = VoxelInferencer(
    bounds = [[-width / 2, width / 2], [-height / 2, height / 2], [0, 0.1]],
    npoints = [128, 128, 128],
    nodes=nodes,
    output_names=["u", "v", "p"],
    export_map={"U": ["u", "v", None], "p": ["p"]},
    mask_fn = mask_fn,
    requires_grad=False,
    batch_size=1024,
)
ldc_domain.add_inferencer(voxel_inferencer, "vox_inf")

Thank you. Yes I can view VTI file properly in Paraview. I have tried with example available with Modulus Bracket (examples/bracket/bracket.py ) and done Post processing by taking reference from the post-processing section of the user guide. Attaching below image for your reference. But now I am trying to do post processing when I am using .stl file as input but not able to convert point cloud data to image based.

Hi @IamARP

Thanks for confirming. Now lets see if its just the SDF calculation for tesselation. In your example can you make the mask_fn just return false all the time.

def mask_fn(x, y, z):
   return false

Also in your examples VTI file, can you confirm that it indeed has the expected fields in it (despite it not being rendered correctly)?

Thank you. I have tried but it gives error.
My VoxelInferencer code :

Voxel interface

# add inferencer data
def mask_fnC(x, y, z):
    return False

voxel_inferencer = VoxelInferencer(
    bounds=[[-2, 2], [-2, 2], [-2, 2]],
    npoints=[256, 128, 256],
    nodes=nodes,
    output_names=["u", "v", "w", "sigma_xy", "sigma_xz", "sigma_zz"],
    export_map={"U": ["u", "v", "w"], "sigma_xx": ["sigma_xy"], "sigma_xz": ["sigma_xy"], "sigma_zz": ["sigma_zz"]},
    mask_fn=mask_fnC,
    requires_grad=False,
    batch_size=10000,
)
domain.add_inferencer(voxel_inferencer, "grid_infeStl314")

This gives following error :
Error executing job with overrides:
Traceback (most recent call last):
File “bracketSTL31.py”, line 372, in run
voxel_inferencer = VoxelInferencer(
File “/modulus/modulus/domain/inferencer/voxel.py”, line 81, in init
super().init(
File “/modulus/modulus/domain/inferencer/vtkpointwise.py”, line 84, in init
mask = np.squeeze(mask_fn(**mask_input).astype(np.bool))
AttributeError: ‘bool’ object has no attribute ‘astype’

Ah sorry , it needs to be a numpy array of false the same size of x I believe. In general, please try:

  • removing of disabling the mask function
  • changing the side of the domain (bounds)

Thank you.
Do you want me to do something like this, shown below? But this don’t work and this is not showing my geometry in point cloud format.

def mask_fnB(x, y, z):

voxel_inferencer = VoxelInferencer(
    bounds=[[-3, 3], [-3, 3], [-3, 3]],
    npoints=[256, 128, 256],
    nodes=nodes,
    output_names=["u", "v", "w", "sigma_xy", "sigma_xz", "sigma_zz"],
    export_map={"U": ["u", "v", "w"], "sigma_xx": ["sigma_xy"], "sigma_xz": ["sigma_xy"], "sigma_zz": ["sigma_zz"]},
    #mask_fn=mask_fnB,
    requires_grad=False,
    batch_size=10000,
)
domain.add_inferencer(voxel_inferencer, "grid_infeStl325")

When I have used Modulus library (modulus.geometry.primitives_3d) to define the geometry for reference example available with Modulus (example name: Bracket); and used VTKUniformGrid class, it converted the point cloud data to image/mesh based data.
But for .stl file as Input file, this VTKUniformGrid class is not working. So I changed this to, “VTKStructuredGrid”, but it gives me error when I defines its parameters like, “points:” & “dims:”
What do you suggest, using “VTKStructuredGrid” is the write way as this class is used for Data stored on a structured domain (This includes structured meshes with curved boundaries).
May you please tell me the correct way to use VTKStructuredGrid class, the correct way to defines it’s parameter, showing any example would be a great help.