-
Notifications
You must be signed in to change notification settings - Fork 3
/
chbndmod.f90
3771 lines (3694 loc) · 117 KB
/
chbndmod.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
! Copyright 2021, Christian Hafner
!
! This file is part of OpenMaXwell.
!
! OpenMaXwell is free software: you can redistribute it and/or modify
! it under the terms of the GNU General Public License as published by
! the Free Software Foundation, either version 3 of the License, or
! (at your option) any later version.
! OpenMaXwell is distributed in the hope that it will be useful,
! but WITHOUT ANY WARRANTY; without even the implied warranty of
! MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
! GNU General Public License for more details.
! You should have received a copy of the GNU General Public License
! along with OpenMaXwell. If not, see <http://www.gnu.org/licenses/>.
MODULE CHBND
! computation of boundaries
USE CHGRA
SAVE
CONTAINS
! Graphics
Subroutine TDrawBoundary(lCheck)
Implicit none
Include 'resource.fd'
Logical(4), intent(in) :: lCheck
Logical(4) ldum
ldum=lCheck
call WaitEndThread()
iThreadAction=1
call StartBNDThread(ldum)
end Subroutine TDrawBoundary
Subroutine StartBNDThread(ldi)
! start a new thread
Implicit none
Include 'resource.fd'
Integer(INT_PTR_KIND()) iThread
Integer(4), Save:: iArgument
Integer(4) iStack,iCreation,idum
Logical(4), intent(in) :: ldi
Logical(4) ldum
if(lThreadStarted) return
call OutTxt('t3','start boundary thread'C)
call OutTxt('n3',' 'C)
call OutTxt('m3',' 'C)
lThreadStarted=.true.
iStack=0
iArgument=0
iCreation=0
iThread=0
if(ldi) iArgument=1_4
if(iThreadHandle.ne.0) then
call OutTxt('t3','close thread handle'C)
ldum=CloseHandle(iThreadHandle)
if(.not.ldum) then
idum=MessageBoxQQ('Cannot close thread handle'C,'Start boundary thread'C, &
MB$OK.or.MB$ICONEXCLAMATION)
lThreadStarted=.false.
return
end if
iThreadHandle=0
endif
call OutTxt('t3','Start boundary thread'C)
iThreadHandle=CreateThread(NULL,iStack,Loc(BNDThread),Loc(iArgument),iCreation,iThread)
if(iThreadHandle.eq.0) then
idum=MessageBoxQQ('Cannot create thread'C,'Start boundary thread'C, &
MB$OK.or.MB$ICONEXCLAMATION)
lThreadStarted=.false.
return
end if
end Subroutine StartBNDThread
Integer(4) Function BNDThread(iWhat)
! tread calls.....
Implicit none
Integer(4) iWhat
Logical(4) ldum
Include 'resource.fd'
lStopThread=.false.
ldum=.false.
if(iWhat.ne.0) ldum=.true.
BNDThread=0_4
if(iThreadAction.eq.1) then
call MTDrawBoundary(ldum)
end if
call endThread()
end Function BNDThread
Subroutine DrawBoundary(kPl)
Implicit none
Real(8) x1,x2,dx,e,vt(2),x,y,xs,ys,s,ds,x0,y0,xPt,yPt,xPtn,yPtn
Integer(4) kPl,kP,k1,k2,kE,nE,i,m,istat,nxP,idum,iClose
Integer(2) iDomL,iDomR,ic0,ic
lWinFld(kWin)=.true.
lGRF_Mark=.false.
if(iWinAction.eq.1_2) lGRF_Mark=.true.
! set window, auto determine borders
call GetKWin(.false.)
istat=SetActiveQQ(10+kWin)
! get pixel size
call I2R(10_2,10_2,x1,dx)
call I2R(11_2,10_2,x2,dx)
dx=4.0d0*(x2-x1)
! determine min/max polygon numbers
if(kPl.lt.1) then
if(kPl.eq.0) then
k1=1
k2=nBnd
else
k1=1
k2=Min(nBnd,Max(1,kPl))
end if
else
if(kPl.gt.nBnd) return
k1=kPl
k2=k1
end if
call cBndGetABO() ! get c-poly, splines, match.pts
! lines in the matching points, normal to the boundary
if((kPl.eq.0).and.(dAbs(errorScale).gt.pSmall)) then
x2=BndLtot
nxP=nBndPt
do i=1,nxP
x1=sBndPt(i)
x1=dmin1(x1,x2*0.9999999999999d0)
call GetBndPt(0,x1,xPt,yPt,vt(1),vt(2),iDomL,iDomR,idum)
if(abs(iDomL).gt.30000_2) Cycle
call unit2DV(vt)
if(AerrorM.gt.pSmall) then
if(eBndPt(i).lt.pSmall) then
e=0.0d0
else
if(errorScale.lt.0.0d0) then
e=-errorScale*(eBndPt(i).div.fBndPt(i))
else
e=errorScale*eBndPt(i)
! e=errorScale*(eBndPt(i).div.AerrorM)
end if
end if
else
e=2.0d0*dx
end if
if(idomR.gt.0) then
if(iDom(Min(iDomR,Int2(nDom))).gt.0) then
xPtn=xPt+vt(2)*e
yPtn=yPt-vt(1)*e
ic0=SetColor(iDom(Min(iDomR,Int2(nDom))))
if(ic0.gt.0) call Draw23DLine(xPt,yPt,xPtn,yPtn)
ic0=SetColor(ic0)
end if
end if
if(idomL.gt.0) then
if(iDom(Min(iDomL,Int2(nDom))).gt.0) then
xPtn=xPt-vt(2)*e
yPtn=yPt+vt(1)*e
ic0=SetColor(iDom(Min(iDomL,Int2(nDom))))
call Draw23DLine(xPt,yPt,xPtn,yPtn)
ic0=SetColor(ic0)
end if
end if
end do
end if
! loop over polygons
ic0=SetColor(1_2)
do kP=k1,k2
if(LSkipBnd(kP)) Cycle
ic=SetColor(tBnd(kP)%iCol)
if((iBound.gt.2_2).and.((tBnd(kP)%nSpline.gt.1).or.((tBnd(kP)%nSpline.gt.0).and.(tBnd(kP)%nEdge.gt.1)))) then
x0=xSpline(tBnd(kP)%iSplineOffset+1)
y0=ySpline(tBnd(kP)%iSplineOffset+1)
m=tBnd(kP)%nSpline
if(m.lt.2) m=tBnd(kP)%nEdge
iClose=0
if(iiabs(tBnd(kP)%iTypB).eq.1_2) iClose=1
m=m+iClose
s=sSpline(tBnd(kP)%iSplineOffset+1)
ds=(sSpline(tBnd(kP)%iSplineOffset+m)-sSpline(tBnd(kP)%iSplineOffset+1))/dble(5*m)
do i=0,5*m
if(iClose.gt.0) then
call splint2(sSpline(tBnd(kP)%iSplineOffset+1),xSpline(tBnd(kP)%iSplineOffset+1), &
& ySpline(tBnd(kP)%iSplineOffset+1),xsSpline(tBnd(kP)%iSplineOffset+1), &
& ysSpline(tBnd(kP)%iSplineOffset+1),0,m-1,s,x,y,xs,ys)
else
call splint2(sSpline(tBnd(kP)%iSplineOffset+1),xSpline(tBnd(kP)%iSplineOffset+1), &
& ySpline(tBnd(kP)%iSplineOffset+1),xsSpline(tBnd(kP)%iSplineOffset+1), &
& ysSpline(tBnd(kP)%iSplineOffset+1),1,m,s,x,y,xs,ys)
end if
call Draw23DLine(x0,y0,x,y)
s=s+ds
x0=x
y0=y
end do
if(.not.lGRF_Mark) Cycle
end if
kE=1+tBnd(kP)%iEdgeOffset
nE=tBnd(kP)%nEdge+tBnd(kP)%iEdgeOffset
if(tBnd(kP)%nEdge.lt.1) Cycle
if(tBnd(kP)%nEdge.eq.1) then ! circle
call Draw23DCircleM(tBndEdg(kE)%x,tBndEdg(kE)%y,tBndEdg(kE)%r,dx)
Cycle
end if
if(tBnd(kP)%nEdge.eq.2) then
call Draw23DLineM(tBndEdg(kE)%x,tBndEdg(kE)%y,tBndEdg(kE+1)%x,tBndEdg(kE+1)%y,dx)
Cycle
end if
if(iiabs(tBnd(kP)%iTypB).eq.1_2) then
if(lGRF_Mark) then
call Draw23DLineM(tBndEdg(nE)%x,tBndEdg(nE)%y,tBndEdg(kE)%x,tBndEdg(kE)%y,dx)
else
call Draw23DLineM(tBndEdg(nE)%xb,tBndEdg(nE)%yb,tBndEdg(kE)%xa,tBndEdg(kE)%ya,dx)
end if
if(tBndEdg(kE)%r.gt.pSmall) then
if(tBndEdg(kE)%iOrient.eq.1_2) then
call Draw23DArcM(tBndEdg(kE)%xo,tBndEdg(kE)%yo,tBndEdg(kE)%xa,tBndEdg(kE)%ya, &
& tBndEdg(kE)%xb,tBndEdg(kE)%yb,dx)
else
call Draw23DArcM(tBndEdg(kE)%xo,tBndEdg(kE)%yo,tBndEdg(kE)%xb,tBndEdg(kE)%yb, &
& tBndEdg(kE)%xa,tBndEdg(kE)%ya,dx)
end if
end if
end if
do i=kE+1,nE
if(lGRF_Mark) then
call Draw23DLineM(tBndEdg(i-1)%x,tBndEdg(i-1)%y,tBndEdg(i)%x,tBndEdg(i)%y,dx)
else
call Draw23DLineM(tBndEdg(i-1)%xb,tBndEdg(i-1)%yb,tBndEdg(i)%xa,tBndEdg(i)%ya,dx)
end if
if(tBndEdg(i)%r.gt.pSmall) then
if(tBndEdg(i)%iOrient.eq.1_2) then
call Draw23DArcM(tBndEdg(i)%xo,tBndEdg(i)%yo,tBndEdg(i)%xa,tBndEdg(i)%ya, &
& tBndEdg(i)%xb,tBndEdg(i)%yb,dx)
else
call Draw23DArcM(tBndEdg(i)%xo,tBndEdg(i)%yo,tBndEdg(i)%xb,tBndEdg(i)%yb, &
& tBndEdg(i)%xa,tBndEdg(i)%ya,dx)
end if
end if
end do
end do
ic0=SetColor(ic0)
lGRF_Mark=.true.
end Subroutine DrawBoundary
Subroutine MTDrawBoundary(lCheck)
Implicit none
Include 'resource.fd'
Integer(4) idum
Logical(4), intent(in) :: lCheck
call EnterCriticalSection(Loc(DrawLock))
lWinFld(kWin)=.true.
if(.not.lCheck) then
idum=MessageBoxQQ('Clear graphic window first?'C,'Draw boundary'C, &
MB$YESNOCANCEL.or.MB$ICONQUESTION)
if(idum.eq.MB$IDCANCEL) then
call LeaveCriticalSection(Loc(DrawLock))
return
end if
if(idum.eq.MB$IDYES) then
call DrawWindow(lCheck)
end if
end if
call DrawBoundary(iDraBnd)
call LeaveCriticalSection(Loc(DrawLock))
end Subroutine MTDrawBoundary
Subroutine MTModifyBoundary(lCheck)
Implicit none
Include 'resource.fd'
Integer(4) idum
Logical(4), intent(in) :: lCheck
Logical(4) ldum
if(.not.lCheck) then
idum=MessageBoxQQ('Set view plane = xy plane?'C,'Modify boundary'C, &
MB$YESNOCANCEL.or.MB$ICONQUESTION)
if(idum.eq.MB$IDCANCEL) return
if(idum.eq.MB$IDYES) then
viewPlane(1:3,1:3)=0.0d0 ! view plane = xy, (origin unchanged)
viewPlane(3,0)=0.0d0
viewPlane(1,1)=1.0d0
viewPlane(2,2)=1.0d0
viewPlane(3,3)=1.0d0
end if
end if
iDraBnd=0
iDomBnd=0_2
iColBnd=0_2
iConBnd=0_2
iWinAction=1_2
call MTDrawBoundary(lCheck)
ldum=ModifyMenuFlagsQQ(3,1,$MenuChecked) !boundary
ldum=ModifyMenuFlagsQQ(3,2,$MenuUnChecked) !expansion
ldum=ModifyMenuFlagsQQ(3,3,$MenuUnChecked) !field
ldum=ModifyMenuFlagsQQ(3,4,$MenuUnChecked) !function
ldum=ModifyMenuFlagsQQ(3,5,$MenuUnChecked) !object
ldum=ModifyMenuFlagsQQ(3,6,$MenuUnChecked) !nothing
call OutTxt('t1','Modify boundary!'C)
end Subroutine MTModifyBoundary
! I/O
Subroutine SaveBoundary(lCheck)
! save Boundary data in a file
Implicit none
Logical(4), intent(in) :: lCheck
Integer(4) iOk,ios,i,idum
if(.not.lCheck) then
call Open2write(-1,'Select Boundary data file to be written!','Boundary data file ',BndFileName,'BND',ios)
if(ios.gt.0) return
end if
open(1,file=BndFileName,iostat=ios)
if(ios.ne.0) then
idum=MessageBoxQQ('Error opening file!\rCannot save data!'C,'Save boundary'C, &
MB$OK.or.MB$IconExclamation)
close(1)
return
end if
call WriteStr(1,CHBndIdent,iOK)
ich(1)=nBnd
sch(1:11)=' boundaries'
call chwrit2(1,ich,1,rch,0,sch,11,iOK)
do i=1,nBnd
ich(1)=tBnd(i)%nEdge
ich(2)=Int4(tBnd(i)%iLDom)
ich(3)=Int4(tBnd(i)%iRDom)
ich(4)=Int4(tBnd(i)%iCond)
ich(5)=Int4(tBnd(i)%iConn)
ich(6)=Int4(tBnd(i)%iTypB)
ich(7)=Int4(tBnd(i)%iCol)
ich(8)=tBnd(i)%nMatPts
call chwrit2(1,ich,8,rch,0,sch,0,iOK)
rch(1)=tBnd(i)%Weight
rch(2)=tBnd(i)%val(1)
rch(3)=tBnd(i)%val(2)
rch(4)=tBnd(i)%Weight2
call chwrit2(1,ich,0,rch,4,sch,0,iOK)
if(tBnd(i)%iTypB.lt.0_2) then
ich(1)=tBnd(i)%nSpline
rch(1)=tBnd(i)%fAmpl
call chwrit2(1,ich,1,rch,1,sch,0,iOK)
call WriteStr(1,tBnd(i)%Formula,iOK)
end if
end do
ich(1)=nBndEdg
sch(1:8)=' corners'
call chwrit2(1,ich,1,rch,0,sch,8,iOK)
do i=1,nBndEdg
ich(1)=tBndEdg(i)%iOrient
rch(1)=tBndEdg(i)%x
rch(2)=tBndEdg(i)%y
rch(3)=tBndEdg(i)%r
rch(4)=tBndEdg(i)%d
rch(5)=tBndEdg(i)%xa
rch(6)=tBndEdg(i)%ya
rch(7)=tBndEdg(i)%xb
rch(8)=tBndEdg(i)%yb
rch(9)=tBndEdg(i)%xo
rch(10)=tBndEdg(i)%yo
call chwrit2(1,ich,1,rch,10,sch,0,iOK)
end do
ich(1)=nBndSpl
sch(1:8)=' splines'
call chwrit2(1,ich,1,rch,0,sch,8,iOK)
do i=1,nBndSpl
rch(1)=sSpline(i)
rch(2)=xSpline(i)
rch(3)=ySpline(i)
rch(4)=xsSpline(i)
rch(5)=ysSpline(i)
call chwrit2(1,ich,0,rch,5,sch,0,iOK)
end do
sch(1:1)=' '
call chwrit2(1,ich,0,rch,0,sch,1,iOK)
EndFile(1)
close(1)
end Subroutine SaveBoundary
Subroutine OpenBoundary(lCheck)
! read Boundary data from a file
Implicit none
Logical, intent(in) :: lCheck
Logical ldum,lFileExist,lTxt
Integer(4) iVers
Integer(4) iOk,ios,i,i1,idum
Character(20) text
if(lAskBnd.or.(.not.lCheck)) then
nInsObj=nBnd
call InsertDialog(.true.)
if(kInsObj.lt.0) return
lInsertBnd=lInsObj
end if
if(.not.lCheck) then
call Open2read(-1,'Select Boundary data file to be read!','Boundary data file ',BndFileName,'BND',ios)
if(ios.gt.0) return
end if
inquire(file=BndFileName,Exist=lFileExist)
if(.not.lFileExist) return
open(1,file=BndFileName,status='old',iostat=ios)
if(ios.ne.0) then
if(.not.lCheck) idum=MessageBoxQQ('Error opening file!\rCannot read data!'C,'Open boundary'C, &
MB$OK.or.MB$IconExclamation)
close(1)
return
end if
call ReadStr(1,text,iOK)
call StrToInt(text(16:16)//text(18:18),iVers,iOK)
lTxt=.false.
if(CHBndIdent(1:15).ne.text(1:15)) then
idum=MessageBoxQQ('Wrong file Type!\rContinue reading?'C,'Open boundary'C, &
MB$YesNo.or.MB$IconQuestion)
if(idum.eq.MB$IDNO) then
close(1)
return
else ! read as primitive TXT file: Dummy line / number of polygons / for each polygon: number of points / for each point: x y
lTxt=.true.
iVers=0
end if
end if
errorM=0.0d0
errorMA=0.0d0
errorA=0.0d0
AerrorM=0.0d0
AerrorA=0.0d0
call chread2(1,ich,1,rch,0,iOK)
if(iOK.ne.0) then
idum=MessageBoxQQ('Error reading input file!\r(number of Boundarys)'C,'Open boundary'C, &
MB$OK.or.MB$ICONSTOP)
close(1)
return
end if
nInsObj=ich(1)
if(lInsertBnd) then
i=kInsObj
else
i=0
nBnd=0
nBndEdg=0
end if
do i1=1,nInsObj
if(lTxt) then
call chread2(1,ich,1,rch,0,iOK)
ich(2)=1
ich(3)=2
ich(4)=0
ich(5)=0
ich(6)=-2
ich(7)=ich(1)
ich(8)=0
else if(iVers.gt.19) then
call chread2(1,ich,8,rch,0,iOK)
else
call chread2(1,ich,7,rch,0,iOK)
ich(8)=0
end if
if(iOK.ne.0) then
idum=MessageBoxQQ('Error reading input file!\r(Boundary data)'C,'Open boundary'C, &
MB$OK.or.MB$ICONSTOP)
close(1)
return
end if
call InsertBnd(i,1,ldum)
if(.not.ldum) then
idum=MessageBoxQQ('Cannot insert boundary!'C,'Open boundary'C, &
MB$OK.or.MB$ICONSTOP)
close(1)
return
end if
i=i+1
tBnd(i)%nEdge=0
tBnd(i)%iLDom=Int2(ich(2))
tBnd(i)%iRDom=Int2(ich(3))
tBnd(i)%iCond=Int2(ich(4))
call GetBndBC(i)
tBnd(i)%iConn=Int2(ich(5))
tBnd(i)%iTypB=Int2(ich(6))
tBnd(i)%iCol=Int2(ich(7))
tBnd(i)%nMatPts=ich(8)
if(tBnd(i)%iTypB.eq.0_2) tBnd(i)%iTypB=2_2
if(lTxt) then
tBnd(i)%Weight=1.0
tBnd(i)%val(1)=0.0
tBnd(i)%val(2)=0.0
tBnd(i)%Weight2=tBnd(i)%Weight
else if(iVers.gt.20) then
call chread2(1,ich,0,rch,4,iOK)
if(iOK.ne.0) then
idum=MessageBoxQQ('Error reading input file!\r(Boundary data)'C,'Open boundary'C, &
MB$OK.or.MB$ICONSTOP)
close(1)
return
end if
tBnd(i)%Weight=rch(1)
tBnd(i)%val(1)=rch(2)
tBnd(i)%val(2)=rch(3)
tBnd(i)%Weight2=rch(4)
else
call chread2(1,ich,0,rch,3,iOK)
if(iOK.ne.0) then
idum=MessageBoxQQ('Error reading input file!\r(Boundary data)'C,'Open boundary'C, &
MB$OK.or.MB$ICONSTOP)
close(1)
return
end if
tBnd(i)%Weight=rch(1)
tBnd(i)%val(1)=rch(2)
tBnd(i)%val(2)=rch(3)
tBnd(i)%Weight2=tBnd(i)%Weight
end if
call InsertBndEdg(i,0,ich(1),ldum)
if(.not.ldum) then
idum=MessageBoxQQ('Cannot insert corner!'C,'Open boundary'C, &
MB$OK.or.MB$ICONSTOP)
close(1)
return
end if
tBnd(i)%nSpline=0
tBnd(i)%fAmpl=0.0d0
tBnd(i)%Formula='0'C
ich(1)=0
if(lTxt) then
tBnd(i)%nSpline=1
tBnd(i)%fAmpl=0.0d0
else if(tBnd(i)%iTypB.lt.0_2) then
call chread2(1,ich,1,rch,1,iOK)
if(iOK.ne.0) then
idum=MessageBoxQQ('Error reading input file!\r(Boundary formula)'C,'Open boundary'C, &
MB$OK.or.MB$ICONSTOP)
close(1)
return
end if
tBnd(i)%nSpline=ich(1)
tBnd(i)%fAmpl=rch(1)
call ReadStr(1,tBnd(i)%Formula,iOK)
if(iOK.ne.0) then
idum=MessageBoxQQ('Error reading input file!\r(Boundary formula)'C,'Open boundary'C, &
MB$OK.or.MB$ICONSTOP)
close(1)
return
end if
end if
end do
call chread2(1,ich,1,rch,0,iOK)
if(iOK.ne.0) then
idum=MessageBoxQQ('Error reading input file!\r(number of Corners)'C,'Open boundary'C, &
MB$OK.or.MB$ICONSTOP)
close(1)
return
end if
nInsObj=ich(1)
if(lInsertBnd) then
i=tBnd(kInsObj+1)%iEdgeOffset
else
i=0
end if
do i1=1,nInsObj
if(lTxt) then
call chread2(1,ich,0,rch,2,iOK)
ich(1)=1
rch(3:10)=0.0d0
else if(ivers.gt.29) then
call chread2(1,ich,1,rch,10,iOK)
else
call chread2(1,ich,1,rch,3,iOK)
rch(4:10)=0.0d0
end if
if(iOK.ne.0) then
idum=MessageBoxQQ('Error reading input file!\r(Corner data)'C,'Open boundary'C, &
MB$OK.or.MB$ICONSTOP)
close(1)
return
end if
i=i+1
tBndEdg(i)%iOrient=ich(1)
tBndEdg(i)%x=rch(1)
tBndEdg(i)%y=rch(2)
tBndEdg(i)%r=rch(3)
tBndEdg(i)%d=rch(4)
end do
close(1)
kBnd=nBnd
kBndEdg=nBndEdg
call cBndGetABO()
end Subroutine OpenBoundary
Subroutine SaveMaS(lCheck)
! save Boundary data in MaS files
Implicit none
Logical, intent(in) :: lCheck
Integer(4) iOk,ios,i,n,idum,n1
Integer(2) iDL,iDR
Real(8) x,y,s1,s2,ds,s,vt1,vt2,rc
if(.not.lCheck) then
call Open2write(-1,'Select Contour data file to be written!','Contour data file ',ConFileName,'DAT',ios)
if(ios.gt.0) return
end if
open(1,file=ConFileName,iostat=ios)
if(ios.ne.0) then
idum=MessageBoxQQ('Error opening file!\rCannot save data!'C,'Save contour'C, &
MB$OK.or.MB$IconExclamation)
close(1)
return
end if
n=abs(tBnd(kBnd)%nSpline)
if(n.lt.2) n=1000
n1=n
if(iiabs(tBnd(kBnd)%iTypB).eq.1_2) n1=n+1
ich(1)=n1
call chwrit2(1,ich,1,rch,0,sch,0,iOK)
s1=tBnd(kBnd)%Start
s2=s1+tBnd(kBnd)%sLength
ds=(s2-s1)/Dble(n)
s=s1-0.5d0*ds
do i=1,n
s=s+ds
call GetBndPt(kBnd,s,x,y,vt1,vt2,iDL,iDR,idum,rc)
rch(1)=x
rch(2)=y
rch(3)=vt1
rch(4)=vt2
rch(5)=rc
rch(6)=s
rch(7)=ds
call chwrit2(1,ich,0,rch,7,sch,0,iOK)
end do
if(n1.gt.n) then
s=s1+0.5d0*ds
call GetBndPt(kBnd,s,x,y,vt1,vt2,iDL,iDR,idum,rc)
rch(1)=x
rch(2)=y
rch(3)=vt1
rch(4)=vt2
rch(5)=rc
rch(6)=s
rch(7)=ds
call chwrit2(1,ich,0,rch,7,sch,0,iOK)
end if
sch(1:1)=' '
call chwrit2(1,ich,0,rch,0,sch,1,iOK)
EndFile(1)
close(1)
end Subroutine SaveMaS
! boundary operations
Subroutine SetBoundaryAmp(kPl,v1,kB2)
Implicit none
Real(8) v1
Integer(4) kPl,kP,k1,k2
Integer(4), Optional:: kB2
if(Present(kB2)) then
call GetRange(kPl,nBnd,k1,k2,kB2)
else
call GetRange(kPl,nBnd,k1,k2)
end if
do kP=k1,k2
if(LSkipBnd(kP)) Cycle
tBnd(kP)%fAmpl=v1
end do
end Subroutine SetBoundaryAmp
Subroutine SetBoundaryCnd(kPl,str,spe,kB2)
Implicit none
Integer(2) iC
Integer(4) kPl,kP,k1,k2
Character(3) str
Character(16) spe
Integer(4), Optional:: kB2
if(Present(kB2)) then
call GetRange(kPl,nBnd,k1,k2,kB2)
else
call GetRange(kPl,nBnd,k1,k2)
end if
do kP=k1,k2
if(LSkipBnd(kP)) Cycle
select case (str(1:3))
case('spe')
iC=0_2
if(spe(1:2).eq.'et') iC=iC+1_2
if(spe(3:4).eq.'ez') iC=iC+2_2
if(spe(5:6).eq.'dn') iC=iC+4_2
if(spe(7:8).eq.'ht') iC=iC+8_2
if(spe(9:10).eq.'hz') iC=iC+16_2
if(spe(11:12).eq.'bn') iC=iC+32_2
if(spe(13:14).eq.'az') iC=iC+64_2
if(spe(15:15).eq.'v') iC=iC+128_2
tBnd(kP)%iCond=iC
case('sib')
tBnd(kP)%iCond=-1_2
case('x-p')
tBnd(kP)%iCond=-101_2
case('y-p')
tBnd(kP)%iCond=-102_2
case('z-p')
tBnd(kP)%iCond=-103_2
case default ! usual
tBnd(kP)%iCond=0_2
end select
end do
end Subroutine SetBoundaryCnd
Subroutine SetBoundaryCol(kPl,ic,kB2)
Implicit none
Integer(4) kPl,kP,k1,k2,ic
Integer(4), Optional:: kB2
if(Present(kB2)) then
call GetRange(kPl,nBnd,k1,k2,kB2)
else
call GetRange(kPl,nBnd,k1,k2)
end if
do kP=k1,k2
if(LSkipBnd(kP)) Cycle
tBnd(kP)%iCol=Int2(ic)
end do
end Subroutine SetBoundaryCol
Subroutine SetBoundaryCon(kPl,ic,kB2)
Implicit none
Integer(4) kPl,kP,k1,k2,ic
Integer(4), Optional:: kB2
if(Present(kB2)) then
call GetRange(kPl,nBnd,k1,k2,kB2)
else
call GetRange(kPl,nBnd,k1,k2)
end if
do kP=k1,k2
if(LSkipBnd(kP)) Cycle
tBnd(kP)%iConn=Int2(ic)
end do
end Subroutine SetBoundaryCon
Subroutine SetBoundaryDom(kPl,ic,jc,kB2)
Implicit none
Integer(4) kPl,kP,k1,k2,ic,jc
Integer(4), Optional:: kB2
if(Present(kB2)) then
call GetRange(kPl,nBnd,k1,k2,kB2)
else
call GetRange(kPl,nBnd,k1,k2)
end if
do kP=k1,k2
if(LSkipBnd(kP)) Cycle
tBnd(kP)%iLDom=Int2(ic)
tBnd(kP)%iRDom=Int2(jc)
end do
end Subroutine SetBoundaryDom
Subroutine SetBoundaryFor(kPl,str,lstr,kB2)
Implicit none
Integer(4) kPl,lstr,kP,k1,k2,idum,lfdum
Integer(4), Optional:: kB2
character(256) str
if(Present(kB2)) then
call GetRange(kPl,nBnd,k1,k2,kB2)
else
call GetRange(kPl,nBnd,k1,k2)
end if
do kP=k1,k2
if(LSkipBnd(kP)) Cycle
tBnd(kP)%Formula=str(1:lstr)//char(0)
cForm(0)=0.0d0
cForm(1)=Pi
vForm(0)=0.789123456 ! any value between 0 and 1 is OK
vForm(1)=vForm(0)
call checkFormula(tBnd(kP)%Formula,lfdum,1,0,1,idum)
end do
end Subroutine SetBoundaryFor
Subroutine IncBoundaryAmp(kPl,v1,kB2)
Implicit none
Real(8) v1
Integer(4) kPl,kP,k1,k2
Integer(4), Optional:: kB2
if(Present(kB2)) then
call GetRange(kPl,nBnd,k1,k2,kB2)
else
call GetRange(kPl,nBnd,k1,k2)
end if
do kP=k1,k2
if(LSkipBnd(kP)) Cycle
tBnd(kP)%fAmpl=tBnd(kP)%fAmpl+v1
end do
end Subroutine IncBoundaryAmp
Subroutine MulBoundaryAmp(kPl,v1,kB2)
Implicit none
Real(8) v1
Integer(4) kPl,kP,k1,k2
Integer(4), Optional:: kB2
if(Present(kB2)) then
call GetRange(kPl,nBnd,k1,k2,kB2)
else
call GetRange(kPl,nBnd,k1,k2)
end if
do kP=k1,k2
if(LSkipBnd(kP)) Cycle
tBnd(kP)%fAmpl=tBnd(kP)%fAmpl*v1
end do
end Subroutine MulBoundaryAmp
Subroutine SetBoundaryPts(kPl,ic,kB2)
Implicit none
Integer(4) kPl,kP,k1,k2,ic
Integer(4), Optional:: kB2
if(Present(kB2)) then
call GetRange(kPl,nBnd,k1,k2,kB2)
else
call GetRange(kPl,nBnd,k1,k2)
end if
do kP=k1,k2
if(LSkipBnd(kP)) Cycle
tBnd(kP)%nMatPts=ic
end do
end Subroutine SetBoundaryPts
Subroutine IncBoundaryPts(kPl,ic,kB2)
Implicit none
Integer(4) kPl,kP,k1,k2,ic
Integer(4), Optional:: kB2
if(Present(kB2)) then
call GetRange(kPl,nBnd,k1,k2,kB2)
else
call GetRange(kPl,nBnd,k1,k2)
end if
do kP=k1,k2
if(LSkipBnd(kP)) Cycle
tBnd(kP)%nMatPts=tBnd(kP)%nMatPts+ic
end do
end Subroutine IncBoundaryPts
Subroutine MulBoundaryPts(kPl,ic,kB2)
Implicit none
Integer(4) kPl,kP,k1,k2,ic
Integer(4), Optional:: kB2
if(Present(kB2)) then
call GetRange(kPl,nBnd,k1,k2,kB2)
else
call GetRange(kPl,nBnd,k1,k2)
end if
do kP=k1,k2
if(LSkipBnd(kP)) Cycle
tBnd(kP)%nMatPts=tBnd(kP)%nMatPts*ic
end do
end Subroutine MulBoundaryPts
Subroutine SetBoundarySpl(kPl,ic,kB2)
Implicit none
Integer(4) kPl,kP,k1,k2,ic
Integer(4), Optional:: kB2
if(Present(kB2)) then
call GetRange(kPl,nBnd,k1,k2,kB2)
else
call GetRange(kPl,nBnd,k1,k2)
end if
do kP=k1,k2
if(LSkipBnd(kP)) Cycle
tBnd(kP)%nSpline=ic
end do
end Subroutine SetBoundarySpl
Subroutine IncBoundarySpl(kPl,ic,kB2)
Implicit none
Integer(4) kPl,kP,k1,k2,ic
Integer(4), Optional:: kB2
if(Present(kB2)) then
call GetRange(kPl,nBnd,k1,k2,kB2)
else
call GetRange(kPl,nBnd,k1,k2)
end if
do kP=k1,k2
if(LSkipBnd(kP)) Cycle
tBnd(kP)%nSpline=tBnd(kP)%nSpline+ic
end do
end Subroutine IncBoundarySpl
Subroutine MulBoundarySpl(kPl,ic,kB2)
Implicit none
Integer(4) kPl,kP,k1,k2,ic
Integer(4), Optional:: kB2
if(Present(kB2)) then
call GetRange(kPl,nBnd,k1,k2,kB2)
else
call GetRange(kPl,nBnd,k1,k2)
end if
do kP=k1,k2
if(LSkipBnd(kP)) Cycle
tBnd(kP)%nSpline=tBnd(kP)%nSpline*ic
end do
end Subroutine MulBoundarySpl
Subroutine SetBoundaryVal(kPl,v1,v2,kB2)
Implicit none
Real(8) v1,v2
Integer(4) kPl,kP,k1,k2
Integer(4), Optional:: kB2
if(Present(kB2)) then
call GetRange(kPl,nBnd,k1,k2,kB2)
else
call GetRange(kPl,nBnd,k1,k2)
end if
do kP=k1,k2
if(LSkipBnd(kP)) Cycle
tBnd(kP)%val(1)=v1
tBnd(kP)%val(2)=v2
end do
end Subroutine SetBoundaryVal
Subroutine IncBoundaryVal(kPl,v1,v2,kB2)
Implicit none
Real(8) v1,v2
Integer(4) kPl,kP,k1,k2
Integer(4), Optional:: kB2
if(Present(kB2)) then
call GetRange(kPl,nBnd,k1,k2,kB2)
else
call GetRange(kPl,nBnd,k1,k2)
end if
do kP=k1,k2
if(LSkipBnd(kP)) Cycle
tBnd(kP)%val(1)=tBnd(kP)%val(1)+v1
tBnd(kP)%val(2)=tBnd(kP)%val(2)+v2
end do
end Subroutine IncBoundaryVal
Subroutine MulBoundaryVal(kPl,v1,v2,kB2)
Implicit none
Real(8) v1,v2
Integer(4) kPl,kP,k1,k2
Integer(4), Optional:: kB2
if(Present(kB2)) then
call GetRange(kPl,nBnd,k1,k2,kB2)
else
call GetRange(kPl,nBnd,k1,k2)
end if
do kP=k1,k2
if(LSkipBnd(kP)) Cycle
tBnd(kP)%val(1)=tBnd(kP)%val(1)*v1
tBnd(kP)%val(2)=tBnd(kP)%val(2)*v2
end do
end Subroutine MulBoundaryVal
Subroutine SetBoundaryWei(kPl,v1,v2,kB2)
Implicit none
Real(8) v1,v2
Integer(4) kPl,kP,k1,k2
Integer(4), Optional:: kB2
if(Present(kB2)) then
call GetRange(kPl,nBnd,k1,k2,kB2)
else
call GetRange(kPl,nBnd,k1,k2)
end if
do kP=k1,k2
if(LSkipBnd(kP)) Cycle
tBnd(kP)%weight=v1
tBnd(kP)%weight2=v2
end do
end Subroutine SetBoundaryWei
Subroutine IncBoundaryWei(kPl,v1,v2,kB2)
Implicit none
Real(8) v1,v2
Integer(4) kPl,kP,k1,k2
Integer(4), Optional:: kB2
if(Present(kB2)) then
call GetRange(kPl,nBnd,k1,k2,kB2)
else
call GetRange(kPl,nBnd,k1,k2)
end if
do kP=k1,k2
if(LSkipBnd(kP)) Cycle
tBnd(kP)%weight=tBnd(kP)%weight+v1
tBnd(kP)%weight2=tBnd(kP)%weight2+v2
end do
end Subroutine IncBoundaryWei
Subroutine MulBoundaryWei(kPl,v1,v2,kB2)
Implicit none
Real(8) v1,v2
Integer(4) kPl,kP,k1,k2
Integer(4), Optional:: kB2
if(Present(kB2)) then
call GetRange(kPl,nBnd,k1,k2,kB2)
else
call GetRange(kPl,nBnd,k1,k2)
end if
do kP=k1,k2
if(LSkipBnd(kP)) Cycle
tBnd(kP)%weight=tBnd(kP)%weight*v1
tBnd(kP)%weight2=tBnd(kP)%weight2*v2
end do
end Subroutine MulBoundaryWei
Subroutine BlowBoundary(kPl,x,y,f,kB2)
Implicit none
Real(8) f,x,y
Integer(4) kPl,kP,k1,k2,kE,nE
Integer(4), Optional:: kB2
if(Present(kB2)) then