walkersw / VTKwrite

Python package to write VTK files in XML format, including time series *without* PVD files
GNU General Public License v3.0
10 stars 4 forks source link

handling of Gauss points #3

Closed maozhuP closed 10 months ago

maozhuP commented 10 months ago

Thank for efforting this useful code. I'm using it to output my FE results to unstructured mesh and have been successfuly for nodal displacements. However, for stresses and strains which are defined at Gauss points inside elements, I'd like to know if there is a way to also output them using your code? I only found all_cell_data and all_point_data in the arguments of unstructuredGridToVTK function, and don't known how to deal with Gauss points. Or if extra work needs to be done, can you show me how to output values at Gauss points? I'm quite struggling with this.

walkersw commented 10 months ago

This isn't really an issue with my package. VTK (essentially) only plots piecewise linear data (point_data) and piecewise constant data (cell_data). Note: there is some support for piecewise quadratic in Paraview (for VTK).

If you want to plot "gradient data", which is what your strains are, you need to compute an L^2 projection of the strain to a piecewise constant FE space, then write that piecewise constant data to VTK. Of course, the strain and stress variables are really matrices, so you need to be careful here. VTK can do tensor valued data.

I suggest you google how other people visualize strains and stresses with VTK. All my package does is write numpy arrays to VTK format. There are examples showing this. It is up to you to make sure your data is consistently formatted.

maozhuP commented 10 months ago

This isn't really an issue with my package. VTK (essentially) only plots piecewise linear data (point_data) and piecewise constant data (cell_data). Note: there is some support for piecewise quadratic in Paraview (for VTK).

If you want to plot "gradient data", which is what your strains are, you need to compute an L^2 projection of the strain to a piecewise constant FE space, then write that piecewise constant data to VTK. Of course, the strain and stress variables are really matrices, so you need to be careful here. VTK can do tensor valued data.

I suggest you google how other people visualize strains and stresses with VTK. All my package does is write numpy arrays to VTK format. There are examples showing this. It is up to you to make sure your data is consistently formatted.

Your explaination is very helpful. I finally decided to extrapolate my data from Gauss points to nodes and average the nodal values. Thank you and happy new year.