VPSC file format not used, if needed convert first to geom

This commit is contained in:
Martin Diehl 2015-05-18 18:59:41 +00:00
parent 76d456ee49
commit cd94469ea0
1 changed files with 10 additions and 43 deletions

View File

@ -189,9 +189,9 @@ def parse_geomFile(content,homog):
for line in content[:skip]: for line in content[:skip]:
data = line.split() data = line.split()
if data[0].lower() == 'grid' or data[0].lower() == 'resolution': if data[0].lower() == 'grid':
grid = map(int,data[2:8:2]) grid = map(int,data[2:8:2])
if data[0].lower() == 'size' or data[0].lower() == 'dimension': if data[0].lower() == 'size':
size = map(float,data[2:8:2]) size = map(float,data[2:8:2])
if data[0].lower() == 'homogenization': if data[0].lower() == 'homogenization':
homog = int(data[1]) homog = int(data[1])
@ -203,31 +203,6 @@ def parse_geomFile(content,homog):
return (grid,size,homog,microstructures) return (grid,size,homog,microstructures)
#-------------------------------------------------------------------------------------------------
def parse_spectralFile(content,homog):
#-------------------------------------------------------------------------------------------------
coords = [{},{},{}]
maxBox = [-1.0e20,-1.0e20,-1.0e20]
minBox = [ 1.0e20, 1.0e20, 1.0e20]
grid = [0.0,0.0,0.0]
size = [0,0,0]
microstructures = []
for line in content:
data = line.split()[3:7]
microstructures.append(int(data[3]))
for i in range(3):
maxBox[i] = max(maxBox[i],float(data[i]))
minBox[i] = min(minBox[i],float(data[i]))
coords[i][data[i]] = True
for i in range(3):
grid[i] = len(coords[i])
size[i] = (maxBox[i]-minBox[i])*grid[i]/(grid[i]-1.0)
return (grid,size,homog,microstructures)
#-------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------
# MAIN # MAIN
#-------------------------------------------------------------------------------------------------- #--------------------------------------------------------------------------------------------------
@ -237,16 +212,11 @@ Generate MSC.Marc FE hexahedral mesh from spectral description file.
""", version = scriptID) """, version = scriptID)
parser.add_option("-p", "--port", type="int",dest="port",metavar='int', parser.add_option('-p', '--port', type='int',dest='port',metavar='int',
help="Mentat connection port") help='Mentat connection port [%default]')
parser.add_option("-g", "--geom", action="store_const", const="geom",dest="filetype", parser.add_option('--homogenization', dest='homogenization', type='int', metavar = 'int',
help="file has 'geom' format") help='homogenization index to be used [%default]')
parser.add_option("-s", "--spectral", action="store_const", const="spectral",dest="filetype", parser.set_defaults(port = None)
help="file has 'spectral' format (VPSC code by R.A. Lebensohn)")
parser.add_option("--homogenization", type="int",dest="homogenization",metavar='int',
help="homogenization index from material.config (only required for 'spectral' file type)")
parser.set_defaults(filetype = 'geom')
parser.set_defaults(homogenization = 1) parser.set_defaults(homogenization = 1)
(options, filenames) = parser.parse_args() (options, filenames) = parser.parse_args()
@ -284,13 +254,10 @@ for file in files:
content = file['input'].readlines() content = file['input'].readlines()
(grid,size,homog,microstructures) = {\ (grid,size,homog,microstructures) = parse_geomFile(content, options.homogenization)
'geom': parse_geomFile,
'spectral': parse_spectralFile,
}[options.filetype](content,options.homogenization)
print('%i microstructures in %s with grid %s and homogenization %i\n'%(len(list(set(microstructures))),str(size),str(grid),homog))
file['croak'].write('%i microstructures in %s with grid %s and homogenization %i\n'
%(len(list(set(microstructures))),str(size),str(grid),homog))
cmds = [\ cmds = [\
init(), init(),