Merge remote-tracking branch 'origin/development' into allocatable-strings
This commit is contained in:
commit
923ce05802
|
@ -902,7 +902,8 @@ class Rotation:
|
|||
return Rotation(Rotation._om2qu(om))
|
||||
|
||||
@staticmethod
|
||||
def from_matrix(R: np.ndarray) -> 'Rotation':
|
||||
def from_matrix(R: np.ndarray,
|
||||
normalize: bool = False) -> 'Rotation':
|
||||
"""
|
||||
Initialize from rotation matrix.
|
||||
|
||||
|
@ -910,13 +911,17 @@ class Rotation:
|
|||
----------
|
||||
R : numpy.ndarray, shape (...,3,3)
|
||||
Rotation matrix with det(R) = 1 and R.T ∙ R = I.
|
||||
normalize : bool, optional
|
||||
Rescales rotation matrix to unit determinant. Defaults to False.
|
||||
|
||||
Returns
|
||||
-------
|
||||
new : damask.Rotation
|
||||
|
||||
"""
|
||||
return Rotation.from_basis(R)
|
||||
return Rotation.from_basis(np.array(R,dtype=float) * (np.linalg.det(R)**(-1./3.))[...,np.newaxis,np.newaxis]
|
||||
if normalize else
|
||||
R)
|
||||
|
||||
@staticmethod
|
||||
def from_parallel(a: np.ndarray,
|
||||
|
|
|
@ -774,9 +774,11 @@ class TestRotation:
|
|||
).all()
|
||||
|
||||
|
||||
def test_matrix(self,multidim_rotations):
|
||||
@pytest.mark.parametrize('normalize',[True,False])
|
||||
def test_matrix(self,multidim_rotations,normalize):
|
||||
m = multidim_rotations
|
||||
o = Rotation.from_matrix(m.as_matrix())
|
||||
o = Rotation.from_matrix(m.as_matrix()*(0.9 if normalize else 1.0),
|
||||
normalize=normalize)
|
||||
f = Rotation(np.where(np.isclose(m.as_quaternion()[...,0],0.0,atol=atol)[...,np.newaxis],~o,o))
|
||||
assert np.logical_or(m.isclose(o,atol=atol),
|
||||
m.isclose(f,atol=atol)
|
||||
|
|
|
@ -286,18 +286,6 @@ p2 : str, optional
|
|||
|
||||
Remaining description
|
||||
"""
|
||||
invalid_docstring = """
|
||||
Function description
|
||||
|
||||
Parameters ----------
|
||||
p0 : numpy.ndarray, shape (...,4)
|
||||
p0 description 1
|
||||
p0 description 2
|
||||
p1 : int, optional
|
||||
p1 description
|
||||
|
||||
Remaining description
|
||||
"""
|
||||
expected = """
|
||||
Function description
|
||||
|
||||
|
|
|
@ -77,6 +77,7 @@ module grid_mechanical_spectral_basic
|
|||
C_volAvgLastInc = 0.0_pReal, & !< previous volume average stiffness
|
||||
C_minMaxAvg = 0.0_pReal, & !< current (min+max)/2 stiffness
|
||||
C_minMaxAvgLastInc = 0.0_pReal, & !< previous (min+max)/2 stiffness
|
||||
C_minMaxAvgRestart = 0.0_pReal, & !< (min+max)/2 stiffnes (restart)
|
||||
S = 0.0_pReal !< current compliance (filled up with zeros)
|
||||
|
||||
real(pReal) :: &
|
||||
|
@ -256,21 +257,17 @@ subroutine grid_mechanical_spectral_basic_init()
|
|||
call HDF5_read(C_volAvgLastInc,groupHandle,'C_volAvgLastInc',.false.)
|
||||
call MPI_Bcast(C_volAvgLastInc,81_MPI_INTEGER_KIND,MPI_DOUBLE,0_MPI_INTEGER_KIND,MPI_COMM_WORLD,err_MPI)
|
||||
if (err_MPI /= 0_MPI_INTEGER_KIND) error stop 'MPI error'
|
||||
call HDF5_read(C_minMaxAvg,groupHandle,'C_minMaxAvg',.false.)
|
||||
call MPI_Bcast(C_minMaxAvg,81_MPI_INTEGER_KIND,MPI_DOUBLE,0_MPI_INTEGER_KIND,MPI_COMM_WORLD,err_MPI)
|
||||
if (err_MPI /= 0_MPI_INTEGER_KIND) error stop 'MPI error'
|
||||
|
||||
call HDF5_closeGroup(groupHandle)
|
||||
call HDF5_closeFile(fileHandle)
|
||||
|
||||
call MPI_File_open(MPI_COMM_WORLD, trim(getSolverJobName())//'.C_ref', &
|
||||
MPI_MODE_RDONLY,MPI_INFO_NULL,fileUnit,err_MPI)
|
||||
if (err_MPI /= 0_MPI_INTEGER_KIND) error stop 'MPI error'
|
||||
call MPI_File_read(fileUnit,C_minMaxAvg,81_MPI_INTEGER_KIND,MPI_DOUBLE,status,err_MPI)
|
||||
if (err_MPI /= 0_MPI_INTEGER_KIND) error stop 'MPI error'
|
||||
call MPI_File_close(fileUnit,err_MPI)
|
||||
if (err_MPI /= 0_MPI_INTEGER_KIND) error stop 'MPI error'
|
||||
end if restartRead2
|
||||
|
||||
call utilities_updateGamma(C_minMaxAvg)
|
||||
call utilities_saveReferenceStiffness
|
||||
C_minMaxAvgRestart = C_minMaxAvg
|
||||
|
||||
end subroutine grid_mechanical_spectral_basic_init
|
||||
|
||||
|
@ -420,6 +417,8 @@ subroutine grid_mechanical_spectral_basic_restartWrite
|
|||
call DMDAVecGetArrayF90(da,solution_vec,F,err_PETSc)
|
||||
CHKERRQ(err_PETSc)
|
||||
|
||||
if (num%update_gamma) C_minMaxAvgRestart = C_minMaxAvg
|
||||
|
||||
print'(1x,a)', 'writing solver data required for restart to file'; flush(IO_STDOUT)
|
||||
|
||||
fileHandle = HDF5_openFile(getSolverJobName()//'_restart.hdf5','w')
|
||||
|
@ -438,13 +437,11 @@ subroutine grid_mechanical_spectral_basic_restartWrite
|
|||
call HDF5_write(F_aimDot,groupHandle,'F_aimDot',.false.)
|
||||
call HDF5_write(C_volAvg,groupHandle,'C_volAvg',.false.)
|
||||
call HDF5_write(C_volAvgLastInc,groupHandle,'C_volAvgLastInc',.false.)
|
||||
call HDF5_write(C_minMaxAvg,groupHandle,'C_minMaxAvg',.false.)
|
||||
call HDF5_write(C_minMaxAvgRestart,groupHandle,'C_minMaxAvg',.false.)
|
||||
call HDF5_closeGroup(groupHandle)
|
||||
call HDF5_closeFile(fileHandle)
|
||||
end if
|
||||
|
||||
if (num%update_gamma) call utilities_saveReferenceStiffness
|
||||
|
||||
call DMDAVecRestoreArrayF90(da,solution_vec,F,err_PETSc)
|
||||
CHKERRQ(err_PETSc)
|
||||
|
||||
|
|
|
@ -85,6 +85,7 @@ module grid_mechanical_spectral_polarisation
|
|||
C_volAvgLastInc = 0.0_pReal, & !< previous volume average stiffness
|
||||
C_minMaxAvg = 0.0_pReal, & !< current (min+max)/2 stiffness
|
||||
C_minMaxAvgLastInc = 0.0_pReal, & !< previous (min+max)/2 stiffness
|
||||
C_minMaxAvgRestart = 0.0_pReal, & !< (min+max)/2 stiffnes (restart)
|
||||
S = 0.0_pReal, & !< current compliance (filled up with zeros)
|
||||
C_scale = 0.0_pReal, &
|
||||
S_scale = 0.0_pReal
|
||||
|
@ -283,21 +284,17 @@ subroutine grid_mechanical_spectral_polarisation_init()
|
|||
call HDF5_read(C_volAvgLastInc,groupHandle,'C_volAvgLastInc',.false.)
|
||||
call MPI_Bcast(C_volAvgLastInc,81_MPI_INTEGER_KIND,MPI_DOUBLE,0_MPI_INTEGER_KIND,MPI_COMM_WORLD,err_MPI)
|
||||
if (err_MPI /= 0_MPI_INTEGER_KIND) error stop 'MPI error'
|
||||
call HDF5_read(C_minMaxAvg,groupHandle,'C_minMaxAvg',.false.)
|
||||
call MPI_Bcast(C_minMaxAvg,81_MPI_INTEGER_KIND,MPI_DOUBLE,0_MPI_INTEGER_KIND,MPI_COMM_WORLD,err_MPI)
|
||||
if (err_MPI /= 0_MPI_INTEGER_KIND) error stop 'MPI error'
|
||||
|
||||
call HDF5_closeGroup(groupHandle)
|
||||
call HDF5_closeFile(fileHandle)
|
||||
|
||||
call MPI_File_open(MPI_COMM_WORLD, trim(getSolverJobName())//'.C_ref', &
|
||||
MPI_MODE_RDONLY,MPI_INFO_NULL,fileUnit,err_MPI)
|
||||
if (err_MPI /= 0_MPI_INTEGER_KIND) error stop 'MPI error'
|
||||
call MPI_File_read(fileUnit,C_minMaxAvg,81_MPI_INTEGER_KIND,MPI_DOUBLE,status,err_MPI)
|
||||
if (err_MPI /= 0_MPI_INTEGER_KIND) error stop 'MPI error'
|
||||
call MPI_File_close(fileUnit,err_MPI)
|
||||
if (err_MPI /= 0_MPI_INTEGER_KIND) error stop 'MPI error'
|
||||
end if restartRead2
|
||||
|
||||
call utilities_updateGamma(C_minMaxAvg)
|
||||
call utilities_saveReferenceStiffness
|
||||
C_minMaxAvgRestart = C_minMaxAvg
|
||||
C_scale = C_minMaxAvg
|
||||
S_scale = math_invSym3333(C_minMaxAvg)
|
||||
|
||||
|
@ -477,6 +474,8 @@ subroutine grid_mechanical_spectral_polarisation_restartWrite
|
|||
F => FandF_tau(0: 8,:,:,:)
|
||||
F_tau => FandF_tau(9:17,:,:,:)
|
||||
|
||||
if (num%update_gamma) C_minMaxAvgRestart = C_minMaxAvg
|
||||
|
||||
print'(1x,a)', 'writing solver data required for restart to file'; flush(IO_STDOUT)
|
||||
|
||||
fileHandle = HDF5_openFile(getSolverJobName()//'_restart.hdf5','w')
|
||||
|
@ -497,12 +496,11 @@ subroutine grid_mechanical_spectral_polarisation_restartWrite
|
|||
call HDF5_write(F_aimDot,groupHandle,'F_aimDot',.false.)
|
||||
call HDF5_write(C_volAvg,groupHandle,'C_volAvg',.false.)
|
||||
call HDF5_write(C_volAvgLastInc,groupHandle,'C_volAvgLastInc',.false.)
|
||||
call HDF5_write(C_minMaxAvgRestart,groupHandle,'C_minMaxAvg',.false.)
|
||||
call HDF5_closeGroup(groupHandle)
|
||||
call HDF5_closeFile(fileHandle)
|
||||
end if
|
||||
|
||||
if (num%update_gamma) call utilities_saveReferenceStiffness
|
||||
|
||||
call DMDAVecRestoreArrayF90(da,solution_vec,FandF_tau,err_PETSc)
|
||||
CHKERRQ(err_PETSc)
|
||||
|
||||
|
|
|
@ -126,8 +126,7 @@ module spectral_utilities
|
|||
utilities_constitutiveResponse, &
|
||||
utilities_calculateRate, &
|
||||
utilities_forwardField, &
|
||||
utilities_updateCoords, &
|
||||
utilities_saveReferenceStiffness
|
||||
utilities_updateCoords
|
||||
|
||||
contains
|
||||
|
||||
|
@ -1098,27 +1097,6 @@ subroutine utilities_updateCoords(F)
|
|||
end subroutine utilities_updateCoords
|
||||
|
||||
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
!> @brief Write out the current reference stiffness for restart.
|
||||
!---------------------------------------------------------------------------------------------------
|
||||
subroutine utilities_saveReferenceStiffness()
|
||||
|
||||
integer :: &
|
||||
fileUnit,ierr
|
||||
|
||||
|
||||
if (worldrank == 0) then
|
||||
print'(/,1x,a)', '... writing reference stiffness data required for restart to file .........'; flush(IO_STDOUT)
|
||||
open(newunit=fileUnit, file=getSolverJobName()//'.C_ref',&
|
||||
status='replace',access='stream',action='write',iostat=ierr)
|
||||
if (ierr /=0) call IO_error(100,ext_msg='could not open file '//getSolverJobName()//'.C_ref')
|
||||
write(fileUnit) C_ref*wgt
|
||||
close(fileUnit)
|
||||
end if
|
||||
|
||||
end subroutine utilities_saveReferenceStiffness
|
||||
|
||||
|
||||
!--------------------------------------------------------------------------------------------------
|
||||
!> @brief Check correctness of forward-backward transform.
|
||||
!--------------------------------------------------------------------------------------------------
|
||||
|
|
|
@ -405,13 +405,13 @@ module lattice
|
|||
contains
|
||||
|
||||
!--------------------------------------------------------------------------------------------------
|
||||
!> @brief Module initialization
|
||||
!> @brief Run self test.
|
||||
!--------------------------------------------------------------------------------------------------
|
||||
subroutine lattice_init
|
||||
subroutine lattice_init()
|
||||
|
||||
print'(/,1x,a)', '<<<+- lattice init -+>>>'; flush(IO_STDOUT)
|
||||
|
||||
call selfTest
|
||||
call selfTest()
|
||||
|
||||
end subroutine lattice_init
|
||||
|
||||
|
@ -2330,14 +2330,14 @@ subroutine selfTest
|
|||
lattice_isotropic_nu(C_tI,'isostress','tI'),1.0e-12_pReal)) error stop 'isotropic_nu/isostress/tI'
|
||||
|
||||
call random_number(C)
|
||||
C = lattice_symmetrize_C66(C,'cI')
|
||||
if (dNeq(lattice_isotropic_mu(C,'isostrain','cI'), lattice_isotropic_mu(C,'isostrain','hP'), 5.0e-9_pReal)) &
|
||||
C = lattice_symmetrize_C66(C+math_eye(6),'cI')
|
||||
if (dNeq(lattice_isotropic_mu(C,'isostrain','cI'), lattice_isotropic_mu(C,'isostrain','hP'), 1.0e-12_pReal)) &
|
||||
error stop 'isotropic_mu/isostrain/cI-hP'
|
||||
if (dNeq(lattice_isotropic_nu(C,'isostrain','cF'), lattice_isotropic_nu(C,'isostrain','cI'), 5.0e-9_pReal)) &
|
||||
if (dNeq(lattice_isotropic_nu(C,'isostrain','cF'), lattice_isotropic_nu(C,'isostrain','cI'), 1.0e-12_pReal)) &
|
||||
error stop 'isotropic_nu/isostrain/cF-tI'
|
||||
if (dNeq(lattice_isotropic_mu(C,'isostress','cI'), lattice_isotropic_mu(C,'isostress'), 5.0e-9_pReal)) &
|
||||
if (dNeq(lattice_isotropic_mu(C,'isostress','cI'), lattice_isotropic_mu(C,'isostress'), 1.0e-12_pReal)) &
|
||||
error stop 'isotropic_mu/isostress/cI-hP'
|
||||
if (dNeq(lattice_isotropic_nu(C,'isostress','cF'), lattice_isotropic_nu(C,'isostress'), 5.0e-9_pReal)) &
|
||||
if (dNeq(lattice_isotropic_nu(C,'isostress','cF'), lattice_isotropic_nu(C,'isostress'), 1.0e-12_pReal)) &
|
||||
error stop 'isotropic_nu/isostress/cF-tI'
|
||||
|
||||
end subroutine selfTest
|
||||
|
|
Loading…
Reference in New Issue