From 1a31ff82bbd2b9b2035714dcaa8bc6ec93a16276 Mon Sep 17 00:00:00 2001 From: Martin Diehl Date: Tue, 21 Jan 2020 07:46:32 +0100 Subject: [PATCH] avoid code duplication --- src/mesh/DAMASK_FEM.f90 | 63 ++++++++++++++------------------------ src/mesh/FEM_utilities.f90 | 1 + 2 files changed, 24 insertions(+), 40 deletions(-) diff --git a/src/mesh/DAMASK_FEM.f90 b/src/mesh/DAMASK_FEM.f90 index 9b9b95b91..269296e84 100644 --- a/src/mesh/DAMASK_FEM.f90 +++ b/src/mesh/DAMASK_FEM.f90 @@ -66,7 +66,7 @@ program DAMASK_FEM PetscInt :: faceSet, currentFaceSet PetscInt :: field, dimPlex PetscErrorCode :: ierr - + integer(kind(COMPONENT_UNDEFINED_ID)) :: ID external :: & quit @@ -166,45 +166,28 @@ program DAMASK_FEM !-------------------------------------------------------------------------------------------------- ! boundary condition information - case('x') ! X 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_X_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 - case('y') ! Y 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_Y_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 - 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 + case('x','y','z') + select case(IO_lc(IO_stringValue(line,chunkPos,i))) + case('x') + ID = COMPONENT_MECH_X_ID + case('y') + ID = COMPONENT_MECH_Y_ID + case('z') + 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 + endif + enddo end select enddo; enddo close(fileUnit) diff --git a/src/mesh/FEM_utilities.f90 b/src/mesh/FEM_utilities.f90 index 34cdd7214..cb30f1590 100644 --- a/src/mesh/FEM_utilities.f90 +++ b/src/mesh/FEM_utilities.f90 @@ -88,6 +88,7 @@ module FEM_utilities utilities_constitutiveResponse, & utilities_projectBCValues, & FIELD_MECH_ID, & + COMPONENT_UNDEFINED_ID, & COMPONENT_MECH_X_ID, & COMPONENT_MECH_Y_ID, & COMPONENT_MECH_Z_ID