Nektar++
FilterPython_Function.py
Go to the documentation of this file.
1import vtk, sys
2from NekPy.FieldUtils import Field, OutputModule
3
4field = Field([], force_output=True)
5output_num = 0
6output_vtk = None
7
8def filter_initialise(fields, time):
9 # Generally this is bad form but we're doing this for proof of concept!!
10 global field, output_vtk
11
12 field.SetupFromExpList(fields)
13 output_vtk = OutputModule.Create("vtu", field, outfile="output_0.vtu")
14
15def filter_update(fields, time):
16 global field, output_num, output_vtk
17
18 output_num += 1
19 if output_num % 10 != 0:
20 return
21
22 field.SetupFromExpList(fields)
23
24 output_vtk.RegisterConfig("outfile", "output_%03d.vtu" % (output_num / 10, ))
25 output_vtk.Run()
26
27 # now here you could e.g. extract a slice using VTK and then dump it out
28 # to a file instead of dumping whole file, or do whatever postprocessing
29 # you would like to
30
31def filter_finalise(fields, time):
32 # print out for testing!
33 sys.stdout.write("FilterPython_Function: %d\n" % output_num)
34 sys.stdout.flush()
def filter_initialise(fields, time)
def filter_update(fields, time)
def filter_finalise(fields, time)