cleaned
This commit is contained in:
parent
c8dfba89e5
commit
b5cec797c0
|
@ -1,30 +1,33 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: UTF-8 no BOM -*-
|
||||
|
||||
import os
|
||||
import sys
|
||||
import math
|
||||
import numpy as np
|
||||
from optparse import OptionParser
|
||||
|
||||
import numpy as np
|
||||
|
||||
import damask
|
||||
|
||||
|
||||
scriptName = os.path.splitext(os.path.basename(__file__))[0]
|
||||
scriptID = ' '.join([scriptName,damask.version])
|
||||
|
||||
|
||||
minimal_surfaces = ['primitive','gyroid','diamond']
|
||||
|
||||
surface = {
|
||||
'primitive': lambda x,y,z: np.cos(x)+np.cos(y)+np.cos(z),
|
||||
'gyroid': lambda x,y,z: np.sin(x)*np.cos(y)+np.sin(y)*np.cos(z)+np.cos(x)*np.sin(z),
|
||||
'diamond': lambda x,y,z: np.cos(x-y)*np.cos(z)+np.sin(x+y)*np.sin(z),
|
||||
}
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# MAIN
|
||||
# --------------------------------------------------------------------
|
||||
|
||||
minimal_surfaces = ['primitive','gyroid','diamond',]
|
||||
|
||||
surface = {
|
||||
'primitive': lambda x,y,z: math.cos(x)+math.cos(y)+math.cos(z),
|
||||
'gyroid': lambda x,y,z: math.sin(x)*math.cos(y)+math.sin(y)*math.cos(z)+math.cos(x)*math.sin(z),
|
||||
'diamond': lambda x,y,z: math.cos(x-y)*math.cos(z)+math.sin(x+y)*math.sin(z),
|
||||
}
|
||||
|
||||
parser = OptionParser(option_class=damask.extendableOption, usage='%prog [option(s)] [geomfile]', description = """
|
||||
Generate a geometry file of a bicontinuous structure of given type.
|
||||
parser = OptionParser(option_class=damask.extendableOption, usage='%prog options [geomfile]', description = """
|
||||
Generate a bicontinuous structure of given type.
|
||||
|
||||
""", version = scriptID)
|
||||
|
||||
|
@ -57,6 +60,7 @@ parser.add_option('--m',
|
|||
dest = 'microstructure',
|
||||
type = 'int', nargs = 2, metavar = 'int int',
|
||||
help = 'two microstructure indices to be used [%default]')
|
||||
|
||||
parser.set_defaults(type = minimal_surfaces[0],
|
||||
threshold = 0.0,
|
||||
periods = 1,
|
||||
|
@ -68,24 +72,23 @@ parser.set_defaults(type = minimal_surfaces[0],
|
|||
|
||||
(options,filenames) = parser.parse_args()
|
||||
|
||||
# --- loop over input files -------------------------------------------------------------------------
|
||||
|
||||
if filenames == []: filenames = [None]
|
||||
|
||||
for name in filenames:
|
||||
damask.util.report(scriptName,name)
|
||||
|
||||
X = options.periods*2.0*math.pi*(np.arange(options.grid[0])+0.5)/options.grid[0]
|
||||
Y = options.periods*2.0*math.pi*(np.arange(options.grid[1])+0.5)/options.grid[1]
|
||||
Z = options.periods*2.0*math.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 z in range(options.grid[2]):
|
||||
for x in range(options.grid[0]):
|
||||
for y in range(options.grid[1]):
|
||||
for x in range(options.grid[0]):
|
||||
for z in range(options.grid[2]):
|
||||
microstructure[x,y,z]=options.microstructure[options.threshold < surface[options.type](X[x],Y[y],Z[z])]
|
||||
|
||||
geom=damask.Geom(options.size,microstructure,options.homogenization,
|
||||
geom=damask.Geom(microstructure,options.size,options.homogenization,
|
||||
comments=[scriptID + ' ' + ' '.join(sys.argv[1:])])
|
||||
|
||||
damask.util.croak(geom)
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
import os
|
||||
import sys
|
||||
import multiprocessing
|
||||
from io import StringIO
|
||||
from optparse import OptionParser,OptionGroup
|
||||
|
||||
import numpy as np
|
||||
|
@ -101,6 +100,7 @@ def laguerreTessellation(undeformed, coords, weights, grains, periodic = True, c
|
|||
# closestSeed is modulo number of original seed points (i.e. excluding periodic copies)
|
||||
return grains[closestSeeds%coords.shape[0]]
|
||||
|
||||
|
||||
# --------------------------------------------------------------------
|
||||
# MAIN
|
||||
# --------------------------------------------------------------------
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
import os
|
||||
import sys
|
||||
from io import StringIO
|
||||
from optparse import OptionParser
|
||||
|
||||
import numpy as np
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
import os
|
||||
import sys
|
||||
from io import StringIO
|
||||
from optparse import OptionParser
|
||||
|
||||
import damask
|
||||
|
@ -49,7 +50,7 @@ for name in filenames:
|
|||
compressType = 'of'
|
||||
reps += 1
|
||||
else:
|
||||
if compressType == None:
|
||||
if compressType is None:
|
||||
out = []
|
||||
elif compressType == '.':
|
||||
out.append('{}\n'.format(former))
|
||||
|
|
|
@ -9,7 +9,6 @@ class Geom():
|
|||
|
||||
def __init__(self,microstructure,size,homogenization=1,comments=[]):
|
||||
"""New geometry definition from array of microstructures and size"""
|
||||
|
||||
if len(microstructure.shape) != 3:
|
||||
raise ValueError('Invalid microstructure shape {}'.format(*microstructure.shape))
|
||||
elif microstructure.dtype not in [int,float]:
|
||||
|
|
Loading…
Reference in New Issue