villaking.blogg.se

Mnist for paraview
Mnist for paraview












mnist for paraview

In this case, the GUI (string list) must be defined through raw XML format. """ ) def SetFileFormat ( self, file_format ). stringvector ( name = "FileFormat", number_of_elements = "1" ) smdomain. stringvector ( name = "StringInfo", information_only = "1" ) def GetStrings ( self ): return meshio_input_filetypes smproperty. The connection between ParaView VTK objects and pure Python is achieved by vtkmodules.numpy_interface.dataset_adapter. Later on we only need to carefully wrap the mesh object into the ParaView-desired output outInfo. The amazing part of this Python approach is that the meshio library can be directly used to do the dirtiest work (through meshio.read) of actually reading the mesh file. SetCells ( cell_types, cell_offsets, cell_conn ) # cell connectivities _file_format ) # Produce ParaView output from mesh To declare this class as an effective reader usable under ParaView, it has to be decorated by ParaView functions.įrom vtkmodules.numpy_interface import dataset_adapter as dsa from vtkmodules.vtkCommonDataModel import vtkUnstructuredGrid def RequestData ( self, request, inInfo, outInfo ): # Use meshio to read the mesh Until now, only VTK objects are involved ( VTKPythonAlgorithmBase is in fact defined by VTK). In this case, as a generic mesh format reader, no inputs are required (so you do not need to select an existing object in ParaView before using this plugin to open a file), and it only returns 1 object as a vtkUnstructuredGrid, an unstructured mesh defined by points coordinates and cell connectivities (as meshio reads and writes). This input / output meta-informaton is needed to initialize the class. Take an or several inputs but do not produce additional data a “filter” performs some operation to inputs and generates the results. A “source” or “reader” do not require inputs, but produce some outputs a “writer” Each operation can be characterized by the number of inputs and the number of outputs. If you are familiar with ParaView or VTK, you know that post-processing of the input data is organized through pipeline. _init_ ( self, nInputPorts = 0, nOutputPorts = 1, outputType = "vtkUnstructuredGrid" ). For reading or writing a mesh file foo, simply useįrom import VTKPythonAlgorithmBase class meshioReader ( VTKPythonAlgorithmBase ): def _init_ ( self ): VTKPythonAlgorithmBase. Directly Python processing is also possible without the use of salome environment. With the MED interface of meshio, these results files can now be converted to a more generic format readable directly by ParaView, like XDMF or VTU. The finite element result produced by code_aster is a MED file and in general requires the rather fatty salome platform for visualization and post-processing. Meshio is a Python library that reads and writes various frequently-used mesh formats: XDMF, VTK, gmsh, Abaqus…Personnally since 2018 I’m actively involved in this project especially for the MED format.

Mnist for paraview code#

The code source of this plugin is available on Github. In this post, I will illustrate the development of such Python plugins via the example of a generic mesh format reader, with the help of meshio. With the newly introduced native VTKPythonAlgorithmBase interface, it is no longer necessary. For generating such XML files, I used a Python package pvpyfilter. Previously before 5.6 only plugins defined by a XML file (or compiled library files) can be loaded. These plugins can then be loaded through Tools / Manage Plugins / Load New under ParaView and can be served as custom sources, readers, writers and filters. Recently I discoved the Python VTKPythonAlgorithmBase interface introduced in the ParaView 5.6 version for defining user plugins with pure Python files. Generic mesh readers under ParaView via the new Python interface














Mnist for paraview