2012-03-09 01:55:28 +05:30
|
|
|
!--------------------------------------------------------------------------------------------------
|
|
|
|
!> @author Franz Roters, Max-Planck-Institut für Eisenforschung GmbH
|
2013-06-11 22:05:04 +05:30
|
|
|
!> @author Philip Eisenlohr, Max-Planck-Institut für Eisenforschung GmbH
|
2018-06-26 22:39:46 +05:30
|
|
|
!> @author Martin Diehl, Max-Planck-Institut für Eisenforschung GmbH
|
2020-09-20 23:16:33 +05:30
|
|
|
!> @brief Defines phase and homogenization
|
2012-03-09 01:55:28 +05:30
|
|
|
!--------------------------------------------------------------------------------------------------
|
|
|
|
module material
|
2019-06-05 13:32:55 +05:30
|
|
|
use prec
|
|
|
|
use config
|
2023-01-19 22:07:45 +05:30
|
|
|
use result
|
2021-07-24 18:33:26 +05:30
|
|
|
use math
|
2019-06-05 13:32:55 +05:30
|
|
|
use IO
|
2019-06-07 18:01:42 +05:30
|
|
|
use rotations
|
2019-06-07 09:48:42 +05:30
|
|
|
use discretization
|
2021-02-12 20:01:43 +05:30
|
|
|
use YAML_types
|
2012-03-09 01:55:28 +05:30
|
|
|
|
2022-06-22 02:16:54 +05:30
|
|
|
implicit none(type,external)
|
2019-09-20 00:10:59 +05:30
|
|
|
private
|
2020-03-16 22:59:15 +05:30
|
|
|
|
2022-02-05 13:33:10 +05:30
|
|
|
type, public :: tRotationContainer
|
|
|
|
type(tRotation), dimension(:), allocatable :: data
|
|
|
|
end type tRotationContainer
|
|
|
|
|
|
|
|
type, public :: tTensorContainer
|
2023-06-04 10:52:25 +05:30
|
|
|
real(pREAL), dimension(:,:,:), allocatable :: data
|
2022-02-05 13:33:10 +05:30
|
|
|
end type tTensorContainer
|
2021-07-24 18:33:26 +05:30
|
|
|
|
2021-05-22 20:51:07 +05:30
|
|
|
|
2022-02-05 13:33:10 +05:30
|
|
|
type(tRotationContainer), dimension(:), allocatable, public, protected :: material_O_0
|
2022-05-18 03:26:05 +05:30
|
|
|
type(tTensorContainer), dimension(:), allocatable, public, protected :: material_V_e_0
|
2021-05-22 20:51:07 +05:30
|
|
|
|
2021-02-12 20:01:43 +05:30
|
|
|
integer, dimension(:), allocatable, public, protected :: &
|
2021-03-01 10:46:16 +05:30
|
|
|
homogenization_Nconstituents !< number of grains in each homogenization
|
2021-05-22 13:03:58 +05:30
|
|
|
integer, public, protected :: &
|
|
|
|
homogenization_maxNconstituents !< max number of grains in any homogenization
|
2020-03-16 22:59:15 +05:30
|
|
|
|
2020-12-06 18:02:20 +05:30
|
|
|
character(len=:), public, protected, allocatable, dimension(:) :: &
|
2020-08-15 19:32:10 +05:30
|
|
|
material_name_phase, & !< name of each phase
|
|
|
|
material_name_homogenization !< name of each homogenization
|
2020-09-13 14:09:17 +05:30
|
|
|
|
2022-02-05 13:33:10 +05:30
|
|
|
integer, dimension(:), allocatable, public, protected :: & ! (cell)
|
2023-01-23 13:01:59 +05:30
|
|
|
material_ID_homogenization, & !< Number of the homogenization
|
|
|
|
material_entry_homogenization !< Position in array of used homogenization
|
2022-02-05 13:33:10 +05:30
|
|
|
integer, dimension(:,:), allocatable, public, protected :: & ! (constituent,cell)
|
2023-01-23 13:01:59 +05:30
|
|
|
material_ID_phase, & !< Number of the phase
|
|
|
|
material_entry_phase !< Position in array of used phase
|
2022-02-05 13:33:10 +05:30
|
|
|
|
2023-06-04 10:52:25 +05:30
|
|
|
real(pREAL), dimension(:,:), allocatable, public, protected :: &
|
2022-02-07 18:55:03 +05:30
|
|
|
material_v ! fraction
|
|
|
|
|
2019-09-20 00:10:59 +05:30
|
|
|
public :: &
|
2023-02-28 12:25:34 +05:30
|
|
|
material_init
|
2013-10-16 18:34:59 +05:30
|
|
|
|
2012-03-09 01:55:28 +05:30
|
|
|
contains
|
2020-01-25 13:54:42 +05:30
|
|
|
|
2013-01-18 17:00:52 +05:30
|
|
|
!--------------------------------------------------------------------------------------------------
|
2021-02-13 11:29:18 +05:30
|
|
|
!> @brief Parse material configuration file (material.yaml).
|
2013-01-18 17:00:52 +05:30
|
|
|
!--------------------------------------------------------------------------------------------------
|
2020-05-06 21:20:59 +05:30
|
|
|
subroutine material_init(restart)
|
|
|
|
|
|
|
|
logical, intent(in) :: restart
|
2020-09-13 14:09:17 +05:30
|
|
|
|
2021-02-12 20:01:43 +05:30
|
|
|
|
2021-11-15 23:05:44 +05:30
|
|
|
print'(/,1x,a)', '<<<+- material init -+>>>'; flush(IO_STDOUT)
|
2020-03-16 22:59:15 +05:30
|
|
|
|
2020-08-15 19:32:10 +05:30
|
|
|
|
2022-01-31 19:35:15 +05:30
|
|
|
call parse()
|
2021-11-15 23:05:44 +05:30
|
|
|
print'(/,1x,a)', 'parsed material.yaml'
|
2020-03-16 22:59:15 +05:30
|
|
|
|
|
|
|
|
2020-05-06 21:20:59 +05:30
|
|
|
if (.not. restart) then
|
2023-02-21 20:48:17 +05:30
|
|
|
call result_openJobFile()
|
2023-01-23 13:01:59 +05:30
|
|
|
call result_mapping_phase(material_ID_phase,material_entry_phase,material_name_phase)
|
|
|
|
call result_mapping_homogenization(material_ID_homogenization,material_entry_homogenization,material_name_homogenization)
|
2023-02-21 20:48:17 +05:30
|
|
|
call result_closeJobFile()
|
2021-11-15 23:05:44 +05:30
|
|
|
end if
|
2019-04-04 16:55:29 +05:30
|
|
|
|
2012-03-09 01:55:28 +05:30
|
|
|
end subroutine material_init
|
2009-03-04 17:18:54 +05:30
|
|
|
|
2020-10-24 17:53:00 +05:30
|
|
|
|
2023-02-25 16:43:27 +05:30
|
|
|
!--------------------------------------------------------------------------------------------------
|
|
|
|
!> @brief Parse material.yaml to get the global structure.
|
2013-01-18 17:00:52 +05:30
|
|
|
!--------------------------------------------------------------------------------------------------
|
2021-05-22 13:03:58 +05:30
|
|
|
subroutine parse()
|
2015-10-14 00:22:01 +05:30
|
|
|
|
2022-10-25 21:39:36 +05:30
|
|
|
type(tList), pointer :: materials, & !> all materials
|
|
|
|
constituents !> all constituents of a material
|
|
|
|
type(tDict), pointer :: phases, & !> all phases
|
|
|
|
homogenizations, & !> all homogenizations
|
|
|
|
material, & !> material definition
|
|
|
|
constituent, & !> constituent definition
|
|
|
|
homogenization
|
2020-03-16 22:59:15 +05:30
|
|
|
|
2022-04-14 04:36:47 +05:30
|
|
|
class(tItem), pointer :: item
|
2020-08-15 19:32:10 +05:30
|
|
|
integer, dimension(:), allocatable :: &
|
2020-09-19 13:30:49 +05:30
|
|
|
counterPhase, &
|
2022-04-14 16:25:11 +05:30
|
|
|
counterHomogenization, &
|
2022-04-19 22:41:40 +05:30
|
|
|
ho_of
|
|
|
|
integer, dimension(:,:), allocatable :: ph_of
|
2023-06-04 10:52:25 +05:30
|
|
|
real(pREAL), dimension(:,:), allocatable :: v_of
|
2020-03-16 22:59:15 +05:30
|
|
|
|
2023-06-04 10:52:25 +05:30
|
|
|
real(pREAL) :: v
|
2020-08-15 19:32:10 +05:30
|
|
|
integer :: &
|
2022-02-05 13:33:10 +05:30
|
|
|
el, ip, &
|
|
|
|
ho, ph, &
|
|
|
|
co, ce, &
|
|
|
|
ma
|
2020-10-24 20:00:48 +05:30
|
|
|
|
2022-04-14 04:36:47 +05:30
|
|
|
|
2022-10-25 21:39:36 +05:30
|
|
|
materials => config_material%get_list('material')
|
|
|
|
phases => config_material%get_dict('phase')
|
|
|
|
homogenizations => config_material%get_dict('homogenization')
|
2020-08-15 19:32:10 +05:30
|
|
|
|
2022-04-14 23:44:08 +05:30
|
|
|
|
|
|
|
if (maxval(discretization_materialAt) > materials%length) &
|
|
|
|
call IO_error(155,ext_msg='More materials requested than found in material.yaml')
|
|
|
|
|
2022-10-25 21:39:36 +05:30
|
|
|
material_name_phase = phases%keys()
|
|
|
|
material_name_homogenization = homogenizations%keys()
|
2020-10-24 18:18:07 +05:30
|
|
|
|
2020-10-28 01:57:26 +05:30
|
|
|
allocate(homogenization_Nconstituents(homogenizations%length))
|
2022-02-05 13:33:10 +05:30
|
|
|
do ho=1, homogenizations%length
|
2022-10-25 21:39:36 +05:30
|
|
|
homogenization => homogenizations%get_dict(ho)
|
2022-02-05 13:33:10 +05:30
|
|
|
homogenization_Nconstituents(ho) = homogenization%get_asInt('N_constituents')
|
2021-11-15 23:05:44 +05:30
|
|
|
end do
|
2020-10-28 01:57:26 +05:30
|
|
|
homogenization_maxNconstituents = maxval(homogenization_Nconstituents)
|
2020-10-24 20:00:48 +05:30
|
|
|
|
2023-06-04 10:52:25 +05:30
|
|
|
allocate(material_v(homogenization_maxNconstituents,discretization_Ncells),source=0.0_pREAL)
|
2021-01-17 19:08:12 +05:30
|
|
|
|
2021-07-24 18:33:26 +05:30
|
|
|
allocate(material_O_0(materials%length))
|
2022-05-18 03:26:05 +05:30
|
|
|
allocate(material_V_e_0(materials%length))
|
2021-05-22 20:51:07 +05:30
|
|
|
|
2022-04-19 22:41:40 +05:30
|
|
|
allocate(ho_of(materials%length))
|
|
|
|
allocate(ph_of(materials%length,homogenization_maxNconstituents),source=-1)
|
2023-06-04 10:52:25 +05:30
|
|
|
allocate( v_of(materials%length,homogenization_maxNconstituents),source=0.0_pREAL)
|
2022-04-14 23:44:08 +05:30
|
|
|
|
2022-12-25 21:06:01 +05:30
|
|
|
! Parse YAML structure. Manual loop over linked list to have O(n) instead of O(n^2) complexity
|
2022-10-25 21:39:36 +05:30
|
|
|
item => materials%first
|
|
|
|
do ma = 1, materials%length
|
|
|
|
material => item%node%asDict()
|
2023-06-04 10:47:38 +05:30
|
|
|
ho_of(ma) = homogenizations%index(material%get_asStr('homogenization'))
|
2022-10-25 21:39:36 +05:30
|
|
|
constituents => material%get_list('constituents')
|
2022-04-14 16:25:11 +05:30
|
|
|
|
2022-10-25 21:39:36 +05:30
|
|
|
homogenization => homogenizations%get_dict(ho_of(ma))
|
|
|
|
if (constituents%length /= homogenization%get_asInt('N_constituents')) call IO_error(148)
|
2022-04-14 16:25:11 +05:30
|
|
|
|
2022-10-25 21:39:36 +05:30
|
|
|
allocate(material_O_0(ma)%data(constituents%length))
|
|
|
|
allocate(material_V_e_0(ma)%data(1:3,1:3,constituents%length))
|
2022-04-14 16:25:11 +05:30
|
|
|
|
2022-10-25 21:39:36 +05:30
|
|
|
do co = 1, constituents%length
|
|
|
|
constituent => constituents%get_dict(co)
|
2023-06-03 20:36:32 +05:30
|
|
|
v_of(ma,co) = constituent%get_asReal('v')
|
2023-06-04 10:47:38 +05:30
|
|
|
ph_of(ma,co) = phases%index(constituent%get_asStr('phase'))
|
2022-04-14 16:25:11 +05:30
|
|
|
|
2023-06-03 20:36:32 +05:30
|
|
|
call material_O_0(ma)%data(co)%fromQuaternion(constituent%get_as1dReal('O',requiredSize=4))
|
|
|
|
material_V_e_0(ma)%data(1:3,1:3,co) = constituent%get_as2dReal('V_e',defaultVal=math_I3,requiredShape=[3,3])
|
2022-10-25 21:39:36 +05:30
|
|
|
if (any(dNeq(material_V_e_0(ma)%data(1:3,1:3,co),transpose(material_V_e_0(ma)%data(1:3,1:3,co))))) &
|
|
|
|
call IO_error(147)
|
2022-04-14 16:25:11 +05:30
|
|
|
|
2022-10-25 21:39:36 +05:30
|
|
|
end do
|
2023-06-04 10:52:25 +05:30
|
|
|
if (dNeq(sum(v_of(ma,:)),1.0_pREAL,1.e-9_pREAL)) call IO_error(153,ext_msg='constituent')
|
2018-10-14 23:46:30 +05:30
|
|
|
|
2022-10-25 21:39:36 +05:30
|
|
|
item => item%next
|
|
|
|
end do
|
2020-09-13 14:09:17 +05:30
|
|
|
|
2022-04-14 23:44:08 +05:30
|
|
|
allocate(counterPhase(phases%length),source=0)
|
|
|
|
allocate(counterHomogenization(homogenizations%length),source=0)
|
|
|
|
|
2023-01-23 13:01:59 +05:30
|
|
|
allocate(material_ID_homogenization(discretization_Ncells),source=0)
|
|
|
|
allocate(material_entry_homogenization(discretization_Ncells),source=0)
|
2022-04-14 23:44:08 +05:30
|
|
|
|
2023-01-23 13:01:59 +05:30
|
|
|
allocate(material_ID_phase(homogenization_maxNconstituents,discretization_Ncells),source=0)
|
|
|
|
allocate(material_entry_phase(homogenization_maxNconstituents,discretization_Ncells),source=0)
|
2022-04-14 23:44:08 +05:30
|
|
|
|
|
|
|
|
2022-04-14 16:25:11 +05:30
|
|
|
! build mappings
|
|
|
|
do el = 1, discretization_Nelems
|
2020-10-24 21:30:17 +05:30
|
|
|
|
2022-04-14 16:25:11 +05:30
|
|
|
ma = discretization_materialAt(el)
|
2022-04-19 22:41:40 +05:30
|
|
|
ho = ho_of(ma)
|
2020-10-24 21:30:17 +05:30
|
|
|
|
2022-04-14 16:25:11 +05:30
|
|
|
do ip = 1, discretization_nIPs
|
|
|
|
ce = (el-1)*discretization_nIPs + ip
|
2023-01-23 13:01:59 +05:30
|
|
|
material_ID_homogenization(ce) = ho
|
2022-04-14 16:25:11 +05:30
|
|
|
counterHomogenization(ho) = counterHomogenization(ho) + 1
|
2023-01-23 13:01:59 +05:30
|
|
|
material_entry_homogenization(ce) = counterHomogenization(ho)
|
2022-04-14 16:25:11 +05:30
|
|
|
end do
|
2020-10-24 21:30:17 +05:30
|
|
|
|
2022-04-19 22:41:40 +05:30
|
|
|
do co = 1, size(ph_of(ma,:)>0)
|
2022-04-14 04:36:47 +05:30
|
|
|
|
2022-04-19 22:41:40 +05:30
|
|
|
v = v_of(ma,co)
|
|
|
|
ph = ph_of(ma,co)
|
2020-10-24 21:30:17 +05:30
|
|
|
|
2022-04-14 16:25:11 +05:30
|
|
|
do ip = 1, discretization_nIPs
|
|
|
|
ce = (el-1)*discretization_nIPs + ip
|
2023-01-23 13:01:59 +05:30
|
|
|
material_ID_phase(co,ce) = ph
|
2022-04-14 16:25:11 +05:30
|
|
|
counterPhase(ph) = counterPhase(ph) + 1
|
2023-01-23 13:01:59 +05:30
|
|
|
material_entry_phase(co,ce) = counterPhase(ph)
|
2022-04-14 16:25:11 +05:30
|
|
|
material_v(co,ce) = v
|
2022-04-14 04:36:47 +05:30
|
|
|
end do
|
2020-10-24 21:30:17 +05:30
|
|
|
|
2022-04-14 16:25:11 +05:30
|
|
|
end do
|
|
|
|
end do
|
|
|
|
|
|
|
|
end subroutine parse
|
2020-10-24 21:30:17 +05:30
|
|
|
|
2022-04-14 23:44:08 +05:30
|
|
|
|
2022-01-21 05:15:47 +05:30
|
|
|
#if defined (__GFORTRAN__)
|
2020-10-24 21:30:17 +05:30
|
|
|
!--------------------------------------------------------------------------------------------------
|
2022-01-21 05:15:47 +05:30
|
|
|
!> @brief %keys() is broken on gfortran
|
2020-10-24 21:30:17 +05:30
|
|
|
!--------------------------------------------------------------------------------------------------
|
|
|
|
function getKeys(dict)
|
|
|
|
|
2022-10-25 21:39:36 +05:30
|
|
|
type(tDict), intent(in) :: dict
|
2023-06-04 10:47:38 +05:30
|
|
|
character(len=:), dimension(:), allocatable :: getKeys
|
|
|
|
character(len=pSTRLEN), dimension(:), allocatable :: temp
|
2020-10-24 21:30:17 +05:30
|
|
|
|
2020-12-06 18:02:20 +05:30
|
|
|
integer :: i,l
|
2020-10-24 21:30:17 +05:30
|
|
|
|
2020-12-06 18:02:20 +05:30
|
|
|
allocate(temp(dict%length))
|
|
|
|
l = 0
|
2020-10-24 21:30:17 +05:30
|
|
|
do i=1, dict%length
|
2022-10-25 21:39:36 +05:30
|
|
|
temp(i) = dict%key(i)
|
2020-12-06 18:02:20 +05:30
|
|
|
l = max(len_trim(temp(i)),l)
|
2021-11-15 23:05:44 +05:30
|
|
|
end do
|
2020-12-10 05:01:58 +05:30
|
|
|
|
2020-12-06 18:02:20 +05:30
|
|
|
allocate(character(l)::getKeys(dict%length))
|
|
|
|
do i=1, dict%length
|
|
|
|
getKeys(i) = trim(temp(i))
|
2021-11-15 23:05:44 +05:30
|
|
|
end do
|
2020-10-24 21:30:17 +05:30
|
|
|
|
|
|
|
end function getKeys
|
2022-01-21 05:15:47 +05:30
|
|
|
#endif
|
2020-10-24 21:30:17 +05:30
|
|
|
|
2013-02-20 03:42:05 +05:30
|
|
|
end module material
|