Merge remote-tracking branch 'origin/development' into 302-dimension-mismatch-when-passing-a-flattened-f-array-to-utilities_updatecoords

This commit is contained in:
Sharan Roongta 2023-07-11 14:27:39 +02:00
commit 9b349bb912
7 changed files with 47 additions and 44 deletions

View File

@ -1 +1 @@
3.0.0-alpha7-604-g65fa62b3f 3.0.0-alpha7-610-g716600299

View File

@ -1201,7 +1201,7 @@ class Result:
'label': f"epsilon_{t}^{m}({F['label']})", 'label': f"epsilon_{t}^{m}({F['label']})",
'meta': { 'meta': {
'unit': F['meta']['unit'], 'unit': F['meta']['unit'],
'description': f'strain tensor of order {m} based on {side} stretch tensor '+\ 'description': f'Seth-Hill strain tensor of order {m} based on {side} stretch tensor '+\
f"of {F['label']} ({F['meta']['description']})", f"of {F['label']} ({F['meta']['description']})",
'creator': 'add_strain' 'creator': 'add_strain'
} }
@ -1210,10 +1210,11 @@ class Result:
F: str = 'F', F: str = 'F',
t: Literal['V', 'U'] = 'V', t: Literal['V', 'U'] = 'V',
m: float = 0.0): m: float = 0.0):
""" r"""
Add strain tensor of a deformation gradient. Add strain tensor (Seth-Hill family) of a deformation gradient.
For details, see damask.mechanics.strain. By default, the logarithmic strain based on the
left stretch tensor is added.
Parameters Parameters
---------- ----------
@ -1247,6 +1248,23 @@ class Result:
spatial/Eulerian strain measures (based on 'V') for elastic strains spatial/Eulerian strain measures (based on 'V') for elastic strains
when calculating averages. when calculating averages.
The strain is defined as:
.. math::
m = 0 \\\\
\vb*{\epsilon}_V^{(0)} = \ln (\vb{V}) \\\\
\vb*{\epsilon}_U^{(0)} = \ln (\vb{U}) \\\\
m \neq 0 \\\\
\vb*{\epsilon}_V^{(m)} = \frac{1}{2m} (\vb{V}^{2m} - \vb{I}) \\\\
\vb*{\epsilon}_U^{(m)} = \frac{1}{2m} (\vb{U}^{2m} - \vb{I})
References
----------
| https://en.wikipedia.org/wiki/Finite_strain_theory
| https://de.wikipedia.org/wiki/Verzerrungstensor
""" """
self._add_generic_pointwise(self._add_strain,{'F':F},{'t':t,'m':m}) self._add_generic_pointwise(self._add_strain,{'F':F},{'t':t,'m':m})

View File

@ -307,7 +307,7 @@ end subroutine grid_damage_spectral_forward
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
!> @brief Write current solver and constitutive data for restart to file. !> @brief Write current solver and constitutive data for restart to file.
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
subroutine grid_damage_spectral_restartWrite subroutine grid_damage_spectral_restartWrite()
PetscErrorCode :: err_PETSc PetscErrorCode :: err_PETSc
DM :: dm_local DM :: dm_local
@ -316,7 +316,7 @@ subroutine grid_damage_spectral_restartWrite
call SNESGetDM(SNES_damage,dm_local,err_PETSc); call SNESGetDM(SNES_damage,dm_local,err_PETSc);
CHKERRQ(err_PETSc) CHKERRQ(err_PETSc)
call DMDAVecGetArrayF90(dm_local,solution_vec,phi,err_PETSc); call DMDAVecGetArrayReadF90(dm_local,solution_vec,phi,err_PETSc);
CHKERRQ(err_PETSc) CHKERRQ(err_PETSc)
print'(1x,a)', 'saving damage solver data required for restart'; flush(IO_STDOUT) print'(1x,a)', 'saving damage solver data required for restart'; flush(IO_STDOUT)
@ -328,7 +328,7 @@ subroutine grid_damage_spectral_restartWrite
call HDF5_closeGroup(groupHandle) call HDF5_closeGroup(groupHandle)
call HDF5_closeFile(fileHandle) call HDF5_closeFile(fileHandle)
call DMDAVecRestoreArrayF90(dm_local,solution_vec,phi,err_PETSc); call DMDAVecRestoreArrayReadF90(dm_local,solution_vec,phi,err_PETSc);
CHKERRQ(err_PETSc) CHKERRQ(err_PETSc)
end subroutine grid_damage_spectral_restartWrite end subroutine grid_damage_spectral_restartWrite

View File

