From a0b7c51bec64848e74e622d4183b341a2f170ebc Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 22 Apr 2020 23:32:34 +0200 Subject: [PATCH 01/23] less strict tolerances grid position reported by EBSD has only a few decimal places, so rounding errors occur --- python/damask/grid_filters.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/python/damask/grid_filters.py b/python/damask/grid_filters.py index d8b136a6b..4181cb7ec 100644 --- a/python/damask/grid_filters.py +++ b/python/damask/grid_filters.py @@ -211,12 +211,13 @@ def cell_coord0_gridSizeOrigin(coord0,ordered=True): start = origin + delta*.5 end = origin - delta*.5 + size - if not _np.allclose(coords[0],_np.linspace(start[0],end[0],grid[0])) and \ - _np.allclose(coords[1],_np.linspace(start[1],end[1],grid[1])) and \ - _np.allclose(coords[2],_np.linspace(start[2],end[2],grid[2])): + atol = 1e-4*_np.max(size) + if not _np.allclose(coords[0],_np.linspace(start[0],end[0],grid[0]),atol=atol) and \ + _np.allclose(coords[1],_np.linspace(start[1],end[1],grid[1]),atol=atol) and \ + _np.allclose(coords[2],_np.linspace(start[2],end[2],grid[2]),atol=atol): raise ValueError('Regular grid spacing violated.') - if ordered and not _np.allclose(coord0.reshape(tuple(grid[::-1])+(3,)),cell_coord0(grid,size,origin)): + if ordered and not _np.allclose(coord0.reshape(tuple(grid[::-1])+(3,)),cell_coord0(grid,size,origin),atol=atol): raise ValueError('Input data is not a regular grid.') return (grid,size,origin) @@ -357,12 +358,13 @@ def node_coord0_gridSizeOrigin(coord0,ordered=False): if (grid+1).prod() != len(coord0): raise ValueError('Data count {} does not match grid {}.'.format(len(coord0),grid)) - if not _np.allclose(coords[0],_np.linspace(mincorner[0],maxcorner[0],grid[0]+1)) and \ - _np.allclose(coords[1],_np.linspace(mincorner[1],maxcorner[1],grid[1]+1)) and \ - _np.allclose(coords[2],_np.linspace(mincorner[2],maxcorner[2],grid[2]+1)): + atol = _np.max(size) + if not _np.allclose(coords[0],_np.linspace(mincorner[0],maxcorner[0],grid[0]+1),atol=atol) and \ + _np.allclose(coords[1],_np.linspace(mincorner[1],maxcorner[1],grid[1]+1),atol=atol) and \ + _np.allclose(coords[2],_np.linspace(mincorner[2],maxcorner[2],grid[2]+1),atol=atol): raise ValueError('Regular grid spacing violated.') - if ordered and not _np.allclose(coord0.reshape(tuple((grid+1)[::-1])+(3,)),node_coord0(grid,size,origin)): + if ordered and not _np.allclose(coord0.reshape(tuple((grid+1)[::-1])+(3,)),node_coord0(grid,size,origin),atol=atol): raise ValueError('Input data is not a regular grid.') return (grid,size,origin) From cc3fa156cfd8dd077e9b02c2d54be3e6d4fcbc54 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 23 Apr 2020 16:29:20 +0200 Subject: [PATCH 02/23] support change of directory one object has been created --- python/damask/_result.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/damask/_result.py b/python/damask/_result.py index a8181b7a1..b2ec4c8d3 100644 --- a/python/damask/_result.py +++ b/python/damask/_result.py @@ -80,7 +80,7 @@ class Result: 'con_physics': self.con_physics, 'mat_physics': self.mat_physics } - self.fname = fname + self.fname = os.path.abspath(fname) def __repr__(self): From f02c77b6d05c60276d2db0b44d1aa0ee6b905211 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Fri, 24 Apr 2020 20:01:57 +0200 Subject: [PATCH 03/23] more reasonable tolerance still relatively high because ctf files store position with constant number of digits and floating dot. Hence, the precision is very low --- python/damask/grid_filters.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/python/damask/grid_filters.py b/python/damask/grid_filters.py index 4fb1012c0..62e9147f7 100644 --- a/python/damask/grid_filters.py +++ b/python/damask/grid_filters.py @@ -237,8 +237,8 @@ def cell_coord0_gridSizeOrigin(coord0,ordered=True): start = origin + delta*.5 end = origin - delta*.5 + size - - atol = _np.max(size) + + atol = _np.max(size)*5e-2 if not (_np.allclose(coords[0],_np.linspace(start[0],end[0],grid[0]),atol=atol) and \ _np.allclose(coords[1],_np.linspace(start[1],end[1],grid[1]),atol=atol) and \ _np.allclose(coords[2],_np.linspace(start[2],end[2],grid[2]),atol=atol)): @@ -386,7 +386,7 @@ def node_coord0_gridSizeOrigin(coord0,ordered=True): if (grid+1).prod() != len(coord0): raise ValueError('Data count {} does not match grid {}.'.format(len(coord0),grid)) - atol = _np.max(size) + atol = _np.max(size)*5e-2 if not (_np.allclose(coords[0],_np.linspace(mincorner[0],maxcorner[0],grid[0]+1),atol=atol) and \ _np.allclose(coords[1],_np.linspace(mincorner[1],maxcorner[1],grid[1]+1),atol=atol) and \ _np.allclose(coords[2],_np.linspace(mincorner[2],maxcorner[2],grid[2]+1),atol=atol)): From adf5e5e99c8e9132da21bfc586192e3356cb4dc7 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 25 Apr 2020 09:39:34 +0200 Subject: [PATCH 04/23] not supported at the moment --- .../Homogenization_HydrogenFlux_CahnHilliard.config | 3 --- 1 file changed, 3 deletions(-) delete mode 100644 examples/ConfigFiles/Homogenization_HydrogenFlux_CahnHilliard.config diff --git a/examples/ConfigFiles/Homogenization_HydrogenFlux_CahnHilliard.config b/examples/ConfigFiles/Homogenization_HydrogenFlux_CahnHilliard.config deleted file mode 100644 index 62e1d2505..000000000 --- a/examples/ConfigFiles/Homogenization_HydrogenFlux_CahnHilliard.config +++ /dev/null @@ -1,3 +0,0 @@ -hydrogenflux cahnhilliard -initialHydrogenConc 0.0 -(output) hydrogenconc From 7ec1ae977ecd4f5726e59f346cba210639fd181e Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 25 Apr 2020 09:56:51 +0200 Subject: [PATCH 05/23] new names spectral => grid FEM => mesh because there are FEM solvers for both discretizations. old names will be available for a certain time --- Makefile | 4 ++++ src/CMakeLists.txt | 10 +++++----- src/grid/DAMASK_grid.f90 | 4 ++-- src/mesh/DAMASK_mesh.f90 | 4 ++-- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index 34ce18c52..60cf3b8e0 100644 --- a/Makefile +++ b/Makefile @@ -9,12 +9,16 @@ all: grid mesh processing .PHONY: grid grid: build/grid @(cd build/grid;make -j${DAMASK_NUM_THREADS} all install;) + @rm -f ${DAMASK_ROOT}/bin/DAMASK_spectral > /dev/null || true + @ln -s ${DAMASK_ROOT}/bin/DAMASK_grid ${DAMASK_ROOT}/bin/DAMASK_spectral .PHONY: spectral spectral: grid .PHONY: mesh mesh: build/mesh @(cd build/mesh; make -j${DAMASK_NUM_THREADS} all install;) + @rm -f ${DAMASK_ROOT}/bin/DAMASK_FEM > /dev/null || true + @ln -s ${DAMASK_ROOT}/bin/DAMASK_mesh ${DAMASK_ROOT}/bin/DAMASK_FEM .PHONY: FEM FEM: mesh diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 53c7ffc70..0cb697013 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -17,10 +17,10 @@ if (PROJECT_NAME STREQUAL "damask-grid") file(GLOB grid-sources grid/*.f90) if(NOT CMAKE_BUILD_TYPE STREQUAL "SYNTAXONLY") - add_executable(DAMASK_spectral ${damask-sources} ${grid-sources}) - install (TARGETS DAMASK_spectral RUNTIME DESTINATION bin) + add_executable(DAMASK_grid ${damask-sources} ${grid-sources}) + install (TARGETS DAMASK_grid RUNTIME DESTINATION bin) else() - add_library(DAMASK_spectral OBJECT ${damask-sources} ${grid-sources}) + add_library(DAMASK_grid OBJECT ${damask-sources} ${grid-sources}) exec_program (mktemp OUTPUT_VARIABLE nothing) exec_program (mktemp ARGS -d OUTPUT_VARIABLE black_hole) install (PROGRAMS ${nothing} DESTINATION ${black_hole}) @@ -30,7 +30,7 @@ elseif (PROJECT_NAME STREQUAL "damask-mesh") file(GLOB mesh-sources mesh/*.f90) - add_executable(DAMASK_FEM ${damask-sources} ${mesh-sources}) - install (TARGETS DAMASK_FEM RUNTIME DESTINATION bin) + add_executable(DAMASK_mesh ${damask-sources} ${mesh-sources}) + install (TARGETS DAMASK_mesh RUNTIME DESTINATION bin) endif() diff --git a/src/grid/DAMASK_grid.f90 b/src/grid/DAMASK_grid.f90 index 84dc7cd51..7b3265740 100644 --- a/src/grid/DAMASK_grid.f90 +++ b/src/grid/DAMASK_grid.f90 @@ -6,7 +6,7 @@ !> @details doing cutbacking, forwarding in case of restart, reporting statistics, writing !> results !-------------------------------------------------------------------------------------------------- -program DAMASK_spectral +program DAMASK_grid #include use PETScsys use prec @@ -495,4 +495,4 @@ program DAMASK_spectral call quit(0) ! no complains ;) -end program DAMASK_spectral +end program DAMASK_grid diff --git a/src/mesh/DAMASK_mesh.f90 b/src/mesh/DAMASK_mesh.f90 index 3c9613d73..d36b27c17 100644 --- a/src/mesh/DAMASK_mesh.f90 +++ b/src/mesh/DAMASK_mesh.f90 @@ -6,7 +6,7 @@ !> @details doing cutbacking, reporting statistics, writing !> results !-------------------------------------------------------------------------------------------------- -program DAMASK_FEM +program DAMASK_mesh #include use PetscDM use prec @@ -367,4 +367,4 @@ program DAMASK_FEM call quit(0) ! no complains ;) -end program DAMASK_FEM +end program DAMASK_mesh From 0effa71276ada143e3f097e12f8719b54bb60b04 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 26 Apr 2020 08:36:16 +0200 Subject: [PATCH 06/23] cleaning large alias lists complicate things --- src/DAMASK_interface.f90 | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/DAMASK_interface.f90 b/src/DAMASK_interface.f90 index 00177fb75..dceef0f7f 100644 --- a/src/DAMASK_interface.f90 +++ b/src/DAMASK_interface.f90 @@ -206,7 +206,7 @@ subroutine DAMASK_interface_init write(6,'(a,/)')' Valid command line switches:' write(6,'(a)') ' --geom (-g, --geometry)' write(6,'(a)') ' --load (-l, --loadcase)' - write(6,'(a)') ' --workingdir (-w, --wd, --workingdirectory, -d, --directory)' + write(6,'(a)') ' --workingdir (-w, --wd, --workingdirectory)' write(6,'(a)') ' --restart (-r, --rs)' write(6,'(a)') ' --help (-h)' write(6,'(/,a)')' -----------------------------------------------------------------------' @@ -223,12 +223,12 @@ subroutine DAMASK_interface_init write(6,'(a)') ' directory.' write(6,'(a)') ' For further configuration place "numerics.config"' write(6,'(a)')' and "debug.config" in that directory.' - write(6,'(/,a)')' --restart XX' - write(6,'(a)') ' Reads in increment XX and continues with calculating' - write(6,'(a)') ' increment XX+1 based on this.' + write(6,'(/,a)')' --restart N' + write(6,'(a)') ' Reads in increment N and continues with calculating' + write(6,'(a)') ' increment N+1 based on this.' write(6,'(a)') ' Appends to existing results file' - write(6,'(a)') ' "NameOfGeom_NameOfLoadFile".' - write(6,'(a)') ' Works only if the restart information for increment XX' + write(6,'(a)') ' "NameOfGeom_NameOfLoadFile.hdf5".' + write(6,'(a)') ' Works only if the restart information for increment N' write(6,'(a)') ' is available in the working directory.' write(6,'(/,a)')' -----------------------------------------------------------------------' write(6,'(a)') ' Help:' @@ -239,7 +239,7 @@ subroutine DAMASK_interface_init call get_command_argument(i+1,loadCaseArg) case ('-g', '--geom', '--geometry') call get_command_argument(i+1,geometryArg) - case ('-w', '-d', '--wd', '--directory', '--workingdir', '--workingdirectory') + case ('-w', '--wd', '--workingdir', '--workingdirectory') call get_command_argument(i+1,workingDirArg) case ('-r', '--rs', '--restart') call get_command_argument(i+1,arg) From 6864b9525da3eda1b4986ca31098e7a0fa1ab369 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sun, 26 Apr 2020 14:52:27 +0200 Subject: [PATCH 07/23] go back to original dir as soon as possible --- python/damask/util.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/damask/util.py b/python/damask/util.py index d45ea366e..cb1d8757d 100644 --- a/python/damask/util.py +++ b/python/damask/util.py @@ -112,8 +112,8 @@ def execute(cmd, """ initialPath = os.getcwd() - os.chdir(wd) myEnv = os.environ if env is None else env + os.chdir(wd) process = subprocess.Popen(shlex.split(cmd), stdout = subprocess.PIPE, stderr = subprocess.PIPE, @@ -121,9 +121,9 @@ def execute(cmd, env = myEnv) out,error = [i for i in (process.communicate() if streamIn is None else process.communicate(streamIn.read().encode('utf-8')))] + os.chdir(initialPath) out = out.decode('utf-8').replace('\x08','') error = error.decode('utf-8').replace('\x08','') - os.chdir(initialPath) if process.returncode != 0: raise RuntimeError('{} failed with returncode {}'.format(cmd,process.returncode)) return out,error From 9565f15415c7b9913c1f89e334481a21be767718 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 28 Apr 2020 10:30:03 +0200 Subject: [PATCH 08/23] clearer description --- src/HDF5_utilities.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/HDF5_utilities.f90 b/src/HDF5_utilities.f90 index 66705cc3f..a0c3b4e81 100644 --- a/src/HDF5_utilities.f90 +++ b/src/HDF5_utilities.f90 @@ -81,7 +81,7 @@ contains !-------------------------------------------------------------------------------------------------- -!> @brief open libary and do sanity checks +!> @brief initialize HDF5 libary and do sanity checks !-------------------------------------------------------------------------------------------------- subroutine HDF5_utilities_init From d99c05860e940238e15ea1e4d154c87b011912b7 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 28 Apr 2020 10:35:43 +0200 Subject: [PATCH 09/23] FEM is now Mesh --- CMakeLists.txt | 2 +- src/CPFEM2.f90 | 6 +++--- src/numerics.f90 | 10 +++++----- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f6870137f..99807ed72 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,7 +110,7 @@ if (DAMASK_SOLVER STREQUAL "grid") message ("Building Grid Solver\n") elseif (DAMASK_SOLVER STREQUAL "fem" OR DAMASK_SOLVER STREQUAL "mesh") project (damask-mesh Fortran C) - add_definitions (-DFEM) + add_definitions (-DMesh) message ("Building Mesh Solver\n") else () message (FATAL_ERROR "Build target (DAMASK_SOLVER) is not defined") diff --git a/src/CPFEM2.f90 b/src/CPFEM2.f90 index 357bcce9f..dea500900 100644 --- a/src/CPFEM2.f90 +++ b/src/CPFEM2.f90 @@ -21,7 +21,7 @@ module CPFEM2 use homogenization use constitutive use crystallite -#if defined(FEM) +#if defined(Mesh) use FEM_quadrature use discretization_mesh #elif defined(Grid) @@ -42,7 +42,7 @@ subroutine CPFEM_initAll call DAMASK_interface_init ! Spectral and FEM interface to commandline call prec_init call IO_init -#ifdef FEM +#ifdef Mesh call FEM_quadrature_init #endif call numerics_init @@ -53,7 +53,7 @@ subroutine CPFEM_initAll call lattice_init call HDF5_utilities_init call results_init -#if defined(FEM) +#if defined(Mesh) call discretization_mesh_init #elif defined(Grid) call discretization_grid_init diff --git a/src/numerics.f90 b/src/numerics.f90 index 8d242c71d..b0163aee3 100644 --- a/src/numerics.f90 +++ b/src/numerics.f90 @@ -63,8 +63,8 @@ module numerics #endif !-------------------------------------------------------------------------------------------------- -! FEM parameters: -#ifdef FEM +! Mesh parameters: +#ifdef Mesh integer, protected, public :: & integrationOrder = 2, & !< order of quadrature rule required structOrder = 2 !< order of displacement shape functions @@ -200,8 +200,8 @@ subroutine numerics_init #endif !-------------------------------------------------------------------------------------------------- -! FEM parameters -#ifdef FEM +! Mesh parameters +#ifdef Mesh case ('integrationorder') integrationorder = IO_intValue(line,chunkPos,2) case ('structorder') @@ -267,7 +267,7 @@ subroutine numerics_init !-------------------------------------------------------------------------------------------------- ! spectral parameters -#ifdef FEM +#ifdef Mesh write(6,'(a24,1x,i8)') ' integrationOrder: ',integrationOrder write(6,'(a24,1x,i8)') ' structOrder: ',structOrder write(6,'(a24,1x,L8)') ' B-Bar stabilisation: ',BBarStabilisation From 81b3dc74d559e67a53772daea63961a1945d185d Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 28 Apr 2020 19:07:17 +0200 Subject: [PATCH 10/23] default value needed (fcc/bcc) thanks to Richard (TU Delft) and Vitesh for reporting --- src/constitutive_plastic_phenopowerlaw.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/constitutive_plastic_phenopowerlaw.f90 b/src/constitutive_plastic_phenopowerlaw.f90 index 12a30478a..fa273cbd3 100644 --- a/src/constitutive_plastic_phenopowerlaw.f90 +++ b/src/constitutive_plastic_phenopowerlaw.f90 @@ -160,7 +160,7 @@ module subroutine plastic_phenopowerlaw_init config%getFloats('interaction_twintwin'), & config%getString('lattice_structure')) prm%gamma_twin_char = lattice_characteristicShear_twin(N_tw,config%getString('lattice_structure'),& - config%getFloat('c/a')) + config%getFloat('c/a',defaultVal=0.0_pReal)) xi_twin_0 = config%getFloats('tau0_twin',requiredSize=size(N_tw)) From 5a4a7393b9c5b647434994bc5a64a64da69b355f Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 28 Apr 2020 19:17:34 +0200 Subject: [PATCH 11/23] statements belong together --- src/lattice.f90 | 1 - 1 file changed, 1 deletion(-) diff --git a/src/lattice.f90 b/src/lattice.f90 index 120c58a15..b1e286f97 100644 --- a/src/lattice.f90 +++ b/src/lattice.f90 @@ -2304,7 +2304,6 @@ subroutine unitTest system = reshape([1.0_pReal+r(1),0.0_pReal,0.0_pReal, 0.0_pReal,1.0_pReal+r(2),0.0_pReal],[6,1]) CoSy = buildCoordinateSystem([1],[1],system,'fcc',0.0_pReal) - if(any(dNeq(CoSy(1:3,1:3,1),math_I3))) & call IO_error(0) From a24ddbab48db3546a1360a72f29b05f24f012e33 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 29 Apr 2020 11:50:43 +0200 Subject: [PATCH 12/23] python is replaced by python3 on newer systems --- Makefile | 2 +- env/DAMASK.csh | 2 +- env/DAMASK.sh | 2 +- env/DAMASK.zsh | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 60cf3b8e0..9a1a41856 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,7 @@ SHELL = /bin/sh ######################################################################################## # Makefile for the installation of DAMASK ######################################################################################## -DAMASK_ROOT = $(shell python -c "import os,sys; print(os.path.normpath(os.path.realpath(os.path.expanduser('$(pwd)'))))") +DAMASK_ROOT = $(shell python3 -c "import os,sys; print(os.path.normpath(os.path.realpath(os.path.expanduser('$(pwd)'))))") .PHONY: all all: grid mesh processing diff --git a/env/DAMASK.csh b/env/DAMASK.csh index a669a4ea0..98693d6b2 100644 --- a/env/DAMASK.csh +++ b/env/DAMASK.csh @@ -3,7 +3,7 @@ set CALLED=($_) 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"/../"` +set DAMASK_ROOT=`python3 -c "import os,sys; print(os.path.realpath(os.path.expanduser(sys.argv[1])))" $ENV_ROOT"/../"` source $ENV_ROOT/CONFIG diff --git a/env/DAMASK.sh b/env/DAMASK.sh index aed99b3bc..5c3d2ba85 100644 --- a/env/DAMASK.sh +++ b/env/DAMASK.sh @@ -2,7 +2,7 @@ # usage: source DAMASK.sh function canonicalPath { - python -c "import os,sys; print(os.path.normpath(os.path.realpath(os.path.expanduser(sys.argv[1]))))" $1 + python3 -c "import os,sys; print(os.path.normpath(os.path.realpath(os.path.expanduser(sys.argv[1]))))" $1 } function blink { diff --git a/env/DAMASK.zsh b/env/DAMASK.zsh index 8769bac34..831268a7e 100644 --- a/env/DAMASK.zsh +++ b/env/DAMASK.zsh @@ -2,7 +2,7 @@ # usage: source DAMASK.zsh function canonicalPath { - python -c "import os,sys; print(os.path.normpath(os.path.realpath(os.path.expanduser(sys.argv[1]))))" $1 + python3 -c "import os,sys; print(os.path.normpath(os.path.realpath(os.path.expanduser(sys.argv[1]))))" $1 } function blink { From 59c5fbc5fe948269fbddf9aa4d841986c484adca Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 30 Apr 2020 08:05:42 +0200 Subject: [PATCH 13/23] position independent code required for Fedora 32 --- CMakeLists.txt | 2 +- cmake/Compiler-GNU.cmake | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 99807ed72..708d8aa3c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -108,7 +108,7 @@ if (DAMASK_SOLVER STREQUAL "grid") project (damask-grid Fortran C) add_definitions (-DGrid) message ("Building Grid Solver\n") -elseif (DAMASK_SOLVER STREQUAL "fem" OR DAMASK_SOLVER STREQUAL "mesh") +elseif (DAMASK_SOLVER STREQUAL "mesh") project (damask-mesh Fortran C) add_definitions (-DMesh) message ("Building Mesh Solver\n") diff --git a/cmake/Compiler-GNU.cmake b/cmake/Compiler-GNU.cmake index 2e8e5841c..589850af6 100644 --- a/cmake/Compiler-GNU.cmake +++ b/cmake/Compiler-GNU.cmake @@ -25,6 +25,9 @@ set (LINKER_FLAGS "${LINKER_FLAGS},-undefined,dynamic_lookup" ) set (COMPILE_FLAGS "${COMPILE_FLAGS} -xf95-cpp-input") # preprocessor +set (COMPILE_FLAGS "${COMPILE_FLAGS} -fPIC -fPIE") +# position independent conde + set (COMPILE_FLAGS "${COMPILE_FLAGS} -ffree-line-length-132") # restrict line length to the standard 132 characters (lattice.f90 require more characters) From 03f671d12aec8015862c6988d7efdd490146b091 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 5 May 2020 09:35:28 +0200 Subject: [PATCH 14/23] do not report error if linking does not work required for syntax check --- Makefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 9a1a41856..f7b783c61 100644 --- a/Makefile +++ b/Makefile @@ -10,7 +10,7 @@ all: grid mesh processing grid: build/grid @(cd build/grid;make -j${DAMASK_NUM_THREADS} all install;) @rm -f ${DAMASK_ROOT}/bin/DAMASK_spectral > /dev/null || true - @ln -s ${DAMASK_ROOT}/bin/DAMASK_grid ${DAMASK_ROOT}/bin/DAMASK_spectral + @ln -s ${DAMASK_ROOT}/bin/DAMASK_grid ${DAMASK_ROOT}/bin/DAMASK_spectral || true .PHONY: spectral spectral: grid @@ -18,7 +18,7 @@ spectral: grid mesh: build/mesh @(cd build/mesh; make -j${DAMASK_NUM_THREADS} all install;) @rm -f ${DAMASK_ROOT}/bin/DAMASK_FEM > /dev/null || true - @ln -s ${DAMASK_ROOT}/bin/DAMASK_mesh ${DAMASK_ROOT}/bin/DAMASK_FEM + @ln -s ${DAMASK_ROOT}/bin/DAMASK_mesh ${DAMASK_ROOT}/bin/DAMASK_FEM || true .PHONY: FEM FEM: mesh From 14cdc031e075c8a6f4eb8471814baea5a8cc43f5 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 5 May 2020 09:57:22 +0200 Subject: [PATCH 15/23] write XDMF files the limitation to scalar, 3-vector and 3x3-tensor comes currently from XDMF/vtk/paraview extension to multiple constituents and unstructured meshes might be possible --- python/damask/_result.py | 96 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 96 insertions(+) diff --git a/python/damask/_result.py b/python/damask/_result.py index 13a41757a..8036f1723 100644 --- a/python/damask/_result.py +++ b/python/damask/_result.py @@ -2,6 +2,8 @@ import multiprocessing import re import glob import os +import xml.etree.ElementTree as ET +import xml.dom.minidom from functools import partial import h5py @@ -1035,6 +1037,100 @@ class Result: pool.join() + def write_XMDF(self): + """ + Write XDMF file to directly visualize data in DADF5 file. + + This works only for scalar, 3-vector and 3x3-tensor data. + Selection is not taken into account. + """ + if len(self.constituents) != 1 or not self.structured: + raise NotImplementedError + + xdmf=ET.Element('Xdmf') + xdmf.attrib={'Version': '3.0', + 'xmlns:xi': 'http://www.w3.org/2001/XInclude'} + + domain=ET.SubElement(xdmf, 'Domain') + + collection = ET.SubElement(domain, 'Grid') + collection.attrib={'GridType': 'Collection', + 'CollectionType': 'Temporal'} + + time = ET.SubElement(collection, 'Time') + time.attrib={'TimeType': 'List'} + + time_data = ET.SubElement(time, 'DataItem') + time_data.attrib={'Dimensions': '{}'.format(len(self.times))} + time_data.text = ' '.join(map(str,self.times)) + + attributes = [] + data_items = [] + + for inc in self.increments: + + grid=ET.SubElement(collection,'Grid') + grid.attrib = {'GridType': 'Uniform', + 'Name': inc} + + topology=ET.SubElement(grid, 'Topology') + topology.attrib={'TopologyType': '3DCORECTMESH', + 'Dimensions': '{} {} {}'.format(*self.grid+1)} + + geometry=ET.SubElement(grid, 'Geometry') + geometry.attrib={'GeometryType':'Origin_DxDyDz'} + + origin=ET.SubElement(geometry, 'DataItem') + origin.attrib={'Format': 'XML', + 'NumberType': 'Float', + 'Dimensions': '3'} + origin.text="{} {} {}".format(*self.origin) + + delta=ET.SubElement(geometry, 'DataItem') + delta.attrib={'Format': 'XML', + 'NumberType': 'Float', + 'Dimensions': '3'} + delta.text="{} {} {}".format(*(self.size/self.grid)) + + + with h5py.File(self.fname,'r') as f: + attributes.append(ET.SubElement(grid, 'Attribute')) + attributes[-1].attrib={'Name': 'u', + 'Center': 'Node', + 'AttributeType': 'Vector'} + data_items.append(ET.SubElement(attributes[-1], 'DataItem')) + data_items[-1].attrib={'Format': 'HDF', + 'Precision': '8', + 'Dimensions': '{} {} {} 3'.format(*(self.grid+1))} + data_items[-1].text='{}:/{}/geometry/u_n'.format(self.fname,inc) + + for o,p in zip(['constituents','materialpoints'],['con_physics','mat_physics']): + for oo in getattr(self,o): + for pp in getattr(self,p): + g = '/'.join([inc,o[:-1],oo,pp]) + for l in f[g]: + name = '/'.join([g,l]) + shape = f[name].shape[1:] + dtype = f[name].dtype + prec = f[name].dtype.itemsize + + if (shape not in [(1,), (3,), (3,3)]) or dtype != np.float64: continue + + attributes.append(ET.SubElement(grid, 'Attribute')) + attributes[-1].attrib={'Name': '{}'.format(name.split('/',2)[2]), + 'Center': 'Cell', + 'AttributeType': 'Tensor'} + data_items.append(ET.SubElement(attributes[-1], 'DataItem')) + data_items[-1].attrib={'Format': 'HDF', + 'NumberType': 'Float', + 'Precision': '{}'.format(prec), + 'Dimensions': '{} {} {} {}'.format(*self.grid,np.prod(shape))} + data_items[-1].text='{}:{}'.format(self.fname,name) + + with open(os.path.splitext(self.fname)[0]+'.xdmf','w') as f: + f.write(xml.dom.minidom.parseString(ET.tostring(xdmf).decode()).toprettyxml()) + + def to_vtk(self,labels=[],mode='cell'): """ Export to vtk cell/point data. From 43442f0722313bf016f8f2665c51f0c2c7ba5cf7 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 5 May 2020 10:03:08 +0200 Subject: [PATCH 16/23] tests use new names (grid/mesh instead of spectral/FEM) --- PRIVATE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PRIVATE b/PRIVATE index c595994cd..c6a91e8ef 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit c595994cd8880acadf50b5dedb79156d04d35b91 +Subproject commit c6a91e8effdb4cf1632bdd115e091a50fee4ecd1 From 31c397255d2ecd0ca74043f5d4ebd7890f244ea6 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 5 May 2020 10:18:48 +0200 Subject: [PATCH 17/23] equivalent (for a valid DADF5 file) but faster --- python/damask/_result.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/damask/_result.py b/python/damask/_result.py index 8036f1723..28277e0ee 100644 --- a/python/damask/_result.py +++ b/python/damask/_result.py @@ -64,8 +64,8 @@ class Result: self.times = [round(f[i].attrs['time/s'],12) for i in self.increments] self.Nmaterialpoints, self.Nconstituents = np.shape(f['mapping/cellResults/constituent']) - self.materialpoints = [m.decode() for m in np.unique(f['mapping/cellResults/materialpoint']['Name'])] - self.constituents = [c.decode() for c in np.unique(f['mapping/cellResults/constituent'] ['Name'])] + self.materialpoints = [m for m in f['inc0/materialpoint']] + self.constituents = [c for c in f['inc0/constituent']] self.con_physics = [] for c in self.constituents: From eeb0df3a551e7775d5360f1246879b35cfef1ae5 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 5 May 2020 10:42:54 +0200 Subject: [PATCH 18/23] do not store absolute path --- python/damask/_result.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/python/damask/_result.py b/python/damask/_result.py index 28277e0ee..d74b1fc4a 100644 --- a/python/damask/_result.py +++ b/python/damask/_result.py @@ -1102,7 +1102,7 @@ class Result: data_items[-1].attrib={'Format': 'HDF', 'Precision': '8', 'Dimensions': '{} {} {} 3'.format(*(self.grid+1))} - data_items[-1].text='{}:/{}/geometry/u_n'.format(self.fname,inc) + data_items[-1].text='{}:/{}/geometry/u_n'.format(os.path.split(self.fname)[1],inc) for o,p in zip(['constituents','materialpoints'],['con_physics','mat_physics']): for oo in getattr(self,o): @@ -1125,7 +1125,7 @@ class Result: 'NumberType': 'Float', 'Precision': '{}'.format(prec), 'Dimensions': '{} {} {} {}'.format(*self.grid,np.prod(shape))} - data_items[-1].text='{}:{}'.format(self.fname,name) + data_items[-1].text='{}:{}'.format(os.path.split(self.fname)[1],name) with open(os.path.splitext(self.fname)[0]+'.xdmf','w') as f: f.write(xml.dom.minidom.parseString(ET.tostring(xdmf).decode()).toprettyxml()) From b891fd4e4e58274a5ecf8c3bc6ffda6a3c5fe820 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 5 May 2020 10:43:06 +0200 Subject: [PATCH 19/23] adjusted test --- PRIVATE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PRIVATE b/PRIVATE index c6a91e8ef..038af521a 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit c6a91e8effdb4cf1632bdd115e091a50fee4ecd1 +Subproject commit 038af521a1ef70ed77b132c426bc1a4880db01ef From 9553a7838bcdd0dd02c107511ec915eba3839706 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 6 May 2020 22:15:09 +0200 Subject: [PATCH 21/23] needs to be logical --- src/mesh/discretization_mesh.f90 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesh/discretization_mesh.f90 b/src/mesh/discretization_mesh.f90 index b98cbbfad..0880de115 100644 --- a/src/mesh/discretization_mesh.f90 +++ b/src/mesh/discretization_mesh.f90 @@ -65,7 +65,7 @@ contains !-------------------------------------------------------------------------------------------------- subroutine discretization_mesh_init(restart) - integer, intent(in) :: restart + logical, intent(in) :: restart integer, dimension(1), parameter:: FE_geomtype = [1] !< geometry type of particular element type integer, dimension(1) :: FE_Nips !< number of IPs in a specific type of element From c2b4f5516e4f6d3a8f7d88cf1cae6016de60a141 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 7 May 2020 00:14:14 +0200 Subject: [PATCH 22/23] DADF5_postResults tries to combine datasets, this does not work --- python/damask/_result.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/python/damask/_result.py b/python/damask/_result.py index d74b1fc4a..622f38919 100644 --- a/python/damask/_result.py +++ b/python/damask/_result.py @@ -64,8 +64,12 @@ class Result: self.times = [round(f[i].attrs['time/s'],12) for i in self.increments] self.Nmaterialpoints, self.Nconstituents = np.shape(f['mapping/cellResults/constituent']) - self.materialpoints = [m for m in f['inc0/materialpoint']] - self.constituents = [c for c in f['inc0/constituent']] + self.materialpoints = [m.decode() for m in np.unique(f['mapping/cellResults/materialpoint']['Name'])] + self.constituents = [c.decode() for c in np.unique(f['mapping/cellResults/constituent'] ['Name'])] + + # faster, but does not work with (deprecated) DADF5_postResults + #self.materialpoints = [m for m in f['inc0/materialpoint']] + #self.constituents = [c for c in f['inc0/constituent']] self.con_physics = [] for c in self.constituents: @@ -428,8 +432,10 @@ class Result: """ with h5py.File(self.fname,'r') as f: shape = (self.Nmaterialpoints,) + np.shape(f[path[0]])[1:] + print(path[0]) if len(shape) == 1: shape = shape +(1,) dataset = np.full(shape,np.nan,dtype=np.dtype(f[path[0]])) + print('dataset shape', dataset.shape) for pa in path: label = pa.split('/')[2] @@ -437,12 +443,19 @@ class Result: dataset = np.array(f[pa]) continue + print(label) p = np.where(f['mapping/cellResults/constituent'][:,c]['Name'] == str.encode(label))[0] + print(len(p)) if len(p)>0: u = (f['mapping/cellResults/constituent']['Position'][p,c]) + print('pa',pa) a = np.array(f[pa]) + print(a.shape) if len(a.shape) == 1: a=a.reshape([a.shape[0],1]) + print('u',u) + print('a[u]',a[u,:].shape) + print('dataset[p]',dataset[p,:].shape) dataset[p,:] = a[u,:] p = np.where(f['mapping/cellResults/materialpoint']['Name'] == str.encode(label))[0] From b75e98ca3f01a7b56137a03bb079aa5c99d9b878 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 7 May 2020 19:12:05 +0200 Subject: [PATCH 23/23] forgotten debug statements + polishing of XDMF output --- python/damask/_result.py | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/python/damask/_result.py b/python/damask/_result.py index 622f38919..9993e90bd 100644 --- a/python/damask/_result.py +++ b/python/damask/_result.py @@ -66,7 +66,7 @@ class Result: self.Nmaterialpoints, self.Nconstituents = np.shape(f['mapping/cellResults/constituent']) self.materialpoints = [m.decode() for m in np.unique(f['mapping/cellResults/materialpoint']['Name'])] self.constituents = [c.decode() for c in np.unique(f['mapping/cellResults/constituent'] ['Name'])] - + # faster, but does not work with (deprecated) DADF5_postResults #self.materialpoints = [m for m in f['inc0/materialpoint']] #self.constituents = [c for c in f['inc0/constituent']] @@ -432,10 +432,8 @@ class Result: """ with h5py.File(self.fname,'r') as f: shape = (self.Nmaterialpoints,) + np.shape(f[path[0]])[1:] - print(path[0]) if len(shape) == 1: shape = shape +(1,) dataset = np.full(shape,np.nan,dtype=np.dtype(f[path[0]])) - print('dataset shape', dataset.shape) for pa in path: label = pa.split('/')[2] @@ -443,19 +441,12 @@ class Result: dataset = np.array(f[pa]) continue - print(label) p = np.where(f['mapping/cellResults/constituent'][:,c]['Name'] == str.encode(label))[0] - print(len(p)) if len(p)>0: u = (f['mapping/cellResults/constituent']['Position'][p,c]) - print('pa',pa) a = np.array(f[pa]) - print(a.shape) if len(a.shape) == 1: a=a.reshape([a.shape[0],1]) - print('u',u) - print('a[u]',a[u,:].shape) - print('dataset[p]',dataset[p,:].shape) dataset[p,:] = a[u,:] p = np.where(f['mapping/cellResults/materialpoint']['Name'] == str.encode(label))[0] @@ -1061,7 +1052,7 @@ class Result: raise NotImplementedError xdmf=ET.Element('Xdmf') - xdmf.attrib={'Version': '3.0', + xdmf.attrib={'Version': '2.0', 'xmlns:xi': 'http://www.w3.org/2001/XInclude'} domain=ET.SubElement(xdmf, 'Domain') @@ -1074,7 +1065,9 @@ class Result: time.attrib={'TimeType': 'List'} time_data = ET.SubElement(time, 'DataItem') - time_data.attrib={'Dimensions': '{}'.format(len(self.times))} + time_data.attrib={'Format': 'XML', + 'NumberType': 'Float', + 'Dimensions': '{}'.format(len(self.times))} time_data.text = ' '.join(map(str,self.times)) attributes = [] @@ -1087,7 +1080,7 @@ class Result: 'Name': inc} topology=ET.SubElement(grid, 'Topology') - topology.attrib={'TopologyType': '3DCORECTMESH', + topology.attrib={'TopologyType': '3DCoRectMesh', 'Dimensions': '{} {} {}'.format(*self.grid+1)} geometry=ET.SubElement(grid, 'Geometry')