The only thing I am trying to figure out now is how to get a smooth interpolation of a scalar field over the triangulation without having to specify a ridiculous number of levels in tricontourf as this gives me crazy big pdf files and takes a long time to create. In the end I was able to achieve the same things whether I use the vtkUnstructuredGridReader or the automatic one. Reader = OpenDataFile('my case.foam') #Creates OpenFoamReader objectĭata = servermanager.Fetch(reader) #Creates a vtkMultiBlockDataSet Your example was great - I was able to figure out what was different between my case and yours (however curiously your potentialFoam example only runs for one time step and when I do foamToVTK the resulting files cannot be read in your example script which is strange - I only mention it in case someone attempts to use it!)īasically what I was doing before was opening the file my 'case.foam' (this is the file that is created when you do paraFoam in the case folder) by vtk file ( I converted it with (c3d -o file. but there is a problem exemple : as you see in the picture 1 I couldn’t open the. I installed the ITK-SNAP and 3cd converter. Thank you very much for your effort and time. I am working with MRI Nifti dataset and I would convert it to. Any ideas what I could do with this? There must be some data contained in the vtkUnstructuredGrid object that tells me the mesh connectivity info. Creating the triangulation array as you have done above doesnt quite work for me I do aīut the resulting mesh is a mess and does not show my actual mesh. So surely I should be able to do this with python. With paraview its really easy to display the mesh and plot contourf plots of a field variable over it. The problem is I want to plot field variables like pressure, and then I need to know the mesh connectivity information. Then unpack like so:ĭata=servermanager.Fetch(reader) # vtkMultiBlockDataSetīlock0 = data.GetBlock(0) # vtkUnstructuredGridĪnd I can plot the points of my mesh by doingĪnd plotting these points. Reader = OpenDataFile("mysimulation.case") Basically I am trying to plot the mesh that I have computed my simulations on. ( Note: updated version of the script adapted for VTK 6.2.0 is posted here)Īnd as a result of this script we'll get this nice picture:Īnd here is a link to the genereated PDF. P.tricontour(x, y, tri, ux, levels, linestyles='-', X, y, tri, ux, uy = load_velocity('U-file.vtk') Tri = triangles.GetTuple(4*i + 3)įor i in xrange(points.GetNumberOfPoints()):įor i in xrange(0, Udata.GetNumberOfTuples()): If not os.path.exists(filename): return None Here is a script for loading a vector field and plotting its X component: Surely this script can be improved to handle vectors and scalars automatically, to handle polymesh files in more general way (currently I suppose, all polygons in the mesh are triangles). In Python, this script reads test.vti and saves test. Well, I guess this module is just a wrapper around C++ so one need to write C++-python instead of python. In ParaView: load your vti file, then in the File menu click 'Save Data.' and chose the image file format you prefer (I tested with PNG, it works). Though there's almost no documentation on python-vtk module. So I've decided to try plotting VTK file with a triangular grid. Also as OpenFOAM's sample utility will anyway create a triangulation of the mesh, why do it again. So if I have a file with (x, y, value) tuples, the hole will be also triangulated with a value equal to zero and a final tricontourf figure will be quite far from the original flow field. And then I can save it as a PDF (or EPS, or PS) so the figure can be scaled without quality loss.Įverything is good (though there's certain problems with matplotlib's triangulation sometimes) but in this case I had a hole in a flow field. So usually I used sample utility to write a slice of interest to a RAW file, then load it with numpy and then use tricontourf to produce color map of a value. But pictures produced by the software is in general raster (maybe I can't use it right but even if I build with gl2ps I can't find a way to export scene to PS or PDF). It works perfectly well in paraview, and I got the desired results, but I want to be able to understand how the entire data (the points and locations of the nodes, the material numbers for each, etc.) is stored.Paraview is good. I did all this to get a single file that contains the information about the nodes and the material numbers for all of them. Also, I chose the number of cuboids as 1. I removed everything else so that now the only file generated is the geometry_iT0000000C00000.vti file. I have cut the cylinder3d program down to the part where it outputs the voxel image only. Simulation of oblate particle suspensions in shearing flow.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |