From 72c835a55417038718b4769fb3742583aec6a1ab Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Mon, 11 May 2020 16:00:53 +0200 Subject: [PATCH 1/9] 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 2/9] 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 3/9] 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 4/9] 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 5/9] 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 6/9] 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 7/9] 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 8/9] 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 9/9] 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