DAMASK with grid solvers  Revision: v2.0.3-2204-gdb1f2151
The Düsseldorf Advanced Material Simulation Kit with Grid Solvers
discretization_grid.f90
Go to the documentation of this file.
1 # 1 "/home/damask_user/GitLabCI_Pipeline_4301/DAMASK/src/grid/discretization_grid.f90"
2 # 1 "<built-in>"
3 # 1 "<command-line>"
4 # 1 "/home/damask_user/GitLabCI_Pipeline_4301/DAMASK/src/grid/discretization_grid.f90"
5 !--------------------------------------------------------------------------------------------------
10 !--------------------------------------------------------------------------------------------------
12 
13 # 1 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h" 1
14 !
15 !
16 ! Part of the base include file for Fortran use of 1.
17 ! Note: This file should contain only define statements and
18 ! not the declaration of variables.
19 
20 ! No spaces for #defines as some compilers (PGI) also adds
21 ! those additional spaces during preprocessing - bad for fixed format
22 !
23 
24 
25 
26 # 1 "/opt/petsc-3.10.3/Intel-18.4-IntelMPI-2018/include/petscconf.h" 1
27 
28 
29 
30 
31 
32 
33 
34 
35 
36 
37 
38 
39 
40 
41 
42 
43 
44 
45 
46 
47 
48 
49 
50 
51 
52 
53 
54 
55 
56 
57 
58 
59 
60 
61 
62 
63 
64 
65 
66 
67 
68 
69 
70 
71 
72 
73 
74 
75 
76 
77 
78 
79 
80 
81 
82 
83 
84 
85 
86 
87 
88 
89 
90 
91 
92 
93 
94 
95 
96 
97 
98 
99 
100 
101 
102 
103 
104 
105 
106 
107 
108 
109 
110 
111 
112 
113 
114 
115 
116 
117 
118 
119 
120 
121 
122 
123 
124 
125 
126 
127 
128 
129 
130 
131 
132 
133 
134 
135 
136 
137 
138 
139 
140 
141 
142 
143 
144 
145 
146 
147 
148 
149 
150 
151 
152 
153 
154 
155 
156 
157 
158 
159 
160 
161 
162 
163 
164 
165 
166 
167 
168 
169 
170 
171 
172 
173 
174 
175 
176 
177 
178 
179 
180 
181 
182 
183 
184 
185 
186 
187 
188 
189 
190 
191 
192 
193 
194 
195 
196 
197 
198 
199 
200 
201 
202 
203 
204 
205 
206 
207 
208 
209 
210 
211 
212 
213 
214 
215 
216 
217 
218 
219 
220 
221 
222 
223 
224 
225 
226 
227 
228 
229 
230 
231 
232 
233 
234 
235 
236 
237 
238 
239 
240 
241 
242 
243 
244 
245 
246 
247 
248 
249 
250 
251 
252 
253 
254 
255 
256 
257 
258 
259 
260 
261 
262 
263 
264 
265 
266 
267 
268 
269 
270 
271 
272 
273 
274 
275 
276 
277 
278 
279 
280 
281 
282 
283 
284 
285 
286 
287 
288 
289 
290 
291 
292 
293 
294 
295 
296 
297 
298 
299 
300 
301 
302 
303 
304 
305 
306 
307 
308 
309 
310 
311 
312 
313 
314 
315 
316 
317 
318 
319 
320 
321 
322 
323 
324 
325 
326 
327 
328 
329 
330 
331 
332 
333 
334 
335 
336 
337 
338 
339 
340 
341 
342 
343 
344 
345 
346 
347 
348 
349 
350 
351 
352 
353 
354 
355 
356 
357 
358 
359 
360 
361 
362 
363 
364 
365 
366 
367 
368 
369 
370 
371 
372 
373 
374 
375 
376 
377 
378 
379 
380 
381 
382 
383 
384 
385 
386 
387 
388 
389 
390 
391 
392 
393 
394 
395 
396 
397 
398 
399 
400 
401 
402 
403 
404 
405 
406 
407 
408 
409 
410 
411 
412 
413 
414 
415 
416 
417 
418 
419 
420 
421 
422 
423 
424 
425 
426 
427 
428 
429 
430 
431 
432 
433 
434 
435 
436 
437 
438 
439 
440 
441 
442 
443 
444 
445 
446 
447 
448 
449 
450 
451 
452 
453 
454 
455 
456 
457 
458 
459 
460 
461 
462 
463 
464 
465 
466 
467 
468 
469 
470 
471 
472 
473 
474 
475 
476 
477 
478 
479 
480 
481 
482 
483 
484 
485 
486 
487 
488 
489 
490 
491 
492 
493 
494 
495 
496 
497 
498 
499 
500 
501 
502 
503 
504 
505 
506 
507 
508 
509 
510 
511 
512 
513 
514 
515 
516 
517 
518 
519 
520 
521 
522 
523 
524 
525 
526 
527 
528 
529 
530 
531 
532 
533 
534 
535 
536 
537 
538 
539 
540 
541 
542 
543 
544 
545 
546 
547 
548 
549 
550 
551 
552 
553 
554 
555 
556 
557 
558 
559 
560 
561 
562 
563 
564 
565 
566 
567 
568 
569 
570 
571 
572 
573 
574 
575 
576 
577 
578 
579 
580 
581 
582 
583 
584 
585 
586 
587 
588 
589 
590 
591 
592 
593 
594 
595 
596 
597 
598 
599 
600 
601 
602 
603 
604 
605 
606 
607 
608 
609 
610 
611 
612 
613 
614 
615 
616 
617 
618 
619 
620 
621 
622 
623 
624 
625 
626 
627 
628 
629 
630 
631 
632 
633 
634 
635 
636 
637 
638 
639 
640 
641 
642 
643 
644 
645 
646 
647 
648 
649 
650 
651 
652 
653 
654 
655 
656 
657 
658 
659 
660 
661 
662 
663 
664 
665 
666 
667 
668 
669 
670 
671 
672 
673 
674 
675 
676 
677 
678 
679 
680 
681 
682 
683 
684 
685 
686 
687 
688 
689 
690 
691 
692 
693 
694 
695 
696 
697 
698 
699 
700 
701 
702 
703 
704 
705 
706 
707 
708 
709 
710 
711 
712 
713 
714 
715 
716 
717 
718 
719 
720 
721 
722 
723 
724 
725 
726 
727 
728 
729 
730 
731 
732 
733 
734 
735 
736 
737 
738 
739 
740 
741 
742 
743 
744 
745 
746 
747 
748 
749 
750 
751 
752 
753 
754 
755 
756 
757 
758 
759 
760 
761 
762 
763 
764 
765 
766 
767 
768 
769 
770 
771 
772 
773 
774 
775 
776 
777 
778 
779 
780 
781 
782 
783 
784 
785 
786 
787 
788 
789 
790 
791 
792 
793 
794 
795 
796 
797 
798 
799 
800 
801 
802 
803 
804 
805 
806 
807 
808 
809 
810 
811 
812 
813 
814 
815 
816 
817 
818 
819 
820 
821 
822 
823 
824 
825 
826 
827 
828 
829 
830 
831 
832 
833 
834 
835 
836 
837 
838 
839 
840 
841 
842 
843 
844 
845 
846 
847 
848 
849 
850 
851 
852 
853 
854 
855 
856 
857 
858 
859 
860 
861 
862 
863 
864 
865 
866 
867 
868 
869 
870 
871 
872 
873 
874 
875 
876 
877 
878 
879 
880 
881 
882 
883 
884 
885 
886 
887 
888 
889 
890 
891 
892 
893 
894 
895 
896 
897 
898 
899 
900 
901 
902 
903 
904 
905 
906 
907 
908 
909 
910 
911 
912 
913 
914 
915 
916 
917 
918 
919 
920 
921 
922 
923 
924 
925 
926 
927 
928 
929 
930 
931 
932 
933 
934 
935 
936 
937 
938 
939 
940 
941 
942 
943 
944 
945 
946 
947 
948 
949 
950 
951 
952 
953 
954 
955 
956 
957 
958 
959 
960 
961 
962 
963 
964 
965 
966 
967 
968 
969 
970 
971 
972 
973 
974 
975 
976 
977 
978 
979 
980 
981 
982 
983 
984 
985 
986 
987 
988 
989 
990 
991 
992 
993 
994 
995 
996 
997 
998 
999 
1000 
1001 
1002 
1003 
1004 
1005 
1006 
1007 
1008 
1009 
1010 
1011 
1012 
1013 
1014 
1015 
1016 
1017 
1018 
1019 
1020 
1021 
1022 
1023 
1024 
1025 
1026 
1027 
1028 
1029 
1030 
1031 
1032 
1033 
1034 
1035 
1036 
1037 
1038 
1039 
1040 
1041 
1042 
1043 
1044 
1045 
1046 
1047 
1048 
1049 
1050 
1051 
1052 
1053 
1054 
1055 
1056 
1057 
1058 
1059 
1060 
1061 
1062 
1063 
1064 
1065 
1066 
1067 
1068 
1069 
1070 
1071 
1072 
1073 
1074 
1075 
1076 
1077 
1078 
1079 
1080 
1081 
1082 
1083 
1084 
1085 
1086 
1087 
1088 
1089 
1090 
1091 
1092 
1093 
1094 
1095 
1096 
1097 
1098 
1099 
1100 
1101 
1102 
1103 
1104 
1105 
1106 
1107 
1108 
1109 
1110 
1111 
1112 
1113 
1114 
1115 
1116 
1117 
1118 
1119 
1120 
1121 
1122 
1123 
1124 
1125 
1126 
1127 
1128 
1129 
1130 
1131 
1132 
1133 
1134 
1135 
1136 
1137 
1138 
1139 
1140 
1141 
1142 
1143 
1144 
1145 
1146 
1147 
1148 
1149 
1150 
1151 
1152 
1153 
1154 
1155 
1156 
1157 
1158 
1159 
1160 
1161 
1162 
1163 
1164 
1165 
1166 
1167 
1168 
1169 
1170 
1171 
1172 
1173 
1174 
1175 
1176 
1177 
1178 
1179 
1180 
1181 
1182 
1183 
1184 
1185 
1186 
1187 
1188 
1189 
1190 
1191 
1192 
1193 
1194 
1195 
1196 
1197 
1198 
1199 
1200 
1201 
1202 
1203 
1204 
1205 
1206 
1207 
1208 
1209 
1210 
1211 
1212 
1213 
1214 
1215 
1216 
1217 
1218 
1219 
1220 
1221 
1222 
1223 
1224 
1225 
1226 
1227 
1228 
1229 
1230 
1231 
1232 
1233 
1234 # 13 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h" 2
1235 
1236 
1237 
1238 
1239 # 1 "/opt/petsc-3.10.3/include/petscversion.h" 1
1240 
1241 
1242 
1243 
1244 
1245 
1246 
1247 
1248 
1249 
1250 
1251 
1252 
1253 
1254 
1255 
1256 
1257 
1258 
1259 
1260 
1261 
1262 
1263 
1264 
1265 
1266 
1267 
1268 
1269 
1270 
1271 
1272 
1273 
1274 
1275 
1276 
1277 
1278 
1279 
1280 
1281 
1282 
1283 
1284 
1285 # 17 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h" 2
1286 
1287 # 1 "/opt/petsc-3.10.3/include/petsc/finclude/petscviewer.h" 1
1288 !
1289 ! Include file for Fortran use of the PetscViewer package in 1
1290 !
1291 
1292 
1293 
1294 
1295 
1296 
1297 
1298 
1299 
1300 
1301 
1302 
1303 
1304 # 31 "/opt/petsc-3.10.3/include/petsc/finclude/petscviewer.h"
1305 
1306 # 18 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h" 2
1307 
1308 # 1 "/opt/petsc-3.10.3/include/petsc/finclude/petscerror.h" 1
1309 
1310 !
1311 ! Include file for Fortran error codes
1312 ! These are also in include/petscerror.h
1313 !
1314 
1315 
1316 
1317 # 24 "/opt/petsc-3.10.3/include/petsc/finclude/petscerror.h"
1318 
1319 # 38 "/opt/petsc-3.10.3/include/petsc/finclude/petscerror.h"
1320 
1321 
1322 
1323 
1324 
1325 
1326 
1327 
1328 
1329 
1330 
1331 
1332 
1333 
1334 
1335 
1336 # 19 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h" 2
1337 
1338 # 1 "/opt/petsc-3.10.3/include/petsc/finclude/petsclog.h" 1
1339 !
1340 ! No includes needed for logging
1341 # 20 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h" 2
1342 
1343 # 1 "/opt/petsc-3.10.3/include/petsc/finclude/petscbag.h" 1
1344 !
1345 !
1346 ! Include file for Fortran use of the Bag package in 1
1347 !
1348 
1349 
1350 
1351 
1352 
1353 !
1354 ! End of Fortran include file for the IS package in 1
1355 
1356 # 21 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h" 2
1357 
1358 !
1359 ! The real*8,complex*16 notatiton is used so that the
1360 ! 1 double/complex variables are not affected by
1361 ! compiler options like -r4,-r8, sometimes invoked
1362 ! by the user. NAG compiler does not like integer*4,real*8
1363 
1364 # 41 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h"
1365 
1366 
1367 
1368 
1369 
1370 
1371 
1372 
1373 
1374 # 63 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h"
1375 
1376 
1377 
1378 
1379 
1380 
1381 !
1382 
1383 
1384 
1385 
1386 
1387 !
1388 # 85 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h"
1389 !
1390 
1391 
1392 
1393 
1394 
1395 
1396 !
1397 
1398 
1399 
1400 
1401 !
1402 
1403 !
1404 
1405 
1406 !
1407 # 128 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h"
1408 
1409 # 150 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h"
1410 !
1411 ! Macro for templating between real and complex
1412 !
1413 # 174 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h"
1414 
1415 
1416 
1417 
1418 
1419 
1420 
1421 
1422 
1423 !
1424 ! Allows the matrix Fortran Kernels to work with single precision
1425 ! matrix data structures
1426 !
1427 
1428 !
1429 ! PetscLogDouble variables are used to contain double precision numbers
1430 ! that are not used in the numerical computations, but rather in logging,
1431 ! timing etc.
1432 !
1433 
1434 
1435 !
1436 ! Macros for error checking
1437 !
1438 
1439 
1440 
1441 
1442 
1443 
1444 
1445 
1446 # 215 "/opt/petsc-3.10.3/include/petsc/finclude/petscsys.h"
1447 
1448 
1449 
1450 
1451 
1452 
1453 
1454 
1455 
1456 
1457 
1458 
1459 # 9 "/home/damask_user/GitLabCI_Pipeline_4301/DAMASK/src/grid/discretization_grid.f90" 2
1460  use petscsys
1461 
1462  use prec
1463  use system_routines
1464  use damask_interface
1465  use io
1466  use debug
1467  use numerics
1468  use results
1469  use discretization
1471  use fesolving
1472 
1473  implicit none
1474  private
1475 
1476  integer, dimension(3), public, protected :: &
1477  grid
1478  integer, public, protected :: &
1479  grid3, & !< (local) grid in 3rd direction
1480  grid3offset
1481  real(preal), dimension(3), public, protected :: &
1482  geomsize
1483  real(preal), public, protected :: &
1484  size3, & !< (local) size in 3rd direction
1485  size3offset
1486 
1487  public :: &
1489 
1490 contains
1491 
1492 
1493 !--------------------------------------------------------------------------------------------------
1495 !--------------------------------------------------------------------------------------------------
1496 subroutine discretization_grid_init
1498  include 'fftw3-mpi.f03'
1499  real(preal), dimension(3) :: &
1500  mysize, & !< domain size of this process
1501  origin
1502  integer, dimension(3) :: &
1503  mygrid
1504 
1505  integer, dimension(:), allocatable :: &
1506  microstructureat, &
1507  homogenizationat
1508 
1509  integer :: j
1510  integer(C_INTPTR_T) :: &
1511  devnull, z, z_offset
1512 
1513  write(6,'(/,a)') ' <<<+- discretization_grid init -+>>>'; flush(6)
1514 
1515  call readgeom(grid,geomsize,origin,microstructureat,homogenizationat)
1516 
1517 !--------------------------------------------------------------------------------------------------
1518 ! grid solver specific quantities
1519  if(worldsize>grid(3)) call io_error(894, ext_msg='number of processes exceeds grid(3)')
1520 
1521  call fftw_mpi_init
1522  devnull = fftw_mpi_local_size_3d(int(grid(3),c_intptr_t), &
1523  int(grid(2),c_intptr_t), &
1524  int(grid(1),c_intptr_t)/2+1, &
1525  petsc_comm_world, &
1526  z, & ! domain grid size along z
1527  z_offset) ! domain grid offset along z
1528  grid3 = int(z)
1529  grid3offset = int(z_offset)
1530  size3 = geomsize(3)*real(grid3,preal) /real(grid(3),preal)
1531  size3offset = geomsize(3)*real(grid3offset,preal)/real(grid(3),preal)
1532  mygrid = [grid(1:2),grid3]
1533  mysize = [geomsize(1:2),size3]
1534 
1535 !--------------------------------------------------------------------------------------------------
1536 ! general discretization
1537  microstructureat = microstructureat(product(grid(1:2))*grid3offset+1: &
1538  product(grid(1:2))*(grid3offset+grid3)) ! reallocate/shrink in case of MPI
1539  homogenizationat = homogenizationat(product(grid(1:2))*grid3offset+1: &
1540  product(grid(1:2))*(grid3offset+grid3)) ! reallocate/shrink in case of MPI
1541 
1542  call discretization_init(homogenizationat,microstructureat, &
1543  ipcoordinates0(mygrid,mysize,grid3offset), &
1544  nodes0(mygrid,mysize,grid3offset),&
1545  merge((grid(1)+1) * (grid(2)+1) * (grid3+1),& ! write bottom layer
1546  (grid(1)+1) * (grid(2)+1) * grid3,& ! do not write bottom layer (is top of rank-1)
1547  worldrank<1))
1548 
1549  fesolving_execelem = [1,product(mygrid)] ! parallel loop bounds set to comprise all elements
1550  fesolving_execip = [1,1] ! parallel loop bounds set to comprise the only IP
1551 
1552 !--------------------------------------------------------------------------------------------------
1553 ! store geometry information for post processing
1554  call results_openjobfile
1555  call results_closegroup(results_addgroup('geometry'))
1556  call results_addattribute('grid', grid, 'geometry')
1557  call results_addattribute('size', geomsize,'geometry')
1558  call results_addattribute('origin',origin, 'geometry')
1560 
1561 !--------------------------------------------------------------------------------------------------
1562 ! geometry information required by the nonlocal CP model
1563  call geometry_plastic_nonlocal_setipvolume(reshape([(product(mysize/real(mygrid,preal)),j=1,product(mygrid))], &
1564  [1,product(mygrid)]))
1568 
1569 !--------------------------------------------------------------------------------------------------
1570 ! sanity checks for debugging
1571  if (debug_e < 1 .or. debug_e > product(mygrid)) call io_error(602,ext_msg='element') ! selected element does not exist
1572  if (debug_i /= 1) call io_error(602,ext_msg='IP') ! selected IP does not exist
1573 
1574 end subroutine discretization_grid_init
1575 
1576 
1577 !--------------------------------------------------------------------------------------------------
1580 ! supposed to be called only once!
1581 !--------------------------------------------------------------------------------------------------
1582 subroutine readgeom(grid,geomSize,origin,microstructure,homogenization)
1584  integer, dimension(3), intent(out) :: &
1585  grid ! grid (for all processes!)
1586  real(pReal), dimension(3), intent(out) :: &
1587  geomSize, & ! size (for all processes!)
1588  origin ! origin (for all processes!)
1589  integer, dimension(:), intent(out), allocatable :: &
1590  microstructure, &
1591  homogenization
1592 
1593  character(len=:), allocatable :: rawData
1594  character(len=65536) :: line
1595  integer, allocatable, dimension(:) :: chunkPos
1596  integer :: &
1597  h =- 1, &
1598  headerlength = -1, &
1599  filelength, &
1600  fileunit, &
1601  startpos, endpos, &
1602  mystat, &
1603  l, &
1604  c, &
1605  o, &
1606  e, &
1607  i, j
1608 
1609  grid = -1
1610  geomsize = -1.0_preal
1611 
1612 !--------------------------------------------------------------------------------------------------
1613 ! read raw data as stream
1614  inquire(file = trim(geometryfile), size=filelength)
1615  open(newunit=fileunit, file=trim(geometryfile), access='stream',&
1616  status='old', position='rewind', action='read',iostat=mystat)
1617  if(mystat /= 0) call io_error(100,ext_msg=trim(geometryfile))
1618  allocate(character(len=fileLength)::rawData)
1619  read(fileunit) rawdata
1620  close(fileunit)
1621 
1622 !--------------------------------------------------------------------------------------------------
1623 ! get header length
1624  endpos = index(rawdata,io_eol)
1625  if(endpos <= index(rawdata,'head')) then ! ToDo: Should be 'header'
1626  startpos = len(rawdata)
1627  call io_error(error_id=841, ext_msg='readGeom')
1628  else
1629  chunkpos = io_stringpos(rawdata(1:endpos))
1630  if (chunkpos(1) < 2) call io_error(error_id=841, ext_msg='readGeom')
1631  headerlength = io_intvalue(rawdata(1:endpos),chunkpos,1)
1632  startpos = endpos + 1
1633  endif
1634 
1635 !--------------------------------------------------------------------------------------------------
1636 ! read and interprete header
1637  origin = 0.0_preal
1638  l = 0
1639  do while (l < headerlength .and. startpos < len(rawdata))
1640  endpos = startpos + index(rawdata(startpos:),io_eol) - 1
1641  if (endpos < startpos) endpos = len(rawdata) ! end of file without new line
1642  line = rawdata(startpos:endpos)
1643  startpos = endpos + 1
1644  l = l + 1
1645 
1646  chunkpos = io_stringpos(trim(line))
1647  if (chunkpos(1) < 2) cycle ! need at least one keyword value pair
1648 
1649  select case (io_lc(io_stringvalue(trim(line),chunkpos,1)) )
1650  case ('grid')
1651  if (chunkpos(1) > 6) then
1652  do j = 2,6,2
1653  select case (io_lc(io_stringvalue(line,chunkpos,j)))
1654  case('a')
1655  grid(1) = io_intvalue(line,chunkpos,j+1)
1656  case('b')
1657  grid(2) = io_intvalue(line,chunkpos,j+1)
1658  case('c')
1659  grid(3) = io_intvalue(line,chunkpos,j+1)
1660  end select
1661  enddo
1662  endif
1663 
1664  case ('size')
1665  if (chunkpos(1) > 6) then
1666  do j = 2,6,2
1667  select case (io_lc(io_stringvalue(line,chunkpos,j)))
1668  case('x')
1669  geomsize(1) = io_floatvalue(line,chunkpos,j+1)
1670  case('y')
1671  geomsize(2) = io_floatvalue(line,chunkpos,j+1)
1672  case('z')
1673  geomsize(3) = io_floatvalue(line,chunkpos,j+1)
1674  end select
1675  enddo
1676  endif
1677 
1678  case ('origin')
1679  if (chunkpos(1) > 6) then
1680  do j = 2,6,2
1681  select case (io_lc(io_stringvalue(line,chunkpos,j)))
1682  case('x')
1683  origin(1) = io_floatvalue(line,chunkpos,j+1)
1684  case('y')
1685  origin(2) = io_floatvalue(line,chunkpos,j+1)
1686  case('z')
1687  origin(3) = io_floatvalue(line,chunkpos,j+1)
1688  end select
1689  enddo
1690  endif
1691 
1692  case ('homogenization')
1693  if (chunkpos(1) > 1) h = io_intvalue(line,chunkpos,2)
1694 
1695  end select
1696 
1697  enddo
1698 
1699 !--------------------------------------------------------------------------------------------------
1700 ! sanity checks
1701  if(h < 1) &
1702  call io_error(error_id = 842, ext_msg='homogenization (readGeom)')
1703  if(any(grid < 1)) &
1704  call io_error(error_id = 842, ext_msg='grid (readGeom)')
1705  if(any(geomsize < 0.0_preal)) &
1706  call io_error(error_id = 842, ext_msg='size (readGeom)')
1707 
1708  allocate(microstructure(product(grid)), source = -1) ! too large in case of MPI (shrink later, not very elegant)
1709  allocate(homogenization(product(grid)), source = h) ! too large in case of MPI (shrink later, not very elegant)
1710 
1711 !--------------------------------------------------------------------------------------------------
1712 ! read and interpret content
1713  e = 1
1714  do while (startpos < len(rawdata))
1715  endpos = startpos + index(rawdata(startpos:),io_eol) - 1
1716  if (endpos < startpos) endpos = len(rawdata) ! end of file without new line
1717  line = rawdata(startpos:endpos)
1718  startpos = endpos + 1
1719  l = l + 1
1720  chunkpos = io_stringpos(trim(line))
1721 
1722  nocompression: if (chunkpos(1) /= 3) then
1723  c = chunkpos(1)
1724  microstructure(e:e+c-1) = [(io_intvalue(line,chunkpos,i+1), i=0, c-1)]
1725  else nocompression
1726  compression: if (io_lc(io_stringvalue(line,chunkpos,2)) == 'of') then
1727  c = io_intvalue(line,chunkpos,1)
1728  microstructure(e:e+c-1) = [(io_intvalue(line,chunkpos,3),i = 1,io_intvalue(line,chunkpos,1))]
1729  else if (io_lc(io_stringvalue(line,chunkpos,2)) == 'to') then compression
1730  c = abs(io_intvalue(line,chunkpos,3) - io_intvalue(line,chunkpos,1)) + 1
1731  o = merge(+1, -1, io_intvalue(line,chunkpos,3) > io_intvalue(line,chunkpos,1))
1732  microstructure(e:e+c-1) = [(i, i = io_intvalue(line,chunkpos,1),io_intvalue(line,chunkpos,3),o)]
1733  else compression
1734  c = chunkpos(1)
1735  microstructure(e:e+c-1) = [(io_intvalue(line,chunkpos,i+1), i=0, c-1)]
1736  endif compression
1737  endif nocompression
1738 
1739  e = e+c
1740  end do
1741 
1742  if (e-1 /= product(grid)) call io_error(error_id = 843, el=e)
1743 
1744 end subroutine readgeom
1745 
1746 
1747 !---------------------------------------------------------------------------------------------------
1749 !---------------------------------------------------------------------------------------------------
1750 function ipcoordinates0(grid,geomSize,grid3Offset)
1752  integer, dimension(3), intent(in) :: grid ! grid (for this process!)
1753  real(preal), dimension(3), intent(in) :: geomsize ! size (for this process!)
1754  integer, intent(in) :: grid3offset ! grid(3) offset
1755 
1756  real(preal), dimension(3,product(grid)) :: ipcoordinates0
1757 
1758  integer :: &
1759  a,b,c, &
1760  i
1761 
1762  i = 0
1763  do c = 1, grid(3); do b = 1, grid(2); do a = 1, grid(1)
1764  i = i + 1
1765  ipcoordinates0(1:3,i) = geomsize/real(grid,preal) * (real([a,b,grid3offset+c],preal) -0.5_preal)
1766  enddo; enddo; enddo
1767 
1768 end function ipcoordinates0
1769 
1770 
1771 !---------------------------------------------------------------------------------------------------
1773 !---------------------------------------------------------------------------------------------------
1774 pure function nodes0(grid,geomSize,grid3Offset)
1776  integer, dimension(3), intent(in) :: grid ! grid (for this process!)
1777  real(preal), dimension(3), intent(in) :: geomsize ! size (for this process!)
1778  integer, intent(in) :: grid3offset ! grid(3) offset
1779 
1780  real(preal), dimension(3,product(grid+1)) :: nodes0
1781 
1782  integer :: &
1783  a,b,c, &
1784  n
1785 
1786  n = 0
1787  do c = 0, grid3; do b = 0, grid(2); do a = 0, grid(1)
1788  n = n + 1
1789  nodes0(1:3,n) = geomsize/real(grid,preal) * real([a,b,grid3offset+c],preal)
1790  enddo; enddo; enddo
1791 
1792 end function nodes0
1793 
1794 
1795 !--------------------------------------------------------------------------------------------------
1797 !--------------------------------------------------------------------------------------------------
1798 pure function cellsurfacearea(geomSize,grid)
1800  real(preal), dimension(3), intent(in) :: geomsize ! size (for this process!)
1801  integer, dimension(3), intent(in) :: grid ! grid (for this process!)
1802 
1803  real(preal), dimension(6,1,product(grid)) :: cellsurfacearea
1804 
1805  cellsurfacearea(1:2,1,:) = geomsize(2)/real(grid(2)) * geomsize(3)/real(grid(3))
1806  cellsurfacearea(3:4,1,:) = geomsize(3)/real(grid(3)) * geomsize(1)/real(grid(1))
1807  cellsurfacearea(5:6,1,:) = geomsize(1)/real(grid(1)) * geomsize(2)/real(grid(2))
1808 
1809 end function cellsurfacearea
1810 
1811 
1812 !--------------------------------------------------------------------------------------------------
1814 !--------------------------------------------------------------------------------------------------
1815 pure function cellsurfacenormal(nElems)
1817  integer, intent(in) :: nelems
1818 
1819  real(preal), dimension(3,6,1,nElems) :: cellsurfacenormal
1820 
1821  cellsurfacenormal(1:3,1,1,:) = spread([+1.0_preal, 0.0_preal, 0.0_preal],2,nelems)
1822  cellsurfacenormal(1:3,2,1,:) = spread([-1.0_preal, 0.0_preal, 0.0_preal],2,nelems)
1823  cellsurfacenormal(1:3,3,1,:) = spread([ 0.0_preal,+1.0_preal, 0.0_preal],2,nelems)
1824  cellsurfacenormal(1:3,4,1,:) = spread([ 0.0_preal,-1.0_preal, 0.0_preal],2,nelems)
1825  cellsurfacenormal(1:3,5,1,:) = spread([ 0.0_preal, 0.0_preal,+1.0_preal],2,nelems)
1826  cellsurfacenormal(1:3,6,1,:) = spread([ 0.0_preal, 0.0_preal,-1.0_preal],2,nelems)
1827 
1828 end function cellsurfacenormal
1829 
1830 
1831 !--------------------------------------------------------------------------------------------------
1833 !--------------------------------------------------------------------------------------------------
1834 pure function ipneighborhood(grid)
1836  integer, dimension(3), intent(in) :: grid ! grid (for this process!)
1837 
1838  integer, dimension(3,6,1,product(grid)) :: ipneighborhood
1839 
1840  integer :: &
1841  x,y,z, &
1842  e
1843 
1844  e = 0
1845  do z = 0,grid(3)-1; do y = 0,grid(2)-1; do x = 0,grid(1)-1
1846  e = e + 1
1847  ! element ID
1848  ipneighborhood(1,1,1,e) = z * grid(1) * grid(2) &
1849  + y * grid(1) &
1850  + modulo(x+1,grid(1)) &
1851  + 1
1852  ipneighborhood(1,2,1,e) = z * grid(1) * grid(2) &
1853  + y * grid(1) &
1854  + modulo(x-1,grid(1)) &
1855  + 1
1856  ipneighborhood(1,3,1,e) = z * grid(1) * grid(2) &
1857  + modulo(y+1,grid(2)) * grid(1) &
1858  + x &
1859  + 1
1860  ipneighborhood(1,4,1,e) = z * grid(1) * grid(2) &
1861  + modulo(y-1,grid(2)) * grid(1) &
1862  + x &
1863  + 1
1864  ipneighborhood(1,5,1,e) = modulo(z+1,grid(3)) * grid(1) * grid(2) &
1865  + y * grid(1) &
1866  + x &
1867  + 1
1868  ipneighborhood(1,6,1,e) = modulo(z-1,grid(3)) * grid(1) * grid(2) &
1869  + y * grid(1) &
1870  + x &
1871  + 1
1872  ! IP ID
1873  ipneighborhood(2,:,1,e) = 1
1874 
1875  ! face ID
1876  ipneighborhood(3,1,1,e) = 2
1877  ipneighborhood(3,2,1,e) = 1
1878  ipneighborhood(3,3,1,e) = 4
1879  ipneighborhood(3,4,1,e) = 3
1880  ipneighborhood(3,5,1,e) = 6
1881  ipneighborhood(3,6,1,e) = 5
1882 
1883  enddo; enddo; enddo
1884 
1885 end function ipneighborhood
1886 
1887 
1888 end module discretization_grid
fesolving::fesolving_execip
integer, dimension(2) fesolving_execip
for ping-pong scheme always range to max IP, otherwise one specific IP
Definition: FEsolving.f90:18
io::io_stringpos
pure integer function, dimension(:), allocatable, public io_stringpos(string)
locates all whitespace-separated chunks in given string and returns array containing number them and ...
Definition: IO.f90:204
results::results_closejobfile
subroutine, public results_closejobfile
closes the results file
Definition: results.f90:102
io::io_error
subroutine, public io_error(error_ID, el, ip, g, instance, ext_msg)
write error statements to standard out and terminate the Marc/spectral run with exit #9xxx
Definition: IO.f90:305
debug::debug_i
integer, public, protected debug_i
Definition: debug.f90:51
io::io_eol
character, parameter, public io_eol
end of line character
Definition: IO.f90:20
geometry_plastic_nonlocal::geometry_plastic_nonlocal_setipneighborhood
subroutine geometry_plastic_nonlocal_setipneighborhood(IPneighborhood)
Set the integration point (IP) neighborhood.
Definition: geometry_plastic_nonlocal.f90:46
damask_interface::geometryfile
character(len=:), allocatable, public, protected geometryfile
parameter given for geometry file
Definition: DAMASK_interface.f90:38
results::results_addattribute
Definition: results.f90:38
discretization_grid::size3
real(preal), public, protected size3
(local) size in 3rd direction
Definition: discretization_grid.f90:1483
discretization_grid::size3offset
real(preal), public, protected size3offset
(local) size offset in 3rd direction
Definition: discretization_grid.f90:1483
numerics::worldsize
integer, public, protected worldsize
MPI worldsize (/=1 for MPI simulations only)
Definition: numerics.f90:1470
discretization_grid::nodes0
pure real(preal) function, dimension(3, product(grid+1)) nodes0(grid, geomSize, grid3Offset)
Calculate position of undeformed nodes (pretend to be an element)
Definition: discretization_grid.f90:1775
discretization_grid::grid3
integer, public, protected grid3
(local) grid in 3rd direction
Definition: discretization_grid.f90:1478
geometry_plastic_nonlocal
Geometric information about the IP cells needed for the nonlocal.
Definition: geometry_plastic_nonlocal.f90:12
discretization_grid::readgeom
subroutine readgeom(grid, geomSize, origin, microstructure, homogenization)
Parses geometry file.
Definition: discretization_grid.f90:1583
discretization_grid
Parse geometry file to set up discretization and geometry for nonlocal model.
Definition: discretization_grid.f90:11
prec
setting precision for real and int type
Definition: prec.f90:13
discretization_grid::geomsize
real(preal), dimension(3), public, protected geomsize
(global) physical size
Definition: discretization_grid.f90:1481
discretization
spatial discretization
Definition: discretization.f90:9
discretization_grid::cellsurfacenormal
pure real(preal) function, dimension(3, 6, 1, nelems) cellsurfacenormal(nElems)
Calculate IP interface areas normals.
Definition: discretization_grid.f90:1816
geometry_plastic_nonlocal::geometry_plastic_nonlocal_setiparea
subroutine geometry_plastic_nonlocal_setiparea(IParea)
Set the initial areas of the unit triangle/unit quadrilateral/tetrahedron/hexahedron.
Definition: geometry_plastic_nonlocal.f90:73
discretization_grid::cellsurfacearea
pure real(preal) function, dimension(6, 1, product(grid)) cellsurfacearea(geomSize, grid)
Calculate IP interface areas.
Definition: discretization_grid.f90:1799
io
input/output functions, partly depending on chosen solver
Definition: IO.f90:12
homogenization
homogenization manager, organizing deformation partitioning and stress homogenization
Definition: homogenization.f90:11
prec::preal
integer, parameter preal
number with 15 significant digits, up to 1e+-307 (typically 64 bit)
Definition: prec.f90:20
debug
Reading in and interpretating the debugging settings for the various modules.
Definition: debug.f90:12
discretization_grid::discretization_grid_init
subroutine, public discretization_grid_init
reads the geometry file to obtain information on discretization
Definition: discretization_grid.f90:1497
discretization_grid::ipcoordinates0
real(preal) function, dimension(3, product(grid)) ipcoordinates0(grid, geomSize, grid3Offset)
Calculate undeformed position of IPs/cell centers (pretend to be an element)
Definition: discretization_grid.f90:1751
results::results_addgroup
integer(hid_t) function, public results_addgroup(groupName)
adds a new group to the results file
Definition: results.f90:154
system_routines
provides wrappers to C routines
Definition: system_routines.f90:9
discretization::discretization_init
subroutine, public discretization_init(homogenizationAt, microstructureAt, IPcoords0, NodeCoords0, sharedNodesBegin)
stores the relevant information in globally accesible variables
Definition: discretization.f90:48
discretization_grid::grid3offset
integer, public, protected grid3offset
(local) grid offset in 3rd direction
Definition: discretization_grid.f90:1478
io::io_intvalue
integer function, public io_intvalue(string, chunkPos, myChunk)
reads integer value at myChunk from string
Definition: IO.f90:252
damask_interface
Interfacing between the 1-based solvers and the material subroutines provided by DAMASK.
Definition: DAMASK_interface.f90:22
results::results_openjobfile
subroutine, public results_openjobfile
opens the results file to append data
Definition: results.f90:92
results
Definition: results.f90:11
numerics::worldrank
integer, public, protected worldrank
MPI worldrank (/=0 for MPI simulations only)
Definition: numerics.f90:1470
discretization_grid::grid
integer, dimension(3), public, protected grid
(global) grid
Definition: discretization_grid.f90:1476
debug::debug_e
integer, public, protected debug_e
Definition: debug.f90:51
discretization_grid::ipneighborhood
pure integer function, dimension(3, 6, 1, product(grid)) ipneighborhood(grid)
Build IP neighborhood relations.
Definition: discretization_grid.f90:1835
geometry_plastic_nonlocal::geometry_plastic_nonlocal_setipareanormal
subroutine geometry_plastic_nonlocal_setipareanormal(IPareaNormal)
Set the direction normal of the areas of the triangle/quadrilateral/tetrahedron/hexahedron.
Definition: geometry_plastic_nonlocal.f90:86
results::results_closegroup
subroutine, public results_closegroup(group_id)
close a group
Definition: results.f90:166
io::io_lc
pure character(len=len(string)) function, public io_lc(string)
changes characters in string to lower case
Definition: IO.f90:280
fesolving::fesolving_execelem
integer, dimension(2) fesolving_execelem
for ping-pong scheme always whole range, otherwise one specific element
Definition: FEsolving.f90:18
io::io_stringvalue
character(len=:) function, allocatable, public io_stringvalue(string, chunkPos, myChunk)
reads string value at myChunk from string
Definition: IO.f90:232
geometry_plastic_nonlocal::geometry_plastic_nonlocal_setipvolume
subroutine geometry_plastic_nonlocal_setipvolume(IPvolume)
Set the initial volume associated with an integration point.
Definition: geometry_plastic_nonlocal.f90:60
numerics
Managing of parameters related to numerics.
Definition: numerics.f90:10
fesolving
global variables for flow control
Definition: FEsolving.f90:10
io::io_floatvalue
real(preal) function, public io_floatvalue(string, chunkPos, myChunk)
reads float value at myChunk from string
Definition: IO.f90:266