diff --git a/python/damask/__init__.py b/python/damask/__init__.py index b2b94b6a5..4c031758f 100644 --- a/python/damask/__init__.py +++ b/python/damask/__init__.py @@ -7,7 +7,8 @@ with open(_Path(__file__).parent/_Path('VERSION')) as _f: version = _re.sub(r'^v','',_f.readline().strip()) # make classes directly accessible as damask.Class -from ._environment import Environment # noqa +from ._environment import Environment as _ # noqa +environment = _() from ._table import Table # noqa from ._vtk import VTK # noqa from ._colormap import Colormap # noqa @@ -19,6 +20,7 @@ from ._geom import Geom # noqa from . import solver # noqa # deprecated +Environment = _ from ._asciitable import ASCIItable # noqa from ._test import Test # noqa from .config import Material # noqa diff --git a/python/damask/_geom.py b/python/damask/_geom.py index bbdcaf9f8..59da5e117 100644 --- a/python/damask/_geom.py +++ b/python/damask/_geom.py @@ -6,9 +6,9 @@ from functools import partial import numpy as np from scipy import ndimage,spatial +import damask from . import VTK from . import util -from . import Environment from . import grid_filters @@ -362,7 +362,7 @@ class Geom: seeds_p = seeds coords = grid_filters.cell_coord0(grid,size).reshape(-1,3) - pool = multiprocessing.Pool(processes = int(Environment().options['DAMASK_NUM_THREADS'])) + pool = multiprocessing.Pool(processes = int(damask.environment.options['DAMASK_NUM_THREADS'])) result = pool.map_async(partial(Geom._find_closest_seed,seeds_p,weights_p), [coord for coord in coords]) pool.close() pool.join() diff --git a/python/damask/_result.py b/python/damask/_result.py index 4b32798f1..a12ee467a 100644 --- a/python/damask/_result.py +++ b/python/damask/_result.py @@ -18,7 +18,6 @@ from . import VTK from . import Table from . import Rotation from . import Orientation -from . import Environment from . import grid_filters from . import mechanics from . import util @@ -1060,7 +1059,7 @@ class Result: Arguments parsed to func. """ - num_threads = Environment().options['DAMASK_NUM_THREADS'] + num_threads = damask.environment.options['DAMASK_NUM_THREADS'] pool = mp.Pool(int(num_threads) if num_threads is not None else None) lock = mp.Manager().Lock() diff --git a/python/damask/_test.py b/python/damask/_test.py index 9c4c7ad3d..78616fabf 100644 --- a/python/damask/_test.py +++ b/python/damask/_test.py @@ -180,7 +180,7 @@ class Test: def fileInRoot(self,dir,file): """Path to a file in the root directory of DAMASK.""" - return os.path.join(damask.Environment().rootDir(),dir,file) + return str(damask.environment.root_dir/dir/file) def fileInReference(self,file): diff --git a/python/damask/_vtk.py b/python/damask/_vtk.py index 656d68412..51175fdd7 100644 --- a/python/damask/_vtk.py +++ b/python/damask/_vtk.py @@ -9,7 +9,6 @@ from vtk.util.numpy_support import numpy_to_vtkIdTypeArray as np_to_vtkIdTypeArr import damask from . import Table -from . import Environment class VTK: @@ -258,7 +257,7 @@ class VTK: ren.AddActor(actor) ren.SetBackground(0.2,0.2,0.2) - window.SetSize(Environment().screen_size[0],Environment().screen_size[1]) + window.SetSize(damask.environment.screen_size[0],damask.environment.screen_size[1]) iren = vtk.vtkRenderWindowInteractor() iren.SetRenderWindow(window) diff --git a/python/damask/solver/_marc.py b/python/damask/solver/_marc.py index 23ae5639d..d0d8cc2fb 100644 --- a/python/damask/solver/_marc.py +++ b/python/damask/solver/_marc.py @@ -3,12 +3,12 @@ import shlex import string from pathlib import Path -from .._environment import Environment +import damask class Marc: """Wrapper to run DAMASK with MSCMarc.""" - def __init__(self,version=Environment().options['MARC_VERSION']): + def __init__(self,version=damask.environment.options['MARC_VERSION']): """ Create a Marc solver object. @@ -24,7 +24,7 @@ class Marc: @property def library_path(self): - path_MSC = Environment().options['MSC_ROOT'] + path_MSC = damask.environment.options['MSC_ROOT'] path_lib = Path(f'{path_MSC}/mentat{self.version}/shlib/linux64') return path_lib if path_lib.is_dir() else None @@ -33,7 +33,7 @@ class Marc: @property def tools_path(self): - path_MSC = Environment().options['MSC_ROOT'] + path_MSC = damsk.environment.options['MSC_ROOT'] path_tools = Path(f'{path_MSC}/marc{self.version}/tools') return path_tools if path_tools.is_dir() else None @@ -49,9 +49,7 @@ class Marc: ): - env = Environment() - - usersub = env.root_dir/Path(f'src/DAMASK_marc{self.version}').with_suffix('.f90' if compile else '.marc') + usersub = damask.environment.root_dir/Path(f'src/DAMASK_marc{self.version}').with_suffix('.f90' if compile else '.marc') if not usersub.is_file(): raise FileNotFoundError("DAMASK4Marc ({}) '{}' not found".format(('source' if compile else 'binary'),usersub))