adapted to VTR geom files

This commit is contained in:
Philip Eisenlohr 2020-11-19 14:26:15 -05:00
parent a82b1adc14
commit 662a033d91
5 changed files with 11 additions and 13 deletions

@ -1 +1 @@
Subproject commit 2d00aa541f071dbfc200f32e358d324995a061f5 Subproject commit d04e6753e7e6cea9089ee1d1602c55a715f73d45

View File

@ -15,8 +15,8 @@ scriptName = os.path.splitext(os.path.basename(__file__))[0]
scriptID = ' '.join([scriptName,damask.version]) scriptID = ' '.join([scriptName,damask.version])
getInterfaceEnergy = lambda A,B: np.float32((A*B != 0)*(A != B)*1.0) # 1.0 if A & B are distinct & nonzero, 0.0 otherwise getInterfaceEnergy = lambda A,B: np.float32((A != B)*1.0) # 1.0 if A & B are distinct, 0.0 otherwise
struc = ndimage.generate_binary_structure(3,1) # 3D von Neumann neighborhood struc = ndimage.generate_binary_structure(3,1) # 3D von Neumann neighborhood
#-------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------
@ -62,7 +62,7 @@ if filenames == []: filenames = [None]
for name in filenames: for name in filenames:
damask.util.report(scriptName,name) damask.util.report(scriptName,name)
geom = damask.Geom.load_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name) geom = damask.Geom.load(StringIO(''.join(sys.stdin.read())) if name is None else name)
grid_original = geom.grid grid_original = geom.grid
damask.util.croak(geom) damask.util.croak(geom)
@ -174,4 +174,4 @@ for name in filenames:
origin = geom.origin, origin = geom.origin,
comments = geom.comments + [scriptID + ' ' + ' '.join(sys.argv[1:])], comments = geom.comments + [scriptID + ' ' + ' '.join(sys.argv[1:])],
)\ )\
.save_ASCII(sys.stdout if name is None else name) .save(sys.stdout if name is None else name)

View File

@ -11,8 +11,6 @@ import numpy as np
import damask import damask
sys.path.append(str(damask.solver.Marc().library_path))
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])
@ -235,6 +233,7 @@ if remote and filenames != []:
if filenames == []: filenames = [None] if filenames == []: filenames = [None]
if remote: if remote:
sys.path.append(str(damask.solver.Marc().library_path))
import py_mentat import py_mentat
damask.util.report(scriptName, 'waiting to connect...') damask.util.report(scriptName, 'waiting to connect...')

View File

@ -9,7 +9,6 @@ import damask
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])
sys.path.append(str(damask.solver.Marc().library_path))
#------------------------------------------------------------------------------------------------- #-------------------------------------------------------------------------------------------------
def outMentat(cmd,locals): def outMentat(cmd,locals):
@ -185,9 +184,10 @@ parser.set_defaults(port = None,
if options.port is not None: if options.port is not None:
try: try:
sys.path.append(str(damask.solver.Marc().library_path))
import py_mentat import py_mentat
except ImportError: except ImportError:
parser.error('no valid Mentat release found.') parser.error('no valid Mentat release found')
# --- loop over input files ------------------------------------------------------------------------ # --- loop over input files ------------------------------------------------------------------------
@ -196,7 +196,7 @@ if filenames == []: filenames = [None]
for name in filenames: for name in filenames:
damask.util.report(scriptName,name) damask.util.report(scriptName,name)
geom = damask.Geom.load_ASCII(StringIO(''.join(sys.stdin.read())) if name is None else name) geom = damask.Geom.load(StringIO(''.join(sys.stdin.read())) if name is None else name)
material = geom.material.flatten(order='F') material = geom.material.flatten(order='F')
cmds = [\ cmds = [\

View File

@ -213,9 +213,8 @@ class Geom:
if not keyword.startswith('head') or header_length < 3: if not keyword.startswith('head') or header_length < 3:
raise TypeError('Header length information missing or invalid') raise TypeError('Header length information missing or invalid')
content = f.readlines()
comments = [] comments = []
content = f.readlines()
for i,line in enumerate(content[:header_length]): for i,line in enumerate(content[:header_length]):
items = line.split('#')[0].lower().strip().split() items = line.split('#')[0].lower().strip().split()
key = items[0] if items else '' key = items[0] if items else ''
@ -510,7 +509,7 @@ class Geom:
Parameters Parameters
---------- ----------
fname : str or or pathlib.Path fname : str or pathlib.Path
Filename to write. Valid extension is .vtr, it will be appended if not given. Filename to write. Valid extension is .vtr, it will be appended if not given.
compress : bool, optional compress : bool, optional
Compress with zlib algorithm. Defaults to True. Compress with zlib algorithm. Defaults to True.