1 # 1 "/home/damask_user/GitLabCI_Pipeline_4301/DAMASK/src/grid/spectral_utilities.f90"
4 # 1 "/home/damask_user/GitLabCI_Pipeline_4301/DAMASK/src/grid/spectral_utilities.f90"
11 use,
intrinsic :: iso_c_binding
13 # 1 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h" 1
26 # 1 "/opt/petsc-3.10.3/Intel-18.4-IntelMPI-2018/include/petscconf.h" 1
1234 # 13 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h" 2
1239 # 1 "/opt/petsc-3.10.3/include/petscversion.h" 1
1285 # 17 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h" 2
1287 # 1 "/opt/petsc-3.10.3/include/petsc/finclude/petscviewer.h" 1
1304 # 31 "/opt/petsc-3.10.3/include/petsc/finclude/petscviewer.h"
1306 # 18 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h" 2
1308 # 1 "/opt/petsc-3.10.3/include/petsc/finclude/petscerror.h" 1
1317 # 24 "/opt/petsc-3.10.3/include/petsc/finclude/petscerror.h"
1319 # 38 "/opt/petsc-3.10.3/include/petsc/finclude/petscerror.h"
1336 # 19 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h" 2
1338 # 1 "/opt/petsc-3.10.3/include/petsc/finclude/petsclog.h" 1
1341 # 20 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h" 2
1343 # 1 "/opt/petsc-3.10.3/include/petsc/finclude/petscbag.h" 1
1356 # 21 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h" 2
1364 # 41 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h"
1374 # 63 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h"
1388 # 85 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h"
1407 # 128 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h"
1409 # 150 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h"
1413 # 174 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h"
1446 # 215 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h"
1459 # 9 "/home/damask_user/GitLabCI_Pipeline_4301/DAMASK/src/grid/spectral_utilities.f90" 2
1477 include
'fftw3-mpi.f03'
1481 enum,
bind(c); enumerator :: &
1503 complex(pReal),
private,
dimension(:,:,:,:,:,:,:),
allocatable ::
gamma_hat
1504 complex(pReal),
private,
dimension(:,:,:,:),
allocatable ::
xi1st
1505 complex(pReal),
private,
dimension(:,:,:,:),
allocatable ::
xi2nd
1511 type(c_ptr),
private :: &
1521 logical,
private :: &
1522 debuggeneral, & !< general debugging of spectral solver
1530 iterationsneeded = 0
1532 converged = .true., &
1533 stagconverged = .true., &
1538 real(
preal),
dimension(3,3) :: values = 0.0_preal, &
1539 maskfloat = 0.0_preal
1540 logical,
dimension(3,3) :: masklogical = .false.
1541 character(len=pStringLen) :: mytype =
'None'
1549 integer :: incs = 0, & !< number of increments
1550 outputfrequency = 1, &
1551 restartfrequency = huge(0), &
1553 logical :: followformertrajectory = .true.
1554 integer(kind(FIELD_UNDEFINED_ID)),
allocatable :: id(:)
1558 real(
preal),
dimension(3,3) :: stress_mask, stress_bc
1568 divergence_correction
1571 character(len=pStringLen) :: &
1572 spectral_derivative, & !< approximation used for derivatives in Fourier space
1573 fftw_plan_mode, & !< FFTW plan mode, see www.fftw.org
1579 enum,
bind(c); enumerator :: &
1585 integer(kind(DERIVATIVE_CONTINUOUS_ID)) :: &
1628 integer(kind=selected_int_kind(5)) :: ierr
1629 integer :: i, j, k, &
1631 integer,
dimension(3) :: k_s
1633 tensorfield, & !< field containing data for FFTW in real and fourier space (in place)
1634 vectorfield, & !< field containing data for FFTW in real space when debugging FFTW (no in place)
1636 integer(C_INTPTR_T),
dimension(3) :: gridfftw
1637 integer(C_INTPTR_T) :: alloc_local, local_k, local_k_offset
1638 integer(C_INTPTR_T),
parameter :: &
1639 scalarsize = 1_c_intptr_t, &
1640 vecsize = 3_c_intptr_t, &
1641 tensorsize = 9_c_intptr_t
1643 write(6,
'(/,a)')
' <<<+- spectral_utilities init -+>>>'
1645 write(6,
'(/,a)')
' Diehl, Diploma Thesis TU München, 2010'
1646 write(6,
'(a)')
' https://doi.org/10.13140/2.1.3234.3840'
1648 write(6,
'(/,a)')
' Eisenlohr et al., International Journal of Plasticity 46:37–53, 2013'
1649 write(6,
'(a)')
' https://doi.org/10.1016/j.ijplas.2012.09.012'
1651 write(6,
'(/,a)')
' Shanthraj et al., International Journal of Plasticity 66:31–45, 2015'
1652 write(6,
'(a)')
' https://doi.org/10.1016/j.ijplas.2014.02.006'
1654 write(6,
'(/,a)')
' Shanthraj et al., Handbook of Mechanics of Materials, 2019'
1655 write(6,
'(a)')
' https://doi.org/10.1007/978-981-10-6855-3_80'
1664 ' Initializing PETSc with debug options: ', &
1666 ' add more using the PETSc_Options keyword in numerics.config ';
flush(6)
1668 call petscoptionsclear(petsc_null_options,ierr)
1669 if (ierr .ne. 0) then;
call petscerrorf(ierr);return;
endif
1671 if (ierr .ne. 0) then;
call petscerrorf(ierr);return;
endif
1672 call petscoptionsinsertstring(petsc_null_options,trim(petsc_options),ierr)
1673 if (ierr .ne. 0) then;
call petscerrorf(ierr);return;
endif
1678 write(6,
'(/,a,3(i12 ))')
' grid a b c: ',
grid
1679 write(6,
'(a,3(es12.5))')
' size x y z: ',
geomsize
1682 num%FFTW_timelimit =
config_numerics%getFloat (
'fftw_timelimit', defaultval=-1.0_preal)
1683 num%divergence_correction =
config_numerics%getInt (
'divergence_correction', defaultval=2)
1684 num%spectral_derivative =
config_numerics%getString(
'spectral_derivative', defaultval=
'continuous')
1685 num%FFTW_plan_mode =
config_numerics%getString(
'fftw_plan_mode', defaultval=
'FFTW_MEASURE')
1687 if (
num%divergence_correction < 0 .or.
num%divergence_correction > 2) &
1688 call io_error(301,ext_msg=
'divergence_correction')
1690 select case (
num%spectral_derivative)
1693 case (
'central_difference')
1695 case (
'fwbw_difference')
1698 call io_error(892,ext_msg=trim(
num%spectral_derivative))
1704 if (
num%divergence_correction == 1)
then
1709 elseif (
num%divergence_correction == 2)
then
1720 select case(
io_lc(
num%FFTW_plan_mode))
1721 case(
'fftw_estimate')
1722 fftw_planner_flag = fftw_estimate
1723 case(
'fftw_measure')
1724 fftw_planner_flag = fftw_measure
1725 case(
'fftw_patient')
1726 fftw_planner_flag = fftw_patient
1727 case(
'fftw_exhaustive')
1728 fftw_planner_flag = fftw_exhaustive
1731 fftw_planner_flag = fftw_measure
1736 if (
preal /= c_double .or. kind(1) /= c_int)
call io_error(0,ext_msg=
'Fortran to C')
1737 call fftw_set_timelimit(
num%FFTW_timelimit)
1739 if (
debuggeneral)
write(6,
'(/,a)')
' FFTW initialized';
flush(6)
1743 gridfftw = int(
grid,c_intptr_t)
1744 alloc_local = fftw_mpi_local_size_3d(gridfftw(3), gridfftw(2), gridfftw(1)/2 +1, &
1745 petsc_comm_world, local_k, local_k_offset)
1749 tensorfield = fftw_alloc_complex(tensorsize*alloc_local)
1750 call c_f_pointer(tensorfield,
tensorfield_real, [3_c_intptr_t,3_c_intptr_t, &
1751 2_c_intptr_t*(gridfftw(1)/2_c_intptr_t + 1_c_intptr_t),gridfftw(2),local_k])
1753 gridfftw(1)/2_c_intptr_t + 1_c_intptr_t , gridfftw(2),local_k])
1755 vectorfield = fftw_alloc_complex(vecsize*alloc_local)
1757 2_c_intptr_t*(gridfftw(1)/2_c_intptr_t + 1_c_intptr_t),gridfftw(2),local_k])
1759 gridfftw(1)/2_c_intptr_t + 1_c_intptr_t, gridfftw(2),local_k])
1761 scalarfield = fftw_alloc_complex(scalarsize*alloc_local)
1763 [2_c_intptr_t*(gridfftw(1)/2_c_intptr_t + 1),gridfftw(2),local_k])
1765 [ gridfftw(1)/2_c_intptr_t + 1 ,gridfftw(2),local_k])
1769 plantensorforth = fftw_mpi_plan_many_dft_r2c(3, [gridfftw(3),gridfftw(2),gridfftw(1)], &
1770 tensorsize, fftw_mpi_default_block, fftw_mpi_default_block, &
1772 petsc_comm_world, fftw_planner_flag)
1774 plantensorback = fftw_mpi_plan_many_dft_c2r(3, [gridfftw(3),gridfftw(2),gridfftw(1)], &
1775 tensorsize, fftw_mpi_default_block, fftw_mpi_default_block, &
1777 petsc_comm_world, fftw_planner_flag)
1782 planvectorforth = fftw_mpi_plan_many_dft_r2c(3, [gridfftw(3),gridfftw(2),gridfftw(1)], &
1783 vecsize, fftw_mpi_default_block, fftw_mpi_default_block,&
1785 petsc_comm_world, fftw_planner_flag)
1787 planvectorback = fftw_mpi_plan_many_dft_c2r(3, [gridfftw(3),gridfftw(2),gridfftw(1)], &
1788 vecsize, fftw_mpi_default_block, fftw_mpi_default_block, &
1790 petsc_comm_world, fftw_planner_flag)
1795 planscalarforth = fftw_mpi_plan_many_dft_r2c(3, [gridfftw(3),gridfftw(2),gridfftw(1)], &
1796 scalarsize, fftw_mpi_default_block, fftw_mpi_default_block, &
1798 petsc_comm_world, fftw_planner_flag)
1800 planscalarback = fftw_mpi_plan_many_dft_c2r(3, [gridfftw(3),gridfftw(2),gridfftw(1)], &
1801 scalarsize, fftw_mpi_default_block, fftw_mpi_default_block, &
1803 petsc_comm_world, fftw_planner_flag)
1810 if(k >
grid(3)/2 + 1) k_s(3) = k_s(3) -
grid(3)
1813 if(j >
grid(2)/2 + 1) k_s(2) = k_s(2) -
grid(2)
1817 where(mod(
grid,2)==0 .and. [i,j,k] ==
grid/2+1 .and. &
1825 if(
num%memory_efficient)
then
1826 allocate (
gamma_hat(3,3,3,3,1,1,1), source = cmplx(0.0_preal,0.0_preal,
preal))
1842 real(
preal),
intent(in),
dimension(3,3,3,3) :: c
1843 complex(pReal),
dimension(3,3) :: temp33_complex, xidyad_cmplx
1844 real(
preal),
dimension(6,6) :: a, a_inv
1852 if(.not.
num%memory_efficient)
then
1855 if (any([i,j,k] /= 1))
then
1856 forall(l = 1:3, m = 1:3) &
1858 forall(l = 1:3, m = 1:3) &
1859 temp33_complex(l,m) = sum(cmplx(
c_ref(l,1:3,m,1:3),0.0_preal)*xidyad_cmplx)
1860 a(1:3,1:3) = real(temp33_complex); a(4:6,4:6) = real(temp33_complex)
1861 a(1:3,4:6) = aimag(temp33_complex); a(4:6,1:3) = -aimag(temp33_complex)
1862 if (abs(
math_det33(a(1:3,1:3))) > 1e-16)
then
1864 temp33_complex = cmplx(a_inv(1:3,1:3),a_inv(1:3,4:6),
preal)
1865 forall(l=1:3, m=1:3, n=1:3, o=1:3) &
1955 real(
preal),
intent(in),
dimension(3,3) :: fieldaim
1956 complex(pReal),
dimension(3,3) :: temp33_complex, xidyad_cmplx
1957 real(
preal),
dimension(6,6) :: a, a_inv
1965 write(6,
'(/,a)')
' ... doing gamma convolution ...............................................'
1970 memoryefficient:
if(
num%memory_efficient)
then
1973 forall(l = 1:3, m = 1:3) &
1974 xidyad_cmplx(l,m) = conjg(-
xi1st(l,i,j,k))*
xi1st(m,i,j,k)
1975 forall(l = 1:3, m = 1:3) &
1976 temp33_complex(l,m) = sum(cmplx(
c_ref(l,1:3,m,1:3),0.0_preal)*xidyad_cmplx)
1977 a(1:3,1:3) = real(temp33_complex); a(4:6,4:6) = real(temp33_complex)
1978 a(1:3,4:6) = aimag(temp33_complex); a(4:6,1:3) = -aimag(temp33_complex)
1979 if (abs(
math_det33(a(1:3,1:3))) > 1e-16)
then
1981 temp33_complex = cmplx(a_inv(1:3,1:3),a_inv(1:3,4:6),
preal)
1982 forall(l=1:3, m=1:3, n=1:3, o=1:3) &
1983 gamma_hat(l,m,n,o,1,1,1) = temp33_complex(l,n)*conjg(-
xi1st(o,i,j,k))*
xi1st(m,i,j,k)
1985 gamma_hat(1:3,1:3,1:3,1:3,1,1,1) = cmplx(0.0_preal,0.0_preal,
preal)
1987 forall(l = 1:3, m = 1:3) &
1988 temp33_complex(l,m) = sum(
gamma_hat(l,m,1:3,1:3,1,1,1)*
tensorfield_fourier(1:3,1:3,i,j,k))
1992 else memoryefficient
1994 forall(l = 1:3, m = 1:3) &
1995 temp33_complex(l,m) = sum(
gamma_hat(l,m,1:3,1:3,i,j,k) *
tensorfield_fourier(1:3,1:3,i,j,k))
1998 endif memoryefficient
2010 real(
preal),
dimension(3,3),
intent(in) :: d_ref
2011 real(
preal),
intent(in) :: mobility_ref, deltat
2012 complex(pReal) :: greenop_hat
2018 greenop_hat = cmplx(1.0_preal,0.0_preal,
preal)/ &
2019 (cmplx(mobility_ref,0.0_preal,
preal) + cmplx(deltat,0.0_preal)*&
2020 sum(conjg(
xi1st(1:3,i,j,k))* matmul(cmplx(d_ref,0.0_preal),
xi1st(1:3,i,j,k))))
2032 integer :: i, j, k, ierr
2033 complex(pReal),
dimension(3) :: rescaledgeom
2035 write(6,
'(/,a)')
' ... calculating divergence ................................................'
2047 conjg(-
xi1st(1:3,i,j,k))*rescaledgeom))**2.0_preal)&
2049 conjg(-
xi1st(1:3,i,j,k))*rescaledgeom))**2.0_preal))
2053 conjg(-
xi1st(1:3,1,j,k))*rescaledgeom))**2.0_preal) &
2055 conjg(-
xi1st(1:3,1,j,k))*rescaledgeom))**2.0_preal) &
2057 conjg(-
xi1st(1:3,
grid1red,j,k))*rescaledgeom))**2.0_preal) &
2063 if(ierr /=0)
call io_error(894, ext_msg=
'utilities_divergenceRMS')
2075 integer :: i, j, k, l, ierr
2076 complex(pReal),
dimension(3,3) :: curl_fourier
2077 complex(pReal),
dimension(3) :: rescaledgeom
2079 write(6,
'(/,a)')
' ... calculating curl ......................................................'
2099 +2.0_preal*sum(real(curl_fourier)**2.0_preal+aimag(curl_fourier)**2.0_preal)
2110 + sum(real(curl_fourier)**2.0_preal + aimag(curl_fourier)**2.0_preal)
2120 + sum(real(curl_fourier)**2.0_preal + aimag(curl_fourier)**2.0_preal)
2123 call mpi_allreduce(mpi_in_place,
utilities_curlrms,1,mpi_double,mpi_sum,petsc_comm_world,ierr)
2124 if(ierr /=0)
call io_error(894, ext_msg=
'utilities_curlRMS')
2137 real(
preal),
intent(in),
dimension(3,3,3,3) :: c
2138 type(
rotation),
intent(in) :: rot_bc
2139 logical,
intent(in),
dimension(3,3) :: mask_stress
2142 logical,
dimension(9) :: mask_stressvector
2143 logical,
dimension(9,9) :: mask
2144 real(
preal),
dimension(9,9) :: temp99_real
2145 integer :: size_reduced = 0
2146 real(
preal),
dimension(:,:),
allocatable :: &
2147 s_reduced, & !< reduced compliance matrix (depending on number of stress BC)
2148 c_reduced, & !< reduced stiffness (depending on number of stress BC)
2150 logical :: errmatinv
2151 character(len=pStringLen):: formatstring
2153 mask_stressvector = reshape(transpose(mask_stress), [9])
2154 size_reduced = count(mask_stressvector)
2155 if(size_reduced > 0)
then
2159 write(6,
'(/,a)')
' ... updating masked compliance ............................................'
2160 write(6,
'(/,a,/,9(9(2x,f12.7,1x)/))',advance=
'no')
' Stiffness C (load) / GPa =',&
2161 transpose(temp99_real)*1.0e-9_preal
2165 do i = 1,9;
do j = 1,9
2166 mask(i,j) = mask_stressvector(i) .and. mask_stressvector(j)
2168 c_reduced = reshape(pack(temp99_real,mask),[size_reduced,size_reduced])
2170 allocate(s_reduced,mold = c_reduced)
2172 if (any(ieee_is_nan(s_reduced))) errmatinv = .true.
2173 if (errmatinv)
call io_error(error_id=400,ext_msg=
'utilities_maskedCompliance')
2177 stimesc = matmul(c_reduced,s_reduced)
2180 write(formatstring,
'(i2)') size_reduced
2181 formatstring =
'(/,a,/,'//trim(formatstring)//
'('//trim(formatstring)//
'(2x,es9.2,1x)/))'
2182 write(6,trim(formatstring),advance=
'no')
' C * S (load) ', &
2183 transpose(matmul(c_reduced,s_reduced))
2184 write(6,trim(formatstring),advance=
'no')
' S (load) ', transpose(s_reduced)
2185 if(errmatinv)
call io_error(error_id=400,ext_msg=
'utilities_maskedCompliance')
2187 temp99_real = reshape(unpack(reshape(s_reduced,[size_reduced**2]),reshape(mask,[81]),0.0_preal),[9,9])
2189 temp99_real = 0.0_preal
2195 write(6,
'(/,a,/,9(9(2x,f10.5,1x)/),/)',advance=
'no') &
2196 ' Masked Compliance (load) * GPa =', transpose(temp99_real)*1.0e9_preal
2236 integer :: i, j, k, m, n
2239 do m = 1, 3;
do n = 1, 3
2240 tensorfield_fourier(m,n,i,j,k) =
vectorfield_fourier(m,i,j,k)*
xi1st(n,i,j,k)
2255 vectorfield_fourier(:,i,j,k) = matmul(
tensorfield_fourier(:,:,i,j,k),conjg(-
xi1st(:,i,j,k)))
2265 F,timeinc,rotation_BC)
2267 real(
preal),
intent(out),
dimension(3,3,3,3) :: c_volavg, c_minmaxavg
2268 real(
preal),
intent(out),
dimension(3,3) :: p_av
2269 real(
preal),
intent(out),
dimension(3,3,grid(1),grid(2),grid3) :: p
2270 real(
preal),
intent(in),
dimension(3,3,grid(1),grid(2),grid3) :: f
2271 real(
preal),
intent(in) :: timeinc
2272 type(
rotation),
intent(in),
optional :: rotation_bc
2277 real(
preal),
dimension(3,3,3,3) :: dpdf_max, dpdf_min
2278 real(
preal) :: dpdf_norm_max, dpdf_norm_min
2279 real(
preal),
dimension(2) :: valueandrank
2281 write(6,
'(/,a)')
' ... evaluating constitutive response ......................................'
2289 p_av = sum(sum(sum(p,dim=5),dim=4),dim=3) *
wgt
2290 call mpi_allreduce(mpi_in_place,p_av,9,mpi_double,mpi_sum,petsc_comm_world,ierr)
2292 write(6,
'(/,a,/,3(3(2x,f12.4,1x)/))',advance=
'no')
' Piola--Kirchhoff stress (lab) / MPa =',&
2293 transpose(p_av)*1.e-6_preal
2294 if(
present(rotation_bc)) &
2295 p_av = rotation_bc%rotate(p_av)
2296 write(6,
'(/,a,/,3(3(2x,f12.4,1x)/))',advance=
'no')
' Piola--Kirchhoff stress / MPa =',&
2297 transpose(p_av)*1.e-6_preal
2300 dpdf_max = 0.0_preal
2301 dpdf_norm_max = 0.0_preal
2302 dpdf_min = huge(1.0_preal)
2303 dpdf_norm_min = huge(1.0_preal)
2316 call mpi_allreduce(mpi_in_place,valueandrank,1, mpi_2double_precision, mpi_maxloc, petsc_comm_world, ierr)
2317 if (ierr /= 0)
call io_error(894, ext_msg=
'MPI_Allreduce max')
2318 call mpi_bcast(dpdf_max,81,mpi_double,int(valueandrank(2)),petsc_comm_world, ierr)
2319 if (ierr /= 0)
call io_error(894, ext_msg=
'MPI_Bcast max')
2322 call mpi_allreduce(mpi_in_place,valueandrank,1, mpi_2double_precision, mpi_minloc, petsc_comm_world, ierr)
2323 if (ierr /= 0)
call io_error(894, ext_msg=
'MPI_Allreduce min')
2324 call mpi_bcast(dpdf_min,81,mpi_double,int(valueandrank(2)),petsc_comm_world, ierr)
2325 if (ierr /= 0)
call io_error(894, ext_msg=
'MPI_Bcast min')
2327 c_minmaxavg = 0.5_preal*(dpdf_max + dpdf_min)
2330 call mpi_allreduce(mpi_in_place,c_volavg,81,mpi_double,mpi_sum,petsc_comm_world,ierr)
2331 c_volavg = c_volavg *
wgt
2342 real(
preal),
intent(in),
dimension(3,3) :: &
2344 real(
preal),
intent(in) :: &
2346 logical,
intent(in) :: &
2348 real(
preal),
intent(in),
dimension(3,3,grid(1),grid(2),grid3) :: &
2349 field0, & !< data of previous step
2351 real(
preal),
dimension(3,3,grid(1),grid(2),grid3) :: &
2354 if (heterogeneous)
then
2369 real(
preal),
intent(in) :: &
2371 real(
preal),
intent(in),
dimension(3,3,grid(1),grid(2),grid3) :: &
2372 field_lastinc, & !< initial field
2374 real(
preal),
intent(in),
optional,
dimension(3,3) :: &
2376 real(
preal),
dimension(3,3,grid(1),grid(2),grid3) :: &
2378 real(
preal),
dimension(3,3) :: fielddiff
2379 integer(kind=selected_int_kind(5)) :: ierr
2382 if (
present(aim))
then
2384 call mpi_allreduce(mpi_in_place,fielddiff,9,mpi_double,mpi_sum,petsc_comm_world,ierr)
2385 fielddiff = fielddiff - aim
2387 spread(spread(spread(fielddiff,3,
grid(1)),4,
grid(2)),5,
grid3)
2400 integer,
intent(in),
dimension(3) :: k_s
2413 cmplx(cos(2.0_preal*
pi*real(k_s(1),
preal)/real(
grid(1),
preal)) - 1.0_preal, &
2415 cmplx(cos(2.0_preal*
pi*real(k_s(2),
preal)/real(
grid(2),
preal)) + 1.0_preal, &
2417 cmplx(cos(2.0_preal*
pi*real(k_s(3),
preal)/real(
grid(3),
preal)) + 1.0_preal, &
2421 cmplx(cos(2.0_preal*
pi*real(k_s(1),
preal)/real(
grid(1),
preal)) + 1.0_preal, &
2423 cmplx(cos(2.0_preal*
pi*real(k_s(2),
preal)/real(
grid(2),
preal)) - 1.0_preal, &
2425 cmplx(cos(2.0_preal*
pi*real(k_s(3),
preal)/real(
grid(3),
preal)) + 1.0_preal, &
2429 cmplx(cos(2.0_preal*
pi*real(k_s(1),
preal)/real(
grid(1),
preal)) + 1.0_preal, &
2431 cmplx(cos(2.0_preal*
pi*real(k_s(2),
preal)/real(
grid(2),
preal)) + 1.0_preal, &
2433 cmplx(cos(2.0_preal*
pi*real(k_s(3),
preal)/real(
grid(3),
preal)) - 1.0_preal, &
2448 real(
preal),
dimension(3,3,grid(1),grid(2),grid3),
intent(in) :: f
2449 real(
preal),
dimension(3, grid(1),grid(2),grid3) :: ipcoords
2450 real(
preal),
dimension(3, grid(1),grid(2),grid3+2) :: ipfluct_padded
2451 real(
preal),
dimension(3, grid(1)+1,grid(2)+1,grid3+1) :: nodecoords
2458 integer,
dimension(MPI_STATUS_SIZE) :: &
2460 real(
preal),
dimension(3) :: step
2461 real(
preal),
dimension(3,3) :: favg
2462 integer,
dimension(3) :: me
2463 integer,
dimension(3,8) :: &
2464 neighbor = reshape([ &
2482 vectorfield_fourier(1:3,i,j,k) = matmul(
tensorfield_fourier(1:3,1:3,i,j,k),
xi2nd(1:3,i,j,k)) &
2494 call mpi_bcast(favg,9,mpi_double,0,petsc_comm_world,ierr)
2495 if(ierr /=0)
call io_error(894, ext_msg=
'update_IPcoords/MPI_Bcast')
2500 c = product(shape(ipfluct_padded(:,:,:,1)))
2505 call mpi_isend(ipfluct_padded(:,:,:,2), c,mpi_double,rank_b,0,petsc_comm_world,r,ierr)
2506 if(ierr /=0)
call io_error(894, ext_msg=
'update_IPcoords/MPI_Isend')
2507 call mpi_irecv(ipfluct_padded(:,:,:,
grid3+2),c,mpi_double,rank_t,0,petsc_comm_world,r,ierr)
2508 if(ierr /=0)
call io_error(894, ext_msg=
'update_IPcoords/MPI_Irecv')
2509 call mpi_wait(r,s,ierr)
2512 if(ierr /=0)
call io_error(894, ext_msg=
'update_IPcoords/MPI_Wait')
2513 call mpi_isend(ipfluct_padded(:,:,:,
grid3+1),c,mpi_double,rank_t,0,petsc_comm_world,r,ierr)
2514 if(ierr /=0)
call io_error(894, ext_msg=
'update_IPcoords/MPI_Isend')
2515 call mpi_irecv(ipfluct_padded(:,:,:,1), c,mpi_double,rank_b,0,petsc_comm_world,r,ierr)
2516 if(ierr /=0)
call io_error(894, ext_msg=
'update_IPcoords/MPI_Irecv')
2517 call mpi_wait(r,s,ierr)
2521 nodecoords = 0.0_preal
2523 nodecoords(1:3,i+1,j+1,k+1) = matmul(favg,step*(real([i,j,k+
grid3offset],
preal)))
2524 averagefluct:
do n = 1,8
2525 me = [i+neighbor(1,n),j+neighbor(2,n),k+neighbor(3,n)]
2526 nodecoords(1:3,i+1,j+1,k+1) = nodecoords(1:3,i+1,j+1,k+1) &
2527 + ipfluct_padded(1:3,modulo(me(1)-1,
grid(1))+1,modulo(me(2)-1,
grid(2))+1,me(3)+1)*0.125_preal
2553 write(6,
'(a)')
' writing reference stiffness data required for restart to file';
flush(6)
2555 write(fileunit)
c_ref