|
DAMASK with grid solvers
Revision: v2.0.3-2204-gdb1f2151
The Düsseldorf Advanced Material Simulation Kit with Grid Solvers
|
|
Go to the documentation of this file. 1 # 1 "/home/damask_user/GitLabCI_Pipeline_4301/DAMASK/src/grid/grid_mech_spectral_basic.f90"
4 # 1 "/home/damask_user/GitLabCI_Pipeline_4301/DAMASK/src/grid/grid_mech_spectral_basic.f90"
13 # 1 "/opt/petsc-3.10.3/include/petsc/finclude/petscsnes.h" 1
21 # 1 "/opt/petsc-3.10.3/include/petsc/finclude/petscksp.h" 1
30 # 1 "/opt/petsc-3.10.3/include/petsc/finclude/petscpc.h" 1
39 # 1 "/opt/petsc-3.10.3/include/petsc/finclude/petscmat.h" 1
48 # 1 "/opt/petsc-3.10.3/include/petsc/finclude/petscvec.h" 1
57 # 1 "/opt/petsc-3.10.3/include/petsc/finclude/petscao.h" 1
66 # 1 "/opt/petsc-3.10.3/include/petsc/finclude/petscis.h" 1
75 # 1 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h" 1
88 # 1 "/opt/petsc-3.10.3/Intel-18.4-IntelMPI-2018/include/petscconf.h" 1
1296 # 13 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h" 2
1301 # 1 "/opt/petsc-3.10.3/include/petscversion.h" 1
1347 # 17 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h" 2
1349 # 1 "/opt/petsc-3.10.3/include/petsc/finclude/petscviewer.h" 1
1366 # 31 "/opt/petsc-3.10.3/include/petsc/finclude/petscviewer.h"
1368 # 18 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h" 2
1370 # 1 "/opt/petsc-3.10.3/include/petsc/finclude/petscerror.h" 1
1379 # 24 "/opt/petsc-3.10.3/include/petsc/finclude/petscerror.h"
1381 # 38 "/opt/petsc-3.10.3/include/petsc/finclude/petscerror.h"
1398 # 19 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h" 2
1400 # 1 "/opt/petsc-3.10.3/include/petsc/finclude/petsclog.h" 1
1403 # 20 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h" 2
1405 # 1 "/opt/petsc-3.10.3/include/petsc/finclude/petscbag.h" 1
1418 # 21 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h" 2
1426 # 41 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h"
1436 # 63 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h"
1450 # 85 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h"
1469 # 128 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h"
1471 # 150 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h"
1475 # 174 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h"
1508 # 215 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h"
1521 # 9 "/opt/petsc-3.10.3/include/petsc/finclude/petscis.h" 2
1523 # 1 "/opt/petsc-3.10.3/include/petsc/finclude/petscviewer.h" 1
1527 # 10 "/opt/petsc-3.10.3/include/petsc/finclude/petscis.h" 2
1549 # 9 "/opt/petsc-3.10.3/include/petsc/finclude/petscao.h" 2
1559 # 9 "/opt/petsc-3.10.3/include/petsc/finclude/petscvec.h" 2
1573 # 30 "/opt/petsc-3.10.3/include/petsc/finclude/petscvec.h"
1577 # 9 "/opt/petsc-3.10.3/include/petsc/finclude/petscmat.h" 2
1583 # 49 "/opt/petsc-3.10.3/include/petsc/finclude/petscmat.h"
1597 # 71 "/opt/petsc-3.10.3/include/petsc/finclude/petscmat.h"
1601 # 115 "/opt/petsc-3.10.3/include/petsc/finclude/petscmat.h"
1603 # 140 "/opt/petsc-3.10.3/include/petsc/finclude/petscmat.h"
1614 # 168 "/opt/petsc-3.10.3/include/petsc/finclude/petscmat.h"
1627 # 9 "/opt/petsc-3.10.3/include/petsc/finclude/petscpc.h" 2
1629 # 1 "/opt/petsc-3.10.3/include/petsc/finclude/petscdm.h" 1
1638 # 1 "/opt/petsc-3.10.3/include/petsc/finclude/petscis.h" 1
1643 # 9 "/opt/petsc-3.10.3/include/petsc/finclude/petscdm.h" 2
1645 # 1 "/opt/petsc-3.10.3/include/petsc/finclude/petscvec.h" 1
1650 # 10 "/opt/petsc-3.10.3/include/petsc/finclude/petscdm.h" 2
1652 # 1 "/opt/petsc-3.10.3/include/petsc/finclude/petscmat.h" 1
1657 # 11 "/opt/petsc-3.10.3/include/petsc/finclude/petscdm.h" 2
1669 # 32 "/opt/petsc-3.10.3/include/petsc/finclude/petscdm.h"
1672 # 47 "/opt/petsc-3.10.3/include/petsc/finclude/petscdm.h"
1674 # 10 "/opt/petsc-3.10.3/include/petsc/finclude/petscpc.h" 2
1678 # 26 "/opt/petsc-3.10.3/include/petsc/finclude/petscpc.h"
1687 # 74 "/opt/petsc-3.10.3/include/petsc/finclude/petscpc.h"
1689 # 9 "/opt/petsc-3.10.3/include/petsc/finclude/petscksp.h" 2
1694 # 21 "/opt/petsc-3.10.3/include/petsc/finclude/petscksp.h"
1698 # 57 "/opt/petsc-3.10.3/include/petsc/finclude/petscksp.h"
1702 # 8 "/opt/petsc-3.10.3/include/petsc/finclude/petscsnes.h" 2
1708 # 30 "/opt/petsc-3.10.3/include/petsc/finclude/petscsnes.h"
1713 # 47 "/opt/petsc-3.10.3/include/petsc/finclude/petscsnes.h"
1737 # 78 "/opt/petsc-3.10.3/include/petsc/finclude/petscsnes.h"
1741 # 9 "/home/damask_user/GitLabCI_Pipeline_4301/DAMASK/src/grid/grid_mech_spectral_basic.f90" 2
1743 # 1 "/opt/petsc-3.10.3/include/petsc/finclude/petscdmda.h" 1
1752 # 1 "/opt/petsc-3.10.3/include/petsc/finclude/petscis.h" 1
1757 # 9 "/opt/petsc-3.10.3/include/petsc/finclude/petscdmda.h" 2
1759 # 1 "/opt/petsc-3.10.3/include/petsc/finclude/petscvec.h" 1
1764 # 10 "/opt/petsc-3.10.3/include/petsc/finclude/petscdmda.h" 2
1766 # 1 "/opt/petsc-3.10.3/include/petsc/finclude/petscmat.h" 1
1771 # 11 "/opt/petsc-3.10.3/include/petsc/finclude/petscdmda.h" 2
1773 # 1 "/opt/petsc-3.10.3/include/petsc/finclude/petscdm.h" 1
1778 # 12 "/opt/petsc-3.10.3/include/petsc/finclude/petscdmda.h" 2
1788 # 39 "/opt/petsc-3.10.3/include/petsc/finclude/petscdmda.h"
1802 # 10 "/home/damask_user/GitLabCI_Pipeline_4301/DAMASK/src/grid/grid_mech_spectral_basic.f90" 2
1826 logical :: update_gamma
1839 real(
preal),
private,
dimension(:,:,:,:,:),
allocatable :: &
1840 f_lastinc, & !< field of previous compatible deformation gradients
1845 real(
preal),
private,
dimension(3,3) :: &
1852 real(
preal),
private,
dimension(3,3,3,3) :: &
1860 err_bc, & !< deviation from stress BC
1863 integer,
private :: &
1880 real(
preal),
dimension(3,3,grid(1),grid(2),grid3) :: p
1881 real(
preal),
dimension(3,3) :: &
1882 temp33_real = 0.0_preal
1884 integer(kind=selected_int_kind(5)) :: ierr
1885 real(kind=selected_real_kind(10)),
pointer,
dimension(:,:,:,:) :: &
1887 integer(kind=selected_int_kind(5)),
dimension(worldsize) :: localk
1888 integer(HID_T) :: filehandle, grouphandle
1890 character(len=pStringLen) :: filename
1892 write(6,
'(/,a)')
' <<<+- grid_mech_spectral_basic init -+>>>';
flush(6)
1894 write(6,
'(/,a)')
' Eisenlohr et al., International Journal of Plasticity 46:37–53, 2013'
1895 write(6,
'(a)')
' https://doi.org/10.1016/j.ijplas.2012.09.012'
1897 write(6,
'(/,a)')
' Shanthraj et al., International Journal of Plasticity 66:31–45, 2015'
1898 write(6,
'(a)')
' https://doi.org/10.1016/j.ijplas.2014.02.006'
1904 call petscoptionsinsertstring(petsc_null_options,
'-mech_snes_type ngmres',ierr)
1905 if (ierr .ne. 0) then;
call petscerrorf(ierr);return;
endif
1906 call petscoptionsinsertstring(petsc_null_options,trim(petsc_options),ierr)
1907 if (ierr .ne. 0) then;
call petscerrorf(ierr);return;
endif
1916 call snescreate(petsc_comm_world,
snes,ierr);
if (ierr .ne. 0) then;
call petscerrorf(ierr);return;
endif
1917 call snessetoptionsprefix(
snes,
'mech_',ierr);
if (ierr .ne. 0) then;
call petscerrorf(ierr);return;
endif
1920 call mpi_allreduce(mpi_in_place,localk,
worldsize,mpi_integer,mpi_sum,petsc_comm_world,ierr)
1921 call dmdacreate3d(petsc_comm_world, &
1922 dm_boundary_none, dm_boundary_none, dm_boundary_none, &
1929 if (ierr .ne. 0) then;
call petscerrorf(ierr);return;
endif
1930 call snessetdm(
snes,
da,ierr);
if (ierr .ne. 0) then;
call petscerrorf(ierr);return;
endif
1931 call dmsetfromoptions(
da,ierr);
if (ierr .ne. 0) then;
call petscerrorf(ierr);return;
endif
1932 call dmsetup(
da,ierr);
if (ierr .ne. 0) then;
call petscerrorf(ierr);return;
endif
1933 call dmcreateglobalvector(
da,
solution_vec,ierr);
if (ierr .ne. 0) then;
call petscerrorf(ierr);return;
endif
1934 call dmdasnessetfunctionlocal(
da,insert_values,
formresidual,petsc_null_snes,ierr)
1935 if (ierr .ne. 0) then;
call petscerrorf(ierr);return;
endif
1936 call snessetconvergencetest(
snes,
converged,petsc_null_snes,petsc_null_function,ierr)
1937 if (ierr .ne. 0) then;
call petscerrorf(ierr);return;
endif
1938 call snessetfromoptions(
snes,ierr);
if (ierr .ne. 0) then;
call petscerrorf(ierr);return;
endif
1942 call dmdavecgetarrayf90(
da,
solution_vec,f,ierr);
if (ierr .ne. 0) then;
call petscerrorf(ierr);return;
endif
1945 write(6,
'(/,a,i0,a)')
' reading restart data of increment ',
interface_restartinc,
' from file'
1967 call dmdavecrestorearrayf90(
da,
solution_vec,f,ierr);
if (ierr .ne. 0) then;
call petscerrorf(ierr);return;
endif
1970 write(6,
'(/,a,i0,a)')
' reading more restart data of increment ',
interface_restartinc,
' from file'
1978 mpi_mode_rdonly,mpi_info_null,fileunit,ierr)
1979 call mpi_file_read(fileunit,
c_minmaxavg,81,mpi_double,mpi_status_ignore,ierr)
1980 call mpi_file_close(fileunit,ierr)
1996 character(len=*),
intent(in) :: &
1998 real(
preal),
intent(in) :: &
1999 timeinc, & !< time increment of current solution
2003 type(rotation),
intent(in) :: &
2009 integer(kind=selected_int_kind(5)) :: ierr
2010 integer(kind=selected_int_kind(5)) :: reason
2021 params%stress_mask = stress_bc%maskFloat
2022 params%stress_BC = stress_bc%values
2023 params%rotation_BC = rotation_bc
2025 params%timeincOld = timeinc_old
2029 call snessolve(
snes,petsc_null_vec,
solution_vec,ierr);
if (ierr .ne. 0) then;
call petscerrorf(ierr);return;
endif
2033 call snesgetconvergedreason(
snes,reason,ierr);
if (ierr .ne. 0) then;
call petscerrorf(ierr);return;
endif
2035 solution%converged = reason > 0
2049 deformation_BC,stress_BC,rotation_BC)
2051 logical,
intent(in) :: &
2054 real(
preal),
intent(in) :: &
2061 type(rotation),
intent(in) :: &
2063 integer(kind=selected_int_kind(5)) :: ierr
2064 real(kind=selected_real_kind(10)),
dimension(:,:,:,:),
pointer :: f
2066 call dmdavecgetarrayf90(
da,
solution_vec,f,ierr);
if (ierr .ne. 0) then;
call petscerrorf(ierr);return;
endif
2080 if (deformation_bc%myType==
'l')
then
2083 elseif(deformation_bc%myType==
'fdot')
then
2085 f_aimdot + deformation_bc%maskFloat * deformation_bc%values
2086 elseif (deformation_bc%myType==
'f')
then
2093 rotation_bc%rotate(
f_aimdot,active=.true.))
2104 call dmdavecrestorearrayf90(
da,
solution_vec,f,ierr);
if (ierr .ne. 0) then;
call petscerrorf(ierr);return;
endif
2114 integer(kind=selected_int_kind(5)) :: ierr
2115 real(kind=selected_real_kind(10)),
dimension(:,:,:,:),
pointer :: f
2117 call dmdavecgetarrayf90(
da,
solution_vec,f,ierr);
if (ierr .ne. 0) then;
call petscerrorf(ierr);return;
endif
2119 call dmdavecrestorearrayf90(
da,
solution_vec,f,ierr);
if (ierr .ne. 0) then;
call petscerrorf(ierr);return;
endif
2129 integer(kind=selected_int_kind(5)) :: ierr
2130 integer(HID_T) :: filehandle, grouphandle
2131 real(kind=selected_real_kind(10)),
dimension(:,:,:,:),
pointer :: f
2132 character(len=pStringLen) :: filename
2134 call dmdavecgetarrayf90(
da,
solution_vec,f,ierr);
if (ierr .ne. 0) then;
call petscerrorf(ierr);return;
endif
2136 write(6,
'(a)')
' writing solver data required for restart to file';
flush(6)
2157 call dmdavecrestorearrayf90(
da,
solution_vec,f,ierr);
if (ierr .ne. 0) then;
call petscerrorf(ierr);return;
endif
2165 subroutine converged(snes_local,PETScIter,devNull1,devNull2,devNull3,reason,dummy,ierr)
2167 type(tsnes) :: snes_local
2168 integer(kind=selected_int_kind(5)),
intent(in) :: PETScIter
2169 real(kind=selected_real_kind(10)),
intent(in) :: &
2173 integer(kind=selected_int_kind(5)) :: reason
2174 integer(kind=selected_int_kind(10)) :: dummy
2175 integer(kind=selected_int_kind(5)) :: ierr
2180 divtol = max(maxval(abs(
p_av))*err_div_tolrel ,err_div_tolabs)
2181 bctol = max(maxval(abs(
p_av))*err_stress_tolrel,err_stress_tolabs)
2185 err_bc /bctol ] < 1.0_preal)) &
2196 write(6,
'(1/,a)')
' ... reporting .............................................................'
2197 write(6,
'(1/,a,f12.2,a,es8.2,a,es9.2,a)')
' error divergence = ', &
2199 write(6,
'(a,f12.2,a,es8.2,a,es9.2,a)')
' error stress BC = ', &
2201 write(6,
'(/,a)')
' ==========================================================================='
2211 residuum, dummy, ierr)
2213 integer(kind=selected_int_kind(5)),
dimension(25) :: in
2214 real(kind=selected_real_kind(10)),
dimension(3,3,in(13)+1:in(13)+in(16),in(14)+1:in(14)+in(17),in(15)+1:in(15)+in(18)), &
2216 real(kind=selected_real_kind(10)),
dimension(3,3,in(7)+1:in(7)+in(10),in(8)+1:in(8)+in(11),in(9)+1:in(9)+in(12)), &
2217 intent(out) :: residuum
2218 real(pReal),
dimension(3,3) :: &
2220 integer(kind=selected_int_kind(5)) :: &
2223 integer(kind=selected_int_kind(10)) :: dummy
2224 integer(kind=selected_int_kind(5)) :: ierr
2226 call snesgetnumberfunctionevals(
snes,nfuncs,ierr);
if (ierr .ne. 0) then;
call petscerrorf(ierr);return;
endif
2227 call snesgetiterationnumber(
snes,petsciter,ierr);
if (ierr .ne. 0) then;
call petscerrorf(ierr);return;
endif
2229 if (nfuncs == 0 .and. petsciter == 0)
totaliter = -1
2232 newiteration:
if (
totaliter <= petsciter)
then
2234 write(6,
'(1x,a,3(a,i0))') trim(
incinfo),
' @ Iteration ',
itmin,
'≤',
totaliter,
'≤',
itmax
2236 write(6,
'(/,a,/,3(3(f12.7,1x)/))',advance=
'no') &
2237 ' deformation gradient aim (lab) =', transpose(
params%rotation_BC%rotate(
f_aim,active=.true.))
2238 write(6,
'(/,a,/,3(3(f12.7,1x)/))',advance=
'no') &
2239 ' deformation gradient aim =', transpose(
f_aim)
2248 call mpi_allreduce(mpi_in_place,
terminallyill,1,mpi_logical,mpi_lor,petsc_comm_world,ierr)
real(preal), dimension(3, 3, 3, 3), private c_minmaxavg
current (min+max)/2 stiffness
integer(hid_t) function hdf5_addgroup(fileHandle, groupName)
adds a new group to the fileHandle
real(preal), dimension(3, 3), private f_aim
current prescribed deformation gradient
real(preal), dimension(3, 3, 3, 3), private c_volavg
current volume average stiffness
real(preal), dimension(3, 3), private p_av
average 1st Piola–Kirchhoff stress
real(preal), dimension(3, 3, 3, 3), private c_volavglastinc
previous volume average stiffness
character(len=pstringlen), private incinfo
time and increment information
subroutine hdf5_closegroup(group_id)
close a group
type(tvec), private solution_vec
real(preal), dimension(:,:,:,:), allocatable, public materialpoint_f0
def grad of IP at start of FE increment
integer, dimension(debug_maxntype+2), public, protected debug_level
subroutine, public grid_mech_spectral_basic_updatecoords
Age.
subroutine, public grid_mech_spectral_basic_restartwrite
Write current solver and constitutive data for restart to file.
type(tsolutionparams), private params
integer(hid_t) function hdf5_openfile(fileName, mode, parallel)
open and initializes HDF5 output file
Utilities used by the different spectral solver variants.
integer, public, protected worldsize
MPI worldsize (/=1 for MPI simulations only)
real(preal) function, public utilities_divergencerms()
calculate root mean square of divergence of field_fourier
Reads in the material configuration from file.
integer, private totaliter
total iteration in current increment
integer, public, protected grid3
(local) grid in 3rd direction
real(preal), dimension(:,:,:,:,:), allocatable, private fdot
field of assumed rate of compatible deformation gradient
Parse geometry file to set up discretization and geometry for nonlocal model.
setting precision for real and int type
pure real(preal) function, dimension(3, 3) math_mul3333xx33(A, B)
matrix double contraction 3333x33 = 33 (ijkl,kl)
Grid solver for mechanics: 1 basic.
subroutine converged(snes_local, PETScIter, devNull1, devNull2, devNull3, reason, dummy, ierr)
convergence check
real(preal), dimension(:,:,:,:,:), allocatable, private f_lastinc
field of previous compatible deformation gradients
subroutine, public utilities_savereferencestiffness
Write out the current reference stiffness for restart.
subroutine, public utilities_ffttensorforward
forward FFT of data in field_real to field_fourier
type(tsnes), private snes
real(preal), dimension(3, 3, 3, 3), private s
current compliance (filled up with zeros)
reads integer or float data of defined shape from file ! ToDo: order of arguments wrong
homogenization manager, organizing deformation partitioning and stress homogenization
integer, parameter preal
number with 15 significant digits, up to 1e+-307 (typically 64 bit)
Reading in and interpretating the debugging settings for the various modules.
real(preal), dimension(3, 3), private f_aim_lastinc
previous average deformation gradient
real(preal), dimension(3, 3), private f_aimdot
assumed rate of average deformation gradient
subroutine, public utilities_fouriergammaconvolution(fieldAim)
doing convolution gamma_hat * field_real, ensuring that average value = fieldAim
subroutine formresidual(in, F, residuum, dummy, ierr)
forms the residual vector
subroutine, public utilities_updatecoords(F)
calculate coordinates in current configuration for given defgrad field
real(preal) function, dimension(3, 3, grid(1), grid(2), grid3), public utilities_forwardfield(timeinc, field_lastInc, rate, aim)
forwards a field with a pointwise given rate, if aim is given, ensures that the average matches the a...
integer, public, protected itmax
maximum number of iterations
subroutine, public utilities_constitutiveresponse(P, P_av, C_volAvg, C_minmaxAvg, F, timeinc, rotation_BC)
calculate constitutive response from materialpoint_F0 to F during timeinc
integer, public, protected interface_restartinc
Increment at which calculation starts.
Interfacing between the 1-based solvers and the material subroutines provided by DAMASK.
type(tpartitionedstringlist), public, protected config_numerics
real(preal), dimension(3, 3, 3, 3), private c_minmaxavglastinc
previous (min+max)/2 stiffness
real(c_double), dimension(:,:,:,:,:), pointer, public tensorfield_real
real representation (some stress or deformation) of field_fourier
integer, parameter, public debug_spectral
subroutine hdf5_closefile(fileHandle)
close the opened HDF5 output file
integer, public, protected worldrank
MPI worldrank (/=0 for MPI simulations only)
Mathematical library, including random number generation and tensor representations.
logical terminallyill
at least one material point is terminally ill
integer, dimension(3), public, protected grid
(global) grid
integer, public, protected itmin
minimum number of iterations
integer, parameter, public debug_spectralrotation
character(len=:) function, allocatable, public getsolverjobname()
solver job name (no extension) as combination of geometry and load case name
real(preal) function, dimension(3, 3, 3, 3), public utilities_maskedcompliance(rot_BC, mask_stress, C)
calculates mask compliance tensor used to adjust F to fullfill stress BC
subroutine, public utilities_updategamma(C)
updates reference stiffness and potentially precalculated gamma operator
set of parameters defining a boundary condition
subroutine, public grid_mech_spectral_basic_init
allocates all necessary fields and fills them with data, potentially from restart info
real(preal), private err_div
RMS of div of P.
Managing of parameters related to numerics.
integer(hid_t) function hdf5_opengroup(fileHandle, groupName)
open an existing group of a file
return type of solution from spectral solver variants
global variables for flow control
real(preal), private err_bc
deviation from stress BC
subroutine, public utilities_ffttensorbackward
backward FFT of data in field_fourier to field_real
pure real(preal) function, dimension(3, 3, grid(1), grid(2), grid3), public utilities_calculaterate(heterogeneous, field0, field, dt, avRate)
calculates forward rate, either guessing or just add delta/timeinc
subroutine, public grid_mech_spectral_basic_forward(cutBack, guess, timeinc, timeinc_old, loadCaseTime, deformation_BC, stress_BC, rotation_BC)
forwarding routine
writes integer or real data of defined shape to file ! ToDo: order of arguments wrong
type(tsolutionstate) function, public grid_mech_spectral_basic_solution(incInfoIn, timeinc, timeinc_old, stress_BC, rotation_BC)
solution for the basic scheme with internal iterations
real(preal), dimension(3, 3), parameter math_i3
3x3 Identity