-
Notifications
You must be signed in to change notification settings - Fork 49
/
Copy pathagd3d.f
executable file
·1706 lines (1504 loc) · 66.6 KB
/
agd3d.f
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
C agd3d
C also includes subroutine polyir
c #####################################################################
subroutine agd3d(cmo,toldamage,tollength,mpary_in,mpno_in
& ,lstrictmergelength,lignoremats,lcheckaxy,lcheckroughness
& ,tol_roughness_in,ierror)
c
c #####################################################################
c
c PURPOSE
c
c AGD3D ("Annihilate on Graph Damage in 3D")
c takes a 3D mesh object and annihilates nodes that
c (i) are in the list of selected mass points,
c (ii) would cause a 'graph damage' of no greater than TOLDAMAGE if
c they are removed, and
c (iii) are within TOLLENGTH of a suitable neighboring node which
c they can merge in to.
c
c INPUT ARGUMENTS -
c
c CMO - name of current mesh object
c TOLDAMAGE - maximum allowable graph damage for
c annihilated nodes
c TOLLENGTH - maximum allowable length of edges
c created by node annihilation
c MPARY_IN - array of mass points
c MPNO_IN - no. of mass points
c LSTRICTMERGELENGTH - interpret TOLLENGTH strictly if true
c LIGNOREMATS - treat as uniform material if true
c LCHECKAXY - check projected area in xy plane is > EPSILONA
c
c OUTPUT ARGUMENTS -
c
c IERROR - error return
c
c CHANGE HISTORY -
c
c $Log: agd3d.f,v $
c Revision 2.00 2007/11/05 19:45:46 spchu
c Import to CVS
c
CPVCS
CPVCS Rev 1.41 29 Apr 2002 13:56:10 dcg
CPVCS fix unassigned index error (nbr)
CPVCS
CPVCS Rev 1.40 14 Mar 2002 10:56:18 dcg
CPVCS remove overflow past column 72
CPVCS
CPVCS Rev 1.39 01 Mar 2002 14:44:18 dcg
CPVCS adaptive merging
CPVCS
CPVCS Rev 1.38 31 Jan 2002 13:14:40 dcg
CPVCS move damage functions to testdamage
CPVCS
CPVCS Rev 1.37 16 Jan 2002 14:27:26 dcg
CPVCS add function damamge_est_discrete
CPVCS
CPVCS Rev 1.37 14 Jan 2002 17:20:00 dcg
CPVCS add function damage_est_discrete
CPVCS
CPVCS Rev 1.36 31 May 2001 14:27:38 kuprat
CPVCS Fixed argument list for POLYIR.
CPVCS
CPVCS Rev 1.35 29 May 2001 17:58:00 kuprat
CPVCS We now refrain from merging out nodes if they would create
CPVCS a roughness > 0.8*TOLROUGHNESS.
CPVCS
CPVCS Rev 1.34 14 May 2001 08:44:06 kuprat
CPVCS Put in CHECKAXY option.
CPVCS
CPVCS Rev 1.33 04 May 2001 14:18:46 kuprat
CPVCS Changed TOLAR to TOLIR, WORSTAR to WORSTIR, etc., reflecting the
CPVCS change that the criterion is now inscribed radius, not aspect ratio.
CPVCS
CPVCS Rev 1.32 07 Jul 2000 15:51:26 kuprat
CPVCS We now use an LSTALE array to prevent us from recomputing whether a node
CPVCS should be merged in a nbd where nothing has been changed.
CPVCS
CPVCS Rev 1.31 01 Mar 2000 14:56:52 kuprat
CPVCS We now can process tets with zero or negative inscribed radii
CPVCS and we try to get their inscribed radii to be positive.
CPVCS If LSTRICTMERGELENGTH is .true., we do not allow some merges of
CPVCS edges of length greater than TOLLENGTH that we would have allowed
CPVCS due to the presence of elements with small inscribed radii.
CPVCS IF LIGNOREMATS is .true., we process the grid as if there was
CPVCS only one material type.
CPVCS
CPVCS Rev 1.30 Thu Nov 18 18:18:06 1999 kuprat
CPVCS We now reduce damage allowed if inscribed radius is large, and
CPVCS only use full user damage tolerance if inscribed radius is small
CPVCS (and we want to try everything to increase it). Similarly, we
CPVCS now all inscribed radius to go down during annihilation UNLESS
CPVCS inscribed radius is already very small (and we want to prevent
CPVCS it from getting smaller).
CPVCS
CPVCS Rev 1.29 Tue Oct 12 08:21:46 1999 kuprat
CPVCS We now annihilate, paying attention to incribed radius maximization,
CPVCS rather than aspect ratio optimization.
CPVCS
CPVCS Rev 1.28 Thu Aug 26 13:46:24 1999 kuprat
CPVCS Changed output mode from 'default' to 'bat' for curve
CPVCS neighbor warnings due to excessive warns.
CPVCS
CPVCS Rev 1.27 Fri Jan 15 13:38:26 1999 kuprat
CPVCS Changed 'Error' to 'Stern Warning' in the case of no
CPVCS common material type; we now all execution to continue.
CPVCS
CPVCS Rev 1.26 Wed Jan 13 15:57:42 1999 kuprat
CPVCS Now use SAFE in denominators in DAMAGE_EST_2.
CPVCS
CPVCS Rev 1.25 Mon Jan 11 11:00:00 1999 kuprat
CPVCS Changed definition of TOLLENGTH so that it is now the
CPVCS merge length.
CPVCS
CPVCS Rev 1.24 Mon Dec 21 13:46:08 1998 kuprat
CPVCS We now allow merging of 'weird' curve points (i.e. those not having
CPVCS unique successors and predecessors) to connected curve points, as
CPVCS long as the movement required is less than TOLDAMAGE.
CPVCS
CPVCS Rev 1.23 Wed Nov 04 11:14:16 1998 dcg
CPVCS fix never used warnings
CPVCS
CPVCS Rev 1.22 Wed Nov 04 02:42:08 1998 kuprat
CPVCS Slightly changed method for calculating number of effective
CPVCS constraints, MCR, for a node.
CPVCS
CPVCS Rev 1.21 Fri Oct 30 15:25:14 1998 kuprat
CPVCS We now look at the aspect ratio situation BEFORE merging
CPVCS (via a call to POLYAR) and look for relative improvements
CPVCS caused by potential merges.
CPVCS
CPVCS Rev 1.20 Fri Oct 23 16:25:10 1998 kuprat
CPVCS We now call SYNTHNORMAL to compute a synthetic normal at NODE in
CPVCS the case of triangulated surfaces. This allows us to pre-reject
CPVCS node merges that would have been rejected by MERGEPTS_SIMPLEX anyway.
CPVCS We now test that we don't created tets or triangles with bad
CPVCS aspect ratios, and we now more aggressively try to eliminate
CPVCS elements with small inscribed radii.
CPVCS
CPVCS Rev 1.19 Tue Sep 15 12:55:02 1998 dcg
CPVCS add last argument in calls to lwontinvert
CPVCS
CPVCS Rev 1.18 Fri Aug 21 16:46:32 1998 dcg
CPVCS make changes to allow for 2d massage
CPVCS
CPVCS Rev 1.17 Fri Jul 31 18:19:24 1998 kuprat
CPVCS Loosened merge criterion by allowing low-projection-
CPVCS distance merges.
CPVCS
CPVCS Rev 1.16 Fri Jun 19 09:40:00 1998 dcg
CPVCS remove duplicate declarations
CPVCS
CPVCS Rev 1.15 Wed Jun 17 11:54:50 1998 dcg
CPVCS move write statement about number of nodes merged
CPVCS
CPVCS Rev 1.14 Wed Jun 10 16:56:24 1998 dcg
CPVCS add print statement of number of nodes merged
CPVCS
CPVCS Rev 1.13 Wed Jun 03 08:45:28 1998 dcg
CPVCS correct loop index nelmnee should be nelmnen
CPVCS call mergepts_simplex
CPVCS
CPVCS Rev 1.12 Sat May 23 23:46:40 1998 kuprat
CPVCS Now merge points with faster MERGEPTS_TET.
CPVCS
CPVCS Rev 1.11 Sat May 23 20:33:18 1998 kuprat
CPVCS Pass TOLDAMAGE on to RECON now.
CPVCS
CPVCS Rev 1.10 Tue May 05 16:46:46 1998 kuprat
CPVCS Put in 'ridge' damage estimate.
CPVCS
CPVCS Rev 1.9 Thu Apr 30 19:41:22 1998 kuprat
CPVCS Fixed bug where LISNBR wasn't always restored to 'all .false.'
CPVCS
CPVCS Rev 1.8 Thu Apr 30 15:13:24 1998 kuprat
CPVCS We now rank neighbors to a given node in order of distance, precheck
CPVCS their viability for annihilation, and then continue down the list
CPVCS until we find one that works. Documentation is now out of date...
CPVCS
CPVCS Rev 1.7 Tue Apr 28 16:26:48 1998 kuprat
CPVCS Got rid of center-of-mass 'worstlength' estimate. Estimate was
CPVCS too pessimistic. New estimate based on knowledge of actual
CPVCS pair of nodes to be merged.
CPVCS
CPVCS Rev 1.6 Fri Apr 10 16:53:16 1998 kuprat
CPVCS No change.
c
c #####################################################################
C input parameters cmo,toldamage,tollength,mpary_in,mpno_in
C ,lstrictmergelength,lignoremats,lcheckaxy,lcheckroughness
C ,tol_roughness_in,ierror
implicit none
C
include 'consts.h'
include 'local_element.h'
include 'chydro.h'
include 'massage.h'
C arguments
character*32 cmo
integer mpno_in, ierror
integer mpary_in(*)
logical lstrictmergelength,lignoremats,lcheckaxy,lcheckroughness
real*8 toldamage,tollength,tol_roughness_in
C variables
character*132 logmess,cbuf
pointer (ipimt1, imt1),(ipitp1, itp1),(ipisn1, isn1)
pointer (ipicr1, icr1)
pointer (ipxic, xic),(ipyic, yic),(ipzic, zic)
pointer (ipitetclr, itetclr)
integer itetclr(*)
pointer (ipitet, itet)
pointer (ipitetoff, itetoff),(ipitettyp, itettyp)
integer imt1(*)
pointer (ipicontab, icontab)
integer icontab(50,*), itp1(*),isn1(*)
integer icr1(*)
real*8 xic(*),yic(*),zic(*)
integer itet(*),itetoff(*),itettyp(*)
pointer (ipjtet,jtet),(ipjtetoff,jtetoff)
integer jtet(*),jtetoff(*)
pointer (iphxx,hxx),(iphxy,hxy),(iphxz,hxz),(iphyy,hyy),
& (iphyz,hyz ),(iphzz,hzz)
real*8 hxx(*),hxy(*),hxz(*),hyy(*),hyz(*),hzz(*)
pointer (ipnodhyb,nodhyb),(ipnodhyboff,nodhyboff)
integer nodhyb(*),nodhyboff(*)
pointer (ipieltary,ieltary)
integer ieltary(*)
pointer (ipireal1,ireal1),(ipinvmpary,invmpary),
& (ipichildary,ichildary),(ipinvchildary,invchildary),
& (ipiparent,iparent),(ipmpary,mpary),(ipirealold,irealold)
integer invmpary(*),ichildary(*),invchildary(*),
& ireal1(*),iparent(*),mpary(*),irealold(*)
pointer (ipelts,elts),(ipedges,edges)
integer elts(*),edges(*)
pointer (ipmcr,mcr),(ipmat,mat),
& (ipnodelist,nodelist),
& (ipnearestnbr,nearestnbr),(ipworst_length,worst_length),
& (iplockout,lockout),(ipinvneibr,invneibr),(ipneibr,neibr),
& (ipdnbr,dnbr),(ipnbrlist,nbrlist),(ipimerge,imerge),
& (ipdnbrproj,dnbrproj),(ipielts,ielts),(iplstale,lstale)
integer mcr(*),mat(*),nodelist(*),
& nearestnbr(*),neibr(*),nbrlist(*),
& imerge(2,*),ielts(*)
real*8 worst_length(*),areak,dnbr(*),
& dnbrproj(*)
integer invneibr(*)
pointer (ipgsynth,gsynth)
real*8 gsynth(3,*)
integer len_gsynth
integer nnodes,length,icmotype,nelements,mbndry,icscode,
& ieltno,i,j,node,nod1,icr,nmat,ii,lochybnod,ihyb,
& ityp,k,locnbr,nbr,nnbr,ioff,ie1,ie2,nelts,
& nearnbr,k1,i2,i3,i4,minmat,maxmat,j1,kk,
& nanni,ianni,ierr,ierrw,mpno,mpno_old,ierrdum,
& ichildno,nod,len_ieltary,len_mat,inc,nummat,
& merge_lives,merge_dies,nsdtopo,jj,
& len_neibr,nodek,i0,nelt,nearnbrj,
& nmrg,nodek1,nnbrk,nnbrk1,nnbr1,ip1,ip2,
& nef_cmo,ioppnod,len_ielts,ifromitp,ifromicr,ntrip,mtrip,idata
real*8 dnearnbr,frac,damage,xproj,
& yproj,zproj,a1x,a1y,a1z,ax,ay,az,atot,avec,
& projmin,projmax,proj,ascend,
& vtol,projdamage,damage_est_2,
& xk1,yk1,zk1,elen,
& xk2,yk2,zk2,xk3,yk3,zk3,
& dprojnearnbr,xk4,yk4,zk4,dir,dirtol,worstir,
& synthx,synthy,synthz,toldamageused,dltol,tolroughness,
& epsln,epsilonv_save,epsilona,toldamage_in
logical lsame,lvalidface,lwontinvert,ltripedge,lsomereversed
logical lockout(*),lstale(*)
character*8 cdefault
character*32 isubname,cdata
integer maxlenstr
parameter (maxlenstr=4095)
real*8 tolcutfactor,tolimprovefactor_up,tolimprovefactor_down
real*8 alg_epsilon
parameter (tolcutfactor=0.25)
parameter (tolimprovefactor_up=1.000001)
parameter (tolimprovefactor_down=0.5)
parameter (alg_epsilon=1.d-10)
include 'statementfunctions.h'
C ####################################################################
C Begin
isubname='agd3d'
len_gsynth=0
cdefault='default'
ierror=0
toldamage_in=toldamage
tolroughness=0.8*tol_roughness_in
call get_epsilon('epsilonl',dltol)
call get_epsilon('epsilonv',epsilonv_save)
call get_epsilon('epsilona',epsilona)
C TAM change unitialised eps to epsln value
epsln=dltol
vtol=-1.d99
call cmo_set_attinfo('epsilonv',cmo,idata,vtol,cdata,2,icscode)
c.... Allocate memory for arrays that cannot grow in size. (There
c.... are a couple of arrays that have to be allocated within the
c.... following loop, since they could grow in size.)
call cmo_get_info('nnodes',cmo,
* nnodes,length,icmotype,ierror)
call mmgetblk('ireal1',isubname,ipireal1,nnodes,1,icscode)
call mmgetblk('irealold',isubname,ipirealold,nnodes,1,icscode)
call mmgetblk('iparent',isubname,ipiparent,nnodes,1,icscode)
call mmgetblk('invmpary',isubname,ipinvmpary,nnodes,1,icscode)
call mmgetblk('ichildary',isubname,ipichildary,nnodes,1,icscode)
call mmgetblk('invchildary',isubname,ipinvchildary,nnodes,1,
& icscode)
call mmgetblk('mpary',isubname,ipmpary,mpno_in,1,icscode)
call mmgetblk('mcr',isubname,ipmcr,mpno_in,1,icscode)
call mmgetblk('nodelist',isubname,ipnodelist,mpno_in,1,icscode)
call mmgetblk('lockout',isubname,iplockout,nnodes,1,icscode)
call mmgetblk('lstale',isubname,iplstale,nnodes,1,icscode)
call mmgetblk('nearestnbr',isubname,ipnearestnbr,
& mpno_in,1,icscode)
call mmgetblk('worst_length',isubname,ipworst_length,
& mpno_in,2,icscode)
call mmgetblk('invneibr',isubname,ipinvneibr,
& nnodes,1,icscode)
call mmgetblk('imerge',isubname,ipimerge,
& 2*nnodes,1,icscode)
call mmgetblk('elts',isubname,ipelts,100,1,icscode)
call mmgetblk('edges',isubname,ipedges,100,1,icscode)
do i=1,nnodes
invneibr(i)=0
enddo
len_ieltary=0
len_mat=0
len_neibr=0
len_ielts=0
c.... We copy the input mass point array to a new array. The new array
c.... will shrink as we deem certain nodes in the array to be
c.... unsuitable for annihilation.
do k=1,mpno_in
mpary(k)=mpary_in(k)
enddo
mpno=mpno_in
c.... Initialize IREALOLD to 2. Eventually, when each element of
c.... IREAL is equal to each element of IREALOLD, then the outer
c.... annihilation loop is not dudding out anymore points and we
c.... break out. The initialization to 2 guarantees that the
c.... arrays won't match to begin with.
do i=1,nnodes
irealold(i)=2
enddo
do i=1,nnodes
lockout(i)=.false.
lstale(i)=.true.
enddo
c.... Outer iteration loop for annihilating nodes. On each iteration of
c.... the outer loop, a set of nodes that do not interfere with each
c.... other is annihilated. Since this changes the mesh object, each
c.... outer loop iteration includes getting fresh pointers for the
c.... mesh object and recalculating the relevant geometric quantities.
do while (mpno.gt.0)
c.... Get info from mesh object.
call cmo_get_info('nnodes',cmo,
* nnodes,length,icmotype,ierror)
call cmo_get_info('nelements',cmo,
* nelements,length,icmotype,ierror)
call cmo_get_info('ndimensions_topo',cmo,
* nsdtopo,length,icmotype,ierror)
call cmo_get_info('mbndry',cmo,
* mbndry,length,icmotype,ierror)
call cmo_get_info('imt1',cmo,ipimt1,length,icmotype,ierror)
call cmo_get_info('itp1',cmo,ipitp1,length,icmotype,ierror)
call cmo_get_info('icr1',cmo,ipicr1,length,icmotype,ierror)
call cmo_get_info('isn1',cmo,ipisn1,length,icmotype,ierror)
call cmo_get_info('xic',cmo,ipxic,length,icmotype,ierror)
call cmo_get_info('yic',cmo,ipyic,length,icmotype,ierror)
call cmo_get_info('zic',cmo,ipzic,length,icmotype,ierror)
call cmo_get_info('itetclr',cmo,
* ipitetclr,length,icmotype,ierror)
call cmo_get_info('itet',cmo,ipitet,length,icmotype,ierror)
call cmo_get_info('itetoff',cmo,ipitetoff,length,icmotype
& ,ierror)
call cmo_get_info('jtet',cmo,ipjtet,length,icmotype,ierror)
call cmo_get_info('jtetoff',cmo,ipjtetoff,length,icmotype
& ,ierror)
call cmo_get_info('itettyp',cmo,ipitettyp,length,icmotype
& ,ierror)
call cmo_get_info('icontab',cmo,ipicontab,length,icmotype
& ,ierror)
call cmo_get_info('faces_per_element',cmo,nef_cmo,
& length,icmotype,ierror)
if(isafield) then
c.... issue SETHESSIAN command to generate necessary 2nd derivatives.
write(cbuf,'(3a)') 'sethessian/',adaption_field_name,
& '/ ; finish'
call dotask(cbuf,ierror)
if (ierror.ne.0) then
write(logmess,'(a)')
& 'CEE_CHAIN: error computing Hessian'
call writloga('default',0,logmess,0,ierrw)
goto 9999
endif
call cmo_get_info('hxx',cmo,iphxx,length,icmotype,ierror)
call cmo_get_info('hxy',cmo,iphxy,length,icmotype,ierror)
call cmo_get_info('hxz',cmo,iphxz,length,icmotype,ierror)
call cmo_get_info('hyy',cmo,iphyy,length,icmotype,ierror)
call cmo_get_info('hyz',cmo,iphyz,length,icmotype,ierror)
call cmo_get_info('hzz',cmo,iphzz,length,icmotype,ierror)
endif
c 1) do we have a real point?
c ireal1() = 0 ==> not a real point.
c ireal1() = 1 ==> a real point.
c
call unpacktp("allreal","set",nnodes,ipitp1,ipireal1,ierrdum)
if(ierrdum.ne.0) call x3d_error('agd3d', 'unpacktp')
c
c
c
c
lsame=.true.
do i=1,nnodes
if (ireal1(i).ne.irealold(i)) lsame=.false.
enddo
if (lsame) goto 9999
do i=1,nnodes
irealold(i)=ireal1(i)
enddo
c ..................................................................
c find the parents of each node.
c
call unpackpc(nnodes,itp1,isn1,iparent)
c.... change mass point array to contain only parent nodes.
do i=1,nnodes
invmpary(i)=0
invchildary(i)=0
enddo
mpno_old=mpno
mpno=0
ichildno=0
do k=1,mpno_old
if (ireal1(mpary(k)).eq.1.or.
& itp1(mpary(k)).eq.ifitpcup) then
nod=iparent(mpary(k))
if (invmpary(nod).eq.0) then
mpno=mpno+1
mpary(mpno)=nod
invmpary(nod)=mpno
if (itp1(nod).eq.ifitpcup) then
nod1=isn1(nod)
do while (nod1.ne.nod.and.nod1.ne.0)
ichildno=ichildno+1
ichildary(ichildno)=nod1
invchildary(nod1)=ichildno
nod1=isn1(nod1)
enddo
else
ichildno=ichildno+1
ichildary(ichildno)=nod
invchildary(nod)=ichildno
endif
endif
endif
enddo
if (mpno.le.0) goto 9999
c.... Compute list of elements that are involved in this computations
c.... (ie contain at least one node in CHILDARY).
if (len_ieltary.eq.0) then
len_ieltary=100+nelements
call mmgetblk('ieltary',isubname,ipieltary,
& len_ieltary,1,icscode)
elseif (len_ieltary.lt.nelements) then
inc=100+nelements-len_ieltary
len_ieltary=len_ieltary+inc
call mmincblk('ieltary',isubname,ipieltary,inc,icscode)
endif
minmat=999999
maxmat=-999999
ieltno=0
do 40 i=1,nelements
do j=1,nelmnen(itettyp(i))
if (invchildary(itet(j+itetoff(i))).ne.0) then
ieltno=ieltno+1
ieltary(ieltno)=i
minmat=min(minmat,imt1(itet(1+itetoff(i))))
maxmat=max(maxmat,imt1(itet(1+itetoff(i))))
goto 40
endif
enddo
40 continue
nummat=maxmat-minmat+1
if (len_mat.eq.0) then
len_mat=100+nummat
call mmgetblk('mat',isubname,ipmat,len_mat,1,icscode)
elseif (len_mat.lt.nummat) then
inc=100+nummat-len_mat
call mmincblk('mat',isubname,ipmat,inc,icscode)
endif
if (len_neibr.eq.0) then
len_neibr=100
call mmgetblk('neibr',isubname,ipneibr,len_neibr,1,icscode)
call mmgetblk('dnbr',isubname,ipdnbr,len_neibr,2,icscode)
call mmgetblk('dnbrproj',isubname,ipdnbrproj,len_neibr,
& 2,icscode)
call mmgetblk('nbrlist',isubname,ipnbrlist,len_neibr,1
& ,icscode)
endif
if (len_ielts.eq.0) then
len_ielts=100
call mmgetblk('ielts',isubname,ipielts,len_ielts,1,icscode)
endif
c obtain node-hyb relation. For a given node, the node-hyb relation
c is a list of numbers that give the hybrid elements that the
c the node belongs to AND the local node number within each element.
call getnodhyb(mpno,mpary,ieltno,ieltary,nnodes,itet,
& itetoff,itettyp,iparent,invmpary,isubname,ipnodhyb
& ,ipnodhyboff)
c.... Define MCR which gives the total effective number of constraints
c.... on each parent node. MCR equals the sum of geometrical
c.... constraints plus 'material constraints'. Geometrical constraints
c.... are, for example, 'plane' where a node is constrained to lie on
c.... a plane. 'Material constraints' occur where a node has more than
c.... one child point so that reconnection must respect the interfaces
c.... between the materials.
c....
c.... Thus, if MCR=0, the point is totally unconstrained, and we
c.... consider the damage of merging it to its neighbor to be zero.
c.... If MCR=1, the point lies on an interface or geometrical constraint
c.... and it can only be merged to interface neighbors.
c.... A nonzero amount of damage may occur which is usually defined
c to be
c.... an estimate of the 'fatness' of the polygon formed by joining
c.... the node to all its interface neighbors.
c.... If MCR=2, the point lies on an interfacial curve and it can
c.... only be merged to either one of its curve neighbors. The
c.... damage incurred by this merge is usually equal to the height
c of the
c.... triangle formed by the node and its two curve neighbors.
c.... If MCR>=3, the point is critical in defining the geometry or
c.... interface. The damage caused by merging this point into
c.... another point would thus be equal to the distance to the
c neighboring
c.... point. Currently, this routine does not allow such a merge.
do i=1,mpno
mcr(i)=0
node=mpary(i)
if (.not.lignoremats) then
if (itp1(node).eq.ifitpcup) then
nod1=isn1(node)
do while (nod1.ne.node.and.nod1.ne.0)
mcr(i)=mcr(i)+1
nod1=isn1(nod1)
enddo
mcr(i)=mcr(i)-1
endif
endif
icr=icr1(node)
if (icr.gt.0) then
ifromicr=icontab(1,icr)
else
ifromicr=0
endif
ifromitp=0
if (itp1(node).eq.ifitpcup) then
nod1=isn1(node)
do while (nod1.ne.node.and.nod1.ne.0)
if (itp1(nod1).ge.ifitpst2.and.itp1(nod1).le.ifitpen2)
& then
ifromitp=1
endif
nod1=isn1(nod1)
enddo
elseif (itp1(node).ge.ifitpst2.and.itp1(node).le.ifitpen2)
& then
ifromitp=1
endif
if (ifromitp.eq.1) then
mcr(i)=mcr(i)+max(1,ifromicr)
endif
enddo
c.... For the surface case, if LCHECKROUGHNESS is true,
c.... compute a synthetic normal at all points. Then
c.... potentially new edges will be projected onto the
c.... synthetic normals at the endpoints. For efficiency
c.... of computation, we keep and do not update the synthetic
c.... normal values inside of a single sweep.
c TAM
c change uninitialized eps to epsln
if ((nsdtopo.eq.2).and.lcheckroughness) then
call getgsynth(epsln,isubname,ieltary,ieltno,iparent,itet
& ,itetoff,invmpary,mpno,xic,yic,zic,ipgsynth,len_gsynth)
endif
c.... Loop over all mass points for potential inclusion into
c.... annihilation list.
do i=1,mpno
if (lstale(mpary(i))) then
lockout(mpary(i))=.false.
else
lockout(mpary(i))=.true.
endif
enddo
nanni=0
do 10 i0=1,mpno
call primestep(mpno,i)
node=mpary(i)
if (lockout(node)) then
goto 10
endif
nelt=nodhyboff(i+1)-nodhyboff(i)
c... Get the materials and constraints that NODE participates in.
if (.not.lignoremats) then
if (itp1(node).eq.ifitpcup) then
nod1=isn1(node)
nmat=0
do while (nod1.ne.node.and.nod1.ne.0)
nmat=nmat+1
mat(nmat)=imt1(nod1)
nod1=isn1(nod1)
enddo
else
nmat=1
mat(nmat)=imt1(node)
endif
endif
c.... In the case of triangular grids, compute a synthetic normal at
c.... NODE to be used to determine the orientation of triangles
c.... incident upon NODE.
if (len_ielts.lt.nelt) then
inc=nelt-len_ielts+100
len_ielts=len_ielts+inc
call mmincblk('ielts',isubname,ipielts,inc,icscode)
endif
do j=nodhyboff(i)+1,nodhyboff(i+1)
ii=1+(nodhyb(j)-1)/maxnen
ihyb=ieltary(ii)
ielts(j-nodhyboff(i))=ihyb
enddo
if (nsdtopo.eq.2) then
C TAM change uninitialised eps to epsln
call synthnormal(node,nelt,ielts,iparent,itet,
& itetoff,xic,yic,zic,epsln,synthx,synthy,synthz
& ,lsomereversed)
endif
call polyir(nelt,ielts,itet,itetoff,xic,yic,
& zic,nsdtopo,lcheckaxy,worstir)
toldamageused=toldamage_in
if(isafield) then
if(toldamage_4d.gt.zero) toldamageused=toldamage_4d
endif
if (worstir.ge.toldamageused) then
toldamageused=toldamageused*tolcutfactor
dirtol=worstir*tolimprovefactor_down
elseif (worstir.ge.dltol) then
dirtol=worstir*tolimprovefactor_up
elseif (worstir.ge.-dltol) then
dirtol=-2*dltol
else
dirtol=2*worstir
endif
c.... Treat the MCR=2 case where the node is a 'curve' point.
if ((mcr(i).eq.2.and.nsdtopo.eq.3).or.
* (mcr(i).eq.1.and.nsdtopo.eq.2)) then
c.... Loop over elements sharing node and determine the
c.... (two) curve neighbors.
nnbr=0
do j=nodhyboff(i)+1,nodhyboff(i+1)
ii=1+(nodhyb(j)-1)/maxnen
lochybnod=nodhyb(j)-maxnen*(ii-1)
ihyb=ieltary(ii)
ityp=itettyp(ihyb)
xk1=xic(iparent(itet(1+itetoff(ihyb))))
yk1=yic(iparent(itet(1+itetoff(ihyb))))
zk1=zic(iparent(itet(1+itetoff(ihyb))))
xk2=xic(iparent(itet(2+itetoff(ihyb))))
yk2=yic(iparent(itet(2+itetoff(ihyb))))
zk2=zic(iparent(itet(2+itetoff(ihyb))))
xk3=xic(iparent(itet(3+itetoff(ihyb))))
yk3=yic(iparent(itet(3+itetoff(ihyb))))
zk3=zic(iparent(itet(3+itetoff(ihyb))))
if (nsdtopo.eq.2) then
dir=dirtri(xk1,yk1,zk1,xk2,yk2,zk2,xk3,yk3,zk3)
else
xk4=xic(iparent(itet(4+itetoff(ihyb))))
yk4=yic(iparent(itet(4+itetoff(ihyb))))
zk4=zic(iparent(itet(4+itetoff(ihyb))))
dir=dirtet(xk1,yk1,zk1,xk2,yk2,zk2,xk3,yk3,zk3,
& xk4,yk4,zk4)
endif
c... LOCHYBNOD is the the local node number of NODE in the
c... general ("hybrid") element IHYB.
c... Loop thru edges emanating from this node in this
c... element, and see if the neighboring nodes obey
c... all the constraints and share in all the materials
c... that NODE has. Nodes that satisfy this (there should
c... be two of them) live on the same boundary curve as NODE.
do 20 k=1,nelmnee(ityp)
if (lochybnod.eq.ielmedge1(1,k,ityp)) then
locnbr=ielmedge1(2,k,ityp)
elseif (lochybnod.eq.ielmedge1(2,k,ityp)) then
locnbr=ielmedge1(1,k,ityp)
else
goto 20
endif
nbr=iparent(itet(locnbr+itetoff(ihyb)))
if (invneibr(nbr).eq.0) then
c.... If the neighboring node is not a curve neighbor, skip him.
if (nsdtopo.eq.2) then
ioppnod=6-locnbr-lochybnod
if (jtet(ioppnod+jtetoff(ihyb)).lt.mbndry)
& goto 20
else
if (.not.ltripedge(ihyb,k,itet,itetoff
& ,itettyp,iparent,jtet,jtetoff,mbndry
& ,nef_cmo,icr1,icontab,lignoremats)) goto
& 20
endif
nnbr=nnbr+1
if (len_neibr.lt.nnbr) then
inc=nnbr-len_neibr+100
len_neibr=len_neibr+inc
call mmincblk('neibr',isubname
& ,ipneibr,inc,icscode)
call mmincblk('dnbr',isubname
& ,ipdnbr,inc,icscode)
call mmincblk('dnbrproj',isubname
& ,ipdnbrproj,inc,icscode)
call mmincblk('nbrlist',isubname
& ,ipnbrlist,inc,icscode)
endif
neibr(nnbr)=nbr
invneibr(nbr)=nnbr
if(isafield) then
c
c... get the 4d distance which includes the edge error
c... find an element to which this edge belongs
c... use that to find all elements surrounding the edge
c... if any edge emanating from node has error > toldamage_4d
c... do not merge this node
c
do kk=1,nelmnee(ityp)
ie1=ielmedge1(1,kk,ityp)
ie2=ielmedge1(2,kk,ityp)
ioff=itetoff(ihyb)
ip1=iparent(itet(ie1+ioff))
ip2=iparent(itet(ie2+ioff))
if ((nbr.eq.ip1.and.
& node.eq.ip2).or.
& (nbr.eq.ip2.and.
& node.eq.ip1)) then
call get_elements_on_edge(ihyb,kk,
* nelts,ipelts,
* ipedges,ipitetoff,ipjtetoff,
* ipitet,ipjtet,
* ipitettyp,ipiparent,nef_cmo,mbndry)
call edgefun_lg(nelts,ipelts,ipedges,
& itettyp,itet,itetoff,xic,yic,zic,
& hxx,hxy,hxz,hyy,hyz,hzz,elen)
if(elen.gt.toldamage_4d) then
do jj=1,nnbr
nbr=neibr(jj)
invneibr(nbr)=0
enddo
go to 10
endif
dnbr(nnbr)=sqrt((
& xic(nbr)-xic(node))**2+
& (yic(nbr)-yic(node))**2+
& (zic(nbr)-zic(node))**2+elen**2)
go to 19
endif
enddo
else
dnbr(nnbr)=sqrt((xic(nbr)-xic(node))**2+
& (yic(nbr)-yic(node))**2+
& (zic(nbr)-zic(node))**2)
endif
19 dnbrproj(nnbr)=1.d99
endif
nnbr1=invneibr(nbr)
dnbrproj(nnbr1)=min(dnbrproj(nnbr1),dir)
20 continue
enddo
c.... Check that we have exactly two curve neighbors.
if (nnbr.ne.2) then
write(logmess,'(a,i10,a,i10)')
& 'Warning: ',nnbr,' curve neighbors at ',node
call writloga('bat',0,logmess,0,ierrw)
if (nnbr.eq.0) goto 900
endif
c.... Check damage that annihilating NODE would cause. We project NODE
c.... orthogonally onto the segment between neibr(1) and neibr(2).
c.... We calculate FRAC, where
c.... XPROJ=(1-FRAC)*XIC(NEIBR(1))+FRAC*XIC(NEIBR(2))
c.... Here XPROJ is the x-coordinate of the orthogonal projection of
c.... NODE onto the segment between NEIBR(1) and NEIBR(2). A similar
c.... statement holds for the y- and z- coordinates.
c.... If 0<=FRAC<=1, we have that the DAMAGE would be equal to the
c.... distance of the orthogonal projection. That is, the distance
c.... between NODE and (XPROJ,YPROJ,ZPROJ). In a previous version, we
c.... had that if FRAC<0, the damage was equal to the distance between NODE
c.... and NEIBR(1) and if FRAC>1, the damage was equal to the distance
c.....between NODE and NEIBR(2). We now simply take the distance
c.... between NODE and (XPROJ,YPROJ,ZPROJ), because in these ``folded
c.... -over'' cases, we want to encourage node annihilation.
if (nnbr.eq.2) then
frac=((xic(neibr(2))-xic(neibr(1)))*
& (xic(node)-xic(neibr(1)))+
& (yic(neibr(2))-yic(neibr(1)))*
& (yic(node)-yic(neibr(1)))+
& (zic(neibr(2))-zic(neibr(1)))*
& (zic(node)-zic(neibr(1))))/
& safe(((xic(neibr(2))-xic(neibr(1)))*
& (xic(neibr(2))-xic(neibr(1)))+
& (yic(neibr(2))-yic(neibr(1)))*
& (yic(neibr(2))-yic(neibr(1)))+
& (zic(neibr(2))-zic(neibr(1)))*
& (zic(neibr(2))-zic(neibr(1)))))
xproj=frac*xic(neibr(2))+(one-frac)*xic(neibr(1))
yproj=frac*yic(neibr(2))+(one-frac)*yic(neibr(1))
zproj=frac*zic(neibr(2))+(one-frac)*zic(neibr(1))
projdamage=sqrt((xic(node)-xproj)**2+
& (yic(node)-yproj)**2+
& (zic(node)-zproj)**2)
if (projdamage.gt.toldamageused) goto 900
else
projdamage=1.d99
endif
do j=1,nnbr
nbrlist(j)=j
enddo
ascend=1.
call hpsort1(nnbr,dnbr,ascend,nbrlist)
do j=1,nnbr
nearnbrj=nbrlist(j)
nearnbr=neibr(nearnbrj)
dnearnbr=dnbr(nearnbrj)
dprojnearnbr=dnbrproj(nearnbrj)
if (projdamage.le.toldamageused.or.
& dnearnbr.le.toldamageused) then
if (dnearnbr.le.tollength.or.
& ((.not.lstrictmergelength).and.(dprojnearnbr.le
& .tollength/10.))) then
if (lwontinvert(i,node,invmpary,nearnbr
& ,nodhyb(nodhyboff(i)+1),ieltary,nelt,itettyp
& ,iparent,itet,itetoff,xic,yic,zic,vtol,synthx
& ,synthy,synthz,lsomereversed,lcheckaxy
& ,epsilona,lcheckroughness,tolroughness,gsynth
& ,dirtol))then
nanni=nanni+1
nodelist(nanni)=i
nearestnbr(i)=nearnbr
worst_length(i)=dnearnbr
goto 900
endif
endif
endif
enddo
900 continue
do k=1,nnbr
invneibr(neibr(k))=0
enddo
c.... Treat the MCR=1 case where the node is a 'surface' point.
elseif ((mcr(i).eq.1.and.nsdtopo.eq.3)
* .or.(mcr(i).eq.0.and.nsdtopo.eq.2)) then
c.... Loop over elements sharing NODE and determine the
c.... area vector pointing out from material mat(1). This
c.... area vector is constructed by taking all the triangle
c.... area vectors from interface faces sharing NODE, and
c.... adding them up. We later normalize this vector, giving
c.... us a good average normal for the interface.
c.... We currently assume the interface facets are triangular...
c.... so we restrict operation to tetrahedral elements.
ax=0.
ay=0.
az=0.
nnbr=0
atot=0.
do 110 j=nodhyboff(i)+1,nodhyboff(i+1)
ii=1+(nodhyb(j)-1)/maxnen
lochybnod=nodhyb(j)-maxnen*(ii-1)
ihyb=ieltary(ii)
ityp=itettyp(ihyb)
c.... Check that current element is material type mat(1).
if (nsdtopo.eq.3) then
if (.not.lignoremats) then
if (imt1(itet(1+itetoff(ihyb))).ne.mat(1)) goto
& 110
endif
endif
if (ityp.ne.ifelmtet.and.ityp.ne.ifelmtri) then