switched importing from "msc_tools" to "damask"
patchFrom... now skips blank lines, has more commenting, treats (artificial) bi-crystal (somewhat) gracefully.
This commit is contained in:
parent
3a22bf7e27
commit
7ed2c19d0f
|
@ -1,10 +1,10 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys, os, msc_tools, string
|
||||
import sys, os, string, damask
|
||||
from colorsys import *
|
||||
from optparse import OptionParser
|
||||
|
||||
sys.path.append(msc_tools.MSC_TOOLS().libraryPath(sys.argv[0],'../../'))
|
||||
sys.path.append(damask.solver.Marc().libraryPath('../../'))
|
||||
|
||||
try:
|
||||
from py_mentat import *
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import pdb, os, sys, gc, math, re, threading, time, struct, string
|
||||
import msc_tools
|
||||
import damask
|
||||
from optparse import OptionParser, OptionGroup, Option, SUPPRESS_HELP
|
||||
|
||||
|
||||
|
@ -755,7 +755,7 @@ if options.filetype not in ['marc','spectral']:
|
|||
parser.error('file type "%s" not supported...'%options.filetype)
|
||||
|
||||
if options.filetype == 'marc':
|
||||
sys.path.append(msc_tools.MSC_TOOLS().libraryPath(sys.argv[0],'../../'))
|
||||
sys.path.append(damask.solver.Marc().libraryPath('../../'))
|
||||
|
||||
try:
|
||||
from py_post import *
|
||||
|
@ -838,7 +838,7 @@ for opt in ['nodalScalar','elemScalar','elemTensor','homogenizationResult','crys
|
|||
|
||||
if options.info:
|
||||
if options.filetype == 'marc':
|
||||
print '\n\nMentat release %s'%msc_tools.MSC_TOOLS().version(sys.argv[0],'../../')
|
||||
print '\n\nMentat release %s'%damask.solver.Marc().version('../../')
|
||||
if options.filetype == 'spectral':
|
||||
print '\n\n',p
|
||||
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys,os,pwd,math,re,string,msc_tools
|
||||
import sys,os,pwd,math,re,string, damask
|
||||
from optparse import OptionParser
|
||||
|
||||
sys.path.append(msc_tools.MSC_TOOLS().libraryPath(sys.argv[0],'../../'))
|
||||
sys.path.append(damask.solver.Marc().libraryPath('../../'))
|
||||
|
||||
try:
|
||||
from py_mentat import *
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os, sys, math, re, threading, time, string, msc_tools
|
||||
import os, sys, math, re, threading, time, string, damask
|
||||
from optparse import OptionParser, OptionGroup, Option, SUPPRESS_HELP
|
||||
|
||||
|
||||
|
@ -251,7 +251,7 @@ parser.set_defaults(homogenization = 1)
|
|||
(options, args) = parser.parse_args()
|
||||
|
||||
|
||||
sys.path.append(msc_tools.MSC_TOOLS().libraryPath(sys.argv[0],'../../'))
|
||||
sys.path.append(damask.solver.Marc().libraryPath('../../'))
|
||||
|
||||
try:
|
||||
from py_mentat import *
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import sys,os,math,re,string, msc_tools
|
||||
import sys,os,math,re,string, damask
|
||||
from optparse import OptionParser, OptionGroup, Option, SUPPRESS_HELP
|
||||
|
||||
|
||||
|
@ -10,7 +10,7 @@ try: # check for Python Image Lib
|
|||
except:
|
||||
ImageCapability = False
|
||||
|
||||
sys.path.append(msc_tools.MSC_TOOLS().libraryPath(sys.argv[0],'../../'))
|
||||
sys.path.append(damask.solver.Marc().libraryPath('../../'))
|
||||
|
||||
try: # check for MSC.Mentat Python interface
|
||||
from py_mentat import *
|
||||
|
@ -79,7 +79,8 @@ def rcbOrientationParser(content):
|
|||
grains = []
|
||||
myOrientation = [0.0,0.0,0.0]
|
||||
for line in content:
|
||||
if line[0] != '#': # skip comments
|
||||
m = re.match(r'\s*(#|$)',line)
|
||||
if m: continue # skip comments and blank lines
|
||||
for grain in range(2):
|
||||
myID = int(line.split()[12+grain]) # get grain id
|
||||
myOrientation = map(float,line.split())[3*grain:3+3*grain] # get orientation
|
||||
|
@ -99,7 +100,8 @@ def rcbParser(content,M,size,tolerance): # parser for TSL-O
|
|||
x = [0.,0.]
|
||||
y = [0.,0.]
|
||||
for line in content:
|
||||
if line[0] != '#': # skip comments
|
||||
m = re.match(r'\s*(#|$)',line)
|
||||
if m: continue # skip comments and blank lines
|
||||
(x[0],y[0],x[1],y[1]) = map(float,line.split())[8:12] # get start and end coordinates of each segment.
|
||||
(x[0],y[0]) = (M[0]*x[0]+M[1]*y[0],M[2]*x[0]+M[3]*y[0]) # apply transformation to coordinates
|
||||
(x[1],y[1]) = (M[0]*x[1]+M[1]*y[1],M[2]*x[1]+M[3]*y[1]) # to get rcb --> Euler system
|
||||
|
@ -122,7 +124,8 @@ def rcbParser(content,M,size,tolerance): # parser for TSL-O
|
|||
grainNeighbors = []
|
||||
|
||||
for line in content:
|
||||
if line[0] != '#': # skip comments
|
||||
m = re.match(r'\s*(#|$)',line)
|
||||
if m: continue # skip comments and blank lines
|
||||
(x[0],y[0],x[1],y[1]) = map(float,line.split())[8:12] # get start and end coordinates of each segment
|
||||
(x[0],y[0]) = (M[0]*x[0]+M[1]*y[0],M[2]*x[0]+M[3]*y[0]) # apply transformation to coordinates
|
||||
(x[1],y[1]) = (M[0]*x[1]+M[1]*y[1],M[2]*x[1]+M[3]*y[1]) # to get rcb --> Euler system
|
||||
|
@ -295,18 +298,23 @@ def rcbParser(content,M,size,tolerance): # parser for TSL-O
|
|||
rcData['segment'].append(segment)
|
||||
print " built %i segments"%(len(rcData['segment']))
|
||||
|
||||
for grain in grains['legs']:
|
||||
rcData['grain'].append(grain)
|
||||
for legs in grains['legs']: # loop over grains
|
||||
rcData['grain'].append(legs) # store list of boundary segments
|
||||
myNeighbors = {}
|
||||
for leg in grain:
|
||||
if leg < len(grainNeighbors):
|
||||
for side in range(2):
|
||||
if grainNeighbors[leg][side] in myNeighbors:
|
||||
for leg in legs: # test each boundary segment
|
||||
if leg < len(grainNeighbors): # a valid segment index?
|
||||
for side in range(2): # look at both sides of the segment
|
||||
if grainNeighbors[leg][side] in myNeighbors: # count occurrence of grain IDs
|
||||
myNeighbors[grainNeighbors[leg][side]] += 1
|
||||
else:
|
||||
myNeighbors[grainNeighbors[leg][side]] = 1
|
||||
if myNeighbors: # do I have any neighbors
|
||||
rcData['grainMapping'].append(sorted(myNeighbors.iteritems(), key=lambda (k,v): (v,k), reverse=True)[0][0]) # most frequent grain is me
|
||||
if myNeighbors: # do I have any neighbors (i.e., non-bounding box segment)
|
||||
candidateGrains = sorted(myNeighbors.iteritems(), key=lambda (k,v): (v,k), reverse=True) # sort grain counting
|
||||
if candidateGrains[0][0] not in rcData['grainMapping']: # most frequent one not yet seen?
|
||||
rcData['grainMapping'].append(candidateGrains[0][0]) # must be me then
|
||||
else:
|
||||
rcData['grainMapping'].append(candidateGrains[1][0]) # special case of bi-crystal situation...
|
||||
|
||||
print " found %i grains\n"%(len(rcData['grain']))
|
||||
|
||||
rcData['box'] = grains['box']
|
||||
|
|
Loading…
Reference in New Issue