diff --git a/src/grid/grid_mech_spectral_basic.f90 b/src/grid/grid_mech_spectral_basic.f90 index ef958d718..4dca95e80 100644 --- a/src/grid/grid_mech_spectral_basic.f90 +++ b/src/grid/grid_mech_spectral_basic.f90 @@ -536,6 +536,7 @@ subroutine formResidual(in, F, & F,params%Delta_t,params%rotation_BC) call MPI_Allreduce(MPI_IN_PLACE,terminallyIll,1_MPI_INTEGER_KIND,MPI_LOGICAL,MPI_LOR,MPI_COMM_WORLD,err_MPI) if (err_MPI /= 0_MPI_INTEGER_KIND) error stop 'MPI error' + err_div = utilities_divergenceRMS(r) !-------------------------------------------------------------------------------------------------- ! stress BC handling @@ -547,7 +548,6 @@ subroutine formResidual(in, F, & ! updated deformation gradient using fix point algorithm of basic scheme tensorField_real(1:3,1:3,1:cells(1),1:cells(2),1:cells3) = r ! store fPK field for subsequent FFT forward transform call utilities_FFTtensorForward ! FFT forward of global "tensorField_real" - err_div = utilities_divergenceRMS() ! divRMS of tensorField_fourier for later use call utilities_fourierGammaConvolution(params%rotation_BC%rotate(deltaF_aim,active=.true.)) ! convolution of Gamma and tensorField_fourier call utilities_FFTtensorBackward ! FFT backward of global tensorField_fourier diff --git a/src/grid/grid_mech_spectral_polarisation.f90 b/src/grid/grid_mech_spectral_polarisation.f90 index c82048d77..9c9a83766 100644 --- a/src/grid/grid_mech_spectral_polarisation.f90 +++ b/src/grid/grid_mech_spectral_polarisation.f90 @@ -634,6 +634,8 @@ subroutine formResidual(in, FandF_tau, & P_av,C_volAvg,C_minMaxAvg, & F - r_F_tau/num%beta,params%Delta_t,params%rotation_BC) call MPI_Allreduce(MPI_IN_PLACE,terminallyIll,1_MPI_INTEGER_KIND,MPI_LOGICAL,MPI_LOR,MPI_COMM_WORLD,err_MPI) + err_div = utilities_divergenceRMS(r_F) + err_curl = utilities_curlRMS(F) !-------------------------------------------------------------------------------------------------- ! stress BC handling @@ -641,10 +643,6 @@ subroutine formResidual(in, FandF_tau, & err_BC = maxval(abs(merge(math_mul3333xx33(C_scale,F_aim-params%rotation_BC%rotate(F_av)), & P_av-P_aim, & params%stress_mask))) -! calculate divergence - tensorField_real(1:3,1:3,1:cells(1),1:cells(2),1:cells3) = r_F !< stress field in disguise - call utilities_FFTtensorForward - err_div = utilities_divergenceRMS() !< root mean squared error in divergence of stress !-------------------------------------------------------------------------------------------------- ! constructing residual @@ -658,12 +656,6 @@ subroutine formResidual(in, FandF_tau, & + r_F_tau(1:3,1:3,i,j,k) end do; end do; end do -!-------------------------------------------------------------------------------------------------- -! calculating curl - tensorField_real(1:3,1:3,1:cells(1),1:cells(2),1:cells3) = F - call utilities_FFTtensorForward - err_curl = utilities_curlRMS() - end subroutine formResidual end module grid_mechanical_spectral_polarisation diff --git a/src/grid/spectral_utilities.f90 b/src/grid/spectral_utilities.f90 index 6cb7edd30..db2efbfec 100644 --- a/src/grid/spectral_utilities.f90 +++ b/src/grid/spectral_utilities.f90 @@ -616,9 +616,11 @@ end subroutine utilities_fourierGreenConvolution !-------------------------------------------------------------------------------------------------- -!> @brief calculate root mean square of divergence of field_fourier +!> @brief Calculate root mean square of divergence. !-------------------------------------------------------------------------------------------------- -real(pReal) function utilities_divergenceRMS() +real(pReal) function utilities_divergenceRMS(tensorField) + + real(pReal), dimension(3,3,cells(1),cells(2),cells3), intent(in) :: tensorField integer :: i, j, k integer(MPI_INTEGER_KIND) :: err_MPI @@ -628,6 +630,9 @@ real(pReal) function utilities_divergenceRMS() print'(/,1x,a)', '... calculating divergence ................................................' flush(IO_STDOUT) + tensorField_real(1:3,1:3,1:cells(1),1:cells(2),1:cells3) = tensorField + call utilities_FFTtensorforward() + rescaledGeom = cmplx(geomSize/scaledGeomSize,0.0_pReal,pReal) !-------------------------------------------------------------------------------------------------- @@ -660,9 +665,11 @@ end function utilities_divergenceRMS !-------------------------------------------------------------------------------------------------- -!> @brief calculate max of curl of field_fourier +!> @brief Calculate root mean square of curl. !-------------------------------------------------------------------------------------------------- -real(pReal) function utilities_curlRMS() +real(pReal) function utilities_curlRMS(tensorField) + + real(pReal), dimension(3,3,cells(1),cells(2),cells3), intent(in) :: tensorField integer :: i, j, k, l integer(MPI_INTEGER_KIND) :: err_MPI @@ -673,6 +680,9 @@ real(pReal) function utilities_curlRMS() print'(/,1x,a)', '... calculating curl ......................................................' flush(IO_STDOUT) + tensorField_real(1:3,1:3,1:cells(1),1:cells(2),1:cells3) = tensorField + call utilities_FFTtensorforward() + rescaledGeom = cmplx(geomSize/scaledGeomSize,0.0_pReal,pReal) !--------------------------------------------------------------------------------------------------