renamed VTK.write() to VTK.to_file()
This commit is contained in:
parent
e3f310fa16
commit
3f24d16603
|
@ -513,7 +513,7 @@ class Geom:
|
||||||
v.add(self.microstructure.flatten(order='F'),'materialpoint')
|
v.add(self.microstructure.flatten(order='F'),'materialpoint')
|
||||||
|
|
||||||
if fname:
|
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:
|
else:
|
||||||
sys.stdout.write(v.__repr__())
|
sys.stdout.write(v.__repr__())
|
||||||
|
|
||||||
|
|
|
@ -1264,4 +1264,4 @@ class Result:
|
||||||
u = self.read_dataset(self.get_dataset_location('u_n' if mode.lower() == 'cell' else 'u_p'))
|
u = self.read_dataset(self.get_dataset_location('u_n' if mode.lower() == 'cell' else 'u_p'))
|
||||||
v.add(u,'u')
|
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)}')
|
||||||
|
|
|
@ -165,7 +165,7 @@ class VTK:
|
||||||
def _write(writer):
|
def _write(writer):
|
||||||
"""Wrapper for parallel writing."""
|
"""Wrapper for parallel writing."""
|
||||||
writer.Write()
|
writer.Write()
|
||||||
def write(self,fname,parallel=True):
|
def to_file(self,fname,parallel=True):
|
||||||
"""
|
"""
|
||||||
Write to file.
|
Write to file.
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ class TestGeom:
|
||||||
|
|
||||||
def test_invalid_vtr(self,tmpdir):
|
def test_invalid_vtr(self,tmpdir):
|
||||||
v = VTK.from_rectilinearGrid(np.random.randint(5,10,3)*2,np.random.random(3) + 1.0)
|
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):
|
for _ in range(10):
|
||||||
time.sleep(.2)
|
time.sleep(.2)
|
||||||
if os.path.exists(tmpdir/'no_materialpoint.vtr'): break
|
if os.path.exists(tmpdir/'no_materialpoint.vtr'): break
|
||||||
|
|
|
@ -21,7 +21,7 @@ class TestVTK:
|
||||||
origin = np.random.random(3)
|
origin = np.random.random(3)
|
||||||
v = VTK.from_rectilinearGrid(grid,size,origin)
|
v = VTK.from_rectilinearGrid(grid,size,origin)
|
||||||
string = v.__repr__()
|
string = v.__repr__()
|
||||||
v.write(tmp_path/'rectilinearGrid',False)
|
v.to_file(tmp_path/'rectilinearGrid',False)
|
||||||
vtr = VTK.from_file(tmp_path/'rectilinearGrid.vtr')
|
vtr = VTK.from_file(tmp_path/'rectilinearGrid.vtr')
|
||||||
with open(tmp_path/'rectilinearGrid.vtk','w') as f:
|
with open(tmp_path/'rectilinearGrid.vtk','w') as f:
|
||||||
f.write(string)
|
f.write(string)
|
||||||
|
@ -32,7 +32,7 @@ class TestVTK:
|
||||||
points = np.random.rand(100,3)
|
points = np.random.rand(100,3)
|
||||||
v = VTK.from_polyData(points)
|
v = VTK.from_polyData(points)
|
||||||
string = v.__repr__()
|
string = v.__repr__()
|
||||||
v.write(tmp_path/'polyData',False)
|
v.to_file(tmp_path/'polyData',False)
|
||||||
vtp = VTK.from_file(tmp_path/'polyData.vtp')
|
vtp = VTK.from_file(tmp_path/'polyData.vtp')
|
||||||
with open(tmp_path/'polyData.vtk','w') as f:
|
with open(tmp_path/'polyData.vtk','w') as f:
|
||||||
f.write(string)
|
f.write(string)
|
||||||
|
@ -51,7 +51,7 @@ class TestVTK:
|
||||||
connectivity = np.random.choice(np.arange(n),n,False).reshape(-1,n)
|
connectivity = np.random.choice(np.arange(n),n,False).reshape(-1,n)
|
||||||
v = VTK.from_unstructuredGrid(nodes,connectivity,cell_type)
|
v = VTK.from_unstructuredGrid(nodes,connectivity,cell_type)
|
||||||
string = v.__repr__()
|
string = v.__repr__()
|
||||||
v.write(tmp_path/'unstructuredGrid',False)
|
v.to_file(tmp_path/'unstructuredGrid',False)
|
||||||
vtu = VTK.from_file(tmp_path/'unstructuredGrid.vtu')
|
vtu = VTK.from_file(tmp_path/'unstructuredGrid.vtu')
|
||||||
with open(tmp_path/'unstructuredGrid.vtk','w') as f:
|
with open(tmp_path/'unstructuredGrid.vtk','w') as f:
|
||||||
f.write(string)
|
f.write(string)
|
||||||
|
@ -64,8 +64,8 @@ class TestVTK:
|
||||||
v = VTK.from_polyData(points)
|
v = VTK.from_polyData(points)
|
||||||
fname_s = tmp_path/'single.vtp'
|
fname_s = tmp_path/'single.vtp'
|
||||||
fname_p = tmp_path/'parallel.vtp'
|
fname_p = tmp_path/'parallel.vtp'
|
||||||
v.write(fname_s,False)
|
v.to_file(fname_s,False)
|
||||||
v.write(fname_p,True)
|
v.to_file(fname_p,True)
|
||||||
for i in range(10):
|
for i in range(10):
|
||||||
if os.path.isfile(fname_p) and filecmp.cmp(fname_s,fname_p):
|
if os.path.isfile(fname_p) and filecmp.cmp(fname_s,fname_p):
|
||||||
assert(True)
|
assert(True)
|
||||||
|
@ -105,4 +105,3 @@ class TestVTK:
|
||||||
else:
|
else:
|
||||||
reference = VTK.from_file(reference_dir/'rectilinearGrid.vtr')
|
reference = VTK.from_file(reference_dir/'rectilinearGrid.vtr')
|
||||||
assert rectilinearGrid.__repr__() == reference.__repr__()
|
assert rectilinearGrid.__repr__() == reference.__repr__()
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue