From 5b66db8a394ffe34b303039fe8cd17b370e60a30 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Thu, 22 Jul 2021 10:12:43 +0200 Subject: [PATCH] only mechanics at the moment will be extended, but most likely differently --- src/mesh/DAMASK_mesh.f90 | 113 ++++++++++++------------------------- src/mesh/FEM_utilities.f90 | 8 +-- 2 files changed, 41 insertions(+), 80 deletions(-) diff --git a/src/mesh/DAMASK_mesh.f90 b/src/mesh/DAMASK_mesh.f90 index d1568e87f..a8446d9fa 100644 --- a/src/mesh/DAMASK_mesh.f90 +++ b/src/mesh/DAMASK_mesh.f90 @@ -21,7 +21,6 @@ program DAMASK_mesh use mesh_mechanical_FEM implicit none - integer :: nActiveFields = 0 type :: tLoadCase real(pReal) :: time = 0.0_pReal !< length of increment @@ -78,7 +77,7 @@ program DAMASK_mesh type(tLoadCase), allocatable, dimension(:) :: loadCases !< array of all load cases type(tSolutionState), allocatable, dimension(:) :: solres - PetscInt :: faceSet, currentFaceSet, field, dimPlex + PetscInt :: faceSet, currentFaceSet, dimPlex PetscErrorCode :: ierr integer(kind(COMPONENT_UNDEFINED_ID)) :: ID external :: & @@ -101,8 +100,7 @@ program DAMASK_mesh ! reading basic information from load case file and allocate data structure containing load cases call DMGetDimension(geomMesh,dimPlex,ierr) !< dimension of mesh (2D or 3D) CHKERRA(ierr) - nActiveFields = 1 - allocate(solres(nActiveFields)) + allocate(solres(1)) !-------------------------------------------------------------------------------------------------- ! reading basic information from load case file and allocate data structure containing load cases @@ -124,32 +122,26 @@ program DAMASK_mesh allocate(loadCases(N_def)) do i = 1, size(loadCases) - allocate(loadCases(i)%fieldBC(nActiveFields)) - field = 1 - loadCases(i)%fieldBC(field)%ID = FIELD_MECH_ID + allocate(loadCases(i)%fieldBC(1)) + loadCases(i)%fieldBC(1)%ID = FIELD_MECH_ID enddo do i = 1, size(loadCases) - do field = 1, nActiveFields - select case (loadCases(i)%fieldBC(field)%ID) - case(FIELD_MECH_ID) - loadCases(i)%fieldBC(field)%nComponents = dimPlex !< X, Y (, Z) displacements - allocate(loadCases(i)%fieldBC(field)%componentBC(loadCases(i)%fieldBC(field)%nComponents)) - do component = 1, loadCases(i)%fieldBC(field)%nComponents - select case (component) - case (1) - loadCases(i)%fieldBC(field)%componentBC(component)%ID = COMPONENT_MECH_X_ID - case (2) - loadCases(i)%fieldBC(field)%componentBC(component)%ID = COMPONENT_MECH_Y_ID - case (3) - loadCases(i)%fieldBC(field)%componentBC(component)%ID = COMPONENT_MECH_Z_ID - end select - enddo + loadCases(i)%fieldBC(1)%nComponents = dimPlex !< X, Y (, Z) displacements + allocate(loadCases(i)%fieldBC(1)%componentBC(loadCases(i)%fieldBC(1)%nComponents)) + do component = 1, loadCases(i)%fieldBC(1)%nComponents + select case (component) + case (1) + loadCases(i)%fieldBC(1)%componentBC(component)%ID = COMPONENT_MECH_X_ID + case (2) + loadCases(i)%fieldBC(1)%componentBC(component)%ID = COMPONENT_MECH_Y_ID + case (3) + loadCases(i)%fieldBC(1)%componentBC(component)%ID = COMPONENT_MECH_Z_ID end select - do component = 1, loadCases(i)%fieldBC(field)%nComponents - allocate(loadCases(i)%fieldBC(field)%componentBC(component)%Value(mesh_Nboundaries), source = 0.0_pReal) - allocate(loadCases(i)%fieldBC(field)%componentBC(component)%Mask (mesh_Nboundaries), source = .false.) - enddo + enddo + do component = 1, loadCases(i)%fieldBC(1)%nComponents + allocate(loadCases(i)%fieldBC(1)%componentBC(component)%Value(mesh_Nboundaries), source = 0.0_pReal) + allocate(loadCases(i)%fieldBC(1)%componentBC(component)%Mask (mesh_Nboundaries), source = .false.) enddo enddo @@ -194,16 +186,12 @@ program DAMASK_mesh ID = COMPONENT_MECH_Z_ID end select - do field = 1, nActiveFields - if (loadCases(currentLoadCase)%fieldBC(field)%ID == FIELD_MECH_ID) then - do component = 1, loadcases(currentLoadCase)%fieldBC(field)%nComponents - if (loadCases(currentLoadCase)%fieldBC(field)%componentBC(component)%ID == ID) then - loadCases(currentLoadCase)%fieldBC(field)%componentBC(component)%Mask (currentFaceSet) = & - .true. - loadCases(currentLoadCase)%fieldBC(field)%componentBC(component)%Value(currentFaceSet) = & - IO_floatValue(line,chunkPos,i+1) - endif - enddo + do component = 1, loadcases(currentLoadCase)%fieldBC(1)%nComponents + if (loadCases(currentLoadCase)%fieldBC(1)%componentBC(component)%ID == ID) then + loadCases(currentLoadCase)%fieldBC(1)%componentBC(component)%Mask (currentFaceSet) = & + .true. + loadCases(currentLoadCase)%fieldBC(1)%componentBC(component)%Value(currentFaceSet) = & + IO_floatValue(line,chunkPos,i+1) endif enddo end select @@ -219,21 +207,16 @@ program DAMASK_mesh print'(a,i0)', ' load case: ', currentLoadCase if (.not. loadCases(currentLoadCase)%followFormerTrajectory) & print'(a)', ' drop guessing along trajectory' - do field = 1, nActiveFields - select case (loadCases(currentLoadCase)%fieldBC(field)%ID) - case(FIELD_MECH_ID) - print'(a)', ' Field '//trim(FIELD_MECH_label) + print'(a)', ' Field '//trim(FIELD_MECH_label) - end select - do faceSet = 1, mesh_Nboundaries - do component = 1, loadCases(currentLoadCase)%fieldBC(field)%nComponents - if (loadCases(currentLoadCase)%fieldBC(field)%componentBC(component)%Mask(faceSet)) & - print'(a,i2,a,i2,a,f12.7)', ' Face ', mesh_boundaries(faceSet), & - ' Component ', component, & - ' Value ', loadCases(currentLoadCase)%fieldBC(field)% & - componentBC(component)%Value(faceSet) - enddo - enddo + do faceSet = 1, mesh_Nboundaries + do component = 1, loadCases(currentLoadCase)%fieldBC(1)%nComponents + if (loadCases(currentLoadCase)%fieldBC(1)%componentBC(component)%Mask(faceSet)) & + print'(a,i2,a,i2,a,f12.7)', ' Face ', mesh_boundaries(faceSet), & + ' Component ', component, & + ' Value ', loadCases(currentLoadCase)%fieldBC(1)% & + componentBC(component)%Value(faceSet) + enddo enddo print'(a,f12.6)', ' time: ', loadCases(currentLoadCase)%time if (loadCases(currentLoadCase)%incs < 1) errorID = 835 ! non-positive incs count @@ -247,12 +230,7 @@ program DAMASK_mesh !-------------------------------------------------------------------------------------------------- ! doing initialization depending on active solvers call FEM_Utilities_init - do field = 1, nActiveFields - select case (loadCases(1)%fieldBC(field)%ID) - case(FIELD_MECH_ID) - call FEM_mechanical_init(loadCases(1)%fieldBC(field)) - end select - enddo + call FEM_mechanical_init(loadCases(1)%fieldBC(1)) if (worldrank == 0) then open(newunit=statUnit,file=trim(getSolverJobName())//'.sta',form='FORMATTED',status='REPLACE') @@ -295,33 +273,16 @@ program DAMASK_mesh '-',stepFraction, '/', subStepFactor**cutBackLevel flush(IO_STDOUT) -!-------------------------------------------------------------------------------------------------- -! forward fields - do field = 1, nActiveFields - select case (loadCases(currentLoadCase)%fieldBC(field)%ID) - case(FIELD_MECH_ID) - call FEM_mechanical_forward (& - guess,timeinc,timeIncOld,loadCases(currentLoadCase)%fieldBC(field)) - - end select - enddo + call FEM_mechanical_forward(guess,timeinc,timeIncOld,loadCases(currentLoadCase)%fieldBC(1)) !-------------------------------------------------------------------------------------------------- ! solve fields stagIter = 0 stagIterate = .true. do while (stagIterate) - do field = 1, nActiveFields - select case (loadCases(currentLoadCase)%fieldBC(field)%ID) - case(FIELD_MECH_ID) - solres(field) = FEM_mechanical_solution (& - incInfo,timeinc,timeIncOld,loadCases(currentLoadCase)%fieldBC(field)) + solres(1) = FEM_mechanical_solution(incInfo,timeinc,timeIncOld,loadCases(currentLoadCase)%fieldBC(1)) + if(.not. solres(1)%converged) exit - end select - - if(.not. solres(field)%converged) exit ! no solution found - - enddo stagIter = stagIter + 1 stagIterate = stagIter < stagItMax & .and. all(solres(:)%converged) & diff --git a/src/mesh/FEM_utilities.f90 b/src/mesh/FEM_utilities.f90 index 319997ad6..64bcc3896 100644 --- a/src/mesh/FEM_utilities.f90 +++ b/src/mesh/FEM_utilities.f90 @@ -53,15 +53,15 @@ module FEM_utilities end type tSolutionState type, public :: tComponentBC - integer(kind(COMPONENT_UNDEFINED_ID)) :: ID - real(pReal), allocatable, dimension(:) :: Value - logical, allocatable, dimension(:) :: Mask + integer(kind(COMPONENT_UNDEFINED_ID)) :: ID + real(pReal), allocatable, dimension(:) :: Value + logical, allocatable, dimension(:) :: Mask end type tComponentBC type, public :: tFieldBC integer(kind(FIELD_UNDEFINED_ID)) :: ID integer :: nComponents = 0 - type(tComponentBC), allocatable :: componentBC(:) + type(tComponentBC), allocatable, dimension(:) :: componentBC end type tFieldBC public :: &