avoid code duplication

This commit is contained in:
Martin Diehl 2020-01-21 07:46:32 +01:00
parent a18057ba4d
commit 1a31ff82bb
2 changed files with 24 additions and 40 deletions

View File

@ -66,7 +66,7 @@ program DAMASK_FEM
PetscInt :: faceSet, currentFaceSet PetscInt :: faceSet, currentFaceSet
PetscInt :: field, dimPlex PetscInt :: field, dimPlex
PetscErrorCode :: ierr PetscErrorCode :: ierr
integer(kind(COMPONENT_UNDEFINED_ID)) :: ID
external :: & external :: &
quit quit
@ -166,45 +166,28 @@ program DAMASK_FEM
!-------------------------------------------------------------------------------------------------- !--------------------------------------------------------------------------------------------------
! boundary condition information ! boundary condition information
case('x') ! X displacement field case('x','y','z')
do field = 1, nActiveFields select case(IO_lc(IO_stringValue(line,chunkPos,i)))
if (loadCases(currentLoadCase)%fieldBC(field)%ID == FIELD_MECH_ID) then case('x')
do component = 1, loadcases(currentLoadCase)%fieldBC(field)%nComponents ID = COMPONENT_MECH_X_ID
if (loadCases(currentLoadCase)%fieldBC(field)%componentBC(component)%ID == COMPONENT_MECH_X_ID) then case('y')
loadCases(currentLoadCase)%fieldBC(field)%componentBC(component)%Mask (currentFaceSet) = & ID = COMPONENT_MECH_Y_ID
.true. case('z')
loadCases(currentLoadCase)%fieldBC(field)%componentBC(component)%Value(currentFaceSet) = & ID = COMPONENT_MECH_Z_ID
IO_floatValue(line,chunkPos,i+1) end select
endif
enddo do field = 1, nActiveFields
endif if (loadCases(currentLoadCase)%fieldBC(field)%ID == FIELD_MECH_ID) then
enddo do component = 1, loadcases(currentLoadCase)%fieldBC(field)%nComponents
case('y') ! Y displacement field if (loadCases(currentLoadCase)%fieldBC(field)%componentBC(component)%ID == ID) then
do field = 1, nActiveFields loadCases(currentLoadCase)%fieldBC(field)%componentBC(component)%Mask (currentFaceSet) = &
if (loadCases(currentLoadCase)%fieldBC(field)%ID == FIELD_MECH_ID) then .true.
do component = 1, loadcases(currentLoadCase)%fieldBC(field)%nComponents loadCases(currentLoadCase)%fieldBC(field)%componentBC(component)%Value(currentFaceSet) = &
if (loadCases(currentLoadCase)%fieldBC(field)%componentBC(component)%ID == COMPONENT_MECH_Y_ID) then IO_floatValue(line,chunkPos,i+1)
loadCases(currentLoadCase)%fieldBC(field)%componentBC(component)%Mask (currentFaceSet) = & endif
.true. enddo
loadCases(currentLoadCase)%fieldBC(field)%componentBC(component)%Value(currentFaceSet) = & endif
IO_floatValue(line,chunkPos,i+1) enddo
endif
enddo
endif
enddo
case('z') ! Z displacement field
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 == COMPONENT_MECH_Z_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
endif
enddo
end select end select
enddo; enddo enddo; enddo
close(fileUnit) close(fileUnit)

View File

@ -88,6 +88,7 @@ module FEM_utilities
utilities_constitutiveResponse, & utilities_constitutiveResponse, &
utilities_projectBCValues, & utilities_projectBCValues, &
FIELD_MECH_ID, & FIELD_MECH_ID, &
COMPONENT_UNDEFINED_ID, &
COMPONENT_MECH_X_ID, & COMPONENT_MECH_X_ID, &
COMPONENT_MECH_Y_ID, & COMPONENT_MECH_Y_ID, &
COMPONENT_MECH_Z_ID COMPONENT_MECH_Z_ID