From a0b7c51bec64848e74e622d4183b341a2f170ebc Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 22 Apr 2020 23:32:34 +0200 Subject: [PATCH 01/32] 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/32] 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/32] 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/32] 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/32] 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/32] 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/32] 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/32] 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/32] 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/32] 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/32] 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/32] 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/32] 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/32] 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/32] 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/32] 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/32] 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/32] 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/32] 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/32] 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/32] 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/32] 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') From 72c835a55417038718b4769fb3742583aec6a1ab Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 11 May 2020 16:00:53 +0200 Subject: [PATCH 24/32] not used --- src/mesh/mesh_mech_FEM.f90 | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/mesh/mesh_mech_FEM.f90 b/src/mesh/mesh_mech_FEM.f90 index 8206f4174..a2f4b9e70 100644 --- a/src/mesh/mesh_mech_FEM.f90 +++ b/src/mesh/mesh_mech_FEM.f90 @@ -17,11 +17,9 @@ module mesh_mech_FEM use prec use FEM_utilities use discretization_mesh - use IO use DAMASK_interface use numerics use FEM_quadrature - use FEsolving use homogenization use math From 661604ff94bd374db97ed846741e3c1f39145669 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 14 May 2020 06:59:30 +0200 Subject: [PATCH 25/32] more error checking --- src/DAMASK_interface.f90 | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/src/DAMASK_interface.f90 b/src/DAMASK_interface.f90 index dceef0f7f..56824d820 100644 --- a/src/DAMASK_interface.f90 +++ b/src/DAMASK_interface.f90 @@ -106,7 +106,7 @@ subroutine DAMASK_interface_init typeSize integer, dimension(8) :: & dateAndTime - integer :: mpi_err + integer :: err PetscErrorCode :: petsc_err external :: & quit @@ -118,8 +118,8 @@ subroutine DAMASK_interface_init #ifdef _OPENMP ! If openMP is enabled, check if the MPI libary supports it and initialize accordingly. ! Otherwise, the first call to PETSc will do the initialization. - call MPI_Init_Thread(MPI_THREAD_FUNNELED,threadLevel,mpi_err) - if (mpi_err /= 0) call quit(1) + call MPI_Init_Thread(MPI_THREAD_FUNNELED,threadLevel,err) + if (err /= 0) call quit(1) if (threadLevel Date: Fri, 15 May 2020 22:33:38 +0200 Subject: [PATCH 26/32] suppress warnings the compiler does not know that IO_error terminates the program --- src/lattice.f90 | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/lattice.f90 b/src/lattice.f90 index b1e286f97..cf985cc19 100644 --- a/src/lattice.f90 +++ b/src/lattice.f90 @@ -1436,6 +1436,7 @@ function lattice_SchmidMatrix_slip(Nslip,structure,cOverA) result(SchmidMatrix) NslipMax = BCT_NSLIPSYSTEM slipSystems = BCT_SYSTEMSLIP case default + allocate(NslipMax(0)) call IO_error(137,ext_msg='lattice_SchmidMatrix_slip: '//trim(structure)) end select @@ -1485,6 +1486,7 @@ function lattice_SchmidMatrix_twin(Ntwin,structure,cOverA) result(SchmidMatrix) NtwinMax = HEX_NTWINSYSTEM twinSystems = HEX_SYSTEMTWIN case default + allocate(NtwinMax(0)) call IO_error(137,ext_msg='lattice_SchmidMatrix_twin: '//trim(structure)) end select @@ -1564,6 +1566,7 @@ function lattice_SchmidMatrix_cleavage(Ncleavage,structure,cOverA) result(Schmid NcleavageMax = BCC_NCLEAVAGESYSTEM cleavageSystems = BCC_SYSTEMCLEAVAGE case default + allocate(NcleavageMax(0)) call IO_error(137,ext_msg='lattice_SchmidMatrix_cleavage: '//trim(structure)) end select @@ -1919,6 +1922,7 @@ function coordinateSystem_slip(Nslip,structure,cOverA) result(coordinateSystem) NslipMax = BCT_NSLIPSYSTEM slipSystems = BCT_SYSTEMSLIP case default + allocate(NslipMax(0)) call IO_error(137,ext_msg='coordinateSystem_slip: '//trim(structure)) end select From e3e70ae42469d222046f4c0db92c7bfac6cdcfb2 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Fri, 15 May 2020 22:45:22 +0200 Subject: [PATCH 27/32] check for recent standard requires Gfortran 8.1.x or later --- cmake/Compiler-GNU.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/Compiler-GNU.cmake b/cmake/Compiler-GNU.cmake index 6fc669299..858e91134 100644 --- a/cmake/Compiler-GNU.cmake +++ b/cmake/Compiler-GNU.cmake @@ -14,7 +14,7 @@ elseif (OPTIMIZATION STREQUAL "AGGRESSIVE") set (OPTIMIZATION_FLAGS "-O3 -ffast-math -funroll-loops -ftree-vectorize") endif () -set (STANDARD_CHECK "-std=f2008ts -pedantic-errors" ) +set (STANDARD_CHECK "-std=f2018 -pedantic-errors" ) set (LINKER_FLAGS "${LINKER_FLAGS} -Wl") # options parsed directly to the linker set (LINKER_FLAGS "${LINKER_FLAGS},-undefined,dynamic_lookup" ) From ae20ab8d42134f05aa41481dc69f5092f5fe20e1 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 16 May 2020 17:05:03 +0200 Subject: [PATCH 28/32] more reasonable name --- src/IO.f90 | 6 +++--- src/YAML_types.f90 | 6 +++--- src/lattice.f90 | 6 +++--- src/math.f90 | 8 ++++---- src/prec.f90 | 8 ++++---- src/quaternions.f90 | 6 +++--- src/rotations.f90 | 6 +++--- 7 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/IO.f90 b/src/IO.f90 index 1bd2df833..c49ca66d0 100644 --- a/src/IO.f90 +++ b/src/IO.f90 @@ -49,7 +49,7 @@ subroutine IO_init write(6,'(/,a)') ' <<<+- IO init -+>>>'; flush(6) - call unitTest + call selfTest end subroutine IO_init @@ -696,7 +696,7 @@ end subroutine IO_warning !-------------------------------------------------------------------------------------------------- !> @brief check correctness of some IO functions !-------------------------------------------------------------------------------------------------- -subroutine unitTest +subroutine selfTest integer, dimension(:), allocatable :: chunkPos character(len=:), allocatable :: str @@ -745,6 +745,6 @@ subroutine unitTest str = IO_rmComment(' ab #') if (str /= ' ab'.or. len(str) /= 3) call IO_error(0,ext_msg='IO_rmComment/7') -end subroutine unitTest +end subroutine selfTest end module IO diff --git a/src/YAML_types.f90 b/src/YAML_types.f90 index 07541bc1a..0282fcb98 100644 --- a/src/YAML_types.f90 +++ b/src/YAML_types.f90 @@ -180,7 +180,7 @@ subroutine YAML_types_init write(6,'(/,a)') ' <<<+- YAML_types init -+>>>' - call unitTest + call selfTest end subroutine YAML_types_init @@ -188,7 +188,7 @@ end subroutine YAML_types_init !-------------------------------------------------------------------------------------------------- !> @brief check correctness of some type bound procedures !-------------------------------------------------------------------------------------------------- -subroutine unitTest +subroutine selfTest class(tNode), pointer :: s1,s2 allocate(tScalar::s1) @@ -260,7 +260,7 @@ subroutine unitTest if(n%get_asString(1) /= 'True') call IO_error(0,ext_msg='byIndex_asString') end block -end subroutine unitTest +end subroutine selfTest !--------------------------------------------------------------------------------------------------- diff --git a/src/lattice.f90 b/src/lattice.f90 index cf985cc19..7a732d2fd 100644 --- a/src/lattice.f90 +++ b/src/lattice.f90 @@ -529,7 +529,7 @@ subroutine lattice_init lattice_DamageMobility(p) = config_phase(p)%getFloat('damage_mobility',defaultVal=0.0_pReal) ! SHOULD NOT BE PART OF LATTICE END - call unitTest + call selfTest enddo @@ -2295,7 +2295,7 @@ end function equivalent_mu !-------------------------------------------------------------------------------------------------- !> @brief check correctness of some lattice functions !-------------------------------------------------------------------------------------------------- -subroutine unitTest +subroutine selfTest real(pReal), dimension(:,:,:), allocatable :: CoSy real(pReal), dimension(:,:), allocatable :: system @@ -2324,6 +2324,6 @@ subroutine unitTest if(dNeq(lambda*0.5_pReal/(lambda+equivalent_mu(C,'reuss')),equivalent_nu(C,'reuss'),1.0e-12_pReal)) & call IO_error(0,ext_msg='equivalent_nu/reuss') -end subroutine unitTest +end subroutine selfTest end module lattice diff --git a/src/math.f90 b/src/math.f90 index 070751de8..33c7c0310 100644 --- a/src/math.f90 +++ b/src/math.f90 @@ -79,7 +79,7 @@ module math !--------------------------------------------------------------------------------------------------- private :: & - unitTest + selfTest contains @@ -113,7 +113,7 @@ subroutine math_init call random_seed(put = randInit) - call unitTest + call selfTest end subroutine math_init @@ -1192,7 +1192,7 @@ end function math_clip !-------------------------------------------------------------------------------------------------- !> @brief check correctness of some math functions !-------------------------------------------------------------------------------------------------- -subroutine unitTest +subroutine selfTest integer, dimension(2,4) :: & sort_in_ = reshape([+1,+5, +5,+6, -1,-1, +3,-2],[2,4]) @@ -1330,6 +1330,6 @@ subroutine unitTest if(dNeq0(math_LeviCivita(ijk(1),ijk(2),ijk(3))))& call IO_error(0,ext_msg='math_LeviCivita') -end subroutine unitTest +end subroutine selfTest end module math diff --git a/src/prec.f90 b/src/prec.f90 index 646f7dd69..73649f76b 100644 --- a/src/prec.f90 +++ b/src/prec.f90 @@ -75,7 +75,7 @@ module prec emptyStringArray = [character(len=pStringLen)::] private :: & - unitTest + selfTest contains @@ -94,7 +94,7 @@ subroutine prec_init write(6,'(a,e10.3)') ' Minimum value: ',tiny(0.0_pReal) write(6,'(a,i3)') ' Decimal precision: ',precision(0.0_pReal) - call unitTest + call selfTest end subroutine prec_init @@ -233,7 +233,7 @@ end function cNeq !-------------------------------------------------------------------------------------------------- !> @brief check correctness of some prec functions !-------------------------------------------------------------------------------------------------- -subroutine unitTest +subroutine selfTest integer, allocatable, dimension(:) :: realloc_lhs_test real(pReal), dimension(2) :: r @@ -249,6 +249,6 @@ subroutine unitTest realloc_lhs_test = [1,2] if (any(realloc_lhs_test/=[1,2])) call quit(9000) -end subroutine unitTest +end subroutine selfTest end module prec diff --git a/src/quaternions.f90 b/src/quaternions.f90 index 991f970ab..f5f5276e8 100644 --- a/src/quaternions.f90 +++ b/src/quaternions.f90 @@ -112,7 +112,7 @@ contains subroutine quaternions_init write(6,'(/,a)') ' <<<+- quaternions init -+>>>'; flush(6) - call unitTest + call selfTest end subroutine quaternions_init @@ -457,7 +457,7 @@ end function inverse !-------------------------------------------------------------------------------------------------- !> @brief check correctness of some quaternions functions !-------------------------------------------------------------------------------------------------- -subroutine unitTest +subroutine selfTest real(pReal), dimension(4) :: qu type(quaternion) :: q, q_2 @@ -524,7 +524,7 @@ subroutine unitTest endif #endif -end subroutine unitTest +end subroutine selfTest end module quaternions diff --git a/src/rotations.f90 b/src/rotations.f90 index fea642170..42afb48e9 100644 --- a/src/rotations.f90 +++ b/src/rotations.f90 @@ -105,7 +105,7 @@ subroutine rotations_init call quaternions_init write(6,'(/,a)') ' <<<+- rotations init -+>>>'; flush(6) - call unitTest + call selfTest end subroutine rotations_init @@ -1340,7 +1340,7 @@ end function GetPyramidOrder !-------------------------------------------------------------------------------------------------- !> @brief check correctness of some rotations functions !-------------------------------------------------------------------------------------------------- -subroutine unitTest +subroutine selfTest type(rotation) :: R real(pReal), dimension(4) :: qu, ax, ro @@ -1443,7 +1443,7 @@ subroutine unitTest enddo -end subroutine unitTest +end subroutine selfTest end module rotations From 044f069437d5b0b4a6d5a6039e803abeda22fc5b Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 16 May 2020 17:06:55 +0200 Subject: [PATCH 29/32] bugfix: selected wrong data --- python/damask/grid_filters.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/damask/grid_filters.py b/python/damask/grid_filters.py index 62e9147f7..76ab20872 100644 --- a/python/damask/grid_filters.py +++ b/python/damask/grid_filters.py @@ -361,7 +361,7 @@ def node_2_cell(node_data): + _np.roll(node_data,1,(0,)) + _np.roll(node_data,1,(1,)) + _np.roll(node_data,1,(2,)) + _np.roll(node_data,1,(0,1)) + _np.roll(node_data,1,(1,2)) + _np.roll(node_data,1,(2,0)))*0.125 - return c[:-1,:-1,:-1] + return c[1:,1:,1:] def node_coord0_gridSizeOrigin(coord0,ordered=True): From a4dfd7fc744e34b5ee7b6e0320c7be19c0a90b35 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 16 May 2020 17:23:05 +0200 Subject: [PATCH 30/32] missing tests --- python/tests/test_Table.py | 15 ++++++++++----- python/tests/test_grid_filters.py | 19 ++++++++++++++++--- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/python/tests/test_Table.py b/python/tests/test_Table.py index cfcdd8813..ac7444808 100644 --- a/python/tests/test_Table.py +++ b/python/tests/test_Table.py @@ -18,7 +18,7 @@ def reference_dir(reference_dir_base): return os.path.join(reference_dir_base,'Table') class TestTable: - + def test_get_scalar(self,default): d = default.get('s') assert np.allclose(d,1.0) and d.shape[1:] == (1,) @@ -29,12 +29,12 @@ class TestTable: def test_get_tensor(self,default): d = default.get('F') - assert np.allclose(d,1.0) and d.shape[1:] == (3,3) + assert np.allclose(d,1.0) and d.shape[1:] == (3,3) def test_get_component(self,default): d = default.get('5_F') assert np.allclose(d,1.0) and d.shape[1:] == (1,) - + def test_write_read_str(self,default,tmpdir): default.to_ASCII(str(tmpdir.join('default.txt'))) new = Table.from_ASCII(str(tmpdir.join('default.txt'))) @@ -69,15 +69,20 @@ class TestTable: def test_read_strange(self,reference_dir,fname): with open(os.path.join(reference_dir,fname)) as f: Table.from_ASCII(f) - + def test_set(self,default): default.set('F',np.zeros((5,3,3)),'set to zero') d=default.get('F') assert np.allclose(d,0.0) and d.shape[1:] == (3,3) + def test_set_component(self,default): + default.set('1_F',np.zeros((5)),'set to zero') + d=default.get('F') + assert np.allclose(d[...,0,0],0.0) and d.shape[1:] == (3,3) + def test_labels(self,default): assert default.labels == ['F','v','s'] - + def test_add(self,default): d = np.random.random((5,9)) default.add('nine',d,'random data') diff --git a/python/tests/test_grid_filters.py b/python/tests/test_grid_filters.py index ab60c0446..8a343e26b 100644 --- a/python/tests/test_grid_filters.py +++ b/python/tests/test_grid_filters.py @@ -42,12 +42,25 @@ class TestGridFilters: assert np.allclose(grid_filters.node_displacement_fluct(size,F), grid_filters.cell_2_node(grid_filters.cell_displacement_fluct(size,F))) - def test_interpolation_nonperiodic(self): + def test_interpolation_to_node(self): size = np.random.random(3) grid = np.random.randint(8,32,(3)) F = np.random.random(tuple(grid)+(3,3)) - assert np.allclose(grid_filters.node_coord(size,F) [1:-1,1:-1,1:-1],grid_filters.cell_2_node( - grid_filters.cell_coord(size,F))[1:-1,1:-1,1:-1]) + assert np.allclose(grid_filters.node_coord(size,F) [1:-1,1:-1,1:-1], + grid_filters.cell_2_node(grid_filters.cell_coord(size,F))[1:-1,1:-1,1:-1]) + + def test_interpolation_to_cell(self): + grid = np.random.randint(1,30,(3)) + + node_coord_x = np.linspace(0,np.pi*2,num=grid[0]+1) + node_field_x = np.cos(node_coord_x) + node_field = np.broadcast_to(node_field_x.reshape(-1,1,1),grid+1) + + cell_coord_x = node_coord_x[:-1]+node_coord_x[1]*.5 + cell_field_x = np.interp(cell_coord_x,node_coord_x,node_field_x,period=np.pi*2.) + cell_field = np.broadcast_to(cell_field_x.reshape(-1,1,1),grid) + + assert np.allclose(cell_field,grid_filters.node_2_cell(node_field)) @pytest.mark.parametrize('mode',['cell','node']) def test_coord0_origin(self,mode): From d8764f2b8fee0ac13ecf0613b28f8a971ddbfabe Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 16 May 2020 18:32:30 +0200 Subject: [PATCH 31/32] status is not the first argument --- src/DAMASK_interface.f90 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/DAMASK_interface.f90 b/src/DAMASK_interface.f90 index 56824d820..8e4369840 100644 --- a/src/DAMASK_interface.f90 +++ b/src/DAMASK_interface.f90 @@ -237,13 +237,13 @@ subroutine DAMASK_interface_init write(6,'(a,/)')' Prints this message and exits' call quit(0) ! normal Termination case ('-l', '--load', '--loadcase') - call get_command_argument(i+1,loadCaseArg,err) + call get_command_argument(i+1,loadCaseArg,status=err) case ('-g', '--geom', '--geometry') - call get_command_argument(i+1,geometryArg,err) + call get_command_argument(i+1,geometryArg,status=err) case ('-w', '--wd', '--workingdir', '--workingdirectory') - call get_command_argument(i+1,workingDirArg,err) + call get_command_argument(i+1,workingDirArg,status=err) case ('-r', '--rs', '--restart') - call get_command_argument(i+1,arg,err) + call get_command_argument(i+1,arg,status=err) read(arg,*,iostat=stat) interface_restartInc if (interface_restartInc < 0 .or. stat /=0) then write(6,'(/,a)') ' ERROR: Could not parse restart increment: '//trim(arg) From 2f8501dbaed9fd964bfb8d82ba63af89cbf79cb2 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 16 May 2020 20:55:05 +0200 Subject: [PATCH 32/32] current state (misc-improvements and master) --- PRIVATE | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PRIVATE b/PRIVATE index 038af521a..72d526e57 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 038af521a1ef70ed77b132c426bc1a4880db01ef +Subproject commit 72d526e5750366a9efe4d1fd9d92e0d1ecd2cd38