2018-08-17 03:44:25 +05:30
|
|
|
!--------------------------------------------------------------------------------------------------
|
|
|
|
!> @author Pratheek Shanthraj, Max-Planck-Institut für Eisenforschung GmbH
|
|
|
|
!> @brief Utilities used by the FEM solver
|
|
|
|
!--------------------------------------------------------------------------------------------------
|
|
|
|
module FEM_utilities
|
2018-08-30 16:08:44 +05:30
|
|
|
#include <petsc/finclude/petscdmplex.h>
|
2018-09-21 11:49:36 +05:30
|
|
|
#include <petsc/finclude/petscdmda.h>
|
|
|
|
#include <petsc/finclude/petscis.h>
|
2018-08-17 14:53:24 +05:30
|
|
|
use prec, only: pReal, pInt
|
|
|
|
|
2018-08-30 16:08:44 +05:30
|
|
|
use PETScdmplex
|
2018-08-17 14:53:24 +05:30
|
|
|
use PETScdmda
|
|
|
|
use PETScis
|
2018-08-17 03:44:25 +05:30
|
|
|
|
|
|
|
implicit none
|
|
|
|
private
|
|
|
|
!--------------------------------------------------------------------------------------------------
|
|
|
|
!
|
|
|
|
logical, public :: cutBack = .false. !< cut back of BVP solver in case convergence is not achieved or a material point is terminally ill
|
|
|
|
integer(pInt), public, parameter :: maxFields = 6_pInt
|
|
|
|
integer(pInt), public :: nActiveFields = 0_pInt
|
|
|
|
|
|
|
|
!--------------------------------------------------------------------------------------------------
|
|
|
|
! grid related information information
|
|
|
|
real(pReal), public :: wgt !< weighting factor 1/Nelems
|
2018-09-19 22:03:37 +05:30
|
|
|
|
2018-08-17 03:44:25 +05:30
|
|
|
!--------------------------------------------------------------------------------------------------
|
|
|
|
! output data
|
|
|
|
Vec, public :: coordinatesVec
|
|
|
|
!--------------------------------------------------------------------------------------------------
|
|
|
|
! field labels information
|
|
|
|
character(len=*), parameter, public :: &
|
2018-09-19 22:03:37 +05:30
|
|
|
FIELD_MECH_label = 'mechanical'
|
|
|
|
|
2018-08-17 03:44:25 +05:30
|
|
|
enum, bind(c)
|
|
|
|
enumerator :: FIELD_UNDEFINED_ID, &
|
2019-05-12 12:59:51 +05:30
|
|
|
FIELD_MECH_ID
|
2018-08-17 03:44:25 +05:30
|
|
|
end enum
|
|
|
|
enum, bind(c)
|
|
|
|
enumerator :: COMPONENT_UNDEFINED_ID, &
|
|
|
|
COMPONENT_MECH_X_ID, &
|
|
|
|
COMPONENT_MECH_Y_ID, &
|
2019-05-12 12:59:51 +05:30
|
|
|
COMPONENT_MECH_Z_ID
|
2018-08-17 03:44:25 +05:30
|
|
|
end enum
|
|
|
|
|
|
|
|
!--------------------------------------------------------------------------------------------------
|
|
|
|
! variables controlling debugging
|
|
|
|
logical, private :: &
|
|
|
|
debugPETSc !< use some in debug defined options for more verbose PETSc solution
|
|
|
|
|
|
|
|
!--------------------------------------------------------------------------------------------------
|
|
|
|
! derived types
|
|
|
|
type, public :: tSolutionState !< return type of solution from FEM solver variants
|
|
|
|
logical :: converged = .true.
|
|
|
|
logical :: stagConverged = .true.
|
|
|
|
logical :: regrid = .false.
|
|
|
|
integer(pInt) :: iterationsNeeded = 0_pInt
|
|
|
|
end type tSolutionState
|
|
|
|
|
|
|
|
type, public :: tComponentBC
|
|
|
|
integer(kind(COMPONENT_UNDEFINED_ID)) :: ID
|
|
|
|
real(pReal), allocatable :: Value(:)
|
|
|
|
logical, allocatable :: Mask(:)
|
|
|
|
end type tComponentBC
|
|
|
|
|
|
|
|
type, public :: tFieldBC
|
|
|
|
integer(kind(FIELD_UNDEFINED_ID)) :: ID
|
|
|
|
integer(pInt) :: nComponents = 0_pInt
|
|
|
|
type(tComponentBC), allocatable :: componentBC(:)
|
|
|
|
end type tFieldBC
|
|
|
|
|
|
|
|
type, public :: tLoadCase
|
|
|
|
real(pReal) :: time = 0.0_pReal !< length of increment
|
|
|
|
integer(pInt) :: incs = 0_pInt, & !< number of increments
|
|
|
|
outputfrequency = 1_pInt, & !< frequency of result writes
|
|
|
|
restartfrequency = 0_pInt, & !< frequency of restart writes
|
|
|
|
logscale = 0_pInt !< linear/logarithmic time inc flag
|
|
|
|
logical :: followFormerTrajectory = .true. !< follow trajectory of former loadcase
|
|
|
|
integer(pInt), allocatable :: faceID(:)
|
|
|
|
type(tFieldBC), allocatable :: fieldBC(:)
|
|
|
|
end type tLoadCase
|
|
|
|
|
|
|
|
type, public :: tFEMInterpolation
|
|
|
|
integer(pInt) :: n
|
|
|
|
real(pReal), dimension(:,:) , allocatable :: shapeFunc, shapeDerivReal, geomShapeDerivIso
|
|
|
|
real(pReal), dimension(:,:,:), allocatable :: shapeDerivIso
|
|
|
|
end type tFEMInterpolation
|
|
|
|
|
|
|
|
type, public :: tQuadrature
|
|
|
|
integer(pInt) :: n
|
|
|
|
real(pReal), dimension(:) , allocatable :: Weights
|
|
|
|
real(pReal), dimension(:,:), allocatable :: Points
|
|
|
|
end type tQuadrature
|
|
|
|
|
|
|
|
public :: &
|
|
|
|
utilities_init, &
|
|
|
|
utilities_constitutiveResponse, &
|
|
|
|
utilities_projectBCValues, &
|
|
|
|
FIELD_MECH_ID, &
|
|
|
|
COMPONENT_MECH_X_ID, &
|
|
|
|
COMPONENT_MECH_Y_ID, &
|
2019-05-12 12:59:51 +05:30
|
|
|
COMPONENT_MECH_Z_ID
|
2018-08-17 03:44:25 +05:30
|
|
|
|
|
|
|
contains
|
|
|
|
|
|
|
|
!--------------------------------------------------------------------------------------------------
|
|
|
|
!> @brief allocates all neccessary fields, sets debug flags
|
|
|
|
!--------------------------------------------------------------------------------------------------
|
2019-05-12 12:59:51 +05:30
|
|
|
subroutine utilities_init
|
2018-08-17 03:44:25 +05:30
|
|
|
use numerics, only: &
|
2018-09-20 11:56:59 +05:30
|
|
|
structOrder, &
|
2018-08-17 03:44:25 +05:30
|
|
|
petsc_defaultOptions, &
|
2018-08-17 14:53:24 +05:30
|
|
|
petsc_options
|
2018-08-17 03:44:25 +05:30
|
|
|
use debug, only: &
|
|
|
|
debug_level, &
|
|
|
|
debug_SPECTRAL, &
|
2019-05-12 12:59:51 +05:30
|
|
|
debug_SPECTRALPETSC,&
|
2018-08-17 03:44:25 +05:30
|
|
|
PETSCDEBUG
|
|
|
|
use math ! must use the whole module for use of FFTW
|
|
|
|
use mesh, only: &
|
|
|
|
mesh_NcpElemsGlobal, &
|
|
|
|
mesh_maxNips, &
|
2018-08-18 17:35:57 +05:30
|
|
|
geomMesh
|
2018-08-17 03:44:25 +05:30
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
2018-09-20 00:09:49 +05:30
|
|
|
character(len=1024) :: petsc_optionsPhysics
|
2018-08-17 03:44:25 +05:30
|
|
|
PetscErrorCode :: ierr
|
|
|
|
|
2018-08-18 17:35:57 +05:30
|
|
|
write(6,'(/,a)') ' <<<+- DAMASK_FEM_utilities init -+>>>'
|
2018-08-17 03:44:25 +05:30
|
|
|
|
|
|
|
!--------------------------------------------------------------------------------------------------
|
|
|
|
! set debugging parameters
|
|
|
|
debugPETSc = iand(debug_level(debug_SPECTRAL),debug_SPECTRALPETSC) /= 0
|
|
|
|
if(debugPETSc) write(6,'(3(/,a),/)') &
|
|
|
|
' Initializing PETSc with debug options: ', &
|
|
|
|
trim(PETScDebug), &
|
|
|
|
' add more using the PETSc_Options keyword in numerics.config '
|
|
|
|
flush(6)
|
2018-08-17 14:53:24 +05:30
|
|
|
call PetscOptionsClear(PETSC_NULL_OPTIONS,ierr)
|
2018-08-17 03:44:25 +05:30
|
|
|
CHKERRQ(ierr)
|
2018-08-17 14:53:24 +05:30
|
|
|
if(debugPETSc) call PetscOptionsInsertString(PETSC_NULL_OPTIONS,trim(PETSCDEBUG),ierr)
|
2018-08-17 03:44:25 +05:30
|
|
|
CHKERRQ(ierr)
|
2018-08-17 14:53:24 +05:30
|
|
|
call PetscOptionsInsertString(PETSC_NULL_OPTIONS,trim(petsc_defaultOptions),ierr)
|
|
|
|
call PetscOptionsInsertString(PETSC_NULL_OPTIONS,trim(petsc_options),ierr)
|
2018-08-17 03:44:25 +05:30
|
|
|
CHKERRQ(ierr)
|
2018-09-22 16:21:02 +05:30
|
|
|
write(petsc_optionsPhysics,'(a,i0)') '-mechFE_petscspace_degree ' , structOrder
|
2018-08-17 14:53:24 +05:30
|
|
|
call PetscOptionsInsertString(PETSC_NULL_OPTIONS,trim(petsc_optionsPhysics),ierr)
|
2018-08-17 03:44:25 +05:30
|
|
|
CHKERRQ(ierr)
|
|
|
|
|
|
|
|
wgt = 1.0/real(mesh_maxNips*mesh_NcpElemsGlobal,pReal)
|
|
|
|
|
|
|
|
|
|
|
|
end subroutine utilities_init
|
|
|
|
|
|
|
|
!--------------------------------------------------------------------------------------------------
|
|
|
|
!> @brief calculates constitutive response
|
|
|
|
!--------------------------------------------------------------------------------------------------
|
|
|
|
subroutine utilities_constitutiveResponse(timeinc,P_av,forwardData)
|
|
|
|
use math, only: &
|
|
|
|
math_det33
|
|
|
|
use FEsolving, only: &
|
|
|
|
restartWrite
|
|
|
|
use homogenization, only: &
|
|
|
|
materialpoint_P, &
|
2018-08-17 14:53:24 +05:30
|
|
|
materialpoint_stressAndItsTangent
|
2018-08-17 03:44:25 +05:30
|
|
|
|
|
|
|
implicit none
|
|
|
|
real(pReal), intent(in) :: timeinc !< loading time
|
|
|
|
logical, intent(in) :: forwardData !< age results
|
|
|
|
|
|
|
|
real(pReal),intent(out), dimension(3,3) :: P_av !< average PK stress
|
|
|
|
|
|
|
|
logical :: &
|
|
|
|
age
|
|
|
|
|
|
|
|
PetscErrorCode :: ierr
|
|
|
|
|
2018-08-20 20:37:20 +05:30
|
|
|
write(6,'(/,a)') ' ... evaluating constitutive response ......................................'
|
2018-08-17 03:44:25 +05:30
|
|
|
|
|
|
|
age = .False.
|
|
|
|
if (forwardData) then ! aging results
|
|
|
|
age = .True.
|
|
|
|
endif
|
|
|
|
if (cutBack) then ! restore saved variables
|
|
|
|
age = .False.
|
|
|
|
endif
|
|
|
|
|
2018-08-17 14:53:24 +05:30
|
|
|
call materialpoint_stressAndItsTangent(.true.,timeinc) ! calculate P field
|
|
|
|
|
2018-08-17 03:44:25 +05:30
|
|
|
restartWrite = .false. ! reset restartWrite status
|
|
|
|
cutBack = .false. ! reset cutBack status
|
|
|
|
|
|
|
|
P_av = sum(sum(materialpoint_P,dim=4),dim=3) * wgt ! average of P
|
|
|
|
call MPI_Allreduce(MPI_IN_PLACE,P_av,9,MPI_DOUBLE,MPI_SUM,PETSC_COMM_WORLD,ierr)
|
|
|
|
|
|
|
|
end subroutine utilities_constitutiveResponse
|
|
|
|
|
2019-03-09 03:53:07 +05:30
|
|
|
|
2018-08-17 03:44:25 +05:30
|
|
|
!--------------------------------------------------------------------------------------------------
|
|
|
|
!> @brief Project BC values to local vector
|
|
|
|
!--------------------------------------------------------------------------------------------------
|
|
|
|
subroutine utilities_projectBCValues(localVec,section,field,comp,bcPointsIS,BCValue,BCDotValue,timeinc)
|
|
|
|
|
|
|
|
implicit none
|
|
|
|
|
|
|
|
Vec :: localVec
|
|
|
|
PetscInt :: field, comp, nBcPoints, point, dof, numDof, numComp, offset
|
|
|
|
PetscSection :: section
|
|
|
|
IS :: bcPointsIS
|
|
|
|
PetscInt, pointer :: bcPoints(:)
|
|
|
|
PetscScalar, pointer :: localArray(:)
|
|
|
|
PetscScalar :: BCValue,BCDotValue,timeinc
|
|
|
|
PetscErrorCode :: ierr
|
|
|
|
|
|
|
|
call PetscSectionGetFieldComponents(section,field,numComp,ierr); CHKERRQ(ierr)
|
|
|
|
call ISGetSize(bcPointsIS,nBcPoints,ierr); CHKERRQ(ierr)
|
|
|
|
if (nBcPoints > 0) call ISGetIndicesF90(bcPointsIS,bcPoints,ierr)
|
|
|
|
call VecGetArrayF90(localVec,localArray,ierr); CHKERRQ(ierr)
|
|
|
|
do point = 1, nBcPoints
|
|
|
|
call PetscSectionGetFieldDof(section,bcPoints(point),field,numDof,ierr)
|
|
|
|
CHKERRQ(ierr)
|
|
|
|
call PetscSectionGetFieldOffset(section,bcPoints(point),field,offset,ierr)
|
|
|
|
CHKERRQ(ierr)
|
|
|
|
do dof = offset+comp+1, offset+numDof, numComp
|
2018-09-23 06:44:23 +05:30
|
|
|
localArray(dof) = localArray(dof) + BCValue + BCDotValue*timeinc
|
2018-08-17 03:44:25 +05:30
|
|
|
enddo
|
|
|
|
enddo
|
|
|
|
call VecRestoreArrayF90(localVec,localArray,ierr); CHKERRQ(ierr)
|
|
|
|
call VecAssemblyBegin(localVec, ierr); CHKERRQ(ierr)
|
|
|
|
call VecAssemblyEnd (localVec, ierr); CHKERRQ(ierr)
|
|
|
|
if (nBcPoints > 0) call ISRestoreIndicesF90(bcPointsIS,bcPoints,ierr)
|
|
|
|
|
|
|
|
end subroutine utilities_projectBCValues
|
|
|
|
|
|
|
|
end module FEM_utilities
|