Merge remote-tracking branch 'origin/development' into unit-in-vtk
This commit is contained in:
commit
287d44c5df
2
PRIVATE
2
PRIVATE
|
@ -1 +1 @@
|
||||||
Subproject commit e719eee4f213baedecb8c68afab12331e3730d62
|
Subproject commit 25b7b78951ab9fb682aaf048d3e0f0d09a3be695
|
|
@ -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)
|
||||||
|
|
|
@ -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...')
|
||||||
|
|
|
@ -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 = [\
|
||||||
|
|
|
@ -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 ''
|
||||||
|
@ -228,7 +227,7 @@ class Geom:
|
||||||
else:
|
else:
|
||||||
comments.append(line.strip())
|
comments.append(line.strip())
|
||||||
|
|
||||||
material = np.empty(grid.prod()) # initialize as flat array
|
material = np.empty(grid.prod()) # initialize as flat array
|
||||||
i = 0
|
i = 0
|
||||||
for line in content[header_length:]:
|
for line in content[header_length:]:
|
||||||
items = line.split('#')[0].split()
|
items = line.split('#')[0].split()
|
||||||
|
@ -246,8 +245,8 @@ class Geom:
|
||||||
if i != grid.prod():
|
if i != grid.prod():
|
||||||
raise TypeError(f'Invalid file: expected {grid.prod()} entries, found {i}')
|
raise TypeError(f'Invalid file: expected {grid.prod()} entries, found {i}')
|
||||||
|
|
||||||
if not np.any(np.mod(material,1) != 0.0): # no float present
|
if not np.any(np.mod(material,1) != 0.0): # no float present
|
||||||
material = material.astype('int')
|
material = material.astype('int') - (1 if material.min() > 0 else 0)
|
||||||
|
|
||||||
return Geom(material.reshape(grid,order='F'),size,origin,comments)
|
return Geom(material.reshape(grid,order='F'),size,origin,comments)
|
||||||
|
|
||||||
|
@ -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.
|
||||||
|
|
|
@ -74,6 +74,7 @@ class TestGeom:
|
||||||
|
|
||||||
def test_save_load_ASCII(self,default,tmp_path):
|
def test_save_load_ASCII(self,default,tmp_path):
|
||||||
default.save_ASCII(tmp_path/'ASCII')
|
default.save_ASCII(tmp_path/'ASCII')
|
||||||
|
default.material -= 1
|
||||||
assert geom_equal(Geom.load_ASCII(tmp_path/'ASCII'),default)
|
assert geom_equal(Geom.load_ASCII(tmp_path/'ASCII'),default)
|
||||||
|
|
||||||
def test_invalid_origin(self,default):
|
def test_invalid_origin(self,default):
|
||||||
|
|
Loading…
Reference in New Issue