no need to loop over files

will procude the same file over and over again
This commit is contained in:
Martin Diehl 2019-05-30 09:31:14 +02:00
parent c5daa7e577
commit f30eda0267
3 changed files with 21 additions and 24 deletions

View File

@ -70,30 +70,28 @@ parser.set_defaults(type = minimal_surfaces[0],
microstructure = (1,2),
)
(options,filenames) = parser.parse_args()
(options,filename) = parser.parse_args()
if filenames == []: filenames = [None]
name = None if filename == [] else filename[0]
damask.util.report(scriptName,name)
for name in filenames:
damask.util.report(scriptName,name)
X = options.periods*2.0*np.pi*(np.arange(options.grid[0])+0.5)/options.grid[0]
Y = options.periods*2.0*np.pi*(np.arange(options.grid[1])+0.5)/options.grid[1]
Z = options.periods*2.0*np.pi*(np.arange(options.grid[2])+0.5)/options.grid[2]
X = options.periods*2.0*np.pi*(np.arange(options.grid[0])+0.5)/options.grid[0]
Y = options.periods*2.0*np.pi*(np.arange(options.grid[1])+0.5)/options.grid[1]
Z = options.periods*2.0*np.pi*(np.arange(options.grid[2])+0.5)/options.grid[2]
microstructure = np.empty(options.grid,dtype=int)
for x in range(options.grid[0]):
for y in range(options.grid[1]):
for z in range(options.grid[2]):
microstructure[x,y,z]=options.microstructure[int(options.threshold < surface[options.type](X[x],Y[y],Z[z]))]
microstructure = np.empty(options.grid,dtype=int)
for x in range(options.grid[0]):
for y in range(options.grid[1]):
for z in range(options.grid[2]):
microstructure[x,y,z]=options.microstructure[int(options.threshold < surface[options.type](X[x],Y[y],Z[z]))]
geom=damask.Geom(microstructure,options.size,
homogenization=options.homogenization,
comments=[scriptID + ' ' + ' '.join(sys.argv[1:])])
geom=damask.Geom(microstructure,options.size,
homogenization=options.homogenization,
comments=[scriptID + ' ' + ' '.join(sys.argv[1:])])
damask.util.croak(geom)
if name is None:
sys.stdout.write(str(geom.show()))
else:
geom.to_file(name)
damask.util.croak(geom)
if name is None:
sys.stdout.write(str(geom.show()))
else:
geom.to_file(name)

View File

@ -1,4 +1,3 @@
import math
from io import StringIO
import numpy as np
@ -193,7 +192,7 @@ class Geom():
"""Writes to file"""
header = self.get_header()
grid = self.get_grid()
format_string = '%{}i'.format(int(math.floor(math.log10(self.microstructure.max())+1))) if self.microstructure.dtype == int \
format_string = '%{}i'.format(1+int(np.floor(np.log10(np.nanmax(self.microstructure)-1)))) if self.microstructure.dtype == int \
else '%g'
np.savetxt(fname,
self.microstructure.reshape([grid[0],np.prod(grid[1:])],order='F').T,