Merge branch 'env-reporting' into 'development'

adjusting env reporting

See merge request damask/DAMASK!375
This commit is contained in:
Francisco Jose Gallardo Basile 2021-05-02 09:11:04 +00:00
commit c78b352956
6 changed files with 23 additions and 29 deletions

6
env/DAMASK.sh vendored
View File

@ -30,7 +30,6 @@ PATH=${DAMASK_ROOT}/bin:$PATH
SOLVER=$(type -p DAMASK_grid || true 2>/dev/null)
[ "x$SOLVER" == "x" ] && SOLVER=$(blink 'Not found!')
[ "x$OMP_NUM_THREADS" == "x" ] && OMP_NUM_THREADS=1
# currently, there is no information that unlimited stack size causes problems
# still, http://software.intel.com/en-us/forums/topic/501500 suggest to fix it
@ -55,9 +54,8 @@ if [ ! -z "$PS1" ]; then
[[ $(canonicalPath "$PETSC_DIR") == $PETSC_DIR ]] \
|| echo " ~~> "$(canonicalPath "$PETSC_DIR")
fi
echo -n "MSC.Marc/Mentat "
[ -d $MSC_ROOT ] && echo $MSC_ROOT || blink $MSC_ROOT
echo
[ "x$PETSC_ARCH" != "x" ] && echo "PETSc architecture $PETSC_ARCH"
[ "x$OMP_NUM_THREADS" == "x" ] && export OMP_NUM_THREADS=4
echo "Multithreading OMP_NUM_THREADS=$OMP_NUM_THREADS"
echo -n "heap size "
[[ "$(ulimit -d)" == "unlimited" ]] \

8
env/DAMASK.zsh vendored
View File

@ -20,7 +20,6 @@ PATH=${DAMASK_ROOT}/bin:$PATH
SOLVER=$(which DAMASK_grid || true 2>/dev/null)
[[ "x$SOLVER" == "x" ]] && SOLVER=$(blink 'Not found!')
[[ "x$OMP_NUM_THREADS" == "x" ]] && OMP_NUM_THREADS=1
# currently, there is no information that unlimited stack size causes problems
# still, http://software.intel.com/en-us/forums/topic/501500 suggest to fix it
@ -45,11 +44,8 @@ if [ ! -z "$PS1" ]; then
[[ $(canonicalPath "$PETSC_DIR") == $PETSC_DIR ]] \
|| echo " ~~> "$(canonicalPath "$PETSC_DIR")
fi
[[ "x$PETSC_ARCH" == "x" ]] \
|| echo "PETSc architecture $PETSC_ARCH"
echo -n "MSC.Marc/Mentat "
[ -d $MSC_ROOT ] && echo $MSC_ROOT || blink $MSC_ROOT
echo
[[ "x$PETSC_ARCH" != "x" ]] && echo "PETSc architecture $PETSC_ARCH"
[[ "x$OMP_NUM_THREADS" == "x" ]] && export OMP_NUM_THREADS=4
echo "Multithreading OMP_NUM_THREADS=$OMP_NUM_THREADS"
echo -n "heap size "
[[ "$(ulimit -d)" == "unlimited" ]] \

View File

