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