Issues with Modulus VTK postprocessing

Hello,
I am currently using modulus to solve conjudate heat transfer problems.
Can anyone show me how to visualize the output variables such as “u”,
“v”, “w”, “p” and “temperature” in the flow region and solid region separately?

It would be great if someone can give me an example of using vtk to save all the variables to a mesh. I have looked into the PointVTKInferencer, but it gives me errors because of the mask functon definition. Can I just save all the variables such as x, y, z, u, v, w, p, t all together to a vtk file and visualize the output?

Hi @cxi1

We have some documentation on using the VTK exporters in our user guide. It would probably be easiest to create two meshes, one for the flow and one solid region, then load these into two separate inferencers. This will generate two VTK filea you can then load together in Paraview and have a good level of control when visualizing.

The VoxelInferencer, works when you dont have a mesh to sample from and is pretty easy to use if you know a bounding box.

I have looked into the PointVTKInferencer, but it gives me errors because of the mask function definition.

I would need some additional details about the error you are seeing. The mask function is a callable that should take the input spacial coordinates then returns a boolean value. On false, the values stored in the VTK point will be set to NaN which can be filtered out in Paraview (see the bottom of the docs here. for example).

Hi @ngeneva ,
Regarding the three_fin_3d example, how to create 2 meshes for the flow and the heat sink?
For example, if the heat sink is created using the primitives geometry, but it only gives me point cloud instead of mesh, right? Also I saw all the contraints are saved as vtp file in the example, when I open it in paraview, it also shows the point cloud instead of mesh.

Is there a way to convert these vtp files to vtk files and visualize them within a mesh? I saw some examples have some yaml config settings such as “save_filetype =vtk”, will that help with the mesh postprocessing? Or should I create a mesh using other CAD software?

Thank you,
Ce

You would need to define a mesh for the heat sink ahead of time. Continuous geometry does not have a mesh representation (its continuous), so a mesh doesn’t exist for it in this example.

You have two options: use the Voxel inferencer for a solid representation or two run a mesh generation filter on the point cloud (Delaunay 3D filter in Paraview).

Just as a head up Delaunay filters require tuning, can be expensive to run and / or completely fail.

@ngeneva
Great tips, I will give it a try for both of the options.

# add inferencer data
vtk_obj = VTKUniformGrid(
    bounds=[limerock.geo_bounds[x], limerock.geo_bounds[y], limerock.geo_bounds[z]],
    npoints=[256, 128, 256],
    export_map={"u": ["u", "v", "w"], "p": ["p"], "theta_f": ["theta_f"]},
)

def mask_fn(x, y, z):
    sdf = limerock.geo.sdf({"x": x, "y": y, "z": z}, {})
    return sdf["sdf"] < 0

grid_inferencer = PointVTKInferencer(
    vtk_obj=vtk_obj,
    nodes=thermal_nodes,
    input_vtk_map={"x": "x", "y": "y", "z": "z"},
    output_names=["u", "v", "w", "p", "theta_f"],
    mask_fn=mask_fn,
    mask_value=np.nan,
    requires_grad=False,
    batch_size=100000,
)
cycle_1_domain.add_inferencer(grid_inferencer, "grid_inferencer")

add solid inferencer data

vtk_obj = VTKUniformGrid(
    bounds=[
        limerock.geo_hr_bounds[x],
        limerock.geo_hr_bounds[y],
        limerock.geo_hr_bounds[z],
    ],
    npoints=[128, 128, 512],
    export_map={"theta_s": ["theta_s"]},
)

def mask_fn(x, y, z):
    sdf = limerock.geo.sdf({"x": x, "y": y, "z": z}, {})
    return sdf["sdf"] > 0

grid_inferencer = PointVTKInferencer(
    vtk_obj=vtk_obj,
    nodes=thermal_nodes,
    input_vtk_map={"x": "x", "y": "y", "z": "z"},
    output_names=["theta_s"],
    mask_fn=mask_fn,
    mask_value=np.nan,
    requires_grad=False,
    batch_size=100000,
)
cycle_n_domain.add_inferencer(grid_inferencer, "grid_inferencer_solid")

Hi @ngeneva ,
Above is the code for postprocessing of limerock case, which create a grid_inferencer for the limerock and the solid part. But after I opened the vti file in paraview, it only gives me a whole square domain.
Basically I wanna conduct inference on the fluid and solid region separately, do the codes above mean the same intention? If so, how to do with this whole bounding box? will it only show the heat sink region by some filter in paraview?

Hi @ngeneva ,
BTW, Do you know how to define the source term in modulus heat transfer example?
If I have a chip that has power of 250w, how to impose it in modulus? I notice the source
term in modulus are of the unit K/m, how to do the conversion to make it correct?
And also the three fin examples are insulated at the wall, what if I want to set up some
film coefficient of h to it to consider the air convection? How should I change the temp_grad_norm at the wall?

And I found a strange thing in my code. I define the inlet temp = 300 C, outlet gradnorm = 0, and insulation at all the other walls. But when I monitor the chip temperature, it’s the same as the fluid inlet temperature of 300 C. I impose a 400k/m at the heat sink bottom, it should give me a different temperature instead of the same as fluid?
I don’t know what happened to my setup.