File: CellIntegrator.py

package info (click to toggle)
paraview 5.4.1%2Bdfsg4-3.1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 218,616 kB
  • sloc: cpp: 2,331,508; ansic: 322,365; python: 111,051; xml: 79,203; tcl: 47,013; yacc: 4,877; java: 4,438; perl: 3,238; sh: 2,920; lex: 1,908; f90: 748; makefile: 273; pascal: 228; objc: 83; fortran: 31
file content (85 lines) | stat: -rw-r--r-- 2,536 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
# Test the vtkCellIntegrator

from paraview import smtesting
import os
import os.path
import sys
import paraview
paraview.compatibility.major = 3
paraview.compatibility.minor = 4
from paraview import servermanager
from paraview import util

smtesting.ProcessCommandLineArguments()

servermanager.Connect()

file1 = os.path.join(smtesting.DataDir, "quadraticTetra01.vtu")
reader1 = servermanager.sources.XMLUnstructuredGridReader(FileName=file1)
reader1Output = servermanager.Fetch(reader1)

# General 3D cell
integVal = util.IntegrateCell(reader1Output, 0)
if integVal < 0.128 or integVal > 0.1285:
    print("ERROR: incorrect result for cell 0 of 1st dataset")
    sys.exit(1)

# General 2D cell
if util.IntegrateCell(reader1Output, 1) != 0.625:
    print("ERROR: incorrect result for cell 1 of 1st dataset")
    sys.exit(1)

file2 = os.path.join(smtesting.DataDir, "elements.vtu")
reader2 = servermanager.sources.XMLUnstructuredGridReader(FileName=file2)
reader2Output = servermanager.Fetch(reader2)

# Line
if util.IntegrateCell(reader2Output, 2) != 1.0:
    print("ERROR: incorrect result for cell 2 of 2nd dataset")
    sys.exit(1)

# Triangle
if util.IntegrateCell(reader2Output, 4) != 0.5:
    print("ERROR: incorrect result for cell 4 of 2nd dataset")
    sys.exit(1)

# Quad
if util.IntegrateCell(reader2Output, 6) != 1.0:
    print("ERROR: incorrect result for cell 6 of 2nd dataset")
    sys.exit(1)

# Pixel
if util.IntegrateCell(reader2Output, 7) != 1.0:
    print("ERROR: incorrect result for cell 7 of 2nd dataset")
    sys.exit(1)

# Tetrahedron
integVal = util.IntegrateCell(reader2Output, 8)
if integVal < 0.166 or integVal > 0.167:
    print("ERROR: incorrect result for cell 8 of 2nd dataset")
    sys.exit(1)

# Voxel
if util.IntegrateCell(reader2Output, 13) != 1.0:
    print("ERROR: incorrect result for cell 13 of 2nd dataset")
    sys.exit(1)

# Polygon
if util.IntegrateCell(reader2Output, 0) != 1.0:
    print("ERROR: incorrect result for cell 0 of 2nd dataset")
    sys.exit(1)

file3 = os.path.join(smtesting.DataDir, "blow.vtk")
reader3 = servermanager.sources.LegacyVTKFileReader(FileNames=file3)
reader3Output = servermanager.Fetch(reader3)

filter1 = servermanager.filters.DataSetSurfaceFilter(Input = reader3)

filter2 = servermanager.filters.Stripper(Input=filter1)
filter2Output = servermanager.Fetch(filter2)

# Triangle Strip
integVal = util.IntegrateCell(filter2Output, 200)
if integVal < 0.569 or integVal > 0.570:
    print("ERROR: incorrect result for cell 200 of 3rd dataset")
    sys.exit(1)