Merge branch 'MiscImprovements' into development

This commit is contained in:
Martin Diehl 2020-02-20 22:15:02 +01:00
commit ab88ffd28e
20 changed files with 70 additions and 75 deletions

View File

@ -66,7 +66,7 @@ if filenames == []: filenames = [None]
for name in filenames: for name in filenames:
try: try:
table = damask.ASCIItable(name = name, buffered = False) table = damask.ASCIItable(name = name)
except IOError: except IOError:
continue continue
damask.util.report(scriptName,name) damask.util.report(scriptName,name)

View File

@ -61,8 +61,8 @@ if filenames == []: filenames = [None]
for name in filenames: for name in filenames:
try: try:
table = damask.ASCIItable(name = name, buffered = False) table = damask.ASCIItable(name = name)
except: except IOError:
continue continue
damask.util.report(scriptName,name) damask.util.report(scriptName,name)

View File

@ -47,9 +47,7 @@ if options.link is None:
if options.asciitable is not None and os.path.isfile(options.asciitable): if options.asciitable is not None and os.path.isfile(options.asciitable):
linkedTable = damask.ASCIItable(name = options.asciitable, linkedTable = damask.ASCIItable(name = options.asciitable, readonly = True)
buffered = False,
readonly = True)
linkedTable.head_read() # read ASCII header info of linked table linkedTable.head_read() # read ASCII header info of linked table
linkDim = linkedTable.label_dimension(options.link[1]) # dimension of linking column linkDim = linkedTable.label_dimension(options.link[1]) # dimension of linking column
@ -72,9 +70,10 @@ else:
if filenames == []: filenames = [None] if filenames == []: filenames = [None]
for name in filenames: for name in filenames:
try: table = damask.ASCIItable(name = name, try:
buffered = False) table = damask.ASCIItable(name = name)
except: continue except IOError:
continue
damask.util.report(scriptName,"{} {} <== {} {}".format(name,damask.util.deemph('@ '+options.link[0]), damask.util.report(scriptName,"{} {} <== {} {}".format(name,damask.util.deemph('@ '+options.link[0]),
options.asciitable,damask.util.deemph('@ '+options.link[1]))) options.asciitable,damask.util.deemph('@ '+options.link[1])))

View File

@ -126,7 +126,7 @@ if filenames == []: filenames = [None]
for name in filenames: for name in filenames:
try: try:
table = damask.ASCIItable(name = name, buffered = False) table = damask.ASCIItable(name = name)
except IOError: except IOError:
continue continue
damask.util.report(scriptName,name) damask.util.report(scriptName,name)

View File

@ -182,9 +182,10 @@ slip_normal /= np.tile(np.linalg.norm(slip_normal ,axis=1),(3,1)).T
if filenames == []: filenames = [None] if filenames == []: filenames = [None]
for name in filenames: for name in filenames:
try: table = damask.ASCIItable(name = name, try:
buffered = False) table = damask.ASCIItable(name = name)
except: continue except IOError:
continue
damask.util.report(scriptName,name) damask.util.report(scriptName,name)
# ------------------------------------------ read header ------------------------------------------ # ------------------------------------------ read header ------------------------------------------

View File

@ -90,13 +90,14 @@ if options.weight is not None: labels += [options.weight]
if filenames == []: filenames = [None] if filenames == []: filenames = [None]
for name in filenames: for name in filenames:
try: table = damask.ASCIItable(name = name, try:
table = damask.ASCIItable(name = name,
outname = os.path.join(os.path.dirname(name), outname = os.path.join(os.path.dirname(name),
'binned-{}-{}_'.format(*options.data) + 'binned-{}-{}_'.format(*options.data) +
('weighted-{}_'.format(options.weight) if options.weight else '') + ('weighted-{}_'.format(options.weight) if options.weight else '') +
os.path.basename(name)) if name else name, os.path.basename(name)) if name else name)
buffered = False) except IOError:
except: continue continue
damask.util.report(scriptName,name) damask.util.report(scriptName,name)
# ------------------------------------------ read header ------------------------------------------ # ------------------------------------------ read header ------------------------------------------

View File

