@@ -11,6 +11,7 @@ program DAMASK_mesh
1111 use PetscDM
1212 use prec
1313 use CLI
14+ use IO
1415 use parallelization
1516 use materialpoint
1617 use discretization_mesh
@@ -40,10 +41,11 @@ program DAMASK_mesh
4041 logical :: &
4142 guess, & ! < guess along former trajectory
4243 stagIterate
44+ logical , allocatable , dimension (:) :: &
45+ read_BC_entries
4346 integer :: &
4447 l, &
4548 m, &
46- errorID, &
4749 cutBackLevel = 0 , & ! < cut back level \f$ t = \frac{t_{inc}}{2^l} \f$
4850 stepFraction = 0 , & ! < fraction of current time interval
4951 inc, & ! < current increment in current load case
@@ -64,32 +66,29 @@ program DAMASK_mesh
6466 mech_u, &
6567 step_mech
6668 character (len= pSTRLEN) :: &
67- incInfo, &
68- loadcase_string
69+ incInfo
6970 integer :: &
71+ bc_tag, &
7072 stagItMax, & ! < max number of field level staggered iterations
7173 maxCutBack, & ! < max number of cutbacks
72- skipBCTagDigits, & ! < number of characters to skip to print BC tag (T descriptor)
73- BCTag ! < tag value read from YAML load file
74- integer , allocatable , dimension (:) :: &
75- knownBCTags ! < array of read BC tags (check for duplicates)
76-
74+ skip_T1, skip_T2 ! < number of characters to skip (T descriptor)
7775
7876 type (tLoadCase), allocatable , dimension (:) :: loadCases ! < array of all load cases
7977 type (tSolutionState), allocatable , dimension (:) :: solres
8078 PetscInt :: boundary, dimPlex
8179 PetscErrorCode :: err_PETSc
8280 character (len= :), allocatable :: &
83- fileContent, fname, tagPrintFormat
84- character (len= 6 ) :: BC_elem
81+ fileContent, fname
82+ character (len= pSTRLEN) :: &
83+ bc_label_name
8584
8685
8786!- -------------------------------------------------------------------------------------------------
8887! init DAMASK (all modules)
8988 call materialpoint_initAll()
9089 print ' (/,1x,a)' , ' <<<+- DAMASK_mesh init -+>>>' ; flush(IO_STDOUT)
9190
92- !- --------------------------------------------------------------------
91+ !- -------------------------------------------------------------------------------------------------
9392! reading field information from numerics file and do sanity checks
9493 num_solver = > config_numerics% get_dict(' solver' ,defaultVal= emptyDict)
9594 num_mesh = > num_solver% get_dict(' mesh' ,defaultVal= emptyDict)
@@ -99,8 +98,10 @@ program DAMASK_mesh
9998 if (stagItMax < 0 ) call IO_error(301 ,ext_msg= ' N_staggered_iter_max' )
10099 if (maxCutBack < 0 ) call IO_error(301 ,ext_msg= ' N_cutback_max' )
101100
102- ! reading basic information from load case file and allocate data structure containing load cases
103- call DMGetDimension(geomMesh,dimPlex,err_PETSc) ! < dimension of mesh (2D or 3D)
101+ !- -------------------------------------------------------------------------------------------------
102+ ! reading basic information from load case file, allocate data structure containing load cases
103+ ! and some checks for invalid tags/labels use
104+ call DMGetDimension(geomMesh,dimPlex,err_PETSc) ! dimension of mesh (2D or 3D)
104105 CHKERRA(err_PETSc)
105106 allocate (solres(1 ))
106107
@@ -117,31 +118,45 @@ program DAMASK_mesh
117118 load = > YAML_str_asDict(fileContent)
118119 load_steps = > load% get_list(' loadstep' )
119120
121+ allocate (read_BC_entries(mesh_nBoundaries), source = .false. )
120122 allocate (loadCases(size (load_steps)))
121123 do l = 1 , size (load_steps)
122124 load_step = > load_steps% get_dict(l)
123125 step_bc = > load_step% get_dict(' boundary_conditions' )
124126 step_mech = > step_bc% get_list(' mechanical' )
125127 allocate (loadCases(l)% mechBC(mesh_Nboundaries))
126- loadCases(l)% mechBC(:)% nComponents = dimPlex ! < X, Y (, Z) displacements
128+ loadCases(l)% mechBC(:)% nComponents = dimPlex ! X, Y (, Z) displacements
127129 do boundary = 1_pPETSCINT , mesh_Nboundaries
128130 allocate (loadCases(l)% mechBC(boundary)% dot_u(dimPlex), source = 0.0_pREAL )
129131 allocate (loadCases(l)% mechBC(boundary)% active(dimPlex), source = .false. )
130132 end do
131133
132- allocate (knownBCTags(size (step_mech)), source = - 1 )
133134 do m = 1 , size (step_mech)
134135 mech_BC = > step_mech% get_dict(m)
135- BCTag = mech_BC% get_asInt(' tag' )
136- boundary = findloc(mesh_boundariesIS, BCtag, dim = 1 )
137- if (boundary == 0 ) then ! < tag not defined in mesh file
138- call IO_error(error_ID = 837 , ext_msg = ' BC tag ' // mech_BC% get_asStr(' tag' )// &
139- ' refers to inexistent node/edge/face mesh group' )
140- else if (findloc(knownBCTags, BCTag, dim = 1 ) /= 0 ) then ! < duplicated tag
141- call IO_error(error_ID = 837 , ext_msg = ' BC redefinition not allowed (tag ' // &
142- mech_BC% get_asStr(' tag' )// ' )' )
136+ if (mech_BC% contains (' label' )) then
137+ bc_label_name = mech_BC% get_asStr(' label' )
138+ boundary = findloc(mesh_BCLabels, bc_label_name, dim = 1 )
139+ if (boundary == 0 ) & ! label not defined in mesh file
140+ call IO_error(812_pI16 , ' label' , trim (bc_label_name), ' not defined' , emph = [2 ])
141+ if (read_BC_entries(boundary)) & ! duplicated label/tag
142+ call IO_error(812_pI16 , ' duplicated entries: label' , trim (bc_label_name), " and tag" , &
143+ mesh_boundariesIS(boundary), emph = [2 ,4 ])
144+ read_BC_entries(boundary) = .true.
145+ loadCases(l)% mechBC(boundary)% use_label = .true.
146+ else if (mech_BC% contains (' tag' )) then
147+ bc_tag = mech_BC% get_asInt(' tag' )
148+ boundary = findloc(mesh_boundariesIS, bc_tag, dim = 1 )
149+ if (boundary == 0 ) & ! tag not defined in mesh file
150+ call IO_error(812_pI16 , ' tag' , bc_tag, ' not defined' , emph = [2 ])
151+ if (read_BC_entries(boundary)) & ! duplicated tag/label
152+ call IO_error(812_pI16 , ' duplicated entries: tag' , bc_tag, ' and label' , &
153+ trim (mesh_BCLabels(boundary)), emph = [2 , 4 ])
154+ read_BC_entries(boundary) = .true.
155+ loadCases(l)% mechBC(boundary)% use_label = .false.
156+ else
157+ call IO_error(837_pI16 , ' entry' // IO_intAsStr(m)// ' : at least one of &
158+ & "tag/label" required' )
143159 end if
144- knownBCTags(m) = BCTag
145160 mech_u = > mech_BC% get_list(' dot_u' )
146161 do component = 1 , dimPlex
147162 if (mech_u% get_asStr(component) /= ' x' ) then
@@ -150,7 +165,7 @@ program DAMASK_mesh
150165 end if
151166 end do
152167 end do
153- deallocate (knownBCTags)
168+ read_BC_entries = .false.
154169
155170 step_discretization = > load_step% get_dict(' discretization' )
156171 loadCases(l)% t = step_discretization% get_asReal(' t' )
@@ -163,38 +178,45 @@ program DAMASK_mesh
163178 end if
164179 loadCases(l)% estimate_rate = (load_step% get_asBool(' estimate_rate' ,defaultVal= .true. ) .and. l> 1 )
165180 end do
181+ deallocate (read_BC_entries)
166182
167183!- -------------------------------------------------------------------------------------------------
168- ! consistency checks and output of load case
169- errorID = 0
170- skipBCTagDigits = 4+6+1 + floor (log10 (real (maxval (mesh_boundariesIS))))+ 1+2 ! < Indentation(4)+BC_elem(6)+blank(1)+descriptor T(1)+NumDigits(floor(..)+1)+2(start printing after 1 blank)
171- allocate (character (len= skipBCTagDigits) :: tagPrintFormat)
172- write (tagPrintFormat,' (i0)' ) skipBCTagDigits
184+ ! loadcase parameters checks and output of load case information
185+ skip_T1 = 4 + max (len (PETSC_GENERIC_LABELS), maxval (len_trim (mesh_BCLabels)))+ 2 ! indentation(4)+length_longest_label+blank
186+ skip_T2 = skip_T1+1 + floor (log10 (real (maxval (mesh_boundariesIS))))+ 1+1+1 ! T1+"("+NumDigits(floor()+1)+")"+blank
173187 checkLoadcases: do l = 1 , size (load_steps)
174- write (loadcase_string, ' (i0)' ) l
188+ if (loadCases(l)% N < 1 ) &
189+ call IO_error(813_pI16 , ' loadcase' , IO_intAsStr(l)// ' :' , ' N' , &
190+ ' must be positive' , emph = [3 ])
191+ if (loadCases(l)% f_out < 1 ) &
192+ call IO_error(813_pI16 , ' loadcase' , IO_intAsStr(l)// ' :' , ' f_out' , &
193+ ' must be positive' , emph = [3 ])
194+
175195 print ' (/,1x,a,1x,i0)' , ' load case:' , l
176- if (.not. loadCases(l)% estimate_rate) &
177- print ' (2x,a)' , ' drop guessing along trajectory'
196+ if (.not. loadCases(l)% estimate_rate) print ' (2x,a)' , ' drop guessing along trajectory'
178197 print ' (2x,a)' , ' Field ' // trim (FIELD_MECH_label)
179198
180199 do boundary = 1_pPETSCINT , mesh_Nboundaries
181- BC_elem = merge (' Vertex' , merge (' Edge ' , ' Face ' , dimplex == 2_pPETSCINT ), &
182- mesh_boundariesIdx(boundary) == mesh_BCTypeVertex)
200+ if (loadCases(l)% mechBC(boundary)% use_label) then
201+ bc_label_name = trim (mesh_BCLabels(boundary))
202+ else
203+ m = mesh_boundariesIdx(boundary)
204+ if (dimPlex == 2_pPETSCINT .and. m < 4 ) m = m + 1
205+ bc_label_name = PETSC_GENERIC_LABELS(m)
206+ end if
183207 do component = 1_pPETSCINT , dimPlex
184208 if (loadCases(l)% mechBC(boundary)% active(component)) &
185- print ' (4x,a,1x,i0,T' // tagPrintFormat// ' ,a,1x,i1,1x,a,1x,f12.7)' , &
186- BC_elem, mesh_boundariesIS(boundary), &
187- ' Component' , component, &
188- ' Value' , loadCases(l)% mechBC(boundary)% dot_u(component)
209+ print ' (4x,a,T' // IO_intAsStr(skip_T1)// ' ,a,i0,a,' // &
210+ ' T' // IO_intAsStr(skip_T2)// ' ,a,1x,i1,1x,a,1x,f12.7)' , &
211+ trim (bc_label_name), " (" , mesh_boundariesIS(boundary), " )" , &
212+ ' Component' , component, &
213+ ' Value' , loadCases(l)% mechBC(boundary)% dot_u(component)
189214 end do
190215 end do
191216
192- print ' (2x,a,T21,g0.6)' , ' time:' , loadCases(l)% t
193- if (loadCases(l)% N < 1 ) errorID = 835 ! non-positive incs count
194- print ' (2x,a,T21,i0)' , ' increments:' , loadCases(l)% N
195- if (loadCases(l)% f_out < 1 ) errorID = 836 ! non-positive result frequency
217+ print ' (2x,a,T21,g0.6)' , ' time:' , loadCases(l)% t
218+ print ' (2x,a,T21,i0)' , ' increments:' , loadCases(l)% N
196219 print ' (2x,a,T21,i0)' , ' output frequency:' , loadCases(l)% f_out
197- if (errorID > 0 ) call IO_error(error_ID = errorID, ext_msg = loadcase_string) ! exit with error message
198220 end do checkLoadcases
199221
200222!- -------------------------------------------------------------------------------------------------
@@ -213,8 +235,8 @@ program DAMASK_mesh
213235 call materialpoint_result(0 ,0.0_pREAL )
214236
215237 loadCaseLooping: do l = 1 , size (load_steps)
216- t_0 = t ! load case start time
217- guess = loadCases(l)% estimate_rate ! change of load case? homogeneous guess for the first inc
238+ t_0 = t ! load case start time
239+ guess = loadCases(l)% estimate_rate ! change of load case? homogeneous guess for the first inc
218240
219241 incLooping: do inc = 1 , loadCases(l)% N
220242 totalIncsCounter = totalIncsCounter + 1
@@ -292,7 +314,7 @@ program DAMASK_mesh
292314 print ' (/,1x,a,1x,i0,1x,a)' , ' increment' , totalIncsCounter, ' NOT converged'
293315 end if ; flush(IO_STDOUT)
294316
295- if (mod (inc,loadCases(l)% f_out) == 0 ) then ! at output frequency
317+ if (mod (inc,loadCases(l)% f_out) == 0 ) then ! at output frequency
296318 print ' (/,1x,a)' , ' ... saving results ........................................................'
297319 call FEM_mechanical_updateCoords()
298320 call materialpoint_result(totalIncsCounter,t)
0 commit comments