The architecture of ParaView allows extending its functionality by creating plugins which can be loaded as dynamic libraries without recompiling ParaView.
The main mesh filetypes we are handling in our lab are
.ugrid
generated by AFLR3 and used widely within FUN3D,
.meshb
from INRIA Gamma Team and .su2
from the SU2 solver. Unfortunately there is no support for these from
Paraview. Fortunately there is documentation for creating readers (plugin
guides).
Here is the boilerplate for writting a reader for an unstructred grid based on the Paraview wiki.
#ifndef vtkUGRIDReader_h
#define vtkUGRIDReader_h
#include "vtkUnstructuredGridAlgorithm.h"
#include "vtkObjectFactory.h"
class vtkUGRIDReader : public vtkUnstructuredGridAlgorithm
{
public:
static vtkUGRIDReader* New();
vtkTypeMacro(vtkUGRIDReader,vtkUnstructuredGridAlgorithm);
void PrintSelf(ostream& os, vtkIndent indent) VTK_OVERRIDE;
vtkSetStringMacro(MeshFile);
vtkGetStringMacro(MeshFile);
protected:
vtkUGRIDReader();
~vtkUGRIDReader() VTK_OVERRIDE;
int RequestData(vtkInformation *, vtkInformationVector **, vtkInformationVector *) VTK_OVERRIDE;
private:
char* MeshFile;
vtkUGRIDReader(const vtkUGRIDReader&) VTK_DELETE_FUNCTION;
void operator=(const vtkUGRIDReader&) VTK_DELETE_FUNCTION;
};
#endif
The only important part is the RequestData
function which looks like that
int vtkUGRIDReader::RequestData( vtkInformation *vtkNotUsed(request),
vtkInformationVector **vtkNotUsed(inputVector),
vtkInformationVector *outputVector)
{
// get the info object
vtkInformation *outInfo = outputVector->GetInformationObject(0);
// get the output
vtkUnstructuredGrid *output = vtkUnstructuredGrid::SafeDownCast( outInfo->Get(vtkDataObject::DATA_OBJECT()));
if (!this->MeshFile)
{
vtkErrorMacro(<<"A File Name for the Mesh must be specified.");
return 0;
}
bool res = read_mesh(this->MeshFile,output);
output->Squeeze();
if (not res)
return 0;
return 1;
}
In the read_mesh
function we need to populate the output
pointer using a custom reader.
Below you may find the repository for each of the readers.
Update 2020.03.16
The code on github has been updated to support Paraview 5.8.0. There are some significant changes in the
way plugin are written and compiled within Paraview. The new documentation is here.
Compilation is now handled by the official paraview plugin builder
.