From 75272163cd4e915a9ccc3933347d47509aac9076 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Tue, 10 May 2022 15:45:19 -0400 Subject: [PATCH 1/8] slight polish of help messages --- python/damask/_rotation.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/python/damask/_rotation.py b/python/damask/_rotation.py index f138fbb8a..4a143585e 100644 --- a/python/damask/_rotation.py +++ b/python/damask/_rotation.py @@ -721,7 +721,7 @@ class Rotation: Parameters ---------- q : numpy.ndarray, shape (...,4) - Unit quaternion (q_0, q_1, q_2, q_3) in positive real hemisphere, i.e. ǀqǀ = 1, q_0 ≥ 0. + Unit quaternion (q_0, q_1, q_2, q_3) in positive real hemisphere, i.e. ǀqǀ = 1 and q_0 ≥ 0. accept_homomorph : bool, optional Allow homomorphic variants, i.e. q_0 < 0 (negative real hemisphere). Defaults to False. @@ -777,11 +777,11 @@ class Rotation: @staticmethod def from_axis_angle(axis_angle: np.ndarray, - degrees:bool = False, + degrees: bool = False, normalize: bool = False, P: Literal[1, -1] = -1) -> 'Rotation': """ - Initialize from Axis angle pair. + Initialize from axis–angle pair. Parameters ---------- @@ -818,12 +818,12 @@ class Rotation: orthonormal: bool = True, reciprocal: bool = False) -> 'Rotation': """ - Initialize from lattice basis vectors. + Initialize from basis vector triplet. Parameters ---------- basis : numpy.ndarray, shape (...,3,3) - Three three-dimensional lattice basis vectors. + Three three-dimensional basis vectors. orthonormal : bool, optional Basis is strictly orthonormal, i.e. is free of stretch components. Defaults to True. reciprocal : bool, optional @@ -857,7 +857,7 @@ class Rotation: Parameters ---------- R : numpy.ndarray, shape (...,3,3) - Rotation matrix with det(R) = 1, R.T ∙ R = I. + Rotation matrix with det(R) = 1 and R.T ∙ R = I. """ return Rotation.from_basis(R) @@ -866,14 +866,14 @@ class Rotation: def from_parallel(a: np.ndarray, b: np.ndarray ) -> 'Rotation': """ - Initialize from pairs of two orthogonal lattice basis vectors. + Initialize from pairs of two orthogonal basis vectors. Parameters ---------- a : numpy.ndarray, shape (...,2,3) - Two three-dimensional lattice vectors of first orthogonal basis. + Two three-dimensional vectors of first orthogonal basis. b : numpy.ndarray, shape (...,2,3) - Corresponding three-dimensional lattice vectors of second basis. + Corresponding three-dimensional vectors of second basis. """ a_ = np.array(a) @@ -896,7 +896,7 @@ class Rotation: normalize: bool = False, P: Literal[1, -1] = -1) -> 'Rotation': """ - Initialize from Rodrigues–Frank vector (angle separated from axis). + Initialize from Rodrigues–Frank vector (with angle separated from axis). Parameters ---------- From b080e414ae73cbfadf198fb0e0fca829728bd7e4 Mon Sep 17 00:00:00 2001 From: Philip Eisenlohr Date: Wed, 11 May 2022 08:55:55 -0400 Subject: [PATCH 2/8] normalize to_pole output by default --- python/damask/_orientation.py | 11 +++++++++-- python/tests/test_Orientation.py | 4 ++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/python/damask/_orientation.py b/python/damask/_orientation.py index 534a9548d..0c995110c 100644 --- a/python/damask/_orientation.py +++ b/python/damask/_orientation.py @@ -786,7 +786,8 @@ class Orientation(Rotation,Crystal): def to_pole(self, *, uvw: FloatSequence = None, hkl: FloatSequence = None, - with_symmetry: bool = False) -> np.ndarray: + with_symmetry: bool = False, + normalize: bool = True) -> np.ndarray: """ Calculate lab frame vector along lattice direction [uvw] or plane normal (hkl). @@ -795,9 +796,13 @@ class Orientation(Rotation,Crystal): uvw|hkl : numpy.ndarray, shape (...,3) Miller indices of crystallographic direction or plane normal. Shape of vector blends with shape of own rotation array. - For example, a rotation array, shape (3,2) and a vector array of shape (2,4) result in (3,2,4) outputs. + For example, a rotation array of shape (3,2) and a vector array of shape (2,4) result in (3,2,4) outputs. with_symmetry : bool, optional Calculate all N symmetrically equivalent vectors. + Defaults to False. + normalize : bool, optional + Normalize output vector. + Defaults to True. Returns ------- @@ -807,6 +812,8 @@ class Orientation(Rotation,Crystal): """ v = self.to_frame(uvw=uvw,hkl=hkl) blend = util.shapeblender(self.shape,v.shape[:-1]) + if normalize: + v /= np.linalg.norm(v,axis=-1,keepdims=len(v.shape)>1) if with_symmetry: sym_ops = self.symmetry_operations shape = v.shape[:-1]+sym_ops.shape diff --git a/python/tests/test_Orientation.py b/python/tests/test_Orientation.py index 729967539..6eedd3b77 100644 --- a/python/tests/test_Orientation.py +++ b/python/tests/test_Orientation.py @@ -173,8 +173,8 @@ class TestOrientation: o = Orientation.from_directions(uvw=a,hkl=c,**kwargs) x = o.to_pole(uvw=a) z = o.to_pole(hkl=c) - assert np.isclose(np.dot(x/np.linalg.norm(x),np.array([1,0,0])),1) \ - and np.isclose(np.dot(z/np.linalg.norm(z),np.array([0,0,1])),1) + assert np.isclose(np.dot(x,np.array([1,0,0])),1) \ + and np.isclose(np.dot(z,np.array([0,0,1])),1) @pytest.mark.parametrize('function',[Orientation.from_random, Orientation.from_quaternion, From 0b6ead1a484fb472e36d8ddf351f39d0e5d977f0 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 12 May 2022 15:36:12 +0200 Subject: [PATCH 3/8] avoid console-spam during initialization --- src/signals.f90 | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/signals.f90 b/src/signals.f90 index bf53912f4..a3eac8025 100644 --- a/src/signals.f90 +++ b/src/signals.f90 @@ -10,9 +10,9 @@ module signals private logical, volatile, public, protected :: & - signals_SIGTERM, & !< termination signal - signals_SIGUSR1, & !< 1. user-defined signal - signals_SIGUSR2 !< 2. user-defined signal + signals_SIGTERM = .false., & !< termination signal + signals_SIGUSR1 = .false., & !< 1. user-defined signal + signals_SIGUSR2 = .false. !< 2. user-defined signal public :: & signals_init, & @@ -31,9 +31,6 @@ subroutine signals_init() call signalterm_c(c_funloc(catchSIGTERM)) call signalusr1_c(c_funloc(catchSIGUSR1)) call signalusr2_c(c_funloc(catchSIGUSR2)) - call signals_setSIGTERM(.false.) - call signals_setSIGUSR1(.false.) - call signals_setSIGUSR2(.false.) end subroutine signals_init From 90c3b3170d4300ebd521bb4b623fc647f5d6e577 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Fri, 13 May 2022 09:53:44 +0200 Subject: [PATCH 4/8] propagate 'normalize' option --- python/damask/_orientation.py | 6 ++++-- python/damask/_result.py | 20 +++++++++++++------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/python/damask/_orientation.py b/python/damask/_orientation.py index 0c995110c..dcc139b7c 100644 --- a/python/damask/_orientation.py +++ b/python/damask/_orientation.py @@ -796,7 +796,8 @@ class Orientation(Rotation,Crystal): uvw|hkl : numpy.ndarray, shape (...,3) Miller indices of crystallographic direction or plane normal. Shape of vector blends with shape of own rotation array. - For example, a rotation array of shape (3,2) and a vector array of shape (2,4) result in (3,2,4) outputs. + For example, a rotation array of shape (3,2) and a vector + array of shape (2,4) result in (3,2,4) outputs. with_symmetry : bool, optional Calculate all N symmetrically equivalent vectors. Defaults to False. @@ -807,7 +808,8 @@ class Orientation(Rotation,Crystal): Returns ------- vector : numpy.ndarray, shape (...,3) or (...,N,3) - Lab frame vector (or vectors if with_symmetry) along [uvw] direction or (hkl) plane normal. + Lab frame vector (or vectors if with_symmetry) along + [uvw] direction or (hkl) plane normal. """ v = self.to_frame(uvw=uvw,hkl=hkl) diff --git a/python/damask/_result.py b/python/damask/_result.py index 253881731..7a58a1621 100644 --- a/python/damask/_result.py +++ b/python/damask/_result.py @@ -1023,26 +1023,26 @@ class Result: @staticmethod - def _add_pole(q,uvw,hkl,with_symmetry): + def _add_pole(q,uvw,hkl,with_symmetry,normalize): c = q['meta']['c/a'] if 'c/a' in q['meta'] else 1 brackets = ['[]','()','⟨⟩','{}'][(uvw is None)*1+with_symmetry*2] label = 'p^' + '{}{} {} {}{}'.format(brackets[0], *(uvw if uvw else hkl), brackets[-1],) - pole = Orientation(q['data'],lattice=q['meta']['lattice'],a=1,c=c).to_pole(uvw=uvw,hkl=hkl,with_symmetry=with_symmetry) + ori = Orientation(q['data'],lattice=q['meta']['lattice'],a=1,c=c) return { - 'data': pole, + 'data': ori.to_pole(uvw=uvw,hkl=hkl,with_symmetry=with_symmetry,normalize=normalize), 'label': label, 'meta' : { 'unit': '1', - 'description': 'lab frame vector along lattice ' \ - + ('direction' if uvw else 'plane') \ + 'description': f'{"normalized " if normalize else ""}lab frame vector along lattice ' \ + + ('direction' if uvw is not None else 'plane') \ + ('s' if with_symmetry else ''), 'creator': 'add_pole' } } - def add_pole(self,q='O',*,uvw=None,hkl=None,with_symmetry=False): + def add_pole(self,q='O',*,uvw=None,hkl=None,with_symmetry=False,normalize=True): """ Add lab frame vector along lattice direction [uvw] or plane normal (hkl). @@ -1055,9 +1055,15 @@ class Result: Miller indices of crystallographic direction or plane normal. with_symmetry : bool, optional Calculate all N symmetrically equivalent vectors. + Defaults to True. + normalize : bool, optional + Normalize output vector. + Defaults to True. """ - self._add_generic_pointwise(self._add_pole,{'q':q},{'uvw':uvw,'hkl':hkl,'with_symmetry':with_symmetry}) + self._add_generic_pointwise(self._add_pole, + {'q':q}, + {'uvw':uvw,'hkl':hkl,'with_symmetry':with_symmetry,'normalize':normalize}) @staticmethod From 3f85027b9ec1dc07eaaa3778b88c0b3ddc9e2829 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 12 May 2022 16:45:42 +0200 Subject: [PATCH 5/8] better use SIGINT for actions triggered by the user SIGTERM is send by MPI if one process fails, catching it results in deadlocks --- PRIVATE | 2 +- src/C_routines.c | 4 ++-- src/grid/DAMASK_grid.f90 | 2 +- src/signals.f90 | 24 ++++++++++++------------ src/system_routines.f90 | 6 +++--- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/PRIVATE b/PRIVATE index 3561f74a5..df33ba9a1 160000 --- a/PRIVATE +++ b/PRIVATE @@ -1 +1 @@ -Subproject commit 3561f74a5852c32e2c3da4dc48090b517cfa8e90 +Subproject commit df33ba9a1360439c5c18a241a1e439dab0cdcafd diff --git a/src/C_routines.c b/src/C_routines.c index a25fde688..37364543d 100644 --- a/src/C_routines.c +++ b/src/C_routines.c @@ -58,8 +58,8 @@ void getusername_c(char username[], int *stat){ } -void signalterm_c(void (*handler)(int)){ - signal(SIGTERM, handler); +void signalint_c(void (*handler)(int)){ + signal(SIGINT, handler); } void signalusr1_c(void (*handler)(int)){ diff --git a/src/grid/DAMASK_grid.f90 b/src/grid/DAMASK_grid.f90 index 835e18b34..824d867c5 100644 --- a/src/grid/DAMASK_grid.f90 +++ b/src/grid/DAMASK_grid.f90 @@ -471,7 +471,7 @@ program DAMASK_grid call materialpoint_restartWrite endif if (signal) call signals_setSIGUSR2(.false.) - call MPI_Allreduce(signals_SIGTERM,signal,1_MPI_INTEGER_KIND,MPI_LOGICAL,MPI_LOR,MPI_COMM_WORLD,err_MPI) + call MPI_Allreduce(signals_SIGINT,signal,1_MPI_INTEGER_KIND,MPI_LOGICAL,MPI_LOR,MPI_COMM_WORLD,err_MPI) if (err_MPI /= 0_MPI_INTEGER_KIND) error stop 'MPI error' if (signal) exit loadCaseLooping endif skipping diff --git a/src/signals.f90 b/src/signals.f90 index a3eac8025..7db101f94 100644 --- a/src/signals.f90 +++ b/src/signals.f90 @@ -10,13 +10,13 @@ module signals private logical, volatile, public, protected :: & - signals_SIGTERM = .false., & !< termination signal + signals_SIGINT = .false., & !< interrupt signal signals_SIGUSR1 = .false., & !< 1. user-defined signal signals_SIGUSR2 = .false. !< 2. user-defined signal public :: & signals_init, & - signals_setSIGTERM, & + signals_setSIGINT, & signals_setSIGUSR1, & signals_setSIGUSR2 @@ -28,7 +28,7 @@ contains !-------------------------------------------------------------------------------------------------- subroutine signals_init() - call signalterm_c(c_funloc(catchSIGTERM)) + call signalint_c(c_funloc(catchSIGINT)) call signalusr1_c(c_funloc(catchSIGUSR1)) call signalusr2_c(c_funloc(catchSIGUSR2)) @@ -36,18 +36,18 @@ end subroutine signals_init !-------------------------------------------------------------------------------------------------- -!> @brief Set global variable signals_SIGTERM to .true. +!> @brief Set global variable signals_SIGINT to .true. !> @details This function can be registered to catch signals send to the executable. !-------------------------------------------------------------------------------------------------- -subroutine catchSIGTERM(signal) bind(C) +subroutine catchSIGINT(signal) bind(C) integer(C_INT), value :: signal print'(a,i0)', ' received signal ',signal - call signals_setSIGTERM(.true.) + call signals_setSIGINT(.true.) -end subroutine catchSIGTERM +end subroutine catchSIGINT !-------------------------------------------------------------------------------------------------- @@ -81,17 +81,17 @@ end subroutine catchSIGUSR2 !-------------------------------------------------------------------------------------------------- -!> @brief Set global variable signals_SIGTERM. +!> @brief Set global variable signals_SIGINT. !-------------------------------------------------------------------------------------------------- -subroutine signals_setSIGTERM(state) +subroutine signals_setSIGINT(state) logical, intent(in) :: state - signals_SIGTERM = state - print*, 'set SIGTERM to',state + signals_SIGINT = state + print*, 'set SIGINT to',state -end subroutine signals_setSIGTERM +end subroutine signals_setSIGINT !-------------------------------------------------------------------------------------------------- diff --git a/src/system_routines.f90 b/src/system_routines.f90 index e0adf9dc0..2af1e12a9 100644 --- a/src/system_routines.f90 +++ b/src/system_routines.f90 @@ -15,7 +15,7 @@ module system_routines getCWD, & getHostName, & getUserName, & - signalterm_C, & + signalint_C, & signalusr1_C, & signalusr2_C, & f_c_string, & @@ -55,11 +55,11 @@ module system_routines integer(C_INT), intent(out) :: stat end subroutine getUserName_C - subroutine signalterm_C(handler) bind(C) + subroutine signalint_C(handler) bind(C) use, intrinsic :: ISO_C_Binding, only: C_FUNPTR type(C_FUNPTR), intent(in), value :: handler - end subroutine signalterm_C + end subroutine signalint_C subroutine signalusr1_C(handler) bind(C) use, intrinsic :: ISO_C_Binding, only: C_FUNPTR From 1448719e6badb62222da78280e522656652fd7a7 Mon Sep 17 00:00:00 2001 From: Test User Date: Fri, 13 May 2022 16:35:24 +0200 Subject: [PATCH 6/8] [skip ci] updated version information after successful test of v3.0.0-alpha6-346-gd83f0acf7 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 2ff635946..701a06286 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.0.0-alpha6-343-gc8d48d6eb +3.0.0-alpha6-346-gd83f0acf7 From b9fd6329daa975cdb153e5fcaa8b02b5f03c2eab Mon Sep 17 00:00:00 2001 From: Test User Date: Sat, 14 May 2022 21:07:33 +0200 Subject: [PATCH 7/8] [skip ci] updated version information after successful test of v3.0.0-alpha6-351-gc9d7cf405 --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index 701a06286..f1bc4ad9a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.0.0-alpha6-346-gd83f0acf7 +3.0.0-alpha6-351-gc9d7cf405 From 10e849801662f72e525453362fb0aaa8bdbf2b71 Mon Sep 17 00:00:00 2001 From: Test User Date: Mon, 16 May 2022 02:43:09 +0200 Subject: [PATCH 8/8] [skip ci] updated version information after successful test of v3.0.0-alpha6-355-g6c7f2344d --- VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION b/VERSION index f1bc4ad9a..d918fb5b1 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -3.0.0-alpha6-351-gc9d7cf405 +3.0.0-alpha6-355-g6c7f2344d