Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Writing to VTK file #3

Closed
PJBunting opened this issue May 16, 2017 · 3 comments
Closed

Writing to VTK file #3

PJBunting opened this issue May 16, 2017 · 3 comments

Comments

@PJBunting
Copy link

I am in the process of adding the functionality to write results to a VTK unstructured grid (.vtu) format using vtk.vtkXMLPUnstructuredGridWriter(). So that I may view results in Paraview and do further post processing.

So far I have made small changes to the reader file to return the uGrid object and then write this to a file. However in paraview the only available data set are the node number. Indicating that I am unsuccessfully associating the data set with the uGrid object when writing to file.

Is this a functionality you are considering? Or something you be able to assist with?

@akaszynski
Copy link
Collaborator

akaszynski commented May 16, 2017 via email

@PJBunting
Copy link
Author

First I have added a return command to Reader.LoadCBD (return self.uGrid)
I have chosen to bypass Tests.Reader and include the DisplayResults in my main code.
So I have the following:

from pyansys import Tests
from pyansys import Reader
import vtk
from os.path import dirname, join, realpath
pth = dirname(realpath(file))

def DisplayResult():
fobj = Reader.ResultReader(join(pth, 'file.rst'))
ruGrid = fobj.LoadCDB(join(pth, 'HexBeam.cdb'))
fobj.PlotDisplacement(0)
return ruGrid

if name == 'main':
result = Reader.ResultReader('file.rst')
result.LoadCDB('HexBeam.cdb')
G = DisplayResult()
gw = vtk.vtkXMLPUnstructuredGridWriter()
gw.SetFileName('file.vtu')
gw.SetInputData(G)
gw.Write()

@akaszynski
Copy link
Collaborator

Just updated the code. See the example from the link below to save an archive file as a *.vtu file.
http://pyansys.readthedocs.io/en/latest/examples.html#loading-and-plotting-an-ansys-archive-file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants