File size: 1,447 Bytes
07af0b5
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""Verify native exported fields and warp the actual negative branch."""
import json,sys
from pathlib import Path
from paraview.simple import OpenDataFile,UpdatePipeline,WarpByVector,Delete
root=Path(sys.argv[1]);checks=[]
for relative in ['paraview/native_agentfem_fig9.pvd','xdmf/native_agentfem_fig9.xdmf']:
    source=OpenDataFile(str(root/relative));UpdatePipeline(proxy=source)
    times=list(source.TimestepValues)
    assert len(times)==3
    frames=[]
    for t in times:
        source.UpdatePipeline(t)
        assert 'U' in source.PointData.keys()
        # XDMF readers may expose scalar DG0 grids as blocks; the single-geometry
        # guarantee is specifically tested for the PVD delivery.
        assert 'MISES' in source.CellData.keys()
        assert 'MICROFORCE_POTENTIAL' in source.CellData.keys()
        assert source.GetDataInformation().GetNumberOfCells()==400
        warp=WarpByVector(Input=source);warp.Vectors=['POINTS','U'];warp.ScaleFactor=1
        warp.UpdatePipeline(t);bounds=list(warp.GetDataInformation().GetBounds())
        assert bounds[2]<-.05
        frames.append(dict(case_index=t,points=warp.GetDataInformation().GetNumberOfPoints(),cells=warp.GetDataInformation().GetNumberOfCells(),warped_bounds=bounds))
        Delete(warp)
    checks.append(dict(file=relative,frames=frames));Delete(source)
(root/'paraview_checks.json').write_text(json.dumps(checks,indent=2));print(json.dumps(checks,indent=2))