예제 #1
0
 def __exit__(self, H_type, H_value, H_traceback):
     if self.quitmentat:
         pm.py_send("*quit yes")
         self.connection = False
     if self.disconnect:
         pm.py_disconnect()
         self.connection = False
예제 #2
0
# --- loop over input files ------------------------------------------------------------------------

if filenames == []: filenames = [None]

for name in filenames:
    print(scriptName+': '+name)

    geom = damask.Grid.load(StringIO(''.join(sys.stdin.read())) if name is None else name)
    material = geom.material.flatten(order='F')

    cmds = [\
      init(),
      mesh(geom.cells,geom.size),
      materials(),
      geometry(),
      initial_conditions(material),
      '*identify_sets',
      '*show_model',
      '*redraw',
      '*draw_automatic',
    ]

    outputLocals = {}
    if options.port:
        py_mentat.py_connect('',options.port)
        output(cmds,outputLocals,'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)
예제 #3
0
  theMap = damask.Colormap()

if options.inverse:
  theMap = theMap.invert()

if options.palettef:
  print theMap.export(format='raw',steps=options.colorcount)
elif options.palette:
  for theColor in theMap.export(format='list',steps=options.colorcount):
    print '\t'.join(map(lambda x: str(int(255*x)),theColor))
else:                                                                                               # connect to Mentat and change colorMap
  sys.path.append(damask.solver.Marc().libraryPath())
  try:
    import py_mentat
    print 'waiting to connect...'
    py_mentat.py_connect('',options.port)
    print 'connected...'
    mentat = True
  except:
    sys.stderr.write('warning: no valid Mentat release found\n')
    mentat = False

  outputLocals = {}
  cmds = colorMap(theMap.export(format='list',steps=options.colorcount),options.baseIdx)
  if mentat:
    output(['*show_table']+cmds+['*show_model *redraw'],outputLocals,'Mentat')
    py_mentat.py_disconnect()
  
  if options.verbose:
    output(cmds,outputLocals,'Stdout')
예제 #4
0
 def __exit__(self, H_type, H_value, H_traceback):
     pm.py_disconnect()