ansys / pymapdl

Pythonic interface to MAPDL
https://mapdl.docs.pyansys.com
MIT License
433 stars 121 forks source link

Writing to VTK file #3

Closed PJBunting closed 7 years ago

PJBunting commented 7 years ago

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 commented 7 years ago

More than willing to help. I actually have modified it on my end for a different project.

Send me what you have and I'll see what I can do.

On Tue 16. May 2017 at 16:32, PJBunting notifications@github.com wrote:

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?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/akaszynski/pyansys/issues/3, or mute the thread https://github.com/notifications/unsubscribe-auth/ALbTP757JzYzSa54Pd56TyQqxHI5_xqsks5r6bNigaJpZM4NclxN .

--

  • Alex
PJBunting commented 7 years ago

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 commented 7 years ago

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