better have tests
This commit is contained in:
parent
0805445ea8
commit
56b011aa54
|
@ -1517,7 +1517,7 @@ class Result:
|
||||||
|
|
||||||
One VTK file per visible increment is created.
|
One VTK file per visible increment is created.
|
||||||
For point data, the VTK format is poly data (.vtp).
|
For point data, the VTK format is poly data (.vtp).
|
||||||
For cell data, either a rectilinear (.vtr) or unstructured (.vtu) dataset
|
For cell data, either an image (.vti) or unstructured (.vtu) dataset
|
||||||
is written for grid-based or mesh-based simulations, respectively.
|
is written for grid-based or mesh-based simulations, respectively.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
|
|
|
@ -8,6 +8,7 @@ import hashlib
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
|
import vtk
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
from damask import Result
|
from damask import Result
|
||||||
|
@ -410,10 +411,27 @@ class TestResult:
|
||||||
single_phase.add_calculation(f"np.ones(np.shape(#F#)[0:1]+{shape[1]},'{dtype}')",f'{shape[0]}_{dtype}')
|
single_phase.add_calculation(f"np.ones(np.shape(#F#)[0:1]+{shape[1]},'{dtype}')",f'{shape[0]}_{dtype}')
|
||||||
fname = os.path.splitext(os.path.basename(single_phase.fname))[0]+'.xdmf'
|
fname = os.path.splitext(os.path.basename(single_phase.fname))[0]+'.xdmf'
|
||||||
os.chdir(tmp_path)
|
os.chdir(tmp_path)
|
||||||
|
|
||||||
single_phase.save_XDMF()
|
single_phase.save_XDMF()
|
||||||
|
single_phase.view('increments',0).save_VTK()
|
||||||
|
|
||||||
|
reader_xdmf = vtk.vtkXdmfReader()
|
||||||
|
reader_xdmf.SetFileName(fname)
|
||||||
|
reader_xdmf.Update()
|
||||||
|
dim_xdmf = reader_xdmf.GetOutput().GetDimensions()
|
||||||
|
bounds_xdmf = reader_xdmf.GetOutput().GetBounds()
|
||||||
|
|
||||||
|
reader_vti = vtk.vtkXMLImageDataReader()
|
||||||
|
reader_vti.SetFileName(os.path.splitext(fname)[0]+'_inc00.vti')
|
||||||
|
reader_vti.Update()
|
||||||
|
dim_vti = reader_vti.GetOutput().GetDimensions()
|
||||||
|
bounds_vti = reader_vti.GetOutput().GetBounds()
|
||||||
|
|
||||||
if update:
|
if update:
|
||||||
shutil.copy(tmp_path/fname,ref_path/fname)
|
shutil.copy(tmp_path/fname,ref_path/fname)
|
||||||
assert sorted(open(tmp_path/fname).read()) == sorted(open(ref_path/fname).read()) # XML is not ordered
|
|
||||||
|
assert dim_vti == dim_xdmf and bounds_vti == bounds_xdmf and \
|
||||||
|
sorted(open(tmp_path/fname).read()) == sorted(open(ref_path/fname).read()) # XML is not ordered
|
||||||
|
|
||||||
def test_XDMF_invalid(self,default):
|
def test_XDMF_invalid(self,default):
|
||||||
with pytest.raises(TypeError):
|
with pytest.raises(TypeError):
|
||||||
|
|
Loading…
Reference in New Issue