From 67228b46a65e404cbb2000a0edd1252a66a460ee Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Wed, 23 Oct 2019 22:50:01 +0200 Subject: [PATCH] modularize --- src/grid/grid_mech_spectral_basic.f90 | 10 ++++-- src/grid/grid_mech_spectral_polarisation.f90 | 6 ++-- src/grid/spectral_utilities.f90 | 34 ++++++++++++-------- 3 files changed, 32 insertions(+), 18 deletions(-) diff --git a/src/grid/grid_mech_spectral_basic.f90 b/src/grid/grid_mech_spectral_basic.f90 index 54190cc30..f27079137 100644 --- a/src/grid/grid_mech_spectral_basic.f90 +++ b/src/grid/grid_mech_spectral_basic.f90 @@ -190,7 +190,8 @@ subroutine grid_mech_spectral_basic_init call MPI_File_close(fileUnit,ierr) endif restartRead2 - call utilities_updateGamma(C_minMaxAvg,.true.) + call utilities_updateGamma(C_minMaxAvg) + call utilities_saveReferenceStiffness end subroutine grid_mech_spectral_basic_init @@ -222,8 +223,11 @@ function grid_mech_spectral_basic_solution(incInfoIn,timeinc,timeinc_old,stress_ !-------------------------------------------------------------------------------------------------- ! update stiffness (and gamma operator) S = utilities_maskedCompliance(rotation_BC,stress_BC%maskLogical,C_volAvg) - if (num%update_gamma) call utilities_updateGamma(C_minMaxAvg,restartWrite) - + if (num%update_gamma) then + call utilities_updateGamma(C_minMaxAvg) + if(restartWrite) call utilities_saveReferenceStiffness + endif + !-------------------------------------------------------------------------------------------------- ! set module wide available data params%stress_mask = stress_BC%maskFloat diff --git a/src/grid/grid_mech_spectral_polarisation.f90 b/src/grid/grid_mech_spectral_polarisation.f90 index e0f12c9ee..a5cfcb012 100644 --- a/src/grid/grid_mech_spectral_polarisation.f90 +++ b/src/grid/grid_mech_spectral_polarisation.f90 @@ -203,7 +203,8 @@ subroutine grid_mech_spectral_polarisation_init call MPI_File_close(fileUnit,ierr) endif restartRead2 - call utilities_updateGamma(C_minMaxAvg,.true.) + call utilities_updateGamma(C_minMaxAvg) + call utilities_saveReferenceStiffness C_scale = C_minMaxAvg S_scale = math_invSym3333(C_minMaxAvg) @@ -238,7 +239,8 @@ function grid_mech_spectral_polarisation_solution(incInfoIn,timeinc,timeinc_old, ! update stiffness (and gamma operator) S = utilities_maskedCompliance(rotation_BC,stress_BC%maskLogical,C_volAvg) if (num%update_gamma) then - call utilities_updateGamma(C_minMaxAvg,restartWrite) + call utilities_updateGamma(C_minMaxAvg) + if(restartWrite) call utilities_saveReferenceStiffness C_scale = C_minMaxAvg S_scale = math_invSym3333(C_minMaxAvg) endif diff --git a/src/grid/spectral_utilities.f90 b/src/grid/spectral_utilities.f90 index 8f47f03ac..74060920b 100644 --- a/src/grid/spectral_utilities.f90 +++ b/src/grid/spectral_utilities.f90 @@ -158,12 +158,11 @@ module spectral_utilities utilities_calculateRate, & utilities_forwardField, & utilities_updateCoords, & + utilities_saveReferenceStiffness, & FIELD_UNDEFINED_ID, & FIELD_MECH_ID, & FIELD_THERMAL_ID, & FIELD_DAMAGE_ID - private :: & - utilities_getFreqDerivative contains @@ -390,27 +389,18 @@ end subroutine utilities_init !> @details Sets the current reference stiffness to the stiffness given as an argument. !> If the gamma operator is precalculated, it is calculated with this stiffness. !> In case of an on-the-fly calculation, only the reference stiffness is updated. -!> Also writes out the current reference stiffness for restart. !--------------------------------------------------------------------------------------------------- -subroutine utilities_updateGamma(C,saveReference) +subroutine utilities_updateGamma(C) real(pReal), intent(in), dimension(3,3,3,3) :: C !< input stiffness to store as reference stiffness - logical , intent(in) :: saveReference !< save reference stiffness to file for restart complex(pReal), dimension(3,3) :: temp33_complex, xiDyad_cmplx real(pReal), dimension(6,6) :: A, A_inv integer :: & i, j, k, & - l, m, n, o, & - fileUnit + l, m, n, o logical :: err C_ref = C - if (saveReference .and. worldrank == 0) then - write(6,'(/,a)') ' writing reference stiffness to file' - flush(6) - fileUnit = IO_open_jobFile_binary('C_ref','w') - write(fileUnit) C_ref; close(fileUnit) - endif if(.not. num%memory_efficient) then gamma_hat = cmplx(0.0_pReal,0.0_pReal,pReal) ! for the singular point and any non invertible A @@ -1130,4 +1120,22 @@ subroutine utilities_updateCoords(F) end subroutine utilities_updateCoords + +!--------------------------------------------------------------------------------------------------- +!> @brief Write out the current reference stiffness for restart. +!--------------------------------------------------------------------------------------------------- +subroutine utilities_saveReferenceStiffness + + integer :: & + fileUnit + + if (worldrank == 0) then + write(6,'(/,a)') ' writing reference stiffness to file' + flush(6) + fileUnit = IO_open_jobFile_binary('C_ref','w') + write(fileUnit) C_ref; close(fileUnit) + endif + +end subroutine utilities_saveReferenceStiffness + end module spectral_utilities