Implementing Programmable Filter ParaView in PyVista

,

Dear FEniCSx Users,
I am trying to port some Fenics Legacy 2019 code (from now on old code) into Fenicsx.
One of the operations the old code performs is to save the mesh in .pvd format. This is a minimal working example:

from ast import Expression from pyclbr import Function from fenics import * from math import * from mshr import * from dolfin import * #from scipy.integrate import dblquad #from scipy.interpolate import griddata #from ufl import Form, TestFunction, TrialFunction, inner, dx import sympy as sym import matplotlib.pyplot as plt import numpy as np import copy import os p1 = Point(0,0) p2 = Point(np.pi,1) nx = 64 ny = 64 mesh = RectangleMesh(p1,p2,nx,ny) file = File('MeshTest.pvd') file << mesh

After saving the mesh file in .pvd format, I import it onto ParaView and I apply the following programmable filter to convert the rectangula domain into a cylinder.

This kind of approach is way more amendable than the Cartesian approach for the mathematical analysis of models in elasticity.

from paraview import vtk import math R=1.0 H=math.pi pdi = self.GetUnstructuredGridInput() pdo = self.GetOutput() newPoints = vtk.vtkPoints() numPoints = pdi.GetNumberOfPoints() for i in range(0,numPoints): coord = pdi.GetPoint(i) x, y, z = coord[:3] s = R*cos(x) t = H*y z = -R*sin(x)+1.5 newPoints.InsertPoint(i, s, t, z) pdo.SetPoints(newPoints) print("Done!")

I would like to implement this programmable filter directly in PyVista, without having to resort to ParaView.

How would you recommend me to proceed?

Many thanks in advance.

This seems like a question more suited for

as it Seems like a question about pyvista functionality on unstructured grids (which dolfinx provides the input for)

1 Like

Thank you. I have just asked the pyvista board. Let’s see what they reply.