Nektar++
FilterPython_Class.py
Go to the documentation of this file.
1import vtk, sys
2
3from NekPy.SolverUtils import Filter
4from NekPy.FieldUtils import Field, OutputModule
5
6class TestVTKFilter(Filter):
7 def __init__(self, session, eqsys, params):
8 # Call super's constructor.
9 super(TestVTKFilter, self).__init__(session, eqsys)
10
11 self.field = Field([], force_output=True)
12 self.num = 0
13 self.module = OutputModule.Create(
14 "vtu", self.field, outfile="output_0.vtu")
15
16 def Initialise(self, fields, time):
17 self.field.SetupFromExpList(fields)
18
19 def Update(self, fields, time):
20 self.num += 1
21 if self.num % 10 != 0:
22 return
23
24 self.field.SetupFromExpList(fields)
25 self.module.RegisterConfig("outfile", "output_%03d.vtu" % (self.num / 10, ))
26 self.module.Run()
27
28 def Finalise(self, fields, time):
29 # Print for testing purposes
30 sys.stdout.write("TestVTKFilter: %d\n" % self.num)
31 sys.stdout.flush()
32
33 def IsTimeDependent(self):
34 return True
35
36# Register filter with factory.
37Filter.Register("TestVTKFilter", TestVTKFilter)
def Initialise(self, fields, time)
def Finalise(self, fields, time)
def __init__(self, session, eqsys, params)
def Update(self, fields, time)