diff --git a/PRIVATE b/PRIVATE index 8dde2a685..a6109acd2 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 8dde2a68538b7cffbe9d370e2b60be90a31627ab +Subproject commit a6109acd264c683fd335b1d1f69934fc4a4078e3 diff --git a/VERSION b/VERSION index f918509c7..9e83f4537 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -v2.0.3-2523-ge22e2cfe +v2.0.3-2629-g404c0659 diff --git a/processing/post/addAPS34IDEstrainCoords.py b/processing/post/addAPS34IDEstrainCoords.py index c14983799..d71116c6a 100755 --- a/processing/post/addAPS34IDEstrainCoords.py +++ b/processing/post/addAPS34IDEstrainCoords.py @@ -32,15 +32,12 @@ parser.add_option('--depth', dest='depth', metavar='string', if filenames == []: filenames = [None] if options.frame is None: - parser.error('frame not specified') + parser.error('frame not specified') if options.depth is None: - parser.error('depth not specified') + parser.error('depth not specified') -theta=-0.75*np.pi -RotMat2TSL=np.array([[1., 0., 0.], - [0., np.cos(theta), np.sin(theta)], # Orientation to account for -135 deg - [0., -np.sin(theta), np.cos(theta)]]) # rotation for TSL convention +rot_to_TSL = damask.Rotation.from_axis_angle([-1,0,0,.75*np.pi]) for name in filenames: damask.util.report(scriptName,name) @@ -50,8 +47,6 @@ for name in filenames: coord = - table.get(options.frame) coord[:,2] += table.get(options.depth)[:,0] - table.add('coord', - np.einsum('ijk,ik->ij',np.broadcast_to(RotMat2TSL,(coord.shape[0],3,3)),coord), - scriptID+' '+' '.join(sys.argv[1:])) + table.add('coord',rot_to_TSL.broadcast_to(coord.shape[0]) @ coord,scriptID+' '+' '.join(sys.argv[1:])) table.to_ASCII(sys.stdout if name is None else name) diff --git a/processing/post/addCalculation.py b/processing/post/addCalculation.py deleted file mode 100755 index 79fdd9455..000000000 --- a/processing/post/addCalculation.py +++ /dev/null @@ -1,183 +0,0 @@ -#!/usr/bin/env python3 - -import os -import sys -from optparse import OptionParser -import re -from collections.abc import Iterable -import math # noqa - -import scipy # noqa -import scipy.linalg # noqa -import numpy as np - -import damask - - -scriptName = os.path.splitext(os.path.basename(__file__))[0] -scriptID = ' '.join([scriptName,damask.version]) - -def listify(x): - return x if isinstance(x, Iterable) else [x] - - -# -------------------------------------------------------------------- -# MAIN -# -------------------------------------------------------------------- - -parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [ASCIItable(s)]', description = """ -Add or alter column(s) with derived values according to user-defined arithmetic operation between column(s). -Column labels are tagged by '#label#' in formulas. Use ';' for ',' in functions. -Numpy is available as 'np'. - -Special variables: #_row_# -- row index -Examples: -(1) magnitude of vector -- "np.linalg.norm(#vec#)" -(2) rounded root of row number -- "round(math.sqrt(#_row_#);3)" - -""", version = scriptID) - -parser.add_option('-l','--label', - dest = 'labels', - action = 'extend', metavar = '', - help = '(list of) new column labels') -parser.add_option('-f','--formula', - dest = 'formulas', - action = 'extend', metavar = '', - help = '(list of) formulas corresponding to labels') - -parser.add_option('-c','--condition', - dest = 'condition', metavar='string', - help = 'condition to alter existing column data (optional)') - -(options,filenames) = parser.parse_args() - -if options.labels is None or options.formulas is None: - parser.error('no formulas and/or labels specified.') -if len(options.labels) != len(options.formulas): - parser.error('number of labels ({}) and formulas ({}) do not match.'.format(len(options.labels),len(options.formulas))) - -for i in range(len(options.formulas)): - options.formulas[i] = options.formulas[i].replace(';',',') - -# ------------------------------------- loop over input files -------------------------------------- - -if filenames == []: filenames = [None] - -for name in filenames: - try: - table = damask.ASCIItable(name = name) - except IOError: - continue - damask.util.report(scriptName,name) - -# ------------------------------------------ read header ------------------------------------------- - - table.head_read() - -# -------------------------------------------------------------------------------------------------- - specials = { \ - '_row_': 0, - } - -# --------------------------------------- evaluate condition --------------------------------------- - if options.condition is not None: - condition = options.condition # copy per file, since might be altered inline - breaker = False - - for position,(all,marker,column) in enumerate(set(re.findall(r'#(([s]#)?(.+?))#',condition))): # find three groups - idx = table.label_index(column) - dim = table.label_dimension(column) - if idx < 0 and column not in specials: - damask.util.croak('column "{}" not found.'.format(column)) - breaker = True - else: - if column in specials: - replacement = 'specials["{}"]'.format(column) - elif dim == 1: # scalar input - replacement = '{}(table.data[{}])'.format({ '':'float', - 's#':'str'}[marker],idx) # take float or string value of data column - elif dim > 1: # multidimensional input (vector, tensor, etc.) - replacement = 'np.array(table.data[{}:{}],dtype=float)'.format(idx,idx+dim) # use (flat) array representation - - condition = condition.replace('#'+all+'#',replacement) - - if breaker: continue # found mistake in condition evaluation --> next file - -# ------------------------------------------ build formulas ---------------------------------------- - - evaluator = {} - - for label,formula in zip(options.labels,options.formulas): - for column in re.findall(r'#(.+?)#',formula): # loop over column labels in formula - idx = table.label_index(column) - dim = table.label_dimension(column) - if column in specials: - replacement = 'specials["{}"]'.format(column) - elif dim == 1: # scalar input - replacement = 'float(table.data[{}])'.format(idx) # take float value of data column - elif dim > 1: # multidimensional input (vector, tensor, etc.) - replacement = 'np.array(table.data[{}:{}],dtype=float)'.format(idx,idx+dim) # use (flat) array representation - else: - damask.util.croak('column {} not found, skipping {}...'.format(column,label)) - options.labels.remove(label) - break - - formula = formula.replace('#'+column+'#',replacement) - - evaluator[label] = formula - -# ---------------------------- separate requested labels into old and new -------------------------- - - veterans = list(set(options.labels)&set(table.labels(raw=False)+table.labels(raw=True)) ) # intersection of requested and existing - newbies = list(set(options.labels)-set(table.labels(raw=False)+table.labels(raw=True)) ) # requested but not existing - -# ------------------------------------------ process data ------------------------------------------ - - firstLine = True - outputAlive = True - - while outputAlive and table.data_read(): # read next data line of ASCII table - specials['_row_'] += 1 # count row - - if firstLine: - firstLine = False - -# ---------------------------- line 1: determine dimension of formulas ----------------------------- - - resultDim = {} - for label in list(options.labels): # iterate over stable copy - resultDim[label] = np.size(eval(evaluator[label])) # get dimension of formula[label] - if resultDim[label] == 0: options.labels.remove(label) # remove label if invalid result - - for veteran in list(veterans): - if resultDim[veteran] != table.label_dimension(veteran): - damask.util.croak('skipping {} due to inconsistent dimension...'.format(veteran)) - veterans.remove(veteran) # discard culprit - -# ----------------------------------- line 1: assemble header -------------------------------------- - - for newby in newbies: - table.labels_append(['{}_{}'.format(i+1,newby) for i in range(resultDim[newby])] - if resultDim[newby] > 1 else newby) - - table.info_append(scriptID + '\t' + ' '.join(sys.argv[1:])) - table.head_write() - -# -------------------------------------- evaluate formulas ----------------------------------------- - - if options.condition is None or eval(condition): # condition for veteran replacement fulfilled - for veteran in veterans: # evaluate formulas that overwrite - table.data[table.label_index(veteran): - table.label_index(veteran)+table.label_dimension(veteran)] = \ - listify(eval(evaluator[veteran])) - - for newby in newbies: # evaluate formulas that append - table.data_append(listify(eval(evaluator[newby]))) - - outputAlive = table.data_write() # output processed line - -# ------------------------------------- output finalization ---------------------------------------- - - table.close() # close ASCII table - diff --git a/processing/post/addIPFcolor.py b/processing/post/addIPFcolor.py deleted file mode 100755 index 014b0147d..000000000 --- a/processing/post/addIPFcolor.py +++ /dev/null @@ -1,68 +0,0 @@ -#!/usr/bin/env python3 - -import os -import sys -from io import StringIO -from optparse import OptionParser - -import numpy as np - -import damask - - -scriptName = os.path.splitext(os.path.basename(__file__))[0] -scriptID = ' '.join([scriptName,damask.version]) - -# -------------------------------------------------------------------- -# MAIN -# -------------------------------------------------------------------- - -parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [ASCIItable(s)]', description = """ -Add RGB color value corresponding to TSL-OIM scheme for inverse pole figures. - -""", version = scriptID) - -parser.add_option('-p', - '--pole', - dest = 'pole', - type = 'float', nargs = 3, metavar = 'float float float', - help = 'lab frame direction for inverse pole figure [%default]') -parser.add_option('-s', - '--symmetry', - dest = 'symmetry', - type = 'choice', choices = damask.Symmetry.lattices[1:], metavar='string', - help = 'crystal symmetry [%default] {{{}}} '.format(', '.join(damask.Symmetry.lattices[1:]))) -parser.add_option('-o', - '--orientation', - dest = 'quaternion', - metavar = 'string', - help = 'label of crystal orientation given as unit quaternion [%default]') - -parser.set_defaults(pole = (0.0,0.0,1.0), - quaternion = 'orientation', - symmetry = damask.Symmetry.lattices[-1], - ) - -(options, filenames) = parser.parse_args() -if filenames == []: filenames = [None] - -# damask.Orientation requires Bravais lattice, but we are only interested in symmetry -symmetry2lattice={'cubic':'fcc','hexagonal':'hex','tetragonal':'bct'} -lattice = symmetry2lattice[options.symmetry] - -pole = np.array(options.pole) -pole /= np.linalg.norm(pole) - -for name in filenames: - damask.util.report(scriptName,name) - - table = damask.Table.from_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name) - orientation = table.get(options.quaternion) - color = np.empty((orientation.shape[0],3)) - for i,o in enumerate(orientation): - color[i] = damask.Orientation(o,lattice = lattice).IPFcolor(pole) - - table.add('IPF_{:g}{:g}{:g}_{sym}'.format(*options.pole,sym = options.symmetry.lower()), - color, - scriptID+' '+' '.join(sys.argv[1:])) - table.to_ASCII(sys.stdout if name is None else name) diff --git a/processing/post/addNorm.py b/processing/post/addNorm.py deleted file mode 100755 index 4ac2bf899..000000000 --- a/processing/post/addNorm.py +++ /dev/null @@ -1,75 +0,0 @@ -#!/usr/bin/env python3 - -import os -import sys -from io import StringIO -from optparse import OptionParser - -import numpy as np - -import damask - - -scriptName = os.path.splitext(os.path.basename(__file__))[0] -scriptID = ' '.join([scriptName,damask.version]) - -# definition of element-wise p-norms for matrices -# ToDo: better use numpy.linalg.norm - -def norm(which,object): - - if which == 'Abs': # p = 1 - return sum(map(abs, object)) - elif which == 'Frobenius': # p = 2 - return np.sqrt(sum([x*x for x in object])) - elif which == 'Max': # p = inf - return max(map(abs, object)) - else: - return -1 - - -# -------------------------------------------------------------------- -# MAIN -# -------------------------------------------------------------------- - -parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [ASCIItable(s)]', description = """ -Add column(s) containing norm of requested column(s) being either vectors or tensors. - -""", version = scriptID) - -normChoices = ['abs','frobenius','max'] -parser.add_option('-n','--norm', - dest = 'norm', - type = 'choice', choices = normChoices, metavar='string', - help = 'type of element-wise p-norm [frobenius] {%s}'%(','.join(map(str,normChoices)))) -parser.add_option('-l','--label', - dest = 'labels', - action = 'extend', metavar = '', - help = 'heading of column(s) to calculate norm of') - -parser.set_defaults(norm = 'frobenius', - ) - -(options,filenames) = parser.parse_args() -if filenames == []: filenames = [None] - -if options.norm.lower() not in normChoices: - parser.error('invalid norm ({}) specified.'.format(options.norm)) -if options.labels is None: - parser.error('no data column specified.') - -for name in filenames: - damask.util.report(scriptName,name) - - table = damask.Table.from_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name) - for label in options.labels: - data = table.get(label) - data_norm = np.empty((data.shape[0],1)) - for i,d in enumerate(data): - data_norm[i] = norm(options.norm.capitalize(),d) - - table.add('norm{}({})'.format(options.norm.capitalize(),label), - data_norm, - scriptID+' '+' '.join(sys.argv[1:])) - - table.to_ASCII(sys.stdout if name is None else name) diff --git a/processing/post/addPK2.py b/processing/post/addPK2.py deleted file mode 100755 index 2894a5a90..000000000 --- a/processing/post/addPK2.py +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env python3 - -import os -import sys -from io import StringIO -from optparse import OptionParser - -import damask - - -scriptName = os.path.splitext(os.path.basename(__file__))[0] -scriptID = ' '.join([scriptName,damask.version]) - -# -------------------------------------------------------------------- -# MAIN -# -------------------------------------------------------------------- - -parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [ASCIItable(s)]', description = """ -Add column(s) containing Second Piola--Kirchhoff stress based on given column(s) of deformation -gradient and first Piola--Kirchhoff stress. - -""", version = scriptID) - -parser.add_option('-f','--defgrad', - dest = 'defgrad', - type = 'string', metavar = 'string', - help = 'heading of columns containing deformation gradient [%default]') -parser.add_option('-p','--stress', - dest = 'stress', - type = 'string', metavar = 'string', - help = 'heading of columns containing first Piola--Kirchhoff stress [%default]') - -parser.set_defaults(defgrad = 'f', - stress = 'p', - ) - -(options,filenames) = parser.parse_args() -if filenames == []: filenames = [None] - -for name in filenames: - damask.util.report(scriptName,name) - - table = damask.Table.from_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name) - - table.add('S', - damask.mechanics.PK2(table.get(options.stress ).reshape(-1,3,3), - table.get(options.defgrad).reshape(-1,3,3)).reshape(-1,9), - scriptID+' '+' '.join(sys.argv[1:])) - - table.to_ASCII(sys.stdout if name is None else name) diff --git a/processing/post/addPole.py b/processing/post/addPole.py deleted file mode 100755 index 58f9235dc..000000000 --- a/processing/post/addPole.py +++ /dev/null @@ -1,65 +0,0 @@ -#!/usr/bin/env python3 - -import os -import sys -from io import StringIO -from optparse import OptionParser - -import numpy as np - -import damask - - -scriptName = os.path.splitext(os.path.basename(__file__))[0] -scriptID = ' '.join([scriptName,damask.version]) - - -# -------------------------------------------------------------------- -# MAIN -# -------------------------------------------------------------------- - -parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [ASCIItable(s)]', description = """ -Add coordinates of stereographic projection of given direction (pole) in crystal frame. - -""", version = scriptID) - -parser.add_option('-p', - '--pole', - dest = 'pole', - type = 'float', nargs = 3, metavar = 'float float float', - help = 'crystal frame direction for pole figure [%default]') -parser.add_option('--polar', - dest = 'polar', - action = 'store_true', - help = 'output polar coordinates (r,φ) instead of Cartesian coordinates (x,y)') -parser.add_option('-o', - '--orientation', - dest = 'quaternion', - metavar = 'string', - help = 'label of crystal orientation given as unit quaternion [%default]') - -parser.set_defaults(pole = (1.0,0.0,0.0), - quaternion = 'orientation', - ) - -(options, filenames) = parser.parse_args() -if filenames == []: filenames = [None] - -pole = np.array(options.pole) -pole /= np.linalg.norm(pole) - -for name in filenames: - damask.util.report(scriptName,name) - - table = damask.Table.from_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name) - orientation = table.get(options.quaternion) - poles = np.empty((orientation.shape[0],2)) - for i,o in enumerate(orientation): - rotatedPole = damask.Rotation(o)*pole # rotate pole according to crystal orientation - (x,y) = rotatedPole[0:2]/(1.+abs(pole[2])) # stereographic projection - poles[i] = [np.sqrt(x*x+y*y),np.arctan2(y,x)] if options.polar else [x,y] # cartesian coordinates - - table.add('pole_{}{}{}'.format(*options.pole), - poles, - scriptID+' '+' '.join(sys.argv[1:])) - table.to_ASCII(sys.stdout if name is None else name) diff --git a/processing/post/addSpectralDecomposition.py b/processing/post/addSpectralDecomposition.py deleted file mode 100755 index 01371cede..000000000 --- a/processing/post/addSpectralDecomposition.py +++ /dev/null @@ -1,58 +0,0 @@ -#!/usr/bin/env python3 - -import os -import sys -from io import StringIO -from optparse import OptionParser - -import numpy as np - -import damask - - -scriptName = os.path.splitext(os.path.basename(__file__))[0] -scriptID = ' '.join([scriptName,damask.version]) - - -# -------------------------------------------------------------------- -# MAIN -# -------------------------------------------------------------------- - -parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [ASCIItable(s)]', description = """ -Add column(s) containing eigenvalues and eigenvectors of requested symmetric tensor column(s). - -""", version = scriptID) - -parser.add_option('-t','--tensor', - dest = 'tensor', - action = 'extend', metavar = '', - help = 'heading of columns containing tensor field values') -parser.add_option('--no-check', - dest = 'rh', - action = 'store_false', - help = 'skip check for right-handed eigenvector basis') - -parser.set_defaults(rh = True, - ) - -(options,filenames) = parser.parse_args() -if filenames == []: filenames = [None] - -for name in filenames: - damask.util.report(scriptName,name) - - table = damask.Table.from_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name) - - for tensor in options.tensor: - - t = table.get(tensor).reshape(-1,3,3) - (u,v) = np.linalg.eigh(damask.mechanics.symmetric(t)) - if options.rh: v[np.linalg.det(v) < 0.0,:,2] *= -1.0 - - for i,o in enumerate(['Min','Mid','Max']): - table.add('eigval{}({})'.format(o,tensor),u[:,i], scriptID+' '+' '.join(sys.argv[1:])) - - for i,o in enumerate(['Min','Mid','Max']): - table.add('eigvec{}({})'.format(o,tensor),v[:,:,i],scriptID+' '+' '.join(sys.argv[1:])) - - table.to_ASCII(sys.stdout if name is None else name) diff --git a/processing/post/addStrainTensors.py b/processing/post/addStrainTensors.py deleted file mode 100755 index 84c460b00..000000000 --- a/processing/post/addStrainTensors.py +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/env python3 - -import os -import sys -from io import StringIO -from optparse import OptionParser - -import damask - - -scriptName = os.path.splitext(os.path.basename(__file__))[0] -scriptID = ' '.join([scriptName,damask.version]) - -def parameters(stretch,strain): - """Albrecht Bertram: Elasticity and Plasticity of Large Deformations An Introduction (3rd Edition, 2012), p. 102.""" - return { - 'V#ln': ('V',0.0), - 'U#ln': ('U',0.0), - 'V#Biot': ('V',-.5), - 'U#Biot': ('U',+.5), - 'V#Green': ('V',-1.), - 'U#Green': ('U',+1.), - }[stretch+'#'+strain] - - -# -------------------------------------------------------------------- -# MAIN -# -------------------------------------------------------------------- - -parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [ASCIItable(s)]', description = """ -Add column(s) containing given strains based on given stretches of requested deformation gradient column(s). - -""", version = scriptID) - -parser.add_option('-u','--right', - dest = 'right', - action = 'store_true', - help = 'material strains based on right Cauchy--Green deformation, i.e., C and U') -parser.add_option('-v','--left', - dest = 'left', - action = 'store_true', - help = 'spatial strains based on left Cauchy--Green deformation, i.e., B and V') -parser.add_option('-0','--logarithmic', - dest = 'logarithmic', - action = 'store_true', - help = 'calculate logarithmic strain tensor') -parser.add_option('-1','--biot', - dest = 'biot', - action = 'store_true', - help = 'calculate biot strain tensor') -parser.add_option('-2','--green', - dest = 'green', - action = 'store_true', - help = 'calculate green strain tensor') -parser.add_option('-f','--defgrad', - dest = 'defgrad', - action = 'extend', - metavar = '', - help = 'heading(s) of columns containing deformation tensor values [%default]') - -parser.set_defaults( - defgrad = ['f'], - ) - -(options,filenames) = parser.parse_args() -if filenames == []: filenames = [None] - -if len(options.defgrad) > 1: - options.defgrad = options.defgrad[1:] - -stretches = [] -strains = [] - -if options.right: stretches.append('U') -if options.left: stretches.append('V') -if options.logarithmic: strains.append('ln') -if options.biot: strains.append('Biot') -if options.green: strains.append('Green') - -if options.defgrad is None: - parser.error('no data column specified.') - -for name in filenames: - damask.util.report(scriptName,name) - - table = damask.Table.from_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name) - - for defgrad in options.defgrad: - F = table.get(defgrad).reshape(-1,3,3) - for theStretch in stretches: - for theStrain in strains: - (t,m) = parameters(theStretch,theStrain) - label = '{}({}){}'.format(theStrain,theStretch,defgrad if defgrad != 'f' else '') - table.add(label, - damask.mechanics.strain_tensor(F,t,m).reshape(-1,9), - scriptID+' '+' '.join(sys.argv[1:])) - - table.to_ASCII(sys.stdout if name is None else name) diff --git a/processing/post/rotateData.py b/processing/post/rotateData.py deleted file mode 100755 index ee172c64d..000000000 --- a/processing/post/rotateData.py +++ /dev/null @@ -1,62 +0,0 @@ -#!/usr/bin/env python3 - -import os -import sys -from io import StringIO -from optparse import OptionParser - -import damask - - -scriptName = os.path.splitext(os.path.basename(__file__))[0] -scriptID = ' '.join([scriptName,damask.version]) - - -# -------------------------------------------------------------------- -# MAIN -# -------------------------------------------------------------------- - -parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [ASCIItable(s)]', description = """ -Rotate vector and/or tensor column data by given angle around given axis. - -""", version = scriptID) - -parser.add_option('-d', '--data', - dest = 'data', - action = 'extend', metavar = '', - help = 'vector/tensor value(s) label(s)') -parser.add_option('-r', '--rotation', - dest = 'rotation', - type = 'float', nargs = 4, metavar = ' '.join(['float']*4), - help = 'axis and angle to rotate data [%default]') -parser.add_option('--degrees', - dest = 'degrees', - action = 'store_true', - help = 'angles are given in degrees') - -parser.set_defaults(rotation = (1.,1.,1.,0), # no rotation about (1,1,1) - degrees = False, - ) - -(options,filenames) = parser.parse_args() -if filenames == []: filenames = [None] - -if options.data is None: - parser.error('no data column specified.') - -r = damask.Rotation.from_axis_angle(options.rotation,options.degrees,normalise=True) - -for name in filenames: - damask.util.report(scriptName,name) - - table = damask.Table.from_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name) - - for data in options.data: - d = table.get(data) - if table.shapes[data] == (9,): d=d.reshape(-1,3,3) - d = r.broadcast_to(d.shape[0:1]) @ d - if table.shapes[data] == (9,): d=d.reshape(-1,9) - - table.set(data,d,scriptID+' '+' '.join(sys.argv[1:])) - - table.to_ASCII(sys.stdout if name is None else name) diff --git a/processing/post/viewTable.py b/processing/post/viewTable.py deleted file mode 100755 index 1f134754d..000000000 --- a/processing/post/viewTable.py +++ /dev/null @@ -1,89 +0,0 @@ -#!/usr/bin/env python3 - -import os -from optparse import OptionParser - -import damask - - -scriptName = os.path.splitext(os.path.basename(__file__))[0] -scriptID = ' '.join([scriptName,damask.version]) - - -# -------------------------------------------------------------------- -# MAIN -# -------------------------------------------------------------------- - -parser = OptionParser(usage='%prog options [ASCIItable(s)]', description = """ -Show components of given ASCIItable(s). - -""", version = scriptID) - - -parser.add_option('-a','--head', - dest = 'head', - action = 'store_true', - help = 'output complete header (info + labels)') -parser.add_option('-i','--info', - dest = 'info', - action = 'store_true', - help = 'output info lines') -parser.add_option('-l','--labels', - dest = 'labels', - action = 'store_true', - help = 'output labels') -parser.add_option('-d','--data', - dest = 'data', - action = 'store_true', - help = 'output data') -parser.add_option('-t','--table', - dest = 'table', - action = 'store_true', - help = 'output heading line for proper ASCIItable format') -parser.add_option('--nolabels', - dest = 'labeled', - action = 'store_false', - help = 'table has no labels') -parser.set_defaults(table = False, - head = False, - info = False, - labels = False, - data = False, - labeled = True, - ) - -(options,filenames) = parser.parse_args() - -# --- loop over input files ------------------------------------------------------------------------- - -if filenames == []: filenames = [None] - -for name in filenames: - try: - 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 []) + - (['labels'] if options.head or options.labels else []) + - (['data'] if options.data else []) + - [] - ) - damask.util.report(scriptName,(name if name is not None else '') + ('' if details == '' else ' -- '+details)) - -# ------------------------------------------ output head --------------------------------------- - - table.head_read() - if not (options.head or options.info): table.info_clear() - if not (options.head or (options.labels and options.labeled)): table.labels_clear() - - table.head_write(header = options.table) - -# ------------------------------------------ output data --------------------------------------- - - outputAlive = options.data - while outputAlive and table.data_read(): # read next data line of ASCII table - outputAlive = table.data_write() # output line - - table.close() diff --git a/processing/pre/geom_canvas.py b/processing/pre/geom_canvas.py deleted file mode 100755 index b309364e8..000000000 --- a/processing/pre/geom_canvas.py +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env python3 - -import os -import sys -from io import StringIO -from optparse import OptionParser - -import numpy as np - -import damask - - -scriptName = os.path.splitext(os.path.basename(__file__))[0] -scriptID = ' '.join([scriptName,damask.version]) - - -# -------------------------------------------------------------------- -# MAIN -# -------------------------------------------------------------------- - -parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [geomfile(s)]', description = """ -Increases or decreases the (three-dimensional) canvas. -Grid can be given as absolute or relative values, e.g. 16 16 16 or 2x 0.5x 32. - -""", version = scriptID) - -parser.add_option('-g','--grid', - dest = 'grid', - type = 'string', nargs = 3, metavar = ' '.join(['string']*3), - help = 'a,b,c grid of hexahedral box') -parser.add_option('-o','--offset', - dest = 'offset', - type = 'int', nargs = 3, metavar = ' '.join(['int']*3), - help = 'a,b,c offset from old to new origin of grid [%default]') -parser.add_option('-f','--fill', - dest = 'fill', - type = 'float', metavar = 'int', - help = 'background microstructure index, defaults to max microstructure index + 1') - -parser.set_defaults(offset = (0,0,0)) - -(options, filenames) = parser.parse_args() -if filenames == []: filenames = [None] - - -for name in filenames: - damask.util.report(scriptName,name) - - geom = damask.Geom.from_file(StringIO(''.join(sys.stdin.read())) if name is None else name) - offset = np.asarray(options.offset) - - if options.grid is not None: - grid = np.maximum(1, - np.array([int(o*float(n.lower().replace('x',''))) if n.lower().endswith('x') \ - else int(n) for o,n in zip(geom.grid,options.grid)],dtype=int)) - else: - grid = np.array(options.grid,dtype=int) - - damask.util.croak(geom.canvas(grid,np.asarray(options.offset),options.fill)) - geom.add_comments(scriptID + ' ' + ' '.join(sys.argv[1:])) - geom.to_file(sys.stdout if name is None else name,pack=False) diff --git a/processing/pre/geom_check.py b/processing/pre/geom_check.py deleted file mode 100755 index e7e4d1009..000000000 --- a/processing/pre/geom_check.py +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env python3 - -import os -import sys -from io import StringIO -from optparse import OptionParser - -import damask - - -scriptName = os.path.splitext(os.path.basename(__file__))[0] -scriptID = ' '.join([scriptName,damask.version]) - - -#-------------------------------------------------------------------------------------------------- -# MAIN -#-------------------------------------------------------------------------------------------------- - -parser = OptionParser(option_class=damask.extendableOption, usage='%prog [geomfile(s)]', description = """ -Writes vtk file for visualization. - -""", version = scriptID) - -(options, filenames) = parser.parse_args() -if filenames == []: filenames = [None] - -for name in filenames: - damask.util.report(scriptName,name) - - geom = damask.Geom.from_file(StringIO(''.join(sys.stdin.read())) if name is None else name) - - damask.util.croak(geom) - - if name: - geom.to_vtk(os.path.splitext(name)[0]) - else: - sys.stdout.write(geom.to_vtk()) diff --git a/processing/pre/geom_renumber.py b/processing/pre/geom_renumber.py deleted file mode 100755 index 8eab9064a..000000000 --- a/processing/pre/geom_renumber.py +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python3 - -import os -import sys -from io import StringIO -from optparse import OptionParser - -import damask - - -scriptName = os.path.splitext(os.path.basename(__file__))[0] -scriptID = ' '.join([scriptName,damask.version]) - - -#-------------------------------------------------------------------------------------------------- -# MAIN -#-------------------------------------------------------------------------------------------------- - -parser = OptionParser(option_class=damask.extendableOption, usage='%prog [geomfile(s)]', description = """ -Renumber sorted microstructure indices to 1,...,N. - -""", version=scriptID) - -(options, filenames) = parser.parse_args() -if filenames == []: filenames = [None] - -for name in filenames: - damask.util.report(scriptName,name) - - geom = damask.Geom.from_file(StringIO(''.join(sys.stdin.read())) if name is None else name) - damask.util.croak(geom.renumber()) - geom.add_comments(scriptID + ' ' + ' '.join(sys.argv[1:])) - geom.to_file(sys.stdout if name is None else name,pack=False) diff --git a/processing/pre/geom_rotate.py b/processing/pre/geom_rotate.py deleted file mode 100755 index 9a65a0e2b..000000000 --- a/processing/pre/geom_rotate.py +++ /dev/null @@ -1,77 +0,0 @@ -#!/usr/bin/env python3 - -import os -import sys -from io import StringIO -from optparse import OptionParser - -import numpy as np - -import damask - - -scriptName = os.path.splitext(os.path.basename(__file__))[0] -scriptID = ' '.join([scriptName,damask.version]) - - -#-------------------------------------------------------------------------------------------------- -# MAIN -#-------------------------------------------------------------------------------------------------- - -parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [geomfile(s)]', description = """ -Rotates original microstructure and embeddeds it into buffer material. - -""", version=scriptID) - -parser.add_option('-r', '--rotation', - dest='rotation', - type = 'float', nargs = 4, metavar = ' '.join(['float']*4), - help = 'rotation given as axis and angle') -parser.add_option('-e', '--eulers', - dest = 'eulers', - type = 'float', nargs = 3, metavar = ' '.join(['float']*3), - help = 'rotation given as Euler angles') -parser.add_option('-d', '--degrees', - dest = 'degrees', - action = 'store_true', - help = 'Euler angles/axis angle are given in degrees') -parser.add_option('-m', '--matrix', - dest = 'matrix', - type = 'float', nargs = 9, metavar = ' '.join(['float']*9), - help = 'rotation given as matrix') -parser.add_option('-q', '--quaternion', - dest = 'quaternion', - type = 'float', nargs = 4, metavar = ' '.join(['float']*4), - help = 'rotation given as quaternion') -parser.add_option('-f', '--fill', - dest = 'fill', - type = 'float', metavar = 'int', - help = 'background microstructure index, defaults to max microstructure index + 1') - -parser.set_defaults(degrees = False) - -(options, filenames) = parser.parse_args() -if filenames == []: filenames = [None] - -if [options.rotation,options.eulers,options.matrix,options.quaternion].count(None) < 3: - parser.error('more than one rotation specified.') -if [options.rotation,options.eulers,options.matrix,options.quaternion].count(None) > 3: - parser.error('no rotation specified.') - -if options.quaternion is not None: - rot = damask.Rotation.from_quaternion(np.array(options.quaternion)) # we might need P=+1 here, too... -if options.rotation is not None: - rot = damask.Rotation.from_axis_angle(np.array(options.rotation),degrees=options.degrees,normalise=True,P=+1) -if options.matrix is not None: - rot = damask.Rotation.from_matrix(np.array(options.Matrix)) -if options.eulers is not None: - rot = damask.Rotation.from_Eulers(np.array(options.eulers),degrees=options.degrees) - - -for name in filenames: - damask.util.report(scriptName,name) - - geom = damask.Geom.from_file(StringIO(''.join(sys.stdin.read())) if name is None else name) - damask.util.croak(geom.rotate(rot,options.fill)) - geom.add_comments(scriptID + ' ' + ' '.join(sys.argv[1:])) - geom.to_file(sys.stdout if name is None else name,pack=False) diff --git a/processing/pre/geom_translate.py b/processing/pre/geom_translate.py deleted file mode 100755 index 6609e3f7e..000000000 --- a/processing/pre/geom_translate.py +++ /dev/null @@ -1,56 +0,0 @@ -#!/usr/bin/env python3 - -import os -import sys -from optparse import OptionParser -from io import StringIO - -import damask - - -scriptName = os.path.splitext(os.path.basename(__file__))[0] -scriptID = ' '.join([scriptName,damask.version]) - - -#-------------------------------------------------------------------------------------------------- -# MAIN -#-------------------------------------------------------------------------------------------------- - -parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [geomfile(s)]', description = """ -Translate microstructure indices (shift or substitute) and/or geometry origin. - -""", version=scriptID) - -parser.add_option('-o', '--origin', - dest = 'origin', - type = 'float', nargs = 3, metavar = ' '.join(['float']*3), - help = 'offset from old to new origin of grid') -parser.add_option('-m', '--microstructure', - dest = 'microstructure', - type = 'int', metavar = 'int', - help = 'offset from old to new microstructure indices (after substitution)') -parser.add_option('-s', '--substitute', - dest = 'substitute', - action = 'extend', metavar = '', - help = 'substitutions of microstructure indices from,to,from,to,...') - -parser.set_defaults(origin = (0.0,0.0,0.0), - microstructure = 0, - substitute = [] - ) - -(options, filenames) = parser.parse_args() -if filenames == []: filenames = [None] - -sub = list(map(int,options.substitute)) - -for name in filenames: - damask.util.report(scriptName,name) - - geom = damask.Geom.from_file(StringIO(''.join(sys.stdin.read())) if name is None else name) - geom.substitute(sub[0::2],sub[1::2]) - geom.set_origin(geom.origin+options.origin) - geom.set_microstructure(geom.microstructure+options.microstructure) - damask.util.croak(geom) - geom.add_comments(scriptID + ' ' + ' '.join(sys.argv[1:])) - geom.to_file(sys.stdout if name is None else name,pack=False) diff --git a/processing/pre/seeds_check.py b/processing/pre/seeds_check.py deleted file mode 100755 index 6ef808a0a..000000000 --- a/processing/pre/seeds_check.py +++ /dev/null @@ -1,39 +0,0 @@ -#!/usr/bin/env python3 - -import os -import sys -from io import StringIO -from optparse import OptionParser - -import damask - - -scriptName = os.path.splitext(os.path.basename(__file__))[0] -scriptID = ' '.join([scriptName,damask.version]) - - -#-------------------------------------------------------------------------------------------------- -# MAIN -#-------------------------------------------------------------------------------------------------- - -parser = OptionParser(option_class=damask.extendableOption, usage='%prog [seedfile(s)]', description = """ -Writes vtk file for visualization. - -""", version = scriptID) - -(options, filenames) = parser.parse_args() -if filenames == []: filenames = [None] - -for name in filenames: - damask.util.report(scriptName,name) - - seeds = damask.Table.from_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name) - v = damask.VTK.from_polyData(seeds.get('pos')) - for label in seeds.shapes.keys(): - if label == 'pos': pass - v.add(seeds.get(label),label) - - if name: - v.write(os.path.splitext(name)[0]) - else: - sys.stdout.write(v.__repr__()) diff --git a/python/damask/_result.py b/python/damask/_result.py index 476d6d24a..56c0eac17 100644 --- a/python/damask/_result.py +++ b/python/damask/_result.py @@ -1270,20 +1270,3 @@ class Result: inc[3:].zfill(N_digits)) v.write(file_out) - -################################################################################################### -# BEGIN DEPRECATED - - def set_by_time(self,start,end): - """ - Set active increments based on start and end time. - - Parameters - ---------- - start : float - start time (included) - end : float - end time (included) - - """ - self._manage_selection('set','times',self.times_in_range(start,end)) diff --git a/python/damask/_rotation.py b/python/damask/_rotation.py index f90c5fcc0..b1b1cd5ad 100644 --- a/python/damask/_rotation.py +++ b/python/damask/_rotation.py @@ -158,6 +158,7 @@ class Rotation: def broadcast_to(self,shape): + if isinstance(shape,int): shape = (shape,) if self.shape == (): q = np.broadcast_to(self.quaternion,shape+(4,)) else: diff --git a/src/mesh/mesh_mech_FEM.f90 b/src/mesh/mesh_mech_FEM.f90 index a2f4b9e70..5038d5f07 100644 --- a/src/mesh/mesh_mech_FEM.f90 +++ b/src/mesh/mesh_mech_FEM.f90 @@ -71,7 +71,7 @@ subroutine FEM_mech_init(fieldBC) PetscQuadrature :: mechQuad, functional PetscDS :: mechDS PetscDualSpace :: mechDualSpace - DMLabel, dimension(:),pointer :: pBCLabel + DMLabel, dimension(:),pointer :: nolabel=> NULL() DMLabel :: BCLabel PetscInt, dimension(:), pointer :: pNumComp, pNumDof, pBcField, pBcPoint @@ -134,7 +134,7 @@ subroutine FEM_mech_init(fieldBC) ! Setup FEM mech boundary conditions call DMGetLabel(mech_mesh,'Face Sets',BCLabel,ierr); CHKERRQ(ierr) call DMPlexLabelComplete(mech_mesh,BCLabel,ierr); CHKERRQ(ierr) -#if (PETSC_VERSION_MINOR < 11) +#if (PETSC_VERSION_MINOR < 12) call DMGetSection(mech_mesh,section,ierr); CHKERRQ(ierr) #else call DMGetLocalSection(mech_mesh,section,ierr); CHKERRQ(ierr) @@ -180,8 +180,7 @@ subroutine FEM_mech_init(fieldBC) call DMPlexCreateSection(mech_mesh,dimPlex,1,pNumComp,pNumDof, & numBC,pBcField,pBcComps,pBcPoints,PETSC_NULL_IS,section,ierr) #else - allocate(pBClabel(1),source=BClabel) - call DMPlexCreateSection(mech_mesh,pBClabel,pNumComp,pNumDof, & + call DMPlexCreateSection(mech_mesh,nolabel,pNumComp,pNumDof, & numBC,pBcField,pBcComps,pBcPoints,PETSC_NULL_IS,section,ierr) #endif @@ -315,7 +314,7 @@ subroutine FEM_mech_formResidual(dm_local,xx_local,f_local,dummy,ierr) PetscReal, pointer,dimension(:) :: pV0, pCellJ, pInvcellJ, basisField, basisFieldDer PetscInt :: cellStart, cellEnd, cell, field, face, & qPt, basis, comp, cidx, & - numFields, depth ! < DEBUG + numFields PetscReal :: detFAvg PetscReal :: BMat(dimPlex*dimPlex,cellDof) @@ -328,7 +327,7 @@ subroutine FEM_mech_formResidual(dm_local,xx_local,f_local,dummy,ierr) allocate(pinvcellJ(dimPlex**2)) allocate(x_scal(cellDof)) -#if (PETSC_VERSION_MINOR < 11) +#if (PETSC_VERSION_MINOR < 12) call DMGetSection(dm_local,section,ierr); CHKERRQ(ierr) #else call DMGetLocalSection(dm_local,section,ierr); CHKERRQ(ierr) @@ -356,15 +355,8 @@ subroutine FEM_mech_formResidual(dm_local,xx_local,f_local,dummy,ierr) ! evaluate field derivatives do cell = cellStart, cellEnd-1 !< loop over all elements - ! BEGIN DEBUG call PetscSectionGetNumFields(section,numFields,ierr) CHKERRQ(ierr) - write(6,*) 'numFields', numFields - call DMPlexGetDepth(dm_local,depth,ierr) - CHKERRQ(ierr) - write(6,*) 'depth', depth - ! END DEBUG - call DMPlexVecGetClosure(dm_local,section,x_local,cell,x_scal,ierr) !< get Dofs belonging to element CHKERRQ(ierr) call DMPlexComputeCellGeometryAffineFEM(dm_local,cell,pV0,pCellJ,pInvcellJ,detJ,ierr) @@ -482,7 +474,7 @@ subroutine FEM_mech_formJacobian(dm_local,xx_local,Jac_pre,Jac,dummy,ierr) call MatZeroEntries(Jac,ierr); CHKERRQ(ierr) call DMGetDS(dm_local,prob,ierr); CHKERRQ(ierr) call PetscDSGetTabulation(prob,0,basisField,basisFieldDer,ierr) -#if (PETSC_VERSION_MINOR < 11) +#if (PETSC_VERSION_MINOR < 12) call DMGetSection(dm_local,section,ierr); CHKERRQ(ierr) #else call DMGetLocalSection(dm_local,section,ierr); CHKERRQ(ierr)