HaomingLuo's picture
Release v0.1 verified programmable rod data and native FE checks
07af0b5 verified
Raw History Blame Contribute Delete
1.45 kB
"""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))