barbagroup/PetIBM

Error of generateVTKFiles.py for 3D cases

frankyugit opened this issue · 1 comments

For post-processing, the python script generateVTKFiles.py works quite for several 2D cases, but when comes to 3D cases, some error got caught
My test python version is python2.7, test cases are the examples, cylinder and lidDrivenCavity. Here are the error messages

XXX/petibm/petibm-linux-dbg/examples/3d/lidDrivenCavity/Re100PeriodicX
[variables] ['velocity', 'pressure']
Read the mesh grid ...
Read the velocity field at time-step 500 ...
Traceback (most recent call last):
File "/home/yu/petibm/PetIBM/scripts/python/generateVTKFiles.py", line 120, in
main()
File "/home/yu/petibm/PetIBM/scripts/python/generateVTKFiles.py", line 103, in main
periodic=args.periodic)
File "/home/yu/petibm/PetIBM/scripts/python/ioPetIBM.py", line 118, in read_velocity
qx = qx.reshape((nz, ny, (nx if 'x' in periodic else nx-1)))
ValueError: total size of new array must be unchanged

XXX/petibm/petibm-linux-dbg/examples/3d/cylinder/Re40
[variables] ['velocity', 'pressure']
Read the mesh grid ...
Read the velocity field at time-step 10 ...
Traceback (most recent call last):
File "/home/yu/petibm/PetIBM/scripts/python/generateVTKFiles.py", line 120, in
main()
File "/home/yu/petibm/PetIBM/scripts/python/generateVTKFiles.py", line 103, in main
periodic=args.periodic)
File "/home/yu/petibm/PetIBM/scripts/python/ioPetIBM.py", line 133, in read_velocity
qz = qz.reshape(((nz if 'z' in periodic else nz-1), ny, nx))
ValueError: total size of new array must be unchanged

I think you have to pass the list of directions where periodic boundary conditions apply. (The number of points in each direction for a field variable depends on the type of boundary conditions used.)

For the 3D lid-driven cavity example with periodic boundary conditions in the x-direction, you should call the script like this:

python $PETIBM_DIR/scripts/python/generateVTKFiles.py --periodic x

For the 3D cylinder example:

python $PETIBM_DIR/scripts/python/generateVTKFiles.py --periodic z