barbagroup/PetIBM

Variable CaseDir is not updated

piyueh opened this issue · 5 comments

We recently moved all output files to the output directory, but it seems we forgot to change the value of CaseDir in XDMF files. At least on my computer, ParaView could not find corresponding HDF5 files because the paths are incorrect.

A temporary solution:

Before we fix the code, a temporary solution is to manually edit all XDMF files. In each XDMF file, there's a variable called CaseDir. The current value of CaseDir is .//output. This value means the location of HDF5 files relative to the location of XDMF files. Now all files are under the same directory, so the value of CaseDir should now be ./.

Hi, Piyueh,

As I have always been using body-fitted mesh for CFD simulation, this is the first time when I try to use an IBM code. So I'm a bit of confused how to remove the flow inside the body when visualize the flow field using ParaView. And add the geometry of the body in the visualization as well.

Many thanks.

Kind regards;

Guangyu

@shi-guangyu I think ParaView can add some simple geometries to the visualization, such as cylinders, disks, and spheres, though with limitations. For example, the orientations of cylinders from ParaView can only be in the y-direction. That means for our 2D cylinder flow examples, we are not able to use the cylinder geometry from ParaView (the cylinder orientation is z-direction in our simulation). So in this example, I probably will use a sphere to mask the cylinder. But as you can see from the figure, a sphere still looks different from a cylinder.
20200309-114804EDT

Another way around may be reading the original body mesh into ParaView. PetIBM does not need body mesh, so we don't have a body mesh for the cylinder in this simulation. But for more complicated geometries, usually, we have body mesh files from CAD software. Then, I believe ParaView can load the body mesh to mask the body.

In my workflow, I usually write my own Python scripts to read HDF5 files and do visualization directly, including masking immersed-boundary bodies. I think ParaView should be able to achieve the same thing, as ParaView also supports custom Python code during runtime. But I'm not familiar with this workflow, to be honest. @mesnardo any idea?

Hi, Pi-Yueh,

Thanks for your reply. So the general idea is to import the geometry file (if applicable) to mask the flow inside the body rather than somehow removing the inside flow from the flow field. Is it correct? Actually, this problem becomes more annoying if you want to generate an animation.

As you said, you prefer writing Python script for post processing. But from the 2D examples you provided, it seems you still keep the flow inside the cylinder. Is it possible to create some scripts to block the inside flow from showing up?

Thanks.

Guangyu

Yes, in the 2D cylinder example we didn't mask the flow inside the cylinder. To mask the flow inside the cylinder, for example, in plotVorticity.py, add either one of the following lines to the code before plotting:

wz = numpy.where((X**2+Y**2)<=0.25, float('nan'), wz)

or

wz = numpy.ma.masked_where((X**2+Y**2)<=0.25, wz)

Then we get
Figure_1
or if we replace ax.contour with ax.contourf
Figure_2

Users can write a Python script or C/C++ code to read solutions from HDF5 files, remove/mask data points, and then write the masked data back to the HDF5. Then ParaView should only show the physical flow data. ParaView itself supports runtime Python, so I guess there might also be a way to do the masking directly in ParaView with Python on the fly.

One issue of this approach is the algorithm to determine if a data point is outside or inside an object. In this example, it's easy to determine this, i.e., we use the logical operation X**2+Y**2<0.25. For more complicated 3D objects, it may require some algorithms to do so. That's why I usually just use a body geometry/mesh to "cover" the area in the figure and still keep the data of inside flow.

Thanks a lot for your explaination. Will open new issues if have more questions about complicated 3D geometries.

Kind regards;

Guangyu