-
Notifications
You must be signed in to change notification settings - Fork 38
/
gmsh_mod.f90
4580 lines (4580 loc) · 163 KB
/
gmsh_mod.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
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
module module_gmsh
!
!.. Use Statements ..
use module_kind_types
use geovar, only : grid
use geovar, only : elem_t
use geovar, only : prop_t
!
implicit none
!
private
!
! ##################################
! ### Module Public Procedures ###
! ##################################
!
! Public Interface for Gmsh element_properties function
!
interface gmsh_element_properties
module procedure element_properties
end interface gmsh_element_properties
!
public :: read_gmsh_gridfile
public :: gmsh_element_properties
public :: gmsh_memory_usage
!
! ###########################
! ### Module Parameters ###
! ###########################
!
! Explanation of different element types created by Gmsh
!
! 1 : 2-node 1st order line
! 2 : 3-node 1st order triangle
! 3 : 4-node 1st order quadrangle
! 4 : 4-node 1st order tetrahedron
! 5 : 8-node 1st order hexahedron
! 6 : 6-node 1st order prism
! 7 : 5-node 1st order pyramid
! 8 : 3-node 2nd order line
! 2 nodes associated with the vertices
! 1 with the edge
! 9 : 6-node 2nd order triangle
! 3 nodes associated with the vertices
! 3 with the edges
! 10 : 9-node 2nd order quadrangle
! 4 nodes associated with the vertices
! 4 with the edges
! 1 with the interior
! 11 : 10-node 2nd order tetrahedron
! 4 nodes associated with the vertices
! 6 with the edges
! 12 : 27-node 2nd order hexahedron
! 8 nodes associated with the vertices
! 12 with the edges
! 6 with the faces
! 1 with the volume
! 13 : 18-node 2nd order prism
! 6 nodes associated with the vertices
! 9 with the edges
! 3 with the quadrangular faces
! 14 : 14-node 2nd order pyramid
! 5 nodes associated with the vertices
! 8 with the edges
! 1 with the quadrangular face
! 15 : 1-node 1st order point
! 16 : 8-node 2nd order EDGE-DEFINED quadrangle
! 4 nodes associated with the vertices
! 4 with the edges
! 17 : 20-node 2nd order EDGE-DEFINED hexahedron
! 8 nodes associated with the vertices
! 12 with the edges
! 18 : 15-node 2nd order EDGE-DEFINED prism
! 6 nodes associated with the vertices
! 9 with the edges
! 19 : 13-node 2nd order EDGE-DEFINED pyramid
! 5 nodes associated with the vertices
! 8 with the edges
! 20 : 9-node 3rd order EDGE-DEFINED triangle
! 3 nodes associated with the vertices
! 6 with the edges
! 21 : 10-node 3rd order triangle
! 3 nodes associated with the vertices
! 6 with the edges
! 1 with the interior
! 22 : 12-node 4th order EDGE-DEFINED triangle
! 3 nodes associated with the vertices
! 9 with the edges
! 23 : 15-node 4th order triangle
! 3 nodes associated with the vertices
! 9 with the edges
! 3 with the interior
! 24 : 15-node 5th order EDGE-DEFINED triangle
! 3 nodes associated with the vertices
! 12 with the edges
! 25 : 21-node 5th order triangle
! 3 nodes associated with the vertices
! 12 with the edges
! 6 with the interior
! 26 : 4-node 3rd order edge
! 2 nodes associated with the vertices
! 2 internal to the edge
! 27 : 5-node 4th order edge
! 2 nodes associated with the vertices
! 3 internal to the edge
! 28 : 6-node 5th order edge
! 2 nodes associated with the vertices
! 4 internal to the edge
! 29 : 20-node 3rd order tetrahedron
! 4 nodes associated with the vertices
! 12 with the edges
! 4 with the faces
! 30 : 35-node 4th order tetrahedron
! 4 nodes associated with the vertices
! 18 with the edges
! 12 with the faces
! 1 in the volume
! 31 : 56-node 5th order tetrahedron
! 4 nodes associated with the vertices
! 24 with the edges
! 24 with the faces
! 4 in the volume
!###############################################################################
!###############################################################################
!###############################################################################
!###############################################################################
!### ###
!### NEWLY ADDED ELEMENTS FROM GMSH SOURCE CODE ###
!### THAT DO NOT SEEM TO HAVE ANY DOCUMENTATION RELATING TO THEM ###
!### ###
!### ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ###
!### VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV ###
!### ###
!###############################################################################
!###############################################################################
!###############################################################################
!###############################################################################
! 32 : 22-node 4th order EDGE-DEFINED tetrahedron
! 4 nodes associated with the vertices
! 18 with the edges
! 33 : 28-node 5th order EDGE-DEFINED tetrahedron
! 4 nodes associated with the vertices
! 24 with the edges
! 34 : ?-node 1st order polygon
! * nodes associated with the vertices
! * with the edges
! * with the faces
! * in the volume
! 35 : ?-node 1st order polyhedron
! * nodes associated with the vertices
! * with the edges
! * with the faces
! * in the volume
! 36 : 16-node 3rd order quadrangle
! 4 nodes associated with the vertices
! 8 with the edges
! 4 in the interior
! 37 : 25-node 4th order quadrangle
! 4 nodes associated with the vertices
! 12 with the edges
! 9 in the interior
! 38 : 36-node 5th order quadrangle
! 4 nodes associated with the vertices
! 16 with the edges
! 16 in the interior
! 39 : 12-node 3rd order EDGE-DEFINED quadrangle
! 4 nodes associated with the vertices
! 8 with the edges
! 40 : 16-node 4th order EDGE-DEFINED quadrangle
! 4 nodes associated with the vertices
! 12 with the edges
! 41 : 20-node 5th order EDGE-DEFINED quadrangle
! 4 nodes associated with the vertices
! 16 with the edges
! 42 : 28-node 6th order triangle
! 3 nodes associated with the vertices
! 15 with the edges
! 10 in the interior
! 43 : 36-node 7th order triangle
! 3 nodes associated with the vertices
! 18 with the edges
! 15 in the interior
! 44 : 45-node 8th order triangle
! 3 nodes associated with the vertices
! 21 with the edges
! 21 in the interior
! 45 : 55-node 9th order triangle
! 3 nodes associated with the vertices
! 24 with the edges
! 28 in the interior
! 46 : 66-node 10th order triangle
! 3 nodes associated with the vertices
! 27 with the edges
! 36 in the interior
! 47 : 49-node 6th order quadrangle
! 4 nodes associated with the vertices
! 20 with the edges
! 25 in the interior
! 48 : 64-node 7th order quadrangle
! 4 nodes associated with the vertices
! 24 with the edges
! 36 in the interior
! 49 : 81-node 8th order quadrangle
! 4 nodes associated with the vertices
! 28 with the edges
! 49 in the interior
! 50 : 100-node 9th order quadrangle
! 4 nodes associated with the vertices
! 32 with the edges
! 64 in the interior
! 51 : 121-node 10th order quadrangle
! 4 nodes associated with the vertices
! 36 with the edges
! 81 in the interior
! 52 : 18-node 6th order EDGE-DEFINED triangle
! 3 nodes associated with the vertices
! 15 with the edges
! 53 : 21-node 7th order EDGE-DEFINED triangle
! 3 nodes associated with the vertices
! 18 with the edges
! 54 : 24-node 8th order EDGE-DEFINED triangle
! 3 nodes associated with the vertices
! 21 with the edges
! 55 : 27-node 9th order EDGE-DEFINED triangle
! 3 nodes associated with the vertices
! 24 with the edges
! 56 : 30-node 10th order EDGE-DEFINED triangle
! 3 nodes associated with the vertices
! 27 with the edges
! 57 : 24-node 6th order EDGE-DEFINED quadrangle
! 4 nodes associated with the vertices
! 20 with the edges
! 58 : 28-node 7th order EDGE-DEFINED quadrangle
! 4 nodes associated with the vertices
! 24 with the edges
! 59 : 32-node 8th order EDGE-DEFINED quadrangle
! 4 nodes associated with the vertices
! 28 with the edges
! 60 : 36-node 9th order EDGE-DEFINED quadrangle
! 4 nodes associated with the vertices
! 32 with the edges
! 61 : 40-node 10th order EDGE-DEFINED quadrangle
! 4 nodes associated with the vertices
! 36 with the edges
! 62 : 7-node 6th order line
! 2 nodes associated with the vertices
! 5 on the edge
! 63 : 8-node 7th order line
! 2 nodes associated with the vertices
! 6 on the edge
! 64 : 9-node 8th order line
! 2 nodes associated with the vertices
! 7 on the edge
! 65 : 10-node 9th order line
! 2 nodes associated with the vertices
! 8 on the edge
! 66 : 11-node 10th order line
! 2 nodes associated with the vertices
! 9 on the edge
! 67 : 2-node 1st order line border
! * nodes associated with the vertices
! * on the edge
! 68 : 3-node 1st order triangle border
! * nodes associated with the vertices
! * with the edges
! * with the interior
! 69 : ?-node 1st order polygon border
! * nodes associated with the vertices
! * with the edges
! * with the faces
! * in the volume
! 70 : 2-node 1st order line child
! * nodes associated with the vertices
! * on the edge
! 71 : 84-node 6th order tetrahedron
! 4 nodes associated with the vertices
! 30 with the edges
! 40 with the faces
! 10 in the volume
! 72 : 120-node 7th order tetrahedron
! 4 nodes associated with the vertices
! 36 with the edges
! 60 with the faces
! 20 in the volume
! 73 : 165-node 8th order tetrahedron
! 4 nodes associated with the vertices
! 42 with the edges
! 84 with the faces
! 35 in the volume
! 74 : 220-node 9th order tetrahedron
! 4 nodes associated with the vertices
! 48 with the edges
! 112 with the faces
! 56 in the volume
! 75 : 286-node 10th order tetrahedron
! 4 nodes associated with the vertices
! 54 with the edges
! 144 with the faces
! 84 in the volume
! 79 : 34-node 6th order EDGE-DEFINED tetrahedron
! 4 nodes associated with the vertices
! 30 with the edges
! 80 : 40-node 7th order EDGE-DEFINED tetrahedron
! 4 nodes associated with the vertices
! 36 with the edges
! 81 : 46-node 8th order EDGE-DEFINED tetrahedron
! 4 nodes associated with the vertices
! 42 with the edges
! 82 : 52-node 9th order EDGE-DEFINED tetrahedron
! 4 nodes associated with the vertices
! 48 with the edges
! 83 : 58-node 10th order EDGE-DEFINED tetrahedron
! 4 nodes associated with the vertices
! 54 with the edges
! 84 : 1-node 0th order line
! 1 on the edge
! 85 : 1-node 0th order triangle
! 1 in the interior
! 86 : 1-node 0th order quadrangle
! 1 in the interior
! 87 : 1-node 0th order tetrahedron
! 1 in the volume
! 88 : 1-node 0th order hexahedron
! 1 in the volume
! 89 : 1-node 0th order prism
! 1 in the volume
! 90 : 40-node 3rd order prism
! 6 nodes associated with the vertices
! 18 with the edges
! 2 with the triangular faces
! 12 with the quadrangular faces
! 2 in the volume
! 91 : 75-node 4th order prism
! 6 nodes associated with the vertices
! 27 with the edges
! 6 with the triangular faces
! 27 with the quadrangular faces
! 9 in the volume
! 92 : 64-node 3rd order hexahedron
! 8 nodes associated with the vertices
! 24 with the edges
! 24 with the faces
! 8 in the volume
! 93 : 125-node 4th order hexahedron
! 8 nodes associated with the vertices
! 36 with the edges
! 54 with the faces
! 27 in the volume
! 94 : 216-node 5th order hexahedron
! 8 nodes associated with the vertices
! 48 with the edges
! 96 with the faces
! 64 in the volume
! 95 : 343-node 6th order hexahedron
! 8 nodes associated with the vertices
! 60 with the edges
! 150 with the faces
! 125 in the volume
! 96 : 512-node 7th order hexahedron
! 8 nodes associated with the vertices
! 72 with the edges
! 216 with the faces
! 216 in the volume
! 97 : 729-node 8th order hexahedron
! 8 nodes associated with the vertices
! 84 with the edges
! 294 with the faces
! 343 in the volume
! 98 : 1000-node 9th order hexahedron
! 8 nodes associated with the vertices
! 96 with the edges
! 384 with the faces
! 512 in the volume
! 99 : 32-node 3rd order EDGE-DEFINED hexahedron
! 8 nodes associated with the vertices
! 24 with the edges
! 100 : 44-node 4th order EDGE-DEFINED hexahedron
! 8 nodes associated with the vertices
! 36 with the edges
! 101 : 56-node 5th order EDGE-DEFINED hexahedron
! 8 nodes associated with the vertices
! 48 with the edges
! 102 : 68-node 6th order EDGE-DEFINED hexahedron
! 8 nodes associated with the vertices
! 60 with the edges
! 103 : 80-node 7th order EDGE-DEFINED hexahedron
! 8 nodes associated with the vertices
! 72 with the edges
! 104 : 92-node 8th order EDGE-DEFINED hexahedron
! 8 nodes associated with the vertices
! 84 with the edges
! 105 : 104-node 9th order EDGE-DEFINED hexahedron
! 8 nodes associated with the vertices
! 96 with the edges
! 106 : 126-node 5th order prism
! 6 nodes associated with the vertices
! 36 with the edges
! 12 with the triangular faces
! 48 with the quadrangular faces
! 24 in the volume
! 107 : 196-node 6th order prism
! 6 nodes associated with the vertices
! 45 with the edges
! 20 with the triangular faces
! 75 with the quadrangular faces
! 50 in the volume
! 108 : 288-node 7th order prism
! 6 nodes associated with the vertices
! 54 with the edges
! 30 with the triangular faces
! 108 with the quadrangular faces
! 90 in the volume
! 109 : 405-node 8th order prism
! 6 nodes associated with the vertices
! 63 with the edges
! 42 with the triangular faces
! 147 with the quadrangular faces
! 147 in the volume
! 110 : 550-node 9th order prism
! 6 nodes associated with the vertices
! 72 with the edges
! 56 with the triangular faces
! 192 with the quadrangular faces
! 224 in the volume
! 111 : 24-node 3rd order EDGE-DEFINED prism
! 6 nodes associated with the vertices
! 18 with the edges
! 112 : 33-node 4th order EDGE-DEFINED prism
! 6 nodes associated with the vertices
! 27 with the edges
! 113 : 42-node 5th order EDGE-DEFINED prism
! 6 nodes associated with the vertices
! 36 with the edges
! 114 : 51-node 6th order EDGE-DEFINED prism
! 6 nodes associated with the vertices
! 45 with the edges
! 115 : 60-node 7th order EDGE-DEFINED prism
! 6 nodes associated with the vertices
! 54 with the edges
! 116 : 69-node 8th order EDGE-DEFINED prism
! 6 nodes associated with the vertices
! 63 with the edges
! 117 : 78-node 9th order EDGE-DEFINED prism
! 6 nodes associated with the vertices
! 72 with the edges
! 118 : 30-node 3rd order pyramid
! 5 nodes associated with the vertices
! 16 with the edges
! 4 with the triangular faces
! 4 with the quadrangular faces
! 1 in the volume
! 119 : 55-node 4th order pyramid
! 5 nodes associated with the vertices
! 24 with the edges
! 12 with the triangular faces
! 9 with the quadrangular faces
! 5 in the volume
! 120 : 91-node 5th order pyramid
! 5 nodes associated with the vertices
! 32 with the edges
! 24 with the triangular faces
! 16 with the quadrangular faces
! 14 in the volume
! 121 : 140-node 6th order pyramid
! 5 nodes associated with the vertices
! 40 with the edges
! 40 with the triangular faces
! 25 with the quadrangular faces
! 30 in the volume
! 122 : 204-node 7th order pyramid
! 5 nodes associated with the vertices
! 48 with the edges
! 60 with the triangular faces
! 36 with the quadrangular faces
! 55 in the volume
! 123 : 285-node 8th order pyramid
! 5 nodes associated with the vertices
! 56 with the edges
! 84 with the triangular faces
! 49 with the quadrangular faces
! 91 in the volume
! 124 : 385-node 9th order pyramid
! 5 nodes associated with the vertices
! 64 with the edges
! 112 with the triangular faces
! 64 with the quadrangular faces
! 140 in the volume
! 125 : 21-node 3rd order EDGE-DEFINED pyramid
! 5 nodes associated with the vertices
! 16 with the edges
! 126 : 29-node 4th order EDGE-DEFINED pyramid
! 5 nodes associated with the vertices
! 24 with the edges
! 127 : 37-node 5th order EDGE-DEFINED pyramid
! 5 nodes associated with the vertices
! 32 with the edges
! 128 : 45-node 6th order EDGE-DEFINED pyramid
! 5 nodes associated with the vertices
! 40 with the edges
! 129 : 53-node 7th order EDGE-DEFINED pyramid
! 5 nodes associated with the vertices
! 48 with the edges
! 130 : 61-node 8th order EDGE-DEFINED pyramid
! 5 nodes associated with the vertices
! 56 with the edges
! 131 : 69-node 9th order EDGE-DEFINED pyramid
! 5 nodes associated with the vertices
! 64 with the edges
! 132 : 1-node 0th order pyramid
! 1 in the volume
! 133 : 1-node 1st order point Xfem
! * nodes associated with the vertices
! * with the edges
! * with the faces
! * in the volume
! 134 : 2-node 1st order line Xfem
! * nodes associated with the vertices
! * on the edge
! 135 : 3-node 1st order triangle Xfem
! * nodes associated with the vertices
! * with the edges
! * with the interior
! 136 : 4-node 1st order tetrahedron Xfem
! * nodes associated with the vertices
! * with the edges
! * with the faces
! * in the volume
! 137 : 16-node 3rd order EDGE-DEFINED tetrahedron
! 4 nodes associated with the vertices
! 12 with the edges
! 138 : MINI-node 1st order triangle
! * nodes associated with the vertices
! * with the edges
! * with the interior
! 139 : MINI-node 1st order tetrahedron
! * nodes associated with the vertices
! * with the edges
! * with the faces
! * in the volume
! 140 : 4-node 1st order trihedron
! * nodes associated with the vertices
! * with the edges
! * with the faces
! * in the volume
!###############################################################################
!###############################################################################
!###############################################################################
!###############################################################################
!### ###
!### AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA ###
!### ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ###
!### ###
!### NEWLY ADDED ELEMENTS FROM GMSH SOURCE CODE ###
!### THAT DO NOT SEEM TO HAVE ANY DOCUMENTATION RELATING TO THEM ###
!### ###
!###############################################################################
!###############################################################################
!###############################################################################
!###############################################################################
!
! ###################################
! ### Module Derived Data Types ###
! ###################################
!
type phys_t
integer :: phys_dim
integer :: phys_id
integer :: ibc
character(len=80) :: phys_nam
integer, allocatable, dimension(:) :: cells
end type phys_t
!
! ################################
! ### Module Local Variables ###
! ################################
!
logical(lk), save :: meshformat_successful
logical(lk), save :: nodes_successful
logical(lk), save :: elements_successful
logical(lk), save :: physicalnames_successful
!
integer, save :: iogmsh
!
! ###################################
! ### Module Allocatable Arrays ###
! ###################################
!
!type(elem_t), allocatable, dimension(:) :: cell_data
type(phys_t), allocatable, dimension(:) :: phys_grps
!
contains
!
!###############################################################################
!
subroutine read_gmsh_gridfile( gridfile )
!
! Routine to read in a grid file using GMSH formatting
!
!.. Formal Arguments ..
character(len=*), intent(in) :: gridfile
!
!.. Local Scalars ..
integer :: ierr
logical(lk) :: end_of_file
character(len=80) :: section_header
!
!.. Local Parameters ..
character(len=*), parameter :: pname = "read_gmsh_gridfile"
!
continue
!
meshformat_successful = fals
nodes_successful = fals
elements_successful = fals
physicalnames_successful = fals
!
! Open the grid file
!
open (newunit=iogmsh,file=gridfile,status="old",action="read", &
position="rewind",iostat=ierr,iomsg=error_message)
call io_error(pname,gridfile,1,__LINE__,__FILE__,ierr,error_message)
!
! Reading the grid file sections, looping until reaching the end of the file
!
do
!
call find_gmsh_section(section_header,end_of_file)
!
! If the end_of_file flag was set, exit the read loop
!
if (end_of_file) exit
!
! Read the next section based on the section header
!
if (section_header == "MESHFORMAT") then
call read_gmsh_section_meshformat
else if (section_header == "NODES") then
call read_gmsh_section_nodes
else if (section_header == "ELEMENTS") then
call read_gmsh_section_elements
else if (section_header == "PHYSICALNAMES") then
call read_gmsh_section_physicalnames
else if (section_header == "PERIODIC") then
call read_gmsh_section_periodic
else if (section_header == "NODEDATA") then
call read_gmsh_section_nodedata
else if (section_header == "ELEMENTDATA") then
call read_gmsh_section_elementdata
else if (section_header == "ELEMENTNODEDATA") then
call read_gmsh_section_elementnodedata
else if (section_header == "INTERPOLATIONSCHEME") then
call read_gmsh_section_interpolationscheme
else
!
! The section header wasnt recognized so continue reading
! the grid file until a valid section header is found
!
cycle
!
end if
!
end do
!
! Check that all the necessary sections were successfully read
!
if ( .not. meshformat_successful ) then
!
if (mypnum == 0) write (iout,2)
call stop_gfr(stop_mpi,pname,__LINE__,__FILE__)
!
else if ( .not. nodes_successful ) then
!
if (mypnum == 0) write (iout,3)
call stop_gfr(stop_mpi,pname,__LINE__,__FILE__)
!
else if ( .not. elements_successful ) then
!
if (mypnum == 0) write (iout,4)
call stop_gfr(stop_mpi,pname,__LINE__,__FILE__)
!
else if ( .not. physicalnames_successful ) then
!
if (mypnum == 0) write (iout,5)
call stop_gfr(stop_mpi,pname,__LINE__,__FILE__)
!
else
!
! We are done reading the grid file so close it
!
close (iogmsh,iostat=ierr,iomsg=error_message)
call io_error(pname,gridfile,2,__LINE__,__FILE__,ierr,error_message)
!
end if
!
! Finish creating the arrays defining the grid geometry.
! bface, nodes_of_cell_ptr, nodes_of_cell, etc.
!
call create_solver_geom_arrays_gmsh
!
! Deallocate the allocatable module arrays cell_data and phys_grps
! before we leave this subroutine.
!
!if (allocated(cell_data)) then
! deallocate ( cell_data , stat=ierr , errmsg=error_message )
! call alloc_error(pname,"cell_data",2,__LINE__,__FILE__,ierr,error_message)
!end if
if (allocated(phys_grps)) then
deallocate ( phys_grps , stat=ierr , errmsg=error_message )
call alloc_error(pname,"phys_grps",2,__LINE__,__FILE__,ierr,error_message)
end if
!
! Format statements
!
1 format (a)
2 format (/,"******************** ERROR! *********************",/, &
" Aborting because there was an error reading the",/, &
" 'MeshFormat' section of the GMSH grid file!",/, &
"******************** ERROR! *********************",/)
3 format (/,"******************** ERROR! *********************",/, &
" Aborting because there was an error reading the",/, &
" 'Nodes' section of the GMSH grid file!",/, &
"******************** ERROR! *********************",/)
4 format (/,"******************** ERROR! *********************",/, &
" Aborting because there was an error reading the",/, &
" 'Elements' section of the GMSH grid file!",/, &
"******************** ERROR! *********************",/)
5 format (/,"******************** ERROR! *********************",/, &
" Aborting because there was an error reading the",/, &
" 'PhysicalNames' section of the GMSH grid file!",/, &
"******************** ERROR! *********************",/)
!
end subroutine read_gmsh_gridfile
!
!###############################################################################
!
subroutine find_gmsh_section(text_out,end_of_file)
!
!.. Formal Arguments ..
logical(lk), intent(out) :: end_of_file
character(len=*), intent(out) :: text_out
!
!.. Local Scalars ..
integer :: ierr,n
character(len=len(text_out)) :: text
!
!.. Local Parameters ..
character(len=*), parameter :: pname = "find_gmsh_section"
!
continue
!
end_of_file = fals
text_out = ""
!
! Find the next line beginning with "$"
!
do
!
read (iogmsh,1,iostat=ierr,end=100,err=101) text
text = trim(adjustl(text))
!
if (text(1:1) == "$") then
n = len_trim(text)
text_out = uppercase(text(2:n))
exit
else
cycle
end if
!
end do
!
! Return if successfully found a new section header
!
return
!
! Read error continuation statements
!
100 end_of_file = true
return
!
101 if (mypnum == 0) write (iout,2) ierr
call stop_gfr(stop_mpi,pname,__LINE__,__FILE__)
!
! Format Statements
!
1 format (a)
2 format (/,"******************** ERROR! *********************",/, &
" Error trying to read the input grid file!", &
" IO Error = ",i0,/, &
"******************** ERROR! *********************",/)
!
end subroutine find_gmsh_section
!
!###############################################################################
!
subroutine read_gmsh_section_meshformat
!
!.. Local Scalars ..
integer :: ierr,gmsh_file_type,gmsh_data_size
logical(lk) :: end_of_file
real(wp) :: gmsh_version_num
character(len=80) :: text
!
!.. Local Parameters ..
character(len=*), parameter :: pname = "read_gmsh_section_meshformat"
!
continue
!
! Read the MeshFormat section of the GMSH grid file
!
read (iogmsh,*,iostat=ierr,end=100,err=101) gmsh_version_num, &
gmsh_file_type, &
gmsh_data_size
!
! Check that the GMSH version number is supported
!
gmsh_version_num = gmsh_version_num * ten
!
if (nint(gmsh_version_num) /= 22) then
if (mypnum == 0) write (iout,1)
call stop_gfr(stop_mpi,pname,__LINE__,__FILE__)
end if
!
! Return if the line marking the end of the MeshFormat section is found
!
call find_gmsh_section(text,end_of_file)
!
if (text == "ENDMESHFORMAT") then
meshformat_successful = true
return
else if (end_of_file) then
if (mypnum == 0) write (iout,2)
else
if (mypnum == 0) write (iout,3)
end if
!
call stop_gfr(stop_mpi,pname,__LINE__,__FILE__)
!
! Read error continuation statements
!
100 if (mypnum == 0) write (iout,2) ierr
call stop_gfr(stop_mpi,pname,__LINE__,__FILE__)
!
101 if (mypnum == 0) write (iout,4) ierr
call stop_gfr(stop_mpi,pname,__LINE__,__FILE__)
!
! Format Statements
!
1 format (/,"******************** ERROR! *********************",/, &
" The version of the GMSH grid file is",/, &
" not supported! Currently, only version",/, &
" 2.2 of the GMSH format is supported!",/, &
"******************** ERROR! *********************",/)
2 format (/,"******************** ERROR! *********************",/, &
" Pre-mature end-of-file while trying to read",/, &
" the 'MeshFormat' section of the GMSH grid file!",/, &
"******************** ERROR! *********************",/)
3 format (/,"*********************** ERROR! ************************",/, &
" While trying to read the 'MeshFormat' section of the",/, &
" GMSH grid file, an unknown and invalid section",/, &
" header was found before the required '$EndMeshFormat'",/, &
" line signifiying the end of the 'MeshFormat' section!",/, &
"*********************** ERROR! ************************",/)
4 format (/,"******************** ERROR! *********************",/, &
" Error trying to read the 'MeshFormat'",/, &
" section of the GMSH grid file!", &
" IO Error = ",i0,/, &
"******************** ERROR! *********************",/)
!
end subroutine read_gmsh_section_meshformat
!
!###############################################################################
!
subroutine read_gmsh_section_nodes
!
!.. Use Statements ..
use geovar, only : nr
use ovar, only : grid_scaling_factor
!
!.. Local Scalars ..
integer :: i,j,n,npts,ierr
logical(lk) :: end_of_file
real(wp) :: minz,maxz
character(len=80) :: text
!
!.. Local Allocatable Arrays ..
real(wp), allocatable, dimension(:,:) :: temp_nodes
!
!.. Local Parameters ..
character(len=*), parameter :: pname = "read_gmsh_section_nodes"
!
continue
!
! Default the number of grid dimensions to 3D since GMSH grid files
! seem to always contain three coordinate values for each node.
!
nr = 3
!
! Read the Nodes section of the GMSH grid file
!
read (iogmsh,*,iostat=ierr,end=100,err=101) npts
!
! Allocate the temporary array to read in the coordinates of the grid nodes
!
allocate ( temp_nodes(1:nr,1:npts) , source=zero , &
stat=ierr , errmsg=error_message )
call alloc_error(pname,"temp_nodes",1,__LINE__,__FILE__,ierr,error_message)
!
! Read the coordinates of the grid nodes
!
do n = 1,npts
read (iogmsh,*,iostat=ierr,end=100,err=101) i, (temp_nodes(j,i), j=1,nr)
end do
!
! If the minimum and maximum values of the coordinate in the third
! dimension are equal, reduce nr to 2 since this is a 2D grid.
!
minz = minval(temp_nodes(nr,:))
maxz = maxval(temp_nodes(nr,:))
!
if (abs(maxz-minz) <= eps6) nr = 2
!
! Allocate grid if it has not yet been allocated
!
if (.not. allocated(grid)) then
allocate ( grid , stat=ierr , errmsg=error_message )
call alloc_error(pname,"grid",1,__LINE__,__FILE__,ierr,error_message)
end if
!
! Allocate the xyz component of the grid derived type
! and use the temp_nodes array as the data source
!
allocate ( grid%xyz(1:nr,1:npts) , source=temp_nodes(1:nr,1:npts) , &
stat=ierr , errmsg=error_message )
call alloc_error(pname,"grid%xyz",1,__LINE__,__FILE__,ierr,error_message)
!
! Apply the grid scaling factor to the coordinates of the grid nodes
!
do n = 1,size(grid%xyz,dim=2)
do i = 1,size(grid%xyz,dim=1)
grid%xyz(i,n) = grid_scaling_factor*grid%xyz(i,n)
end do
end do
!
! Deallocate temp_nodes now that we no longer need it
!
deallocate ( temp_nodes , stat=ierr , errmsg=error_message )
call alloc_error(pname,"temp_nodes",2,__LINE__,__FILE__,ierr,error_message)
!
! Return if the line marking the end of the Nodes section is found
!
call find_gmsh_section(text,end_of_file)
!
if (text == "ENDNODES") then
nodes_successful = true
return
else if (end_of_file) then
if (mypnum == 0) write (iout,1)
else
if (mypnum == 0) write (iout,2)
end if
!
call stop_gfr(stop_mpi,pname,__LINE__,__FILE__)
!
! Read error continuation statements
!
100 if (mypnum == 0) write (iout,1) ierr
call stop_gfr(stop_mpi,pname,__LINE__,__FILE__)
!
101 if (mypnum == 0) write (iout,3) ierr
call stop_gfr(stop_mpi,pname,__LINE__,__FILE__)
!
! Format Statements
!
1 format (/,"******************** ERROR! *********************",/, &
" Pre-mature end-of-file while trying to read",/, &
" the 'Nodes' section of the GMSH grid file!",/, &
"******************** ERROR! *********************",/)
2 format (/,"*********************** ERROR! ************************",/, &
" While trying to read the 'Nodes' section of the",/, &
" GMSH grid file, an unknown and invalid section",/, &
" header was found before the required '$EndNodes'",/, &
" line signifiying the end of the 'Nodes' section!",/, &
"*********************** ERROR! ************************",/)
3 format (/,"******************** ERROR! *********************",/, &
" Error trying to read the 'Nodes'",/, &
" section of the GMSH grid file!", &
" IO Error = ",i0,/, &
"******************** ERROR! *********************",/)
!
end subroutine read_gmsh_section_nodes
!
!###############################################################################
!
subroutine read_gmsh_section_elements
!
!.. Local Scalars ..
integer :: i,j,m,n,ierr,nods
integer :: ntype,ntags,npts,geom
integer :: num_cell_data
logical(lk) :: end_of_file