[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Getfem-commits] (no subject)
From: |
Tetsuo Koyama |
Subject: |
[Getfem-commits] (no subject) |
Date: |
Sat, 3 Oct 2020 20:45:54 -0400 (EDT) |
branch: devel-tetsuo-xml-binary
commit 92740add6633c70d01101ecad7bd9c32b9632f0e
Author: Tetsuo Koyama <tkoyama010@gmail.com>
AuthorDate: Sat May 30 13:25:15 2020 +0000
Add tests for VTK(XML) in check_export.py
---
interface/tests/python/check_export.py | 41 ++++++++++++++++++++++++++++++++++
requirements.txt | 1 +
2 files changed, 42 insertions(+)
diff --git a/interface/tests/python/check_export.py
b/interface/tests/python/check_export.py
index 2102019..7409a44 100644
--- a/interface/tests/python/check_export.py
+++ b/interface/tests/python/check_export.py
@@ -28,6 +28,8 @@
"""
import numpy as np
+import vtk
+
import getfem as gf
m0 = gf.Mesh('cartesian',[0,1,2,3],[0,1,2],[-3,-2])
@@ -77,6 +79,45 @@ mf0.export_to_vtk('check_export2.vtk','ascii')
mf1.export_to_vtk('check_export3.vtk','ascii')
+reader = vtk.vtkUnstructuredGridReader()
+reader.SetFileName('check_export1.vtk')
+reader.Update()
+output = reader.GetOutput()
+cell_data = output.GetCellData()
+assert output.GetNumberOfPoints() == m1.nbpts(), 'Number of points is not
correct.'
+assert output.GetNumberOfCells() == m1.nbcvs(), 'Number of cells is not
correct.'
+array_name = cell_data.GetArrayName(0)
+assert cell_data.GetArrayName(0) == "convex_quality", 'Cell data name is not
correct.'
+
+reader = vtk.vtkUnstructuredGridReader()
+reader.SetFileName('check_export3.vtk')
+reader.Update()
+output = reader.GetOutput()
+assert output.GetNumberOfPoints() == m1.nbpts(), 'Number of points is not
correct.'
+assert output.GetNumberOfCells() == m1.nbcvs(), 'Number of cells is not
correct.'
+
+# VTK(XML):
+m0.export_to_vtu('check_export0.vtu','quality')
+m1.export_to_vtu('check_export1.vtu','quality')
+mf0.export_to_vtu('check_export2.vtu','ascii')
+mf1.export_to_vtu('check_export3.vtu','ascii')
+
+reader = vtk.vtkXMLUnstructuredGridReader()
+reader.SetFileName('check_export1.vtu')
+reader.Update()
+output = reader.GetOutput()
+cell_data = output.GetCellData()
+assert output.GetNumberOfPoints() == m1.nbpts(), 'Number of points is not
correct.'
+assert output.GetNumberOfCells() == m1.nbcvs(), 'Number of cells is not
correct.'
+array_name = cell_data.GetArrayName(0)
+assert cell_data.GetArrayName(0) == "convex_quality", 'Cell data name is not
correct.'
+
+reader = vtk.vtkXMLUnstructuredGridReader()
+reader.SetFileName('check_export3.vtu')
+reader.Update()
+output = reader.GetOutput()
+assert output.GetNumberOfPoints() == m1.nbpts(), 'Number of points is not
correct.'
+assert output.GetNumberOfCells() == m1.nbcvs(), 'Number of cells is not
correct.'
# DX:
try:
diff --git a/requirements.txt b/requirements.txt
index 358da32..13536d5 100644
--- a/requirements.txt
+++ b/requirements.txt
@@ -1,3 +1,4 @@
numpy
scipy
Sphinx
+vtk
- [Getfem-commits] [getfem-commits] branch devel-tetsuo-xml-binary created (now fa91962), Tetsuo Koyama, 2020/10/03
- [Getfem-commits] (no subject),
Tetsuo Koyama <=
- [Getfem-commits] (no subject), Tetsuo Koyama, 2020/10/03
- [Getfem-commits] (no subject), Tetsuo Koyama, 2020/10/03
- [Getfem-commits] (no subject), Tetsuo Koyama, 2020/10/03
- [Getfem-commits] (no subject), Tetsuo Koyama, 2020/10/03
- [Getfem-commits] (no subject), Tetsuo Koyama, 2020/10/03
- [Getfem-commits] (no subject), Tetsuo Koyama, 2020/10/03
- [Getfem-commits] (no subject), Tetsuo Koyama, 2020/10/03
- [Getfem-commits] (no subject), Tetsuo Koyama, 2020/10/03
- [Getfem-commits] (no subject), Tetsuo Koyama, 2020/10/03
- [Getfem-commits] (no subject), Tetsuo Koyama, 2020/10/03