@ -21,7 +21,7 @@ def sortingList(labels,whitelistitems):
names = [] names = []
for label in labels: for label in labels:
if re.match('^\d+_',label): if re.match(r'^\d+_',label):
indices.append(int(label.split('_',1)[0])) indices.append(int(label.split('_',1)[0]))
names.append(label.split('_',1)[1]) names.append(label.split('_',1)[1])
else: else:
@ -66,9 +66,10 @@ parser.set_defaults(condition = None,
if filenames == []: filenames = [None] if filenames == []: filenames = [None]
for name in filenames: for name in filenames:
try: table = damask.ASCIItable(name = name, try:
buffered = False) table = damask.ASCIItable(name = name)
except: continue except IOError:
continue
damask.util.report(scriptName,name) damask.util.report(scriptName,name)
# ------------------------------------------ assemble info --------------------------------------- # ------------------------------------------ assemble info ---------------------------------------
@ -143,7 +144,7 @@ for name in filenames:
try: try:
table.data_readArray(positions+1) # read desired columns (indexed 1,...) table.data_readArray(positions+1) # read desired columns (indexed 1,...)
table.data_writeArray() # directly write out table.data_writeArray() # directly write out
except: except Exception:
table.data_rewind() table.data_rewind()
atOnce = False # data contains items that prevent array chunking atOnce = False # data contains items that prevent array chunking

View File

@ -11,11 +11,12 @@ import damask
def periodicAverage(coords, limits): def periodicAverage(coords, limits):
"""Centroid in periodic domain, see https://en.wikipedia.org/wiki/Center_of_mass#Systems_with_periodic_boundary_conditions""" """Centroid in periodic domain, see https://en.wikipedia.org/wiki/Center_of_mass#Systems_with_periodic_boundary_conditions."""
theta = 2.0*np.pi * (coords - limits[0])/(limits[1] - limits[0]) theta = 2.0*np.pi * (coords - limits[0])/(limits[1] - limits[0])
theta_avg = np.pi + np.arctan2(-np.sin(theta).mean(axis=0), -np.cos(theta).mean(axis=0)) theta_avg = np.pi + np.arctan2(-np.sin(theta).mean(axis=0), -np.cos(theta).mean(axis=0))
return limits[0] + theta_avg * (limits[1] - limits[0])/2.0/np.pi return limits[0] + theta_avg * (limits[1] - limits[0])/2.0/np.pi
scriptName = os.path.splitext(os.path.basename(__file__))[0] scriptName = os.path.splitext(os.path.basename(__file__))[0]
scriptID = ' '.join([scriptName,damask.version]) scriptID = ' '.join([scriptName,damask.version])
@ -73,7 +74,7 @@ try:
globals().get(funcModule) or globals().get(funcModule) or
__import__(funcModule), __import__(funcModule),
funcName) funcName)
except: except Exception:
mapFunction = None mapFunction = None
if options.label is []: if options.label is []:
@ -87,9 +88,10 @@ if not hasattr(mapFunction,'__call__'):
if filenames == []: filenames = [None] if filenames == []: filenames = [None]
for name in filenames: for name in filenames:
try: table = damask.ASCIItable(name = name, try:
buffered = False) table = damask.ASCIItable(name = name)
except: continue except IOError:
continue
damask.util.report(scriptName,name) damask.util.report(scriptName,name)
# ------------------------------------------ sanity checks --------------------------------------- # ------------------------------------------ sanity checks ---------------------------------------

View File

@ -76,10 +76,10 @@ else:
if filenames == []: filenames = [None] if filenames == []: filenames = [None]
for name in filenames: for name in filenames:
try: table = damask.ASCIItable(name = name, try:
buffered = False, table = damask.ASCIItable(name = name, readonly = True)
readonly = True) except IOError:
except: continue continue
damask.util.report(scriptName,name) damask.util.report(scriptName,name)
# ------------------------------------------ read header ------------------------------------------ # ------------------------------------------ read header ------------------------------------------

View File

@ -117,11 +117,9 @@ if filenames == []: filenames = [None]
for name in filenames: for name in filenames:
try: try:
table = damask.ASCIItable(name = name, table = damask.ASCIItable(name = name, labeled = options.label is not None, readonly = True)
buffered = False, except IOError:
labeled = options.label is not None, continue
readonly = True)
except: continue
damask.util.report(scriptName,name) damask.util.report(scriptName,name)
# ------------------------------------------ read header ------------------------------------------ # ------------------------------------------ read header ------------------------------------------

View File