@ -7,6 +7,11 @@ from pathlib import Path
import damask
def copy_and_replace(in_file,dst,msc_root,editor):
with open(in_file) as f_in, open(dst/Path(in_file).name,'w') as f_out:
f_out.write(f_in.read().replace('%INSTALLDIR%',msc_root).replace('%EDITOR%',editor))
parser = argparse.ArgumentParser(
description='Apply DAMASK modification to MSC.Marc/Mentat',
prog = Path(__file__).name,
@ -17,34 +22,25 @@ parser.add_argument('--editor', dest='editor', metavar='string', default='vi',
parser.add_argument('--msc-root', dest='msc_root', metavar='string',
default=damask.solver._marc._msc_root,
help='MSC.Marc/Mentat root directory')
parser.add_argument('--msc-version', dest='msc_version', metavar='string',
parser.add_argument('--msc-version', dest='msc_version', type=float, metavar='float',
default=damask.solver._marc._msc_version,
help='MSC.Marc/Mentat version')
parser.add_argument('--damask-root', dest='damask_root', type=float, metavar = 'float',
parser.add_argument('--damask-root', dest='damask_root', metavar = 'string',
default=damask.solver._marc._damask_root,
help='DAMASK root directory')
args = parser.parse_args()
msc_root = Path(args.msc_root)
damask_root = Path(args.damask_root)
msc_version = args.msc_version
def copy_and_replace(in_file,dst):
with open(in_file) as f:
content = f.read()
content = content.replace('%INSTALLDIR%',str(msc_root))
content = content.replace('%EDITOR%', args.editor)
with open(dst/Path(in_file).name,'w') as f:
f.write(content)
print('adapting Marc tools...\n')
src = damask_root/f'installation/mods_MarcMentat/{msc_version}/Marc_tools'
dst = msc_root/f'marc{msc_version}/tools'
for in_file in glob.glob(str(src/'*damask*')) + [str(src/'include_linux64')]:
copy_and_replace(in_file,dst)
copy_and_replace(in_file,dst,args.msc_root,args.editor)
print('adapting Mentat scripts and menus...\n')
@ -52,12 +48,12 @@ print('adapting Mentat scripts and menus...\n')
src = damask_root/f'installation/mods_MarcMentat/{msc_version}/Mentat_bin'
dst = msc_root/f'mentat{msc_version}/bin'
for in_file in glob.glob(str(src/'*[!.original]')):
copy_and_replace(in_file,dst)
copy_and_replace(in_file,dst,args.msc_root,args.editor)
src = damask_root/f'installation/mods_MarcMentat/{msc_version}/Mentat_menus'
dst = msc_root/f'mentat{msc_version}/menus'
for in_file in glob.glob(str(src/'job_run.ms')):
copy_and_replace(in_file,dst)
copy_and_replace(in_file,dst,args.msc_root,args.editor)
print('compiling Mentat menu binaries...')

View File

@ -392,7 +392,7 @@ class Grid:
seeds_p = seeds
coords = grid_filters.coordinates0_point(cells,size).reshape(-1,3)
pool = mp.Pool(int(os.environ.get('OMP_NUM_THREADS',1)))
pool = mp.Pool(int(os.environ.get('OMP_NUM_THREADS',4)))
result = pool.map_async(partial(Grid._find_closest_seed,seeds_p,weights_p), [coord for coord in coords])
pool.close()
pool.join()
@ -436,8 +436,12 @@ class Grid:
"""
coords = grid_filters.coordinates0_point(cells,size).reshape(-1,3)
KDTree = spatial.cKDTree(seeds,boxsize=size) if periodic else spatial.cKDTree(seeds)
devNull,material_ = KDTree.query(coords)
tree = spatial.cKDTree(seeds,boxsize=size) if periodic else \
spatial.cKDTree(seeds)
try:
material_ = tree.query(coords, workers = int(os.environ.get('OMP_NUM_THREADS',4)))[1]
except TypeError:
material_ = tree.query(coords, n_jobs = int(os.environ.get('OMP_NUM_THREADS',4)))[1] # scipy <1.6
return Grid(material = (material_ if material is None else material[material_]).reshape(cells),
size = size,

View File

@ -1179,7 +1179,7 @@ class Result:
"""
chunk_size = 1024**2//8
pool = mp.Pool(int(os.environ.get('OMP_NUM_THREADS',1)))
pool = mp.Pool(int(os.environ.get('OMP_NUM_THREADS',4)))
lock = mp.Manager().Lock()
groups = []

View File

@ -78,7 +78,7 @@ def from_Poisson_disc(size,N_seeds,N_candidates,distance,periodic=True,rng_seed=
candidates = rng.random((N_candidates,3))*_np.broadcast_to(size,(N_candidates,3))
tree = _spatial.cKDTree(coords[:s],boxsize=size) if periodic else \
_spatial.cKDTree(coords[:s])
distances, dev_null = tree.query(candidates)
distances = tree.query(candidates)[0]
best = distances.argmax()
if distances[best] > distance: # require minimum separation
coords[s] = candidates[best] # maximum separation to existing point cloud