polishing
This commit is contained in:
parent
d6995d780b
commit
db1882e4de
|
@ -108,6 +108,10 @@ class ConfigMaterial(Config):
|
||||||
and grain- or cell-wise data. Defaults to None, in which case
|
and grain- or cell-wise data. Defaults to None, in which case
|
||||||
it is set as the path that contains _SIMPL_GEOMETRY/SPACING.
|
it is set as the path that contains _SIMPL_GEOMETRY/SPACING.
|
||||||
|
|
||||||
|
Notes
|
||||||
|
-----
|
||||||
|
Homogenization and phase entries are emtpy and need to be defined separately.
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
loaded : damask.ConfigMaterial
|
loaded : damask.ConfigMaterial
|
||||||
|
|
|
@ -31,14 +31,14 @@ class Grid:
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
material : numpy.ndarray
|
material : numpy.ndarray of shape (:,:,:)
|
||||||
Material index array (3D).
|
Material indices.
|
||||||
size : list or numpy.ndarray
|
size : list or numpy.ndarray
|
||||||
Physical size of the grid in meter.
|
Physical size of grid in meter.
|
||||||
origin : list or numpy.ndarray, optional
|
origin : list or numpy.ndarray, optional
|
||||||
Physical origin of the grid in meter.
|
Coordinates of grid origin in meter.
|
||||||
comments : list of str, optional
|
comments : list of str, optional
|
||||||
Comment lines.
|
Comments, e.g. history of operations.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
self.material = material
|
self.material = material
|
||||||
|
|
|
@ -78,7 +78,7 @@ class Result:
|
||||||
>>> r = damask.Result('my_file.hdf5')
|
>>> r = damask.Result('my_file.hdf5')
|
||||||
>>> r.add_Cauchy()
|
>>> r.add_Cauchy()
|
||||||
>>> r.add_equivalent_Mises('sigma')
|
>>> r.add_equivalent_Mises('sigma')
|
||||||
>>> r.save_VTK()
|
>>> r.export_VTK()
|
||||||
>>> r_last = r.view('increments',-1)
|
>>> r_last = r.view('increments',-1)
|
||||||
>>> sigma_vM_last = r_last.get('sigma_vM')
|
>>> sigma_vM_last = r_last.get('sigma_vM')
|
||||||
|
|
||||||
|
@ -1377,13 +1377,13 @@ class Result:
|
||||||
pool.join()
|
pool.join()
|
||||||
|
|
||||||
|
|
||||||
def save_XDMF(self,output='*'):
|
def export_XDMF(self,output='*'):
|
||||||
"""
|
"""
|
||||||
Write XDMF file to directly visualize data in DADF5 file.
|
Write XDMF file to directly visualize data in DADF5 file.
|
||||||
|
|
||||||
The XDMF format is only supported for structured grids
|
The XDMF format is only supported for structured grids
|
||||||
with single phase and single constituent.
|
with single phase and single constituent.
|
||||||
For other cases use `save_VTK`.
|
For other cases use `export_VTK`.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
|
@ -1511,7 +1511,7 @@ class Result:
|
||||||
return at_cell_ph,in_data_ph,at_cell_ho,in_data_ho
|
return at_cell_ph,in_data_ph,at_cell_ho,in_data_ho
|
||||||
|
|
||||||
|
|
||||||
def save_VTK(self,output='*',mode='cell',constituents=None,fill_float=np.nan,fill_int=0,parallel=True):
|
def export_VTK(self,output='*',mode='cell',constituents=None,fill_float=np.nan,fill_int=0,parallel=True):
|
||||||
"""
|
"""
|
||||||
Export to VTK cell/point data.
|
Export to VTK cell/point data.
|
||||||
|
|
||||||
|
@ -1550,7 +1550,7 @@ class Result:
|
||||||
else:
|
else:
|
||||||
raise ValueError(f'invalid mode {mode}')
|
raise ValueError(f'invalid mode {mode}')
|
||||||
|
|
||||||
v.set_comments(util.execution_stamp('Result','save_VTK'))
|
v.set_comments(util.execution_stamp('Result','export_VTK'))
|
||||||
|
|
||||||
N_digits = int(np.floor(np.log10(max(1,int(self.increments[-1][10:])))))+1
|
N_digits = int(np.floor(np.log10(max(1,int(self.increments[-1][10:])))))+1
|
||||||
|
|
||||||
|
@ -1733,3 +1733,6 @@ class Result:
|
||||||
if flatten: r = util.dict_flatten(r)
|
if flatten: r = util.dict_flatten(r)
|
||||||
|
|
||||||
return None if (type(r) == dict and r == {}) else r
|
return None if (type(r) == dict and r == {}) else r
|
||||||
|
|
||||||
|
save_VTK = export_VTK
|
||||||
|
save_XDMF = export_XDMF
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
d5db0be324a959f00245e42704ea2d6f
|
|
@ -0,0 +1 @@
|
||||||
|
fe9ddaf54ac1fb785094251d29fcdc9c
|
|
@ -0,0 +1 @@
|
||||||
|
9c8ac0bb1eb4a7b9ebc3e5fd5840b0a4
|
|
@ -0,0 +1 @@
|
||||||
|
1b9ebd17c5257e2edba48d006f25d4e6
|
|
@ -0,0 +1 @@
|
||||||
|
8967bb1a6c329a072baaa83da534ae56
|
|
@ -0,0 +1 @@
|
||||||
|
752e8b6186ad2b6b1b5c781940669cb1
|
|
@ -1 +0,0 @@
|
||||||
6d4da1188f1de0a80142692e9e135aed
|
|
|
@ -1 +0,0 @@
|
||||||
5926c1f393871ee942750069545798a7
|
|
|
@ -1 +0,0 @@
|
||||||
743c9a868d54b78ee0648613249a0bdc
|
|
|
@ -1 +0,0 @@
|
||||||
09f5a7a6dd7a8e7d30e47aec07f7f616
|
|
|
@ -1 +0,0 @@
|
||||||
5715cfc5fc21c6d04590354f0941cf7b
|
|
|
@ -1 +0,0 @@
|
||||||
2f7b43ea8fe65173f47acb8281f0a919
|
|
|
@ -368,7 +368,7 @@ class TestResult:
|
||||||
def test_vtk(self,request,tmp_path,ref_path,update,patch_execution_stamp,patch_datetime_now,output,fname,inc):
|
def test_vtk(self,request,tmp_path,ref_path,update,patch_execution_stamp,patch_datetime_now,output,fname,inc):
|
||||||
result = Result(ref_path/fname).view('increments',inc)
|
result = Result(ref_path/fname).view('increments',inc)
|
||||||
os.chdir(tmp_path)
|
os.chdir(tmp_path)
|
||||||
result.save_VTK(output)
|
result.export_VTK(output)
|
||||||
fname = fname.split('.')[0]+f'_inc{(inc if type(inc) == int else inc[0]):0>2}.vti'
|
fname = fname.split('.')[0]+f'_inc{(inc if type(inc) == int else inc[0]):0>2}.vti'
|
||||||
last = ''
|
last = ''
|
||||||
for i in range(10):
|
for i in range(10):
|
||||||
|
@ -381,9 +381,9 @@ class TestResult:
|
||||||
last = cur
|
last = cur
|
||||||
time.sleep(.5)
|
time.sleep(.5)
|
||||||
if update:
|
if update:
|
||||||
with open((ref_path/'save_VTK'/request.node.name).with_suffix('.md5'),'w') as f:
|
with open((ref_path/'export_VTK'/request.node.name).with_suffix('.md5'),'w') as f:
|
||||||
f.write(cur)
|
f.write(cur)
|
||||||
with open((ref_path/'save_VTK'/request.node.name).with_suffix('.md5')) as f:
|
with open((ref_path/'export_VTK'/request.node.name).with_suffix('.md5')) as f:
|
||||||
assert cur == f.read()
|
assert cur == f.read()
|
||||||
|
|
||||||
@pytest.mark.parametrize('mode',['point','cell'])
|
@pytest.mark.parametrize('mode',['point','cell'])
|
||||||
|
@ -391,7 +391,7 @@ class TestResult:
|
||||||
def test_vtk_marc(self,tmp_path,ref_path,mode,output):
|
def test_vtk_marc(self,tmp_path,ref_path,mode,output):
|
||||||
os.chdir(tmp_path)
|
os.chdir(tmp_path)
|
||||||
result = Result(ref_path/'check_compile_job1.hdf5')
|
result = Result(ref_path/'check_compile_job1.hdf5')
|
||||||
result.save_VTK(output,mode)
|
result.export_VTK(output,mode)
|
||||||
|
|
||||||
def test_marc_coordinates(self,ref_path):
|
def test_marc_coordinates(self,ref_path):
|
||||||
result = Result(ref_path/'check_compile_job1.hdf5').view('increments',-1)
|
result = Result(ref_path/'check_compile_job1.hdf5').view('increments',-1)
|
||||||
|
@ -402,7 +402,7 @@ class TestResult:
|
||||||
@pytest.mark.parametrize('mode',['point','cell'])
|
@pytest.mark.parametrize('mode',['point','cell'])
|
||||||
def test_vtk_mode(self,tmp_path,single_phase,mode):
|
def test_vtk_mode(self,tmp_path,single_phase,mode):
|
||||||
os.chdir(tmp_path)
|
os.chdir(tmp_path)
|
||||||
single_phase.save_VTK(mode=mode)
|
single_phase.export_VTK(mode=mode)
|
||||||
|
|
||||||
def test_XDMF(self,tmp_path,single_phase,update,ref_path):
|
def test_XDMF(self,tmp_path,single_phase,update,ref_path):
|
||||||
for shape in [('scalar',()),('vector',(3,)),('tensor',(3,3)),('matrix',(12,))]:
|
for shape in [('scalar',()),('vector',(3,)),('tensor',(3,3)),('matrix',(12,))]:
|
||||||
|
@ -410,14 +410,14 @@ 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.export_XDMF()
|
||||||
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 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):
|
||||||
default.save_XDMF()
|
default.export_XDMF()
|
||||||
|
|
||||||
@pytest.mark.parametrize('view,output,flatten,prune',
|
@pytest.mark.parametrize('view,output,flatten,prune',
|
||||||
[({},['F','P','F','L_p','F_e','F_p'],True,True),
|
[({},['F','P','F','L_p','F_e','F_p'],True,True),
|
||||||
|
|
Loading…
Reference in New Issue