@ -114,11 +114,10 @@ if filenames == []: filenames = [None]
for name in filenames: for name in filenames:
try: try:
table = damask.ASCIItable(name = name, table = damask.ASCIItable(name = name, readonly = True,
buffered = False, labeled = options.label is not None)
labeled = options.label is not None, except IOError:
readonly = True) continue
except: continue
table.report_name(scriptName,name) table.report_name(scriptName,name)
# ------------------------------------------ read header ------------------------------------------ # ------------------------------------------ read header ------------------------------------------

View File

@ -82,11 +82,10 @@ if filenames == []: filenames = [None]
for name in filenames: for name in filenames:
try: try:
table = damask.ASCIItable(name = name, table = damask.ASCIItable(name = name, readonly = True,
buffered = False, labeled = options.label is not None)
labeled = options.label is not None, except IOError:
readonly = True) continue
except: continue
damask.util.report(scriptName,name) damask.util.report(scriptName,name)
# ------------------------------------------ read header ------------------------------------------ # ------------------------------------------ read header ------------------------------------------

View File

@ -51,8 +51,7 @@ if filenames == []: filenames = [None]
for name in filenames: for name in filenames:
try: try:
table = damask.ASCIItable(name = name, table = damask.ASCIItable(name = name)
buffered = False)
except IOError: except IOError:
continue continue
damask.util.report(scriptName,name) damask.util.report(scriptName,name)

View File

@ -52,9 +52,9 @@ if filenames == []: filenames = [None]
for name in filenames: for name in filenames:
try: try:
table = damask.ASCIItable(name = name, table = damask.ASCIItable(name = name)
buffered = False) except IOError:
except: continue continue
damask.util.report(scriptName,name) damask.util.report(scriptName,name)
# --- interpret header ---------------------------------------------------------------------------- # --- interpret header ----------------------------------------------------------------------------

View File

