From bedcd0ad8cc8e25f2d2a5df61e8d54101329a78c Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Sat, 22 Feb 2020 11:14:11 +0100 Subject: [PATCH] sanity check for homogenization number of (constituent) per microstructure need to match Nconstituents in homogenization. --- src/IO.f90 | 2 ++ src/material.f90 | 28 +++++++++++++++++++--------- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/src/IO.f90 b/src/IO.f90 index c31ebdfab..6ab87715c 100644 --- a/src/IO.f90 +++ b/src/IO.f90 @@ -400,6 +400,8 @@ subroutine IO_error(error_ID,el,ip,g,instance,ext_msg) msg = 'number of values does not match' case (147) msg = 'not supported anymore' + case (148) + msg = 'Nconstituents mismatch between homogenization and microstructure' !-------------------------------------------------------------------------------------------------- ! material error messages and related messages in mesh diff --git a/src/material.f90 b/src/material.f90 index 7e68049b8..05c027d55 100644 --- a/src/material.f90 +++ b/src/material.f90 @@ -257,7 +257,7 @@ subroutine material_init allocate(damage (material_Nhomogenization)) allocate(temperatureRate (material_Nhomogenization)) - + do m = 1,size(config_microstructure) if(minval(microstructure_phase(1:microstructure_Nconstituents(m),m)) < 1 .or. & maxval(microstructure_phase(1:microstructure_Nconstituents(m),m)) > size(config_phase)) & @@ -268,6 +268,7 @@ subroutine material_init if(microstructure_Nconstituents(m) < 1) & call IO_error(151,m) enddo + if(homogenization_maxNgrains > size(microstructure_phase,1)) call IO_error(148) debugOut: if (iand(myDebug,debug_levelExtensive) /= 0) then write(6,'(/,a,/)') ' MATERIAL configuration' @@ -290,6 +291,7 @@ subroutine material_init !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ! new mappings + allocate(material_phaseAt(homogenization_maxNgrains,discretization_nElem), source=0) allocate(material_texture(homogenization_maxNgrains,discretization_nIP,discretization_nElem),source=0) !this is only needed by plasticity nonlocal allocate(material_orientation0(homogenization_maxNgrains,discretization_nIP,discretization_nElem)) @@ -298,9 +300,17 @@ subroutine material_init do i = 1, discretization_nIP myMicro = discretization_microstructureAt(e) do c = 1, homogenization_Ngrains(discretization_homogenizationAt(e)) - material_phaseAt(c,e) = microstructure_phase(c,myMicro) - material_texture(c,i,e) = microstructure_texture(c,myMicro) - material_orientation0(c,i,e) = texture_orientation(material_texture(c,i,e)) + if(microstructure_phase(c,myMicro) > 0) then + material_phaseAt(c,e) = microstructure_phase(c,myMicro) + else + call IO_error(150,ext_msg='phase') + endif + if(microstructure_texture(c,myMicro) > 0) then + material_texture(c,i,e) = microstructure_texture(c,myMicro) + material_orientation0(c,i,e) = texture_orientation(material_texture(c,i,e)) + else + call IO_error(150,ext_msg='texture') + endif enddo enddo enddo @@ -464,7 +474,7 @@ subroutine material_parseMicrostructure real(pReal), dimension(:,:), allocatable :: & microstructure_fraction !< vol fraction of each constituent in microstructure integer :: & - microstructure_maxNconstituents !< max number of constituents in any phase + maxNconstituents !< max number of constituents in any phase allocate(microstructure_Nconstituents(size(config_microstructure)), source=0) @@ -475,10 +485,10 @@ subroutine material_parseMicrostructure microstructure_Nconstituents(m) = config_microstructure(m)%countKeys('(constituent)') enddo - microstructure_maxNconstituents = maxval(microstructure_Nconstituents) - allocate(microstructure_phase (microstructure_maxNconstituents,size(config_microstructure)),source=0) - allocate(microstructure_texture (microstructure_maxNconstituents,size(config_microstructure)),source=0) - allocate(microstructure_fraction(microstructure_maxNconstituents,size(config_microstructure)),source=0.0_pReal) + maxNconstituents = maxval(microstructure_Nconstituents) + allocate(microstructure_phase (maxNconstituents,size(config_microstructure)),source=0) + allocate(microstructure_texture (maxNconstituents,size(config_microstructure)),source=0) + allocate(microstructure_fraction(maxNconstituents,size(config_microstructure)),source=0.0_pReal) allocate(strings(1)) ! Intel 16.0 Bug do m=1, size(config_microstructure)