2010-10-26 20:32:20 +05:30
|
|
|
#!/usr/bin/env python
|
|
|
|
|
2011-11-09 23:34:51 +05:30
|
|
|
# Makes postprocessing routines acessible from everywhere.
|
2010-10-26 20:32:20 +05:30
|
|
|
|
2011-12-06 22:28:17 +05:30
|
|
|
import os,sys,glob,string
|
|
|
|
from optparse import OptionParser, Option
|
2010-10-26 20:32:20 +05:30
|
|
|
|
2011-12-06 22:28:17 +05:30
|
|
|
import damask_tools
|
2011-11-09 21:50:52 +05:30
|
|
|
|
2011-12-06 22:28:17 +05:30
|
|
|
# -----------------------------
|
|
|
|
class extendableOption(Option):
|
|
|
|
# -----------------------------
|
|
|
|
# used for definition of new option parser action 'extend', which enables to take multiple option arguments
|
|
|
|
# taken from online tutorial http://docs.python.org/library/optparse.html
|
|
|
|
|
|
|
|
ACTIONS = Option.ACTIONS + ("extend",)
|
|
|
|
STORE_ACTIONS = Option.STORE_ACTIONS + ("extend",)
|
|
|
|
TYPED_ACTIONS = Option.TYPED_ACTIONS + ("extend",)
|
|
|
|
ALWAYS_TYPED_ACTIONS = Option.ALWAYS_TYPED_ACTIONS + ("extend",)
|
|
|
|
|
|
|
|
def take_action(self, action, dest, opt, value, values, parser):
|
|
|
|
if action == "extend":
|
|
|
|
lvalue = value.split(",")
|
|
|
|
values.ensure_value(dest, []).extend(lvalue)
|
|
|
|
else:
|
|
|
|
Option.take_action(self, action, dest, opt, value, values, parser)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
########################################################
|
|
|
|
# MAIN
|
|
|
|
########################################################
|
|
|
|
|
|
|
|
parser = OptionParser(option_class=extendableOption, usage='%prog options', description = """
|
|
|
|
Sets up the pre and post processing tools of DAMASK
|
|
|
|
|
|
|
|
""" + string.replace('$Id: addDivergence.py 1129 2011-12-01 12:01:13Z MPIE\m.diehl $','\n','\\n')
|
|
|
|
)
|
|
|
|
|
|
|
|
parser.add_option('--F90', dest='compiler', type='string', \
|
|
|
|
help='name of F90 compiler [%default]')
|
|
|
|
|
|
|
|
parser.set_defaults(compiler = 'ifort')
|
|
|
|
(options,filenames) = parser.parse_args()
|
|
|
|
|
|
|
|
#translating name of compiler for use with f2py and setting subdirname of acml
|
|
|
|
if options.compiler == 'gfortran':
|
|
|
|
f2py_compiler='gnu95 --f90flags="-fno-range-check"'
|
|
|
|
acml_subdir='ifort64/lib'
|
|
|
|
else:
|
|
|
|
f2py_compiler='intelem'
|
|
|
|
acml_subdir='ifort64/lib'
|
|
|
|
|
|
|
|
|
|
|
|
#getting pathinfo
|
|
|
|
damask_variables = damask_tools.DAMASK_TOOLS()
|
|
|
|
baseDir = os.path.join(damask_variables.rootDir(),'processing/')
|
|
|
|
codeDir = os.path.join(damask_variables.rootDir(),'code/')
|
|
|
|
|
|
|
|
#define ToDo list
|
2011-01-26 20:47:03 +05:30
|
|
|
bin_link = { \
|
2011-11-09 23:21:00 +05:30
|
|
|
'pre' : [
|
|
|
|
'marc_addUserOutput.py',
|
|
|
|
'mentat_pbcOnBoxMesh.py',
|
|
|
|
'mentat_spectralBox.py',
|
|
|
|
'patchFromReconstructedBoundaries.py',
|
|
|
|
'spectral_geomCheck.py',
|
|
|
|
'spectral_minimalSurface.py',
|
|
|
|
'spectral_vicinityOffset.py',
|
2011-12-06 22:28:17 +05:30
|
|
|
'voronoi_randomSeeding.exe',
|
|
|
|
'voronoi_tessellation.exe',
|
2011-11-09 23:21:00 +05:30
|
|
|
],
|
|
|
|
'post' : [
|
|
|
|
'3Dvisualize.py',
|
|
|
|
'addCauchy.py',
|
2011-12-02 20:45:36 +05:30
|
|
|
'addCalculation.py',
|
2011-11-09 23:21:00 +05:30
|
|
|
'addDeterminant.py',
|
|
|
|
'addDivergence.py',
|
|
|
|
'addMises.py',
|
|
|
|
'addNorm.py',
|
|
|
|
'addStrainTensors.py',
|
|
|
|
'addCompatibilityMismatch.py',
|
|
|
|
'averageDown.py',
|
|
|
|
'mentat_colorMap.py',
|
|
|
|
'postResults.py',
|
|
|
|
'spectral_iterationCount.py',
|
|
|
|
'spectral_convergence.py',
|
|
|
|
'spectral_scaleGeom.py',
|
|
|
|
],
|
|
|
|
}
|
2010-10-26 20:32:20 +05:30
|
|
|
|
2011-01-26 20:47:03 +05:30
|
|
|
compile = { \
|
2011-11-09 23:21:00 +05:30
|
|
|
'pre' : [
|
|
|
|
'voronoi_randomSeeding.f90',
|
|
|
|
'voronoi_tessellation.f90',
|
|
|
|
],
|
|
|
|
'post' : [
|
|
|
|
],
|
|
|
|
}
|
2011-12-06 22:28:17 +05:30
|
|
|
|
2011-01-26 20:47:03 +05:30
|
|
|
|
2011-03-11 14:50:37 +05:30
|
|
|
execute = { \
|
2011-12-06 22:28:17 +05:30
|
|
|
'postMath' : [
|
|
|
|
'rm %slib/DAMASK.so' %(os.path.join(damask_variables.rootDir(),'lib/')),
|
|
|
|
# The following command is used to compile math.f90 and make the functions defined in DAMASK_math.pyf
|
|
|
|
# avialable for python in the module DAMASK_math.so
|
|
|
|
# It uses the fortran wrapper f2py that is included in the numpy package to construct the
|
|
|
|
# module postprocessingMath.so out of the fortran code postprocessingMath.f90
|
|
|
|
# for the generation of the pyf file:
|
|
|
|
#f2py -m DAMASK -h DAMASK.pyf --overwrite-signature ../../code/math.f90 \
|
|
|
|
'f2py %sDAMASK.pyf '%(codeDir) +\
|
|
|
|
'-c --fcompiler=%s '%(f2py_compiler) +\
|
|
|
|
'%sDAMASK2Python_helper.f90 ' %(codeDir)+\
|
|
|
|
'%smath.f90 ' %(codeDir)+\
|
|
|
|
'%s/libfftw3.a ' %(damask_variables.pathInfo['fftw'])+\
|
|
|
|
'%s/%s/libacml.a' %(damask_variables.pathInfo['acml'],acml_subdir),
|
|
|
|
'mv %sDAMASK.so %s/.' %(codeDir,os.path.join(damask_variables.rootDir(),'lib/')),
|
|
|
|
]
|
2011-11-09 23:21:00 +05:30
|
|
|
}
|
2011-03-11 14:50:37 +05:30
|
|
|
|
2011-11-09 21:07:45 +05:30
|
|
|
|
2011-12-06 22:28:17 +05:30
|
|
|
for dir in compile:
|
|
|
|
for file in compile[dir]:
|
|
|
|
src = os.path.abspath(os.path.join(baseDir,dir,file))
|
|
|
|
if os.path.isfile(src):
|
|
|
|
try:
|
|
|
|
os.system('rm %s.exe'%(os.path.splitext(src)[0]))
|
|
|
|
print 'removing %s.exe '%(os.path.splitext(src)[0])
|
|
|
|
except:
|
|
|
|
pass
|
|
|
|
print 'compiling ',src,'using',options.compiler
|
|
|
|
os.system('%s -O2 -o%s.exe %s'%(options.compiler,os.path.splitext(src)[0],src))
|
|
|
|
|
|
|
|
os.chdir(codeDir) # needed for compilation with gfortran and f2py
|
|
|
|
for tasks in execute:
|
|
|
|
for cmd in execute[tasks]:
|
|
|
|
os.system(cmd)
|
|
|
|
os.chdir(os.path.join(damask_variables.rootDir(),'processing/setup/'))
|
|
|
|
|
|
|
|
modules = glob.glob('*.mod')
|
|
|
|
for module in modules:
|
|
|
|
print 'removing', module
|
|
|
|
os.remove(module)
|
|
|
|
|
2011-01-26 20:47:03 +05:30
|
|
|
for dir in bin_link:
|
|
|
|
for file in bin_link[dir]:
|
2011-12-06 22:28:17 +05:30
|
|
|
src = os.path.abspath(os.path.join(baseDir,dir,file))
|
2010-10-26 20:32:20 +05:30
|
|
|
if (file == ''):
|
2011-12-06 22:28:17 +05:30
|
|
|
sym_link = os.path.abspath(os.path.join(damask_variables.binDir(),dir))
|
2010-10-26 20:32:20 +05:30
|
|
|
else:
|
2011-12-06 22:28:17 +05:30
|
|
|
sym_link = os.path.abspath(os.path.join(damask_variables.binDir(),os.path.splitext(file)[0]))
|
2011-11-09 21:50:52 +05:30
|
|
|
print sym_link,'-->',src
|
|
|
|
if os.path.lexists(sym_link):
|
|
|
|
os.remove(sym_link)
|
|
|
|
os.symlink(src,sym_link)
|
|
|
|
|
|
|
|
#--- uncomment next lines to remove your old symbolic links in ~/bin
|
2011-11-09 23:34:51 +05:30
|
|
|
#old_link=sym_link.replace(damask_root,os.getenv('HOME'))
|
2011-11-09 21:50:52 +05:30
|
|
|
#if os.path.lexists(old_link):
|
|
|
|
# os.remove(old_link)
|
|
|
|
|