@ -60,9 +60,9 @@ if filenames == []: filenames = [None]
for name in filenames: for name in filenames:
try: try:
table = damask.ASCIItable(name = name, table = damask.ASCIItable(name = name, labeled = options.labeled, readonly = True)
buffered = False, labeled = options.labeled, readonly = True) except IOError:
except: continue continue
details = ', '.join( details = ', '.join(
(['header'] if options.table else []) + (['header'] if options.table else []) +
(['info'] if options.head or options.info else []) + (['info'] if options.head or options.info else []) +

View File

@ -234,7 +234,7 @@ if filenames == []: filenames = [None]
for name in filenames: for name in filenames:
try: try:
table = damask.ASCIItable(name = name, buffered = False, readonly=True) table = damask.ASCIItable(name = name, readonly=True)
except IOError: except IOError:
continue continue
damask.util.report(scriptName,name) damask.util.report(scriptName,name)

View File

@ -966,9 +966,7 @@ if any(output in options.output for output in ['spectral','mentat']):
if 'spectral' in options.output: if 'spectral' in options.output:
fftdata = fftbuild(rcData, options.size, options.xmargin, options.ymargin, options.grid, options.extrusion) fftdata = fftbuild(rcData, options.size, options.xmargin, options.ymargin, options.grid, options.extrusion)
table = damask.ASCIItable(outname = myName+'_'+str(int(fftdata['grid'][0]))+'.geom', table = damask.ASCIItable(outname = myName+'_'+str(int(fftdata['grid'][0]))+'.geom', labeled = False)
labeled = False,
buffered = False)
table.labels_clear() table.labels_clear()
table.info_clear() table.info_clear()
table.info_append([ table.info_append([

View File

@ -14,7 +14,7 @@ scriptID = ' '.join([scriptName,damask.version])
# ------------------------------------------ aux functions --------------------------------- # ------------------------------------------ aux functions ---------------------------------
def kdtree_search(cloud, queryPoints): def kdtree_search(cloud, queryPoints):
"""Find distances to nearest neighbor among cloud (N,d) for each of the queryPoints (n,d)""" """Find distances to nearest neighbor among cloud (N,d) for each of the queryPoints (n,d)."""
n = queryPoints.shape[0] n = queryPoints.shape[0]
distances = np.zeros(n,dtype=float) distances = np.zeros(n,dtype=float)
tree = spatial.cKDTree(cloud) tree = spatial.cKDTree(cloud)
@ -24,6 +24,7 @@ def kdtree_search(cloud, queryPoints):
return distances return distances
# -------------------------------------------------------------------- # --------------------------------------------------------------------
# MAIN # MAIN
# -------------------------------------------------------------------- # --------------------------------------------------------------------
@ -132,9 +133,10 @@ random.seed(options.randomSeed)
if filenames == []: filenames = [None] if filenames == []: filenames = [None]
for name in filenames: for name in filenames:
try: table = damask.ASCIItable(outname = name, try:
buffered = False) table = damask.ASCIItable(outname = name)
except: continue except IOError:
continue
damask.util.report(scriptName,name) damask.util.report(scriptName,name)
# --- sanity checks ------------------------------------------------------------------------- # --- sanity checks -------------------------------------------------------------------------

View File

@ -148,7 +148,7 @@ class Geom():
""" """
if microstructure is not None: if microstructure is not None:
if len(microstructure.shape) != 3: if len(microstructure.shape) != 3:
raise ValueError('Invalid microstructure shape {}'.format(*microstructure.shape)) raise ValueError('Invalid microstructure shape {}'.format(microstructure.shape))
elif microstructure.dtype not in np.sctypes['float'] + np.sctypes['int']: elif microstructure.dtype not in np.sctypes['float'] + np.sctypes['int']:
raise TypeError('Invalid data type {} for microstructure'.format(microstructure.dtype)) raise TypeError('Invalid data type {} for microstructure'.format(microstructure.dtype))
else: else:
@ -169,7 +169,7 @@ class Geom():
self.size = grid/np.max(grid) self.size = grid/np.max(grid)
else: else:
if len(size) != 3 or any(np.array(size)<=0): if len(size) != 3 or any(np.array(size)<=0):
raise ValueError('Invalid size {}'.format(*size)) raise ValueError('Invalid size {}'.format(size))
else: else:
self.size = np.array(size) self.size = np.array(size)
@ -185,7 +185,7 @@ class Geom():
""" """
if origin is not None: if origin is not None:
if len(origin) != 3: if len(origin) != 3:
raise ValueError('Invalid origin {}'.format(*origin)) raise ValueError('Invalid origin {}'.format(origin))
else: else:
self.origin = np.array(origin) self.origin = np.array(origin)
@ -297,7 +297,7 @@ class Geom():
i += len(items) i += len(items)
if i != grid.prod(): if i != grid.prod():
raise TypeError('Invalid file: expected {} entries,found {}'.format(grid.prod(),i)) raise TypeError('Invalid file: expected {} entries, found {}'.format(grid.prod(),i))
microstructure = microstructure.reshape(grid,order='F') microstructure = microstructure.reshape(grid,order='F')
if not np.any(np.mod(microstructure.flatten(),1) != 0.0): # no float present if not np.any(np.mod(microstructure.flatten(),1) != 0.0): # no float present
@ -458,7 +458,7 @@ class Geom():
if not all(isinstance(d, str) for d in directions): if not all(isinstance(d, str) for d in directions):
raise TypeError('Directions are not of type str.') raise TypeError('Directions are not of type str.')
elif not set(directions).issubset(valid): elif not set(directions).issubset(valid):
raise ValueError('Invalid direction specified {}'.format(*set(directions).difference(valid))) raise ValueError('Invalid direction specified {}'.format(set(directions).difference(valid)))
limits = [None,None] if reflect else [-2,0] limits = [None,None] if reflect else [-2,0]
ms = self.get_microstructure() ms = self.get_microstructure()

View File

@ -57,7 +57,6 @@ module crystallite
crystallite_Li0, & !< intermediate velocitiy grad at start of FE inc crystallite_Li0, & !< intermediate velocitiy grad at start of FE inc
crystallite_partionedLi0 !< intermediate velocity grad at start of homog inc crystallite_partionedLi0 !< intermediate velocity grad at start of homog inc
real(pReal), dimension(:,:,:,:,:), allocatable :: & real(pReal), dimension(:,:,:,:,:), allocatable :: &
crystallite_subS0, & !< 2nd Piola-Kirchhoff stress vector at start of crystallite inc
crystallite_invFp, & !< inverse of current plastic def grad (end of converged time step) crystallite_invFp, & !< inverse of current plastic def grad (end of converged time step)
crystallite_subFp0,& !< plastic def grad at start of crystallite inc crystallite_subFp0,& !< plastic def grad at start of crystallite inc
crystallite_invFi, & !< inverse of current intermediate def grad (end of converged time step) crystallite_invFi, & !< inverse of current intermediate def grad (end of converged time step)
@ -136,7 +135,6 @@ subroutine crystallite_init
allocate(crystallite_S0(3,3,cMax,iMax,eMax), source=0.0_pReal) allocate(crystallite_S0(3,3,cMax,iMax,eMax), source=0.0_pReal)
allocate(crystallite_partionedS0(3,3,cMax,iMax,eMax), source=0.0_pReal) allocate(crystallite_partionedS0(3,3,cMax,iMax,eMax), source=0.0_pReal)
allocate(crystallite_S(3,3,cMax,iMax,eMax), source=0.0_pReal) allocate(crystallite_S(3,3,cMax,iMax,eMax), source=0.0_pReal)
allocate(crystallite_subS0(3,3,cMax,iMax,eMax), source=0.0_pReal)
allocate(crystallite_P(3,3,cMax,iMax,eMax), source=0.0_pReal) allocate(crystallite_P(3,3,cMax,iMax,eMax), source=0.0_pReal)
allocate(crystallite_F0(3,3,cMax,iMax,eMax), source=0.0_pReal) allocate(crystallite_F0(3,3,cMax,iMax,eMax), source=0.0_pReal)
allocate(crystallite_partionedF0(3,3,cMax,iMax,eMax), source=0.0_pReal) allocate(crystallite_partionedF0(3,3,cMax,iMax,eMax), source=0.0_pReal)
@ -351,7 +349,6 @@ function crystallite_stress(dummyArgumentToPreventInternalCompilerErrorWithGCC)
crystallite_subFi0(1:3,1:3,c,i,e) = crystallite_partionedFi0(1:3,1:3,c,i,e) crystallite_subFi0(1:3,1:3,c,i,e) = crystallite_partionedFi0(1:3,1:3,c,i,e)
crystallite_subLi0(1:3,1:3,c,i,e) = crystallite_partionedLi0(1:3,1:3,c,i,e) crystallite_subLi0(1:3,1:3,c,i,e) = crystallite_partionedLi0(1:3,1:3,c,i,e)
crystallite_subF0(1:3,1:3,c,i,e) = crystallite_partionedF0(1:3,1:3,c,i,e) crystallite_subF0(1:3,1:3,c,i,e) = crystallite_partionedF0(1:3,1:3,c,i,e)
crystallite_subS0(1:3,1:3,c,i,e) = crystallite_partionedS0(1:3,1:3,c,i,e)
crystallite_subFrac(c,i,e) = 0.0_pReal crystallite_subFrac(c,i,e) = 0.0_pReal
crystallite_subStep(c,i,e) = 1.0_pReal/num%subStepSizeCryst crystallite_subStep(c,i,e) = 1.0_pReal/num%subStepSizeCryst
crystallite_todo(c,i,e) = .true. crystallite_todo(c,i,e) = .true.
@ -397,7 +394,6 @@ function crystallite_stress(dummyArgumentToPreventInternalCompilerErrorWithGCC)
crystallite_subLi0(1:3,1:3,c,i,e) = crystallite_Li (1:3,1:3,c,i,e) crystallite_subLi0(1:3,1:3,c,i,e) = crystallite_Li (1:3,1:3,c,i,e)
crystallite_subFp0(1:3,1:3,c,i,e) = crystallite_Fp (1:3,1:3,c,i,e) crystallite_subFp0(1:3,1:3,c,i,e) = crystallite_Fp (1:3,1:3,c,i,e)
crystallite_subFi0(1:3,1:3,c,i,e) = crystallite_Fi (1:3,1:3,c,i,e) crystallite_subFi0(1:3,1:3,c,i,e) = crystallite_Fi (1:3,1:3,c,i,e)
crystallite_subS0 (1:3,1:3,c,i,e) = crystallite_S (1:3,1:3,c,i,e)
!if abbrevation, make c and p private in omp !if abbrevation, make c and p private in omp
plasticState( material_phaseAt(c,e))%subState0(:,material_phaseMemberAt(c,i,e)) & plasticState( material_phaseAt(c,e))%subState0(:,material_phaseMemberAt(c,i,e)) &
= plasticState(material_phaseAt(c,e))%state( :,material_phaseMemberAt(c,i,e)) = plasticState(material_phaseAt(c,e))%state( :,material_phaseMemberAt(c,i,e))