adopting to Python standards
This commit is contained in:
parent
20f984fc87
commit
03a81b81e8
|
@ -11,8 +11,8 @@ import numpy as np
|
|||
|
||||
import damask
|
||||
|
||||
scriptName = os.path.splitext(os.path.basename(__file__))[0]
|
||||
scriptID = ' '.join([scriptName,damask.version])
|
||||
script_name = os.path.splitext(os.path.basename(__file__))[0]
|
||||
script_id = ' '.join([script_name,damask.version])
|
||||
|
||||
# Convert .mfd file into a usable format
|
||||
# Broken into labeled sections (eg. nodes, links, etc)
|
||||
|
@ -143,7 +143,7 @@ def add_servoLinks(mfd_data,active=[True,True,True]): # directions on which to
|
|||
|
||||
if Nmax > 0 and Nmax >= Nmin: # node is on at least as many front than back faces
|
||||
if any([maxFlag[i] and active[i] for i in range(3)]):
|
||||
linkNodes.append({'id': node+1,'coord': NodeCoords[node], 'faceMember': [maxFlag[i] and active[i] for i in range(3)]})
|
||||
linkNodes.append({'id':node+1,'coord':NodeCoords[node],'faceMember':[maxFlag[i] and active[i] for i in range(3)]})
|
||||
|
||||
mfd_data[mfd_dict['entities']]['els'][0][0] += len(linkNodes) * 3
|
||||
|
||||
|
@ -209,7 +209,7 @@ def add_servoLinks(mfd_data,active=[True,True,True]): # directions on which to
|
|||
parser = OptionParser(usage='%prog options [file[s]]', description = """
|
||||
Set up servo linking to achieve periodic boundary conditions for a regular hexahedral mesh.
|
||||
Use *py_connection to operate on model presently opened in MSC.Mentat.
|
||||
""", version = scriptID)
|
||||
""", version = script_id)
|
||||
|
||||
parser.add_option('-p', '--port',
|
||||
type = int, metavar = 'int', default = None,
|
||||
|
@ -236,7 +236,7 @@ if remote:
|
|||
sys.path.append(str(damask.solver.Marc().library_path))
|
||||
import py_mentat
|
||||
|
||||
print(scriptName+': waiting to connect...')
|
||||
print(script_name+': waiting to connect...')
|
||||
filenames = [os.path.join(tempfile._get_default_tempdir(), next(tempfile._get_candidate_names()) + '.mfd')]
|
||||
try:
|
||||
py_mentat.py_connect('',options.port)
|
||||
|
@ -250,13 +250,13 @@ if remote:
|
|||
|
||||
for name in filenames:
|
||||
while remote and not os.path.exists(name): time.sleep(0.5)
|
||||
with open( name,'r') if name is not None else sys.stdin as fileIn:
|
||||
print(scriptName+': '+name)
|
||||
mfd = parseMFD(fileIn)
|
||||
with open( name,'r') if name is not None else sys.stdin as file_in:
|
||||
print(script_name+': '+name)
|
||||
mfd = parseMFD(file_in)
|
||||
|
||||
add_servoLinks(mfd,[options.x,options.y,options.z])
|
||||
with open( name,'w') if name is not None else sys.stdout as fileOut:
|
||||
fileOut.write(asMFD(mfd))
|
||||
with open( name,'w') if name is not None else sys.stdout as file_out:
|
||||
file_out.write(asMFD(mfd))
|
||||
|
||||
if remote:
|
||||
py_mentat.py_send('*open_model "{}"'.format(filenames[0]))
|
||||
|
|
|
@ -7,8 +7,8 @@ from optparse import OptionParser
|
|||
|
||||
import damask
|
||||
|
||||
scriptName = os.path.splitext(os.path.basename(__file__))[0]
|
||||
scriptID = ' '.join([scriptName,damask.version])
|
||||
script_name = os.path.splitext(os.path.basename(__file__))[0]
|
||||
script_id = ' '.join([script_name,damask.version])
|
||||
|
||||
#-------------------------------------------------------------------------------------------------
|
||||
def outMentat(cmd,locals):
|
||||
|
@ -45,7 +45,7 @@ def output(cmds,locals,dest):
|
|||
#-------------------------------------------------------------------------------------------------
|
||||
def init():
|
||||
return [
|
||||
"|"+' '.join([scriptID] + sys.argv[1:]),
|
||||
"|"+' '.join([script_id] + sys.argv[1:]),
|
||||
"*draw_manual", # prevent redrawing in Mentat, should be much faster
|
||||
"*new_model yes",
|
||||
"*reset",
|
||||
|
@ -170,7 +170,7 @@ def initial_conditions(material):
|
|||
parser = OptionParser(usage='%prog options [file[s]]', description = """
|
||||
Generate MSC.Marc FE hexahedral mesh from geom file.
|
||||
|
||||
""", version = scriptID)
|
||||
""", version = script_id)
|
||||
|
||||
parser.add_option('-p', '--port',
|
||||
dest = 'port',
|
||||
|
@ -194,7 +194,7 @@ if options.port is not None:
|
|||
if filenames == []: filenames = [None]
|
||||
|
||||
for name in filenames:
|
||||
print(scriptName+': '+name)
|
||||
print(script_name+': '+name)
|
||||
|
||||
geom = damask.Grid.load(StringIO(''.join(sys.stdin.read())) if name is None else name)
|
||||
material = geom.material.flatten(order='F')
|
||||
|
@ -211,11 +211,11 @@ for name in filenames:
|
|||
'*draw_automatic',
|
||||
]
|
||||
|
||||
outputLocals = {}
|
||||
output_locals = {}
|
||||
if options.port:
|
||||
py_mentat.py_connect('',options.port)
|
||||
output(cmds,outputLocals,'Mentat')
|
||||
output(cmds,output_locals,'Mentat')
|
||||
py_mentat.py_disconnect()
|
||||
else:
|
||||
with sys.stdout if name is None else open(os.path.splitext(name)[0]+'.proc','w') as f:
|
||||
output(cmds,outputLocals,f)
|
||||
output(cmds,output_locals,f)
|
||||
|
|
Loading…
Reference in New Issue