From 7f0c2d3825b9bd77f64f9fb781e5ec9f2ee8be44 Mon Sep 17 00:00:00 2001 From: Sharan Roongta Date: Tue, 16 Jun 2020 20:49:58 +0200 Subject: [PATCH] further removal of public variables --- src/grid/grid_mech_FEM.f90 | 19 +++++-- src/grid/grid_mech_spectral_basic.f90 | 18 +++++-- src/grid/grid_mech_spectral_polarisation.f90 | 34 +++++++++++-- src/numerics.f90 | 52 -------------------- 4 files changed, 61 insertions(+), 62 deletions(-) diff --git a/src/grid/grid_mech_FEM.f90 b/src/grid/grid_mech_FEM.f90 index c8bef7ff2..e8257cdba 100644 --- a/src/grid/grid_mech_FEM.f90 +++ b/src/grid/grid_mech_FEM.f90 @@ -16,6 +16,7 @@ module grid_mech_FEM use math use spectral_utilities use FEsolving + use YAML_types use numerics use homogenization use discretization @@ -412,11 +413,23 @@ subroutine converged(snes_local,PETScIter,devNull1,devNull2,fnorm,reason,dummy,i real(pReal) :: & err_div, & divTol, & - BCTol + BCTol, & + eps_div_atol, & + eps_div_rtol, & + eps_stress_atol, & + eps_stress_rtol + class(tNode), pointer :: & + num_grid + + num_grid => numerics_root%get('grid',defaultVal=emptyDict) + eps_div_atol = num_grid%get_asFloat('eps_div_atol',defaultVal=1.0e-4_pReal) + eps_div_rtol = num_grid%get_asFloat('eps_div_rtol',defaultVal=5.0e-4_pReal) + eps_stress_atol = num_grid%get_asFloat('eps_stress_atol',defaultVal=1.0e3_pReal) + eps_stress_rtol = num_grid%get_asFloat('eps_stress_rtol',defaultVal=0.01_pReal) err_div = fnorm*sqrt(wgt)*geomSize(1)/scaledGeomSize(1)/detJ - divTol = max(maxval(abs(P_av))*err_div_tolRel ,err_div_tolAbs) - BCTol = max(maxval(abs(P_av))*err_stress_tolRel,err_stress_tolAbs) + divTol = max(maxval(abs(P_av))*eps_div_rtol ,eps_div_atol) + BCTol = max(maxval(abs(P_av))*eps_stress_rtol,eps_stress_atol) if ((totalIter >= itmin .and. & all([ err_div/divTol, & diff --git a/src/grid/grid_mech_spectral_basic.f90 b/src/grid/grid_mech_spectral_basic.f90 index c69fcdc02..639b170f0 100644 --- a/src/grid/grid_mech_spectral_basic.f90 +++ b/src/grid/grid_mech_spectral_basic.f90 @@ -386,10 +386,22 @@ subroutine converged(snes_local,PETScIter,devNull1,devNull2,devNull3,reason,dumm PetscErrorCode :: ierr real(pReal) :: & divTol, & - BCTol + BCTol, & + eps_div_atol, & + eps_div_rtol, & + eps_stress_atol, & + eps_stress_rtol + class(tNode), pointer :: & + num_grid + + num_grid => numerics_root%get('grid',defaultVal=emptyDict) + eps_div_atol = num_grid%get_asFloat('eps_div_atol',defaultVal=1.0e-4_pReal) + eps_div_rtol = num_grid%get_asFloat('eps_div_rtol',defaultVal=5.0e-4_pReal) + eps_stress_atol = num_grid%get_asFloat('eps_stress_atol',defaultVal=1.0e3_pReal) + eps_stress_rtol = num_grid%get_asFloat('eps_stress_rtol',defaultVal=0.01_pReal) - divTol = max(maxval(abs(P_av))*err_div_tolRel ,err_div_tolAbs) - BCTol = max(maxval(abs(P_av))*err_stress_tolRel,err_stress_tolAbs) + divTol = max(maxval(abs(P_av))*eps_div_rtol ,eps_div_atol) + BCTol = max(maxval(abs(P_av))*eps_stress_rtol,eps_stress_atol) if ((totalIter >= itmin .and. & all([ err_div/divTol, & diff --git a/src/grid/grid_mech_spectral_polarisation.f90 b/src/grid/grid_mech_spectral_polarisation.f90 index ce20c0e08..74cfa0414 100644 --- a/src/grid/grid_mech_spectral_polarisation.f90 +++ b/src/grid/grid_mech_spectral_polarisation.f90 @@ -434,11 +434,28 @@ subroutine converged(snes_local,PETScIter,devNull1,devNull2,devNull3,reason,dumm real(pReal) :: & curlTol, & divTol, & - BCTol + BCTol, & + eps_div_atol, & + eps_div_rtol, & + eps_curl_atol, & + eps_curl_rtol, & + eps_stress_atol, & + eps_stress_rtol + class(tNode), pointer :: & + num_grid + + num_grid => numerics_root%get('grid',defaultVal=emptyDict) + eps_div_atol = num_grid%get_asFloat('eps_div_atol',defaultVal=1.0e-4_pReal) + eps_div_rtol = num_grid%get_asFloat('eps_div_rtol',defaultVal=5.0e-4_pReal) + eps_curl_atol = num_grid%get_asFloat('eps_curl_atol',defaultVal=1.0e-10_pReal) + eps_curl_rtol = num_grid%get_asFloat('eps_curl_rtol',defaultVal=5.0e-4_pReal) + eps_stress_atol = num_grid%get_asFloat('eps_stress_atol',defaultVal=1.0e3_pReal) + eps_stress_rtol = num_grid%get_asFloat('eps_stress_rtol',defaultVal=0.01_pReal) - curlTol = max(maxval(abs(F_aim-math_I3))*err_curl_tolRel ,err_curl_tolAbs) - divTol = max(maxval(abs(P_av)) *err_div_tolRel ,err_div_tolAbs) - BCTol = max(maxval(abs(P_av)) *err_stress_tolRel,err_stress_tolAbs) + + curlTol = max(maxval(abs(F_aim-math_I3))*eps_curl_rtol ,eps_curl_atol) + divTol = max(maxval(abs(P_av)) *eps_div_rtol ,eps_div_atol) + BCTol = max(maxval(abs(P_av)) *eps_stress_rtol,eps_stress_atol) if ((totalIter >= itmin .and. & all([ err_div /divTol, & @@ -488,9 +505,18 @@ subroutine formResidual(in, FandF_tau, & nfuncs PetscObject :: dummy PetscErrorCode :: ierr + class(tNode), pointer :: & + num_grid + real(pReal) :: & + polarAlpha, & + polarBeta integer :: & i, j, k, e + num_grid => numerics_root%get('grid',defaultVal = emptyDict) + polarAlpha = num_grid%get_asFloat('polaralpha',defaultVal=1.0_pReal) + polarBeta = num_grid%get_asFloat('polarbeta', defaultVal=1.0_pReal) + F => FandF_tau(1:3,1:3,1,& XG_RANGE,YG_RANGE,ZG_RANGE) F_tau => FandF_tau(1:3,1:3,2,& diff --git a/src/numerics.f90 b/src/numerics.f90 index e6f24281b..ac16c5496 100644 --- a/src/numerics.f90 +++ b/src/numerics.f90 @@ -44,15 +44,6 @@ module numerics !-------------------------------------------------------------------------------------------------- ! spectral parameters: #ifdef Grid - real(pReal), protected, public :: & - err_div_tolAbs = 1.0e-4_pReal, & !< absolute tolerance for equilibrium - err_div_tolRel = 5.0e-4_pReal, & !< relative tolerance for equilibrium - err_curl_tolAbs = 1.0e-10_pReal, & !< absolute tolerance for compatibility - err_curl_tolRel = 5.0e-4_pReal, & !< relative tolerance for compatibility - err_stress_tolAbs = 1.0e3_pReal, & !< absolute tolerance for fullfillment of stress BC - err_stress_tolRel = 0.01_pReal, & !< relative tolerance for fullfillment of stress BC - polarAlpha = 1.0_pReal, & !< polarization scheme parameter 0.0 < alpha < 2.0. alpha = 1.0 ==> AL scheme, alpha = 2.0 ==> accelerated scheme - polarBeta = 1.0_pReal !< polarization scheme parameter 0.0 < beta < 2.0. beta = 1.0 ==> AL scheme, beta = 2.0 ==> accelerated scheme character(len=pStringLen), protected, public :: & petsc_options = '' #endif @@ -117,24 +108,6 @@ subroutine numerics_init do i=1,num_grid%length key = num_grid%getKey(i) select case(key) -#ifdef Grid - case ('err_div_tolabs') - err_div_tolAbs = num_grid%get_asFloat(key) - case ('err_div_tolrel') - err_div_tolRel = num_grid%get_asFloat(key) - case ('err_stress_tolrel') - err_stress_tolrel = num_grid%get_asFloat(key) - case ('err_stress_tolabs') - err_stress_tolabs = num_grid%get_asFloat(key) - case ('err_curl_tolabs') - err_curl_tolAbs = num_grid%get_asFloat(key) - case ('err_curl_tolrel') - err_curl_tolRel = num_grid%get_asFloat(key) - case ('polaralpha') - polarAlpha = num_grid%get_asFloat(key) - case ('polarbeta') - polarBeta = num_grid%get_asFloat(key) -#endif case ('itmax') itmax = num_grid%get_asInt(key) case ('itmin') @@ -208,19 +181,6 @@ subroutine numerics_init write(6,'(a24,1x,i8)') ' maxCutBack: ',maxCutBack write(6,'(a24,1x,i8)') ' maxStaggeredIter: ',stagItMax -!-------------------------------------------------------------------------------------------------- -! spectral parameters -#ifdef Grid - write(6,'(a24,1x,es8.1)') ' err_stress_tolAbs: ',err_stress_tolAbs - write(6,'(a24,1x,es8.1)') ' err_stress_tolRel: ',err_stress_tolRel - write(6,'(a24,1x,es8.1)') ' err_div_tolAbs: ',err_div_tolAbs - write(6,'(a24,1x,es8.1)') ' err_div_tolRel: ',err_div_tolRel - write(6,'(a24,1x,es8.1)') ' err_curl_tolAbs: ',err_curl_tolAbs - write(6,'(a24,1x,es8.1)') ' err_curl_tolRel: ',err_curl_tolRel - write(6,'(a24,1x,es8.1)') ' polarAlpha: ',polarAlpha - write(6,'(a24,1x,es8.1)') ' polarBeta: ',polarBeta -#endif - !-------------------------------------------------------------------------------------------------- #ifdef PETSC write(6,'(a24,1x,a)') ' PETSc_options: ',trim(petsc_options) @@ -236,18 +196,6 @@ subroutine numerics_init if (itmin > itmax .or. itmin < 1) call IO_error(301,ext_msg='itmin') if (maxCutBack < 0) call IO_error(301,ext_msg='maxCutBack') if (stagItMax < 0) call IO_error(301,ext_msg='maxStaggeredIter') -#ifdef Grid - if (err_stress_tolrel <= 0.0_pReal) call IO_error(301,ext_msg='err_stress_tolRel') - if (err_stress_tolabs <= 0.0_pReal) call IO_error(301,ext_msg='err_stress_tolAbs') - if (err_div_tolRel < 0.0_pReal) call IO_error(301,ext_msg='err_div_tolRel') - if (err_div_tolAbs <= 0.0_pReal) call IO_error(301,ext_msg='err_div_tolAbs') - if (err_curl_tolRel < 0.0_pReal) call IO_error(301,ext_msg='err_curl_tolRel') - if (err_curl_tolAbs <= 0.0_pReal) call IO_error(301,ext_msg='err_curl_tolAbs') - if (polarAlpha <= 0.0_pReal .or. & - polarAlpha > 2.0_pReal) call IO_error(301,ext_msg='polarAlpha') - if (polarBeta < 0.0_pReal .or. & - polarBeta > 2.0_pReal) call IO_error(301,ext_msg='polarBeta') -#endif end subroutine numerics_init