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:
try:
table = damask.ASCIItable(name = name, buffered = False)
table = damask.ASCIItable(name = name)
except IOError:
continue
damask.util.report(scriptName,name)

View File

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

View File

@ -126,7 +126,7 @@ if filenames == []: filenames = [None]
for name in filenames:
try:
table = damask.ASCIItable(name = name, buffered = False)
table = damask.ASCIItable(name = name)
except IOError:
continue
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]
for name in filenames:
try: table = damask.ASCIItable(name = name,
buffered = False)
except: continue
try:
table = damask.ASCIItable(name = name)
except IOError:
continue
damask.util.report(scriptName,name)
# ------------------------------------------ read header ------------------------------------------

View File

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

View File

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

View File

@ -11,11 +11,12 @@ import damask
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_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
scriptName = os.path.splitext(os.path.basename(__file__))[0]
scriptID = ' '.join([scriptName,damask.version])
@ -73,7 +74,7 @@ try:
globals().get(funcModule) or
__import__(funcModule),
funcName)
except:
except Exception:
mapFunction = None
if options.label is []:
@ -87,9 +88,10 @@ if not hasattr(mapFunction,'__call__'):
if filenames == []: filenames = [None]
for name in filenames:
try: table = damask.ASCIItable(name = name,
buffered = False)
except: continue
try:
table = damask.ASCIItable(name = name)
except IOError:
continue
damask.util.report(scriptName,name)
# ------------------------------------------ sanity checks ---------------------------------------

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -234,7 +234,7 @@ if filenames == []: filenames = [None]
for name in filenames:
try:
table = damask.ASCIItable(name = name, buffered = False, readonly=True)
table = damask.ASCIItable(name = name, readonly=True)
except IOError:
continue
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:
fftdata = fftbuild(rcData, options.size, options.xmargin, options.ymargin, options.grid, options.extrusion)
table = damask.ASCIItable(outname = myName+'_'+str(int(fftdata['grid'][0]))+'.geom',
labeled = False,
buffered = False)
table = damask.ASCIItable(outname = myName+'_'+str(int(fftdata['grid'][0]))+'.geom', labeled = False)
table.labels_clear()
table.info_clear()
table.info_append([

View File

@ -14,7 +14,7 @@ scriptID = ' '.join([scriptName,damask.version])
# ------------------------------------------ aux functions ---------------------------------
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]
distances = np.zeros(n,dtype=float)
tree = spatial.cKDTree(cloud)
@ -24,6 +24,7 @@ def kdtree_search(cloud, queryPoints):
return distances
# --------------------------------------------------------------------
# MAIN
# --------------------------------------------------------------------
@ -132,9 +133,10 @@ random.seed(options.randomSeed)
if filenames == []: filenames = [None]
for name in filenames:
try: table = damask.ASCIItable(outname = name,
buffered = False)
except: continue
try:
table = damask.ASCIItable(outname = name)
except IOError:
continue
damask.util.report(scriptName,name)
# --- sanity checks -------------------------------------------------------------------------

View File

@ -148,7 +148,7 @@ class Geom():
"""
if microstructure is not None:
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']:
raise TypeError('Invalid data type {} for microstructure'.format(microstructure.dtype))
else:
@ -169,7 +169,7 @@ class Geom():
self.size = grid/np.max(grid)
else:
if len(size) != 3 or any(np.array(size)<=0):
raise ValueError('Invalid size {}'.format(*size))
raise ValueError('Invalid size {}'.format(size))
else:
self.size = np.array(size)
@ -185,7 +185,7 @@ class Geom():
"""
if origin is not None:
if len(origin) != 3:
raise ValueError('Invalid origin {}'.format(*origin))
raise ValueError('Invalid origin {}'.format(origin))
else:
self.origin = np.array(origin)
@ -458,7 +458,7 @@ class Geom():
if not all(isinstance(d, str) for d in directions):
raise TypeError('Directions are not of type str.')
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]
ms = self.get_microstructure()

View File

@ -57,7 +57,6 @@ module crystallite
crystallite_Li0, & !< intermediate velocitiy grad at start of FE inc
crystallite_partionedLi0 !< intermediate velocity grad at start of homog inc
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_subFp0,& !< plastic def grad at start of crystallite inc
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_partionedS0(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_F0(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_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_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_subStep(c,i,e) = 1.0_pReal/num%subStepSizeCryst
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_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_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
plasticState( material_phaseAt(c,e))%subState0(:,material_phaseMemberAt(c,i,e)) &
= plasticState(material_phaseAt(c,e))%state( :,material_phaseMemberAt(c,i,e))