renamed VTK.write() to VTK.to_file()

This commit is contained in:
Philip Eisenlohr 2020-08-26 16:15:15 -04:00
parent e3f310fa16
commit 3f24d16603
5 changed files with 9 additions and 10 deletions

View File

@ -513,7 +513,7 @@ class Geom:
v.add(self.microstructure.flatten(order='F'),'materialpoint')
if fname:
v.write(fname if str(fname).endswith('.vtr') else str(fname)+'.vtr')
v.to_file(fname if str(fname).endswith('.vtr') else str(fname)+'.vtr')
else:
sys.stdout.write(v.__repr__())

View File

@ -1264,4 +1264,4 @@ class Result:
u = self.read_dataset(self.get_dataset_location('u_n' if mode.lower() == 'cell' else 'u_p'))
v.add(u,'u')
v.write(f'{self.fname.stem}_inc{inc[3:].zfill(N_digits)}')
v.to_file(f'{self.fname.stem}_inc{inc[3:].zfill(N_digits)}')

View File

@ -165,7 +165,7 @@ class VTK:
def _write(writer):
"""Wrapper for parallel writing."""
writer.Write()
def write(self,fname,parallel=True):
def to_file(self,fname,parallel=True):
"""
Write to file.

View File

@ -80,7 +80,7 @@ class TestGeom:
def test_invalid_vtr(self,tmpdir):
v = VTK.from_rectilinearGrid(np.random.randint(5,10,3)*2,np.random.random(3) + 1.0)
v.write(tmpdir/'no_materialpoint.vtr')
v.to_file(tmpdir/'no_materialpoint.vtr')
for _ in range(10):
time.sleep(.2)
if os.path.exists(tmpdir/'no_materialpoint.vtr'): break

View File

@ -21,7 +21,7 @@ class TestVTK:
origin = np.random.random(3)
v = VTK.from_rectilinearGrid(grid,size,origin)
string = v.__repr__()
v.write(tmp_path/'rectilinearGrid',False)
v.to_file(tmp_path/'rectilinearGrid',False)
vtr = VTK.from_file(tmp_path/'rectilinearGrid.vtr')
with open(tmp_path/'rectilinearGrid.vtk','w') as f:
f.write(string)
@ -32,7 +32,7 @@ class TestVTK:
points = np.random.rand(100,3)
v = VTK.from_polyData(points)
string = v.__repr__()
v.write(tmp_path/'polyData',False)
v.to_file(tmp_path/'polyData',False)
vtp = VTK.from_file(tmp_path/'polyData.vtp')
with open(tmp_path/'polyData.vtk','w') as f:
f.write(string)
@ -51,7 +51,7 @@ class TestVTK:
connectivity = np.random.choice(np.arange(n),n,False).reshape(-1,n)
v = VTK.from_unstructuredGrid(nodes,connectivity,cell_type)
string = v.__repr__()
v.write(tmp_path/'unstructuredGrid',False)
v.to_file(tmp_path/'unstructuredGrid',False)
vtu = VTK.from_file(tmp_path/'unstructuredGrid.vtu')
with open(tmp_path/'unstructuredGrid.vtk','w') as f:
f.write(string)
@ -64,8 +64,8 @@ class TestVTK:
v = VTK.from_polyData(points)
fname_s = tmp_path/'single.vtp'
fname_p = tmp_path/'parallel.vtp'
v.write(fname_s,False)
v.write(fname_p,True)
v.to_file(fname_s,False)
v.to_file(fname_p,True)
for i in range(10):
if os.path.isfile(fname_p) and filecmp.cmp(fname_s,fname_p):
assert(True)
@ -105,4 +105,3 @@ class TestVTK:
else:
reference = VTK.from_file(reference_dir/'rectilinearGrid.vtr')
assert rectilinearGrid.__repr__() == reference.__repr__()