diff --git a/.gitignore b/.gitignore index c34f2f0b7..02cc8d926 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ *.hdf5 *.bak *~ +.DS_Store bin PRIVATE build diff --git a/Makefile b/Makefile index 64c83f5f7..549d0541e 100644 --- a/Makefile +++ b/Makefile @@ -4,7 +4,7 @@ SHELL = /bin/sh ######################################################################################## DAMASK_ROOT = $(shell python -c "import os,sys; print(os.path.normpath(os.path.realpath(os.path.expanduser('$(pwd)'))))") .PHONY: all -all: grid mesh python processing +all: grid mesh processing .PHONY: grid grid: build/grid @@ -35,8 +35,3 @@ clean: .PHONY: processing processing: @./installation/symlink_Processing.py ${MAKEFLAGS} - -.PHONY: python -python: - @pip install --user ./python - diff --git a/PRIVATE b/PRIVATE index 036faecca..12de3e01e 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 036faecca39b46fd2328597ca858cbb04e37f79a +Subproject commit 12de3e01e3dfa407a724b6aeca51c78e9981b80d diff --git a/CONFIG b/env/CONFIG similarity index 100% rename from CONFIG rename to env/CONFIG diff --git a/env/DAMASK.csh b/env/DAMASK.csh index b1b9dfb98..fbfbfd1a7 100644 --- a/env/DAMASK.csh +++ b/env/DAMASK.csh @@ -2,15 +2,14 @@ # usage: source DAMASK_env.csh set CALLED=($_) -set DIRNAME=`dirname $CALLED[2]` -set DAMASK_ROOT=`python -c "import os,sys; print(os.path.realpath(os.path.expanduser(sys.argv[1])))" $DIRNAME"/../"` +set ENV_ROOT=`dirname $CALLED[2]` +set DAMASK_ROOT=`python -c "import os,sys; print(os.path.realpath(os.path.expanduser(sys.argv[1])))" $ENV_ROOT"/../"` -source $DAMASK_ROOT/CONFIG +source $ENV_ROOT/CONFIG set path = ($DAMASK_ROOT/bin $path) set SOLVER=`which DAMASK_spectral` -set PROCESSING=`which postResults` if ( "x$DAMASK_NUM_THREADS" == "x" ) then set DAMASK_NUM_THREADS=1 endif @@ -32,7 +31,6 @@ if ( $?prompt ) then echo Using environment with ... echo "DAMASK $DAMASK_ROOT" echo "Grid Solver $SOLVER" - echo "Post Processing $PROCESSING" if ( $?PETSC_DIR) then echo "PETSc location $PETSC_DIR" endif @@ -52,3 +50,6 @@ if ( ! $?PYTHONPATH ) then else setenv PYTHONPATH $DAMASK_ROOT/python:$PYTHONPATH endif +setenv MSC_ROOT +setenv ABAQUS_VERSION +setenv MARC_VERSION diff --git a/env/DAMASK.sh b/env/DAMASK.sh index 50760b76d..aed99b3bc 100644 --- a/env/DAMASK.sh +++ b/env/DAMASK.sh @@ -10,14 +10,14 @@ function blink { } if [ "$OSTYPE" == "linux-gnu" ] || [ "$OSTYPE" == 'linux' ]; then - DAMASK_ROOT=$(dirname $BASH_SOURCE) + ENV_ROOT=$(dirname $BASH_SOURCE) else [[ "${BASH_SOURCE::1}" == "/" ]] && BASE="" || BASE="$(pwd)/" STAT=$(stat "$(dirname $BASE$BASH_SOURCE)") - DAMASK_ROOT=${STAT##* } + ENV_ROOT=${STAT##* } fi -DAMASK_ROOT=$(canonicalPath "$DAMASK_ROOT/../") +DAMASK_ROOT=$(canonicalPath "$ENV_ROOT/../") # shorthand command to change to DAMASK_ROOT directory @@ -27,7 +27,7 @@ eval "function DAMASK_root() { cd $DAMASK_ROOT; }" set() { export $1$2$3 } -source $DAMASK_ROOT/CONFIG +source $ENV_ROOT/CONFIG unset -f set # add BRANCH if DAMASK_ROOT is a git repository @@ -38,9 +38,6 @@ PATH=${DAMASK_ROOT}/bin:$PATH SOLVER=$(type -p DAMASK_spectral || true 2>/dev/null) [ "x$SOLVER" == "x" ] && SOLVER=$(blink 'Not found!') -PROCESSING=$(type -p postResults || true 2>/dev/null) -[ "x$PROCESSING" == "x" ] && PROCESSING=$(blink 'Not found!') - [ "x$DAMASK_NUM_THREADS" == "x" ] && DAMASK_NUM_THREADS=1 # currently, there is no information that unlimited stack size causes problems @@ -60,7 +57,6 @@ if [ ! -z "$PS1" ]; then echo Using environment with ... echo "DAMASK $DAMASK_ROOT $BRANCH" echo "Grid Solver $SOLVER" - echo "Post Processing $PROCESSING" if [ "x$PETSC_DIR" != "x" ]; then echo -n "PETSc location " [ -d $PETSC_DIR ] && echo $PETSC_DIR || blink $PETSC_DIR @@ -93,12 +89,8 @@ fi export DAMASK_NUM_THREADS export PYTHONPATH=$DAMASK_ROOT/python:$PYTHONPATH -for var in BASE STAT SOLVER PROCESSING BRANCH; do +for var in BASE STAT SOLVER BRANCH; do unset "${var}" done -for var in DAMASK MSC; do - unset "${var}_ROOT" -done -for var in ABAQUS MARC; do - unset "${var}_VERSION" -done +unset "ENV_ROOT" +unset "DAMASK_ROOT" diff --git a/env/DAMASK.zsh b/env/DAMASK.zsh index 066d56dd6..8769bac34 100644 --- a/env/DAMASK.zsh +++ b/env/DAMASK.zsh @@ -9,6 +9,7 @@ function blink { echo -e "\033[2;5m$1\033[0m" } +ENV_ROOT=$(canonicalPath "${0:a:h}") DAMASK_ROOT=$(canonicalPath "${0:a:h}'/..") # shorthand command to change to DAMASK_ROOT directory @@ -18,7 +19,7 @@ eval "function DAMASK_root() { cd $DAMASK_ROOT; }" set() { export $1$2$3 } -source $DAMASK_ROOT/CONFIG +source $ENV_ROOT/CONFIG unset -f set # add BRANCH if DAMASK_ROOT is a git repository @@ -29,9 +30,6 @@ PATH=${DAMASK_ROOT}/bin:$PATH SOLVER=$(which DAMASK_spectral || true 2>/dev/null) [[ "x$SOLVER" == "x" ]] && SOLVER=$(blink 'Not found!') -PROCESSING=$(which postResults || true 2>/dev/null) -[[ "x$PROCESSING" == "x" ]] && PROCESSING=$(blink 'Not found!') - [[ "x$DAMASK_NUM_THREADS" == "x" ]] && DAMASK_NUM_THREADS=1 # currently, there is no information that unlimited stack size causes problems @@ -51,7 +49,6 @@ if [ ! -z "$PS1" ]; then echo "Using environment with ..." echo "DAMASK $DAMASK_ROOT $BRANCH" echo "Grid Solver $SOLVER" - echo "Post Processing $PROCESSING" if [ "x$PETSC_DIR" != "x" ]; then echo -n "PETSc location " [ -d $PETSC_DIR ] && echo $PETSC_DIR || blink $PETSC_DIR @@ -86,12 +83,8 @@ fi export DAMASK_NUM_THREADS export PYTHONPATH=$DAMASK_ROOT/python:$PYTHONPATH -for var in SOLVER PROCESSING BRANCH; do +for var in SOLVER BRANCH; do unset "${var}" done -for var in DAMASK MSC; do - unset "${var}_ROOT" -done -for var in ABAQUS MARC; do - unset "${var}_VERSION" -done +unset "ENV_ROOT" +unset "DAMASK_ROOT" diff --git a/installation/mods_MarcMentat/apply_DAMASK_modifications.sh b/installation/mods_MarcMentat/apply_DAMASK_modifications.sh index d6cd6b171..ac0daf036 100755 --- a/installation/mods_MarcMentat/apply_DAMASK_modifications.sh +++ b/installation/mods_MarcMentat/apply_DAMASK_modifications.sh @@ -2,11 +2,6 @@ SCRIPTLOCATION="$( cd "$( dirname "$0" )" && pwd )" DAMASK_ROOT=$SCRIPTLOCATION/../../ -# defining set() allows to source the same file for tcsh and bash, with and without space around = -set() { - export $1$2$3 - } -source $DAMASK_ROOT/CONFIG if [ "x$MSC_ROOT" != "x" ]; then DEFAULT_DIR=$MSC_ROOT @@ -15,7 +10,7 @@ if [ "x$MARC_VERSION" != "x" ]; then DEFAULT_VERSION=$MARC_VERSION fi if [ "x$DAMASK_BIN" != "x" ]; then - BIN_DIR=$DAMASK_BIN + BIN_DIR=$DAMASK_ROOT/bin fi while [ ! -d "$SCRIPTLOCATION/$VERSION" ] || [ -z "$VERSION" ] diff --git a/python/MANIFEST.in b/python/MANIFEST.in index cd47f5e61..4050d1c29 100644 --- a/python/MANIFEST.in +++ b/python/MANIFEST.in @@ -1,3 +1,2 @@ -include damask/README include damask/VERSION include damask/LICENSE diff --git a/python/damask/README b/python/README similarity index 100% rename from python/damask/README rename to python/README diff --git a/python/damask/LICENSE b/python/damask/LICENSE deleted file mode 100644 index 1ab20178c..000000000 --- a/python/damask/LICENSE +++ /dev/null @@ -1,14 +0,0 @@ -Copyright 2011-19 Max-Planck-Institut für Eisenforschung GmbH - -DAMASK is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . diff --git a/python/damask/LICENSE b/python/damask/LICENSE new file mode 120000 index 000000000..30cff7403 --- /dev/null +++ b/python/damask/LICENSE @@ -0,0 +1 @@ +../../LICENSE \ No newline at end of file diff --git a/python/damask/README.md b/python/damask/README.md deleted file mode 100644 index 7fc372881..000000000 --- a/python/damask/README.md +++ /dev/null @@ -1,13 +0,0 @@ -DAMASK - The Düsseldorf Advanced Material Simulation Kit -Visit damask.mpie.de for installation and usage instructions - -CONTACT INFORMATION - -Max-Planck-Institut für Eisenforschung GmbH -Max-Planck-Str. 1 -40237 Düsseldorf -Germany - -Email: DAMASK@mpie.de -https://damask.mpie.de -https://magit1.mpie.de diff --git a/python/damask/VERSION b/python/damask/VERSION deleted file mode 100644 index ac39a106c..000000000 --- a/python/damask/VERSION +++ /dev/null @@ -1 +0,0 @@ -0.9.0 diff --git a/python/damask/VERSION b/python/damask/VERSION new file mode 120000 index 000000000..558194c5a --- /dev/null +++ b/python/damask/VERSION @@ -0,0 +1 @@ +../../VERSION \ No newline at end of file diff --git a/python/damask/environment.py b/python/damask/environment.py index ff0c0e418..9964e9be7 100644 --- a/python/damask/environment.py +++ b/python/damask/environment.py @@ -1,5 +1,4 @@ import os -import re class Environment(): __slots__ = [ \ @@ -18,12 +17,9 @@ class Environment(): return os.path.normpath(os.path.join(os.path.realpath(__file__),'../../../')) def get_options(self): - with open(self.relPath(self.rootDir()+'/CONFIG')) as configFile: - for line in configFile: - line = line.strip() - line = line[4:] if line.startswith('set ') else line # remove "set" (tcsh) when setting variables - if line and not line.startswith('#'): - items = re.split(r'\s*=\s*',line) - if len(items) == 2: - self.options[items[0].upper()] = \ - re.sub(r'\${?DAMASK_ROOT}?',self.rootDir(),os.path.expandvars(items[1])) # expand all shell variables and DAMASK_ROOT + for item in ['DAMASK_NUM_THREADS', + 'MSC_ROOT', + 'MARC_VERSION', + 'ABAQUS_VERSION', + ]: + self.options[item] = os.environ[item] if item in os.environ else None diff --git a/python/damask/solver/abaqus.py b/python/damask/solver/abaqus.py index 00d711da2..037829013 100644 --- a/python/damask/solver/abaqus.py +++ b/python/damask/solver/abaqus.py @@ -5,29 +5,35 @@ import damask class Abaqus(Solver): - """Wrapper to run DAMASK with Abaqus.""" + """Wrapper to run DAMASK with Abaqus.""" - def __init__(self,version=int(damask.Environment().options['ABAQUS_VERSION'])): - """ - Create a Abaqus solver object. + def __init__(self,version=None): + """ + Create a Abaqus solver object. - Parameters - ---------- - version : integer - Abaqus version + Parameters + ---------- + version : integer + Abaqus version - """ - self.solver = 'Abaqus' - self.version = int(version) + """ + self.solver = 'Abaqus' + try: + self.version = int(version) + except TypeError: + try: + self.version = int(damask.Environment().options['ABAQUS_VERSION']) + except TypeError: + self.version = -1 - def return_run_command(self,model): - try: - cmd = 'abq'+self.version - subprocess.check_output([cmd,'information=release']) - except OSError: # link to abqXXX not existing - cmd = 'abaqus' - process = subprocess.Popen([cmd,'information=release'],stdout = subprocess.PIPE,stderr = subprocess.PIPE) - detectedVersion = int(process.stdout.readlines()[1].split()[1].decode('utf-8')) - if self.version != detectedVersion: - raise Exception('found Abaqus version {}, but requested {}'.format(detectedVersion,self.version)) - return '{} -job {} -user {}/src/DAMASK_abaqus interactive'.format(cmd,model,damask.Environment().rootDir()) + def return_run_command(self,model): + try: + cmd = 'abq{}'.format(self.version) + subprocess.check_output([cmd,'information=release']) + except OSError: # link to abqXXX not existing + cmd = 'abaqus' + process = subprocess.Popen([cmd,'information=release'],stdout = subprocess.PIPE,stderr = subprocess.PIPE) + detectedVersion = int(process.stdout.readlines()[1].split()[1].decode('utf-8')) + if self.version != detectedVersion: + raise Exception('found Abaqus version {}, but requested {}'.format(detectedVersion,self.version)) + return '{} -job {} -user {}/src/DAMASK_abaqus interactive'.format(cmd,model,damask.Environment().rootDir()) diff --git a/python/damask/solver/marc.py b/python/damask/solver/marc.py index 16e867ac1..a30ce7aea 100644 --- a/python/damask/solver/marc.py +++ b/python/damask/solver/marc.py @@ -1,88 +1,94 @@ import os import subprocess import shlex +import string from .solver import Solver import damask class Marc(Solver): - """Wrapper to run DAMASK with MSCMarc.""" + """Wrapper to run DAMASK with MSCMarc.""" - def __init__(self,version=damask.Environment().options['MARC_VERSION']): - """ - Create a Marc solver object. + def __init__(self,version=damask.Environment().options['MARC_VERSION']): + """ + Create a Marc solver object. - Parameters - ---------- - version : float - Marc version + Parameters + ---------- + version : float + Marc version - """ - self.solver = 'Marc' - self.version = damask.Environment().options['MARC_VERSION'] + """ + self.solver = 'Marc' + try: + self.version = int(version) + except TypeError: + try: + self.version = int(damask.Environment().options['MARC_VERSION']) + except TypeError: + self.version = -1 #-------------------------- - def libraryPath(self): + def libraryPath(self): - path_MSC = damask.Environment().options['MSC_ROOT'] - path_lib = '{}/mentat{}/shlib/linux64'.format(path_MSC,self.version) + path_MSC = damask.Environment().options['MSC_ROOT'] + path_lib = '{}/mentat{}/shlib/linux64'.format(path_MSC,self.version) - return path_lib if os.path.exists(path_lib) else '' + return path_lib if os.path.exists(path_lib) else '' #-------------------------- - def toolsPath(self): + def toolsPath(self): - path_MSC = damask.Environment().options['MSC_ROOT'] - path_tools = '{}/marc{}/tools'.format(path_MSC,self.version) + path_MSC = damask.Environment().options['MSC_ROOT'] + path_tools = '{}/marc{}/tools'.format(path_MSC,self.version) - return path_tools if os.path.exists(path_tools) else '' + return path_tools if os.path.exists(path_tools) else '' #-------------------------- - def submit_job(self, - model, - job = 'job1', - logfile = False, - compile = False, - optimization = '', - ): + def submit_job(self, + model, + job = 'job1', + logfile = False, + compile = False, + optimization = '', + ): - damaskEnv = damask.Environment() + damaskEnv = damask.Environment() - user = os.path.join(damaskEnv.relPath('src'),'DAMASK_marc{}.{}'.format(self.version,'f90' if compile else 'marc')) - if not os.path.isfile(user): - raise FileNotFoundError("DAMASK4Marc ({}) '{}' not found".format(('source' if compile else 'binary'),user)) + user = os.path.join(damaskEnv.relPath('src'),'DAMASK_marc{}.{}'.format(self.version,'f90' if compile else 'marc')) + if not os.path.isfile(user): + raise FileNotFoundError("DAMASK4Marc ({}) '{}' not found".format(('source' if compile else 'binary'),user)) - # Define options [see Marc Installation and Operation Guide, pp 23] - script = 'run_damask_{}mp'.format(optimization) + # Define options [see Marc Installation and Operation Guide, pp 23] + script = 'run_damask_{}mp'.format(optimization) - cmd = os.path.join(self.toolsPath(),script) + \ - ' -jid ' + model + '_' + job + \ - ' -nprocd 1 -autorst 0 -ci n -cr n -dcoup 0 -b no -v no' + cmd = os.path.join(self.toolsPath(),script) + \ + ' -jid ' + model + '_' + job + \ + ' -nprocd 1 -autorst 0 -ci n -cr n -dcoup 0 -b no -v no' - if compile: cmd += ' -u ' + user + ' -save y' - else: cmd += ' -prog ' + os.path.splitext(user)[0] + if compile: cmd += ' -u ' + user + ' -save y' + else: cmd += ' -prog ' + os.path.splitext(user)[0] - print('job submission {} compilation: {}'.format('with' if compile else 'without',user)) - if logfile: log = open(logfile, 'w') - print(cmd) - process = subprocess.Popen(shlex.split(cmd),stdout = log,stderr = subprocess.STDOUT) - log.close() - process.wait() + print('job submission {} compilation: {}'.format('with' if compile else 'without',user)) + if logfile: log = open(logfile, 'w') + print(cmd) + process = subprocess.Popen(shlex.split(cmd),stdout = log,stderr = subprocess.STDOUT) + log.close() + process.wait() #-------------------------- - def exit_number_from_outFile(self,outFile=None): - import string - exitnumber = -1 - with open(outFile,'r') as fid_out: - for line in fid_out: - if (string.find(line,'tress iteration') != -1): - print(line) - elif (string.find(line,'Exit number') != -1): - substr = line[string.find(line,'Exit number'):len(line)] - exitnumber = int(substr[12:16]) + def exit_number_from_outFile(self,outFile=None): + exitnumber = -1 + with open(outFile,'r') as fid_out: + for line in fid_out: + if (string.find(line,'tress iteration') != -1): + print(line) + elif (string.find(line,'Exit number') != -1): + substr = line[string.find(line,'Exit number'):len(line)] + exitnumber = int(substr[12:16]) - return exitnumber + return exitnumber diff --git a/python/makeDistribution.sh b/python/makeDistribution.sh deleted file mode 100644 index ed81257cf..000000000 --- a/python/makeDistribution.sh +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" -cd $DIR - -VERSION=$(head -n1 damask/VERSION) -read -p "updated version [${VERSION}]: " UP -echo ${UP:-$VERSION} > damask/VERSION - -rm -rf dist/ -python3 setup.py sdist bdist_wheel -python3 -m twine upload dist/* diff --git a/python/setup.py b/python/setup.py index 8126d1331..a1b5ea166 100644 --- a/python/setup.py +++ b/python/setup.py @@ -3,7 +3,7 @@ import os import re with open(os.path.join(os.path.dirname(__file__),'damask/VERSION')) as f: - version = re.sub(r'^v','',f.readline().strip()) + version = re.sub(r'(-([^-]*)).*$',r'.\2',re.sub(r'^v(\d+\.\d+(\.\d+)?)',r'\1',f.readline().strip())) setuptools.setup( name="damask",