make setup data easily accessible to the user
This commit is contained in:
parent
b9d4eb23cc
commit
26ae352a4c
2
PRIVATE
2
PRIVATE
|
@ -1 +1 @@
|
|||
Subproject commit 72c58103860e127d37ccf3a06827331de29406ca
|
||||
Subproject commit 7d48d8158c1b2c0ab8bdd1c5d2baa3d020ae006d
|
|
@ -99,8 +99,10 @@ class Result:
|
|||
self.version_major = f.attrs['DADF5_version_major']
|
||||
self.version_minor = f.attrs['DADF5_version_minor']
|
||||
|
||||
if self.version_major != 0 or not 12 <= self.version_minor <= 13:
|
||||
if self.version_major != 0 or not 12 <= self.version_minor <= 14:
|
||||
raise TypeError(f'Unsupported DADF5 version {self.version_major}.{self.version_minor}')
|
||||
if self.version_major == 0 and self.version_minor < 14:
|
||||
self.export_setup = None
|
||||
|
||||
self.structured = 'cells' in f['geometry'].attrs.keys()
|
||||
|
||||
|
@ -1395,7 +1397,7 @@ class Result:
|
|||
|
||||
def export_XDMF(self,output='*'):
|
||||
"""
|
||||
Write XDMF file to directly visualize data in DADF5 file.
|
||||
Write XDMF file to directly visualize data from DADF5 file.
|
||||
|
||||
The XDMF format is only supported for structured grids
|
||||
with single phase and single constituent.
|
||||
|
@ -1748,3 +1750,29 @@ class Result:
|
|||
if flatten: r = util.dict_flatten(r)
|
||||
|
||||
return None if (type(r) == dict and r == {}) else r
|
||||
|
||||
|
||||
def export_setup(self,output='*',overwrite=False):
|
||||
"""
|
||||
Export configuration files.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
output : (list of) str, optional
|
||||
Names of the datasets to export to the file.
|
||||
Defaults to '*', in which case all datasets are exported.
|
||||
overwrite : boolean, optional
|
||||
Overwrite existing configuration files.
|
||||
Defaults to False.
|
||||
|
||||
"""
|
||||
with h5py.File(self.fname,'r') as f_in:
|
||||
for out in _match(output,f_in['setup'].keys()):
|
||||
description = f_in['/'.join(('setup',out))].attrs['description']
|
||||
if not h5py3: description = description.decode()
|
||||
if not Path(out).exists() or overwrite:
|
||||
with open(out,'w') as f_out:
|
||||
f_out.write(f_in['/'.join(('setup',out))][()].decode())
|
||||
print(f"exported {description} to '{out}'")
|
||||
else:
|
||||
print(f"'{out}' exists, {description} not exported")
|
||||
|
|
|
@ -25,11 +25,11 @@ module parallelization
|
|||
worldsize = 1 !< MPI worldsize (/=1 for MPI simulations only)
|
||||
|
||||
#ifndef PETSC
|
||||
public :: parallelization_broadcast_str
|
||||
public :: parallelization_bcast_str
|
||||
|
||||
contains
|
||||
subroutine parallelization_bcast_str(string)
|
||||
character(len=*), allocatable, intent(inout) :: string
|
||||
character(len=:), allocatable, intent(inout) :: string
|
||||
end subroutine parallelization_bcast_str
|
||||
|
||||
#else
|
||||
|
|
|
@ -74,7 +74,7 @@ subroutine results_init(restart)
|
|||
if(.not. restart) then
|
||||
resultsFile = HDF5_openFile(getSolverJobName()//'.hdf5','w')
|
||||
call results_addAttribute('DADF5_version_major',0)
|
||||
call results_addAttribute('DADF5_version_minor',13)
|
||||
call results_addAttribute('DADF5_version_minor',14)
|
||||
call get_command_argument(0,commandLine)
|
||||
call results_addAttribute('creator',trim(commandLine)//' '//DAMASKVERSION)
|
||||
call results_addAttribute('created',now())
|
||||
|
|
Loading…
Reference in New Issue