@ -351,15 +351,8 @@ subroutine grid_mechanical_FEM_forward(cutBack,guess,Delta_t,Delta_t_old,t_remai
rotation_BC rotation_BC
PetscErrorCode :: err_PETSc PetscErrorCode :: err_PETSc
PetscScalar, pointer, dimension(:,:,:,:) :: &
u,u_lastInc
call DMDAVecGetArrayF90(mechanical_grid,solution_current,u,err_PETSc)
CHKERRQ(err_PETSc)
call DMDAVecGetArrayF90(mechanical_grid,solution_lastInc,u_lastInc,err_PETSc)
CHKERRQ(err_PETSc)
if (cutBack) then if (cutBack) then
C_volAvg = C_volAvgLastInc C_volAvg = C_volAvgLastInc
else else
@ -408,10 +401,6 @@ subroutine grid_mechanical_FEM_forward(cutBack,guess,Delta_t,Delta_t_old,t_remai
call VecAXPY(solution_current,Delta_t,solution_rate,err_PETSc) call VecAXPY(solution_current,Delta_t,solution_rate,err_PETSc)
CHKERRQ(err_PETSc) CHKERRQ(err_PETSc)
call DMDAVecRestoreArrayF90(mechanical_grid,solution_current,u,err_PETSc)
CHKERRQ(err_PETSc)
call DMDAVecRestoreArrayF90(mechanical_grid,solution_lastInc,u_lastInc,err_PETSc)
CHKERRQ(err_PETSc)
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
! set module wide available data ! set module wide available data
@ -425,7 +414,7 @@ end subroutine grid_mechanical_FEM_forward
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
!> @brief Update coordinates !> @brief Update coordinates
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
subroutine grid_mechanical_FEM_updateCoords subroutine grid_mechanical_FEM_updateCoords()
call utilities_updateCoords(F) call utilities_updateCoords(F)
@ -435,16 +424,16 @@ end subroutine grid_mechanical_FEM_updateCoords
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
!> @brief Write current solver and constitutive data for restart to file !> @brief Write current solver and constitutive data for restart to file
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
subroutine grid_mechanical_FEM_restartWrite subroutine grid_mechanical_FEM_restartWrite()
PetscErrorCode :: err_PETSc PetscErrorCode :: err_PETSc
integer(HID_T) :: fileHandle, groupHandle integer(HID_T) :: fileHandle, groupHandle
PetscScalar, dimension(:,:,:,:), pointer :: u,u_lastInc PetscScalar, dimension(:,:,:,:), pointer :: u,u_lastInc
call DMDAVecGetArrayF90(mechanical_grid,solution_current,u,err_PETSc) call DMDAVecGetArrayReadF90(mechanical_grid,solution_current,u,err_PETSc)
CHKERRQ(err_PETSc) CHKERRQ(err_PETSc)
call DMDAVecGetArrayF90(mechanical_grid,solution_lastInc,u_lastInc,err_PETSc) call DMDAVecGetArrayReadF90(mechanical_grid,solution_lastInc,u_lastInc,err_PETSc)
CHKERRQ(err_PETSc) CHKERRQ(err_PETSc)
print'(1x,a)', 'saving solver data required for restart'; flush(IO_STDOUT) print'(1x,a)', 'saving solver data required for restart'; flush(IO_STDOUT)
@ -471,9 +460,9 @@ subroutine grid_mechanical_FEM_restartWrite
call HDF5_closeFile(fileHandle) call HDF5_closeFile(fileHandle)
end if end if
call DMDAVecRestoreArrayF90(mechanical_grid,solution_current,u,err_PETSc) call DMDAVecRestoreArrayReadF90(mechanical_grid,solution_current,u,err_PETSc)
CHKERRQ(err_PETSc) CHKERRQ(err_PETSc)
call DMDAVecRestoreArrayF90(mechanical_grid,solution_lastInc,u_lastInc,err_PETSc) call DMDAVecRestoreArrayReadF90(mechanical_grid,solution_lastInc,u_lastInc,err_PETSc)
CHKERRQ(err_PETSc) CHKERRQ(err_PETSc)
end subroutine grid_mechanical_FEM_restartWrite end subroutine grid_mechanical_FEM_restartWrite
@ -566,7 +555,7 @@ subroutine formResidual(da_local,x_local, &
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
! get deformation gradient ! get deformation gradient
call DMDAVecGetArrayF90(da_local,x_local,x_scal,err_PETSc) call DMDAVecGetArrayReadF90(da_local,x_local,x_scal,err_PETSc)
CHKERRQ(err_PETSc) CHKERRQ(err_PETSc)
do k = cells3Offset+1, cells3Offset+cells3; do j = 1, cells(2); do i = 1, cells(1) do k = cells3Offset+1, cells3Offset+cells3; do j = 1, cells(2); do i = 1, cells(1)
ctr = 0 ctr = 0
@ -576,7 +565,7 @@ subroutine formResidual(da_local,x_local, &
end do; end do; end do end do; end do; end do
F(1:3,1:3,i,j,k-cells3Offset) = params%rotation_BC%rotate(F_aim,active=.true.) + transpose(matmul(BMat,x_elem)) F(1:3,1:3,i,j,k-cells3Offset) = params%rotation_BC%rotate(F_aim,active=.true.) + transpose(matmul(BMat,x_elem))
end do; end do; end do end do; end do; end do
call DMDAVecRestoreArrayF90(da_local,x_local,x_scal,err_PETSc) call DMDAVecRestoreArrayReadF90(da_local,x_local,x_scal,err_PETSc)
CHKERRQ(err_PETSc) CHKERRQ(err_PETSc)
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
@ -596,7 +585,7 @@ subroutine formResidual(da_local,x_local, &
! constructing residual ! constructing residual
call DMDAVecGetArrayF90(da_local,f_local,r,err_PETSc) call DMDAVecGetArrayF90(da_local,f_local,r,err_PETSc)
CHKERRQ(err_PETSc) CHKERRQ(err_PETSc)
call DMDAVecGetArrayF90(da_local,x_local,x_scal,err_PETSc) call DMDAVecGetArrayReadF90(da_local,x_local,x_scal,err_PETSc)
CHKERRQ(err_PETSc) CHKERRQ(err_PETSc)
ele = 0 ele = 0
r = 0.0_pREAL r = 0.0_pREAL
@ -617,7 +606,7 @@ subroutine formResidual(da_local,x_local, &
r(0:2,i+ii,j+jj,k+kk) = r(0:2,i+ii,j+jj,k+kk) + f_elem(ctr,1:3) r(0:2,i+ii,j+jj,k+kk) = r(0:2,i+ii,j+jj,k+kk) + f_elem(ctr,1:3)
end do; end do; end do end do; end do; end do
end do; end do; end do end do; end do; end do
call DMDAVecRestoreArrayF90(da_local,x_local,x_scal,err_PETSc) call DMDAVecRestoreArrayReadF90(da_local,x_local,x_scal,err_PETSc)
CHKERRQ(err_PETSc) CHKERRQ(err_PETSc)
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------

View File

@ -382,11 +382,10 @@ subroutine grid_mechanical_spectral_basic_updateCoords()
PetscErrorCode :: err_PETSc PetscErrorCode :: err_PETSc
real(pREAL), dimension(:,:,:,:), pointer :: F real(pREAL), dimension(:,:,:,:), pointer :: F
call DMDAVecGetArrayReadF90(da,solution_vec,F,err_PETSc)
call DMDAVecGetArrayF90(da,solution_vec,F,err_PETSc)
CHKERRQ(err_PETSc) CHKERRQ(err_PETSc)
call utilities_updateCoords(reshape(F,[3,3,size(F,2),size(F,3),size(F,4)])) call utilities_updateCoords(reshape(F,[3,3,size(F,2),size(F,3),size(F,4)]))
call DMDAVecRestoreArrayF90(da,solution_vec,F,err_PETSc) call DMDAVecRestoreArrayReadF90(da,solution_vec,F,err_PETSc)
CHKERRQ(err_PETSc) CHKERRQ(err_PETSc)
end subroutine grid_mechanical_spectral_basic_updateCoords end subroutine grid_mechanical_spectral_basic_updateCoords
@ -401,8 +400,7 @@ subroutine grid_mechanical_spectral_basic_restartWrite()
integer(HID_T) :: fileHandle, groupHandle integer(HID_T) :: fileHandle, groupHandle
real(pREAL), dimension(:,:,:,:), pointer :: F real(pREAL), dimension(:,:,:,:), pointer :: F
call DMDAVecGetArrayReadF90(da,solution_vec,F,err_PETSc)
call DMDAVecGetArrayF90(da,solution_vec,F,err_PETSc)
CHKERRQ(err_PETSc) CHKERRQ(err_PETSc)
if (num%update_gamma) C_minMaxAvgRestart = C_minMaxAvg if (num%update_gamma) C_minMaxAvgRestart = C_minMaxAvg
@ -430,7 +428,7 @@ subroutine grid_mechanical_spectral_basic_restartWrite()
call HDF5_closeFile(fileHandle) call HDF5_closeFile(fileHandle)
end if end if
call DMDAVecRestoreArrayF90(da,solution_vec,F,err_PETSc) call DMDAVecRestoreArrayReadF90(da,solution_vec,F,err_PETSc)
CHKERRQ(err_PETSc) CHKERRQ(err_PETSc)
end subroutine grid_mechanical_spectral_basic_restartWrite end subroutine grid_mechanical_spectral_basic_restartWrite

View File

@ -439,11 +439,10 @@ subroutine grid_mechanical_spectral_polarisation_updateCoords()
PetscErrorCode :: err_PETSc PetscErrorCode :: err_PETSc
real(pREAL), dimension(:,:,:,:), pointer :: FandF_tau real(pREAL), dimension(:,:,:,:), pointer :: FandF_tau
call DMDAVecGetArrayReadF90(da,solution_vec,FandF_tau,err_PETSc)
call DMDAVecGetArrayF90(da,solution_vec,FandF_tau,err_PETSc)
CHKERRQ(err_PETSc) CHKERRQ(err_PETSc)
call utilities_updateCoords(reshape(FandF_tau(0:8,:,:,:),[3,3,size(FandF_tau,2),size(FandF_tau,3),size(FandF_tau,4)])) call utilities_updateCoords(reshape(FandF_tau(0:8,:,:,:),[3,3,size(FandF_tau,2),size(FandF_tau,3),size(FandF_tau,4)]))
call DMDAVecRestoreArrayF90(da,solution_vec,FandF_tau,err_PETSc) call DMDAVecRestoreArrayReadF90(da,solution_vec,FandF_tau,err_PETSc)
CHKERRQ(err_PETSc) CHKERRQ(err_PETSc)
end subroutine grid_mechanical_spectral_polarisation_updateCoords end subroutine grid_mechanical_spectral_polarisation_updateCoords
@ -458,8 +457,7 @@ subroutine grid_mechanical_spectral_polarisation_restartWrite()
integer(HID_T) :: fileHandle, groupHandle integer(HID_T) :: fileHandle, groupHandle
real(pREAL), dimension(:,:,:,:), pointer :: FandF_tau, F, F_tau real(pREAL), dimension(:,:,:,:), pointer :: FandF_tau, F, F_tau
call DMDAVecGetArrayReadF90(da,solution_vec,FandF_tau,err_PETSc)
call DMDAVecGetArrayF90(da,solution_vec,FandF_tau,err_PETSc)
CHKERRQ(err_PETSc) CHKERRQ(err_PETSc)
F => FandF_tau(0: 8,:,:,:) F => FandF_tau(0: 8,:,:,:)
F_tau => FandF_tau(9:17,:,:,:) F_tau => FandF_tau(9:17,:,:,:)
@ -491,7 +489,7 @@ subroutine grid_mechanical_spectral_polarisation_restartWrite()
call HDF5_closeFile(fileHandle) call HDF5_closeFile(fileHandle)
end if end if
call DMDAVecRestoreArrayF90(da,solution_vec,FandF_tau,err_PETSc) call DMDAVecRestoreArrayReadF90(da,solution_vec,FandF_tau,err_PETSc)
CHKERRQ(err_PETSc) CHKERRQ(err_PETSc)
end subroutine grid_mechanical_spectral_polarisation_restartWrite end subroutine grid_mechanical_spectral_polarisation_restartWrite

View File

@ -285,7 +285,7 @@ end subroutine grid_thermal_spectral_forward
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
!> @brief Write current solver and constitutive data for restart to file. !> @brief Write current solver and constitutive data for restart to file.
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
subroutine grid_thermal_spectral_restartWrite subroutine grid_thermal_spectral_restartWrite()
PetscErrorCode :: err_PETSc PetscErrorCode :: err_PETSc
DM :: dm_local DM :: dm_local
@ -294,7 +294,7 @@ subroutine grid_thermal_spectral_restartWrite
call SNESGetDM(SNES_thermal,dm_local,err_PETSc); call SNESGetDM(SNES_thermal,dm_local,err_PETSc);
CHKERRQ(err_PETSc) CHKERRQ(err_PETSc)
call DMDAVecGetArrayF90(dm_local,solution_vec,T,err_PETSc); call DMDAVecGetArrayReadF90(dm_local,solution_vec,T,err_PETSc);
CHKERRQ(err_PETSc) CHKERRQ(err_PETSc)
print'(1x,a)', 'saving thermal solver data required for restart'; flush(IO_STDOUT) print'(1x,a)', 'saving thermal solver data required for restart'; flush(IO_STDOUT)
@ -307,7 +307,7 @@ subroutine grid_thermal_spectral_restartWrite
call HDF5_closeGroup(groupHandle) call HDF5_closeGroup(groupHandle)
call HDF5_closeFile(fileHandle) call HDF5_closeFile(fileHandle)
call DMDAVecRestoreArrayF90(dm_local,solution_vec,T,err_PETSc); call DMDAVecRestoreArrayReadF90(dm_local,solution_vec,T,err_PETSc);
CHKERRQ(err_PETSc) CHKERRQ(err_PETSc)
end subroutine grid_thermal_spectral_restartWrite end subroutine grid_thermal_spectral_restartWrite