1 /*
2 * ***************************************************************************
3 * MC = < Manifold Code >
4 * Copyright (C) 1994-- Michael Holst
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 *
20 * rcsid="$Id: gem.c,v 1.22 2010/08/12 05:18:46 fetk Exp $"
21 * ***************************************************************************
22 */
23
24 /*
25 * ***************************************************************************
26 * File: Gem.c
27 *
28 * Purpose: Class Gem: methods.
29 *
30 * Author: Michael Holst
31 * ***************************************************************************
32 */
33
34 #include "gem_p.h"
35
36 VEMBED(rcsid="$Id: gem.c,v 1.22 2010/08/12 05:18:46 fetk Exp $")
37
38 /* Hook for external structure updating */
defaultxUpFunc(SS ** sms,int numS)39 VPRIVATE void defaultxUpFunc(SS **sms, int numS) { VASSERT(0); }
40
41 /*
42 * ***************************************************************************
43 * Class Gem: Inlineable methods
44 * ***************************************************************************
45 */
46 #if !defined(VINLINE_GEM)
47
48 /*
49 * ***************************************************************************
50 * Routine: Gem_dim
51 *
52 * Purpose: Return the extrinsic spatial dimension.
53 *
54 * Author: Michael Holst
55 * ***************************************************************************
56 */
Gem_dim(Gem * thee)57 VPUBLIC int Gem_dim(Gem *thee)
58 {
59 return thee->dim;
60 }
61
62 /*
63 * ***************************************************************************
64 * Routine: Gem_dimII
65 *
66 * Purpose: Return the intrinsic spatial dimension.
67 *
68 * Author: Michael Holst
69 * ***************************************************************************
70 */
Gem_dimII(Gem * thee)71 VPUBLIC int Gem_dimII(Gem *thee)
72 {
73 return thee->dimII;
74 }
75
76 /*
77 * ***************************************************************************
78 * Routine: Gem_dimVV
79 *
80 * Purpose: Return the number of vertices in a simplex.
81 *
82 * Author: Michael Holst
83 * ***************************************************************************
84 */
Gem_dimVV(Gem * thee)85 VPUBLIC int Gem_dimVV(Gem *thee)
86 {
87 return thee->dimVV;
88 }
89
90 /*
91 * ***************************************************************************
92 * Routine: Gem_dimEE
93 *
94 * Purpose: Return the number of edges in a simplex.
95 *
96 * Author: Michael Holst
97 * ***************************************************************************
98 */
Gem_dimEE(Gem * thee)99 VPUBLIC int Gem_dimEE(Gem *thee)
100 {
101 return thee->dimEE;
102 }
103
104 /*
105 * ***************************************************************************
106 * Routine: Gem_numVirtVV
107 *
108 * Purpose: Return the logical number of vertices in the mesh.
109 *
110 * Author: Michael Holst
111 * ***************************************************************************
112 */
Gem_numVirtVV(Gem * thee)113 VPUBLIC int Gem_numVirtVV(Gem *thee)
114 {
115 return thee->numVV;
116 }
117
118 /*
119 * ***************************************************************************
120 * Routine: Gem_numVirtEE
121 *
122 * Purpose: Return the logical number of edges in the mesh.
123 *
124 * Author: Michael Holst
125 * ***************************************************************************
126 */
Gem_numVirtEE(Gem * thee)127 VPUBLIC int Gem_numVirtEE(Gem *thee)
128 {
129 return thee->numEE;
130 }
131
132 /*
133 * ***************************************************************************
134 * Routine: Gem_numVirtFF
135 *
136 * Purpose: Return the logical number of faces in the mesh.
137 *
138 * Author: Michael Holst
139 * ***************************************************************************
140 */
Gem_numVirtFF(Gem * thee)141 VPUBLIC int Gem_numVirtFF(Gem *thee)
142 {
143 return thee->numFF;
144 }
145
146 /*
147 * ***************************************************************************
148 * Routine: Gem_numVirtSS
149 *
150 * Purpose: Return the logical number of simplices in the mesh.
151 *
152 * Author: Michael Holst
153 * ***************************************************************************
154 */
Gem_numVirtSS(Gem * thee)155 VPUBLIC int Gem_numVirtSS(Gem *thee)
156 {
157 return thee->numSS;
158 }
159
160 /*
161 * ***************************************************************************
162 * Routine: Gem_setNumVirtVV
163 *
164 * Purpose: Set the logical number of vertices in the mesh.
165 *
166 * Author: Michael Holst
167 * ***************************************************************************
168 */
Gem_setNumVirtVV(Gem * thee,int i)169 VPUBLIC void Gem_setNumVirtVV(Gem *thee, int i)
170 {
171 thee->numVV = i;
172 }
173
174 /*
175 * ***************************************************************************
176 * Routine: Gem_setNumVirtEE
177 *
178 * Purpose: Set the logical number of edges in the mesh.
179 *
180 * Author: Michael Holst
181 * ***************************************************************************
182 */
Gem_setNumVirtEE(Gem * thee,int i)183 VPUBLIC void Gem_setNumVirtEE(Gem *thee, int i)
184 {
185 thee->numEE = i;
186 }
187
188 /*
189 * ***************************************************************************
190 * Routine: Gem_setNumVirtFF
191 *
192 * Purpose: Geometry manager constructor.
193 *
194 * Author: Michael Holst
195 * ***************************************************************************
196 */
Gem_setNumVirtFF(Gem * thee,int i)197 VPUBLIC void Gem_setNumVirtFF(Gem *thee, int i)
198 {
199 thee->numFF = i;
200 }
201
202 /*
203 * ***************************************************************************
204 * Routine: Gem_setNumVirtSS
205 *
206 * Purpose: Set the logical number of simplices in the mesh.
207 *
208 * Author: Michael Holst
209 * ***************************************************************************
210 */
Gem_setNumVirtSS(Gem * thee,int i)211 VPUBLIC void Gem_setNumVirtSS(Gem *thee, int i)
212 {
213 thee->numSS = i;
214 }
215
216 /*
217 * ***************************************************************************
218 * Routine: Gem_numVV
219 *
220 * Purpose: Return the number of vertices in the mesh.
221 *
222 * Author: Michael Holst
223 * ***************************************************************************
224 */
Gem_numVV(Gem * thee)225 VPUBLIC int Gem_numVV(Gem *thee)
226 {
227 return Vset_num(thee->vertices);
228 }
229
230 /*
231 * ***************************************************************************
232 * Routine: Gem_VV
233 *
234 * Purpose: Return a given vertex.
235 *
236 * Author: Michael Holst
237 * ***************************************************************************
238 */
Gem_VV(Gem * thee,int i)239 VPUBLIC VV* Gem_VV(Gem *thee, int i)
240 {
241 return (VV*)Vset_access(thee->vertices,i);
242 }
243
244 /*
245 * ***************************************************************************
246 * Routine: Gem_createVV
247 *
248 * Purpose: Create a new vertex (becoming the new last vertex).
249 *
250 * Author: Michael Holst
251 * ***************************************************************************
252 */
Gem_createVV(Gem * thee)253 VPUBLIC VV* Gem_createVV(Gem *thee)
254 {
255 return (VV*)Vset_create(thee->vertices);
256 }
257
258 /*
259 * ***************************************************************************
260 * Routine: Gem_firstVV
261 *
262 * Purpose: Return the first vertex.
263 *
264 * Author: Michael Holst
265 * ***************************************************************************
266 */
Gem_firstVV(Gem * thee)267 VPUBLIC VV* Gem_firstVV(Gem *thee)
268 {
269 return (VV*)Vset_first(thee->vertices);
270 }
271
272 /*
273 * ***************************************************************************
274 * Routine: Gem_lastVV
275 *
276 * Purpose: Return the last vertex.
277 *
278 * Author: Michael Holst
279 * ***************************************************************************
280 */
Gem_lastVV(Gem * thee)281 VPUBLIC VV* Gem_lastVV(Gem *thee)
282 {
283 return (VV*)Vset_last(thee->vertices);
284 }
285
286 /*
287 * ***************************************************************************
288 * Routine: Gem_nextVV
289 *
290 * Purpose: Return the next vertex.
291 *
292 * Author: Michael Holst
293 * ***************************************************************************
294 */
Gem_nextVV(Gem * thee)295 VPUBLIC VV* Gem_nextVV(Gem *thee)
296 {
297 return (VV*)Vset_next(thee->vertices);
298 }
299
300 /*
301 * ***************************************************************************
302 * Routine: Gem_prevVV
303 *
304 * Purpose: Return the previous vertex.
305 *
306 * Author: Michael Holst
307 * ***************************************************************************
308 */
Gem_prevVV(Gem * thee)309 VPUBLIC VV* Gem_prevVV(Gem *thee)
310 {
311 return (VV*)Vset_prev(thee->vertices);
312 }
313
314 /*
315 * ***************************************************************************
316 * Routine: Gem_peekFirstVV
317 *
318 * Purpose: Peek at the first vertex.
319 *
320 * Author: Michael Holst
321 * ***************************************************************************
322 */
Gem_peekFirstVV(Gem * thee)323 VPUBLIC VV* Gem_peekFirstVV(Gem *thee)
324 {
325 return (VV*)Vset_peekFirst(thee->vertices);
326 }
327
328 /*
329 * ***************************************************************************
330 * Routine: Gem_peekLastVV
331 *
332 * Purpose: Peek at the last vertex.
333 *
334 * Author: Michael Holst
335 * ***************************************************************************
336 */
Gem_peekLastVV(Gem * thee)337 VPUBLIC VV* Gem_peekLastVV(Gem *thee)
338 {
339 return (VV*)Vset_peekLast(thee->vertices);
340 }
341
342 /*
343 * ***************************************************************************
344 * Routine: Gem_destroyVV
345 *
346 * Purpose: Destroy the last vertex.
347 *
348 * Author: Michael Holst
349 * ***************************************************************************
350 */
Gem_destroyVV(Gem * thee)351 VPUBLIC void Gem_destroyVV(Gem *thee)
352 {
353 Vset_destroy(thee->vertices);
354 }
355
356 /*
357 * ***************************************************************************
358 * Routine: Gem_resetVV
359 *
360 * Purpose: Destroy all of the vertices.
361 *
362 * Author: Michael Holst
363 * ***************************************************************************
364 */
Gem_resetVV(Gem * thee)365 VPUBLIC void Gem_resetVV(Gem *thee)
366 {
367 Vset_reset(thee->vertices);
368 }
369
370 /*
371 * ***************************************************************************
372 * Routine: Gem_numEE
373 *
374 * Purpose: Return the number of edges.
375 *
376 * Author: Michael Holst
377 * ***************************************************************************
378 */
Gem_numEE(Gem * thee)379 VPUBLIC int Gem_numEE(Gem *thee)
380 {
381 return Vset_num(thee->edges);
382 }
383
384 /*
385 * ***************************************************************************
386 * Routine: Gem_EE
387 *
388 * Purpose: Return a given edge.
389 *
390 * Author: Michael Holst
391 * ***************************************************************************
392 */
Gem_EE(Gem * thee,int i)393 VPUBLIC EE* Gem_EE(Gem *thee, int i)
394 {
395 return (EE*)Vset_access(thee->edges,i);
396 }
397
398 /*
399 * ***************************************************************************
400 * Routine: Gem_createEE
401 *
402 * Purpose: Create a new edge (becoming the new last edge).
403 *
404 * Author: Michael Holst
405 * ***************************************************************************
406 */
Gem_createEE(Gem * thee)407 VPUBLIC EE* Gem_createEE(Gem *thee)
408 {
409 return (EE*)Vset_create(thee->edges);
410 }
411
412 /*
413 * ***************************************************************************
414 * Routine: Gem_firstEE
415 *
416 * Purpose: Return the first edge.
417 *
418 * Author: Michael Holst
419 * ***************************************************************************
420 */
Gem_firstEE(Gem * thee)421 VPUBLIC EE* Gem_firstEE(Gem *thee)
422 {
423 return (EE*)Vset_first(thee->edges);
424 }
425
426 /*
427 * ***************************************************************************
428 * Routine: Gem_lastEE
429 *
430 * Purpose: Return the last edge.
431 *
432 * Author: Michael Holst
433 * ***************************************************************************
434 */
Gem_lastEE(Gem * thee)435 VPUBLIC EE* Gem_lastEE(Gem *thee)
436 {
437 return (EE*)Vset_last(thee->edges);
438 }
439
440 /*
441 * ***************************************************************************
442 * Routine: Gem_nextEE
443 *
444 * Purpose: Return the next edge.
445 *
446 * Author: Michael Holst
447 * ***************************************************************************
448 */
Gem_nextEE(Gem * thee)449 VPUBLIC EE* Gem_nextEE(Gem *thee)
450 {
451 return (EE*)Vset_next(thee->edges);
452 }
453
454 /*
455 * ***************************************************************************
456 * Routine: Gem_prevEE
457 *
458 * Purpose: Return the previous edge.
459 *
460 * Author: Michael Holst
461 * ***************************************************************************
462 */
Gem_prevEE(Gem * thee)463 VPUBLIC EE* Gem_prevEE(Gem *thee)
464 {
465 return (EE*)Vset_prev(thee->edges);
466 }
467
468 /*
469 * ***************************************************************************
470 * Routine: Gem_peekFirstEE
471 *
472 * Purpose: Peek at the first edge.
473 *
474 * Author: Michael Holst
475 * ***************************************************************************
476 */
Gem_peekFirstEE(Gem * thee)477 VPUBLIC EE* Gem_peekFirstEE(Gem *thee)
478 {
479 return (EE*)Vset_peekFirst(thee->edges);
480 }
481
482 /*
483 * ***************************************************************************
484 * Routine: Gem_peekLastEE
485 *
486 * Purpose: Peek at the last edge.
487 *
488 * Author: Michael Holst
489 * ***************************************************************************
490 */
Gem_peekLastEE(Gem * thee)491 VPUBLIC EE* Gem_peekLastEE(Gem *thee)
492 {
493 return (EE*)Vset_peekLast(thee->edges);
494 }
495
496 /*
497 * ***************************************************************************
498 * Routine: Gem_destroyEE
499 *
500 * Purpose: Destroy the last edge.
501 *
502 * Author: Michael Holst
503 * ***************************************************************************
504 */
Gem_destroyEE(Gem * thee)505 VPUBLIC void Gem_destroyEE(Gem *thee)
506 {
507 Vset_destroy(thee->edges);
508 }
509
510 /*
511 * ***************************************************************************
512 * Routine: Gem_resetEE
513 *
514 * Purpose: Destroy all of the edges.
515 *
516 * Author: Michael Holst
517 * ***************************************************************************
518 */
Gem_resetEE(Gem * thee)519 VPUBLIC void Gem_resetEE(Gem *thee)
520 {
521 Vset_reset(thee->edges);
522 }
523
524 /*
525 * ***************************************************************************
526 * Routine: Gem_numSS
527 *
528 * Purpose: Return the number of simplices.
529 *
530 * Author: Michael Holst
531 * ***************************************************************************
532 */
Gem_numSS(Gem * thee)533 VPUBLIC int Gem_numSS(Gem *thee)
534 {
535 return Vset_num(thee->simplices);
536 }
537
538 /*
539 * ***************************************************************************
540 * Routine: Gem_SS
541 *
542 * Purpose: Return a given simplex.
543 *
544 * Author: Michael Holst
545 * ***************************************************************************
546 */
Gem_SS(Gem * thee,int i)547 VPUBLIC SS* Gem_SS(Gem *thee, int i)
548 {
549 return (SS*)Vset_access(thee->simplices,i);
550 }
551
552 /*
553 * ***************************************************************************
554 * Routine: Gem_createSS
555 *
556 * Purpose: Create a new simplex (becoming the new last simplex).
557 *
558 * Author: Michael Holst
559 * ***************************************************************************
560 */
Gem_createSS(Gem * thee)561 VPUBLIC SS* Gem_createSS(Gem *thee)
562 {
563 return (SS*)Vset_create(thee->simplices);
564 }
565
566 /*
567 * ***************************************************************************
568 * Routine: Gem_firstSS
569 *
570 * Purpose: Return the first simplex.
571 *
572 * Author: Michael Holst
573 * ***************************************************************************
574 */
Gem_firstSS(Gem * thee)575 VPUBLIC SS* Gem_firstSS(Gem *thee)
576 {
577 return (SS*)Vset_first(thee->simplices);
578 }
579
580 /*
581 * ***************************************************************************
582 * Routine: Gem_lastSS
583 *
584 * Purpose: Return the last simplex.
585 *
586 * Author: Michael Holst
587 * ***************************************************************************
588 */
Gem_lastSS(Gem * thee)589 VPUBLIC SS* Gem_lastSS(Gem *thee)
590 {
591 return (SS*)Vset_last(thee->simplices);
592 }
593
594 /*
595 * ***************************************************************************
596 * Routine: Gem_nextSS
597 *
598 * Purpose: Return the next simplex.
599 *
600 * Author: Michael Holst
601 * ***************************************************************************
602 */
Gem_nextSS(Gem * thee)603 VPUBLIC SS* Gem_nextSS(Gem *thee)
604 {
605 return (SS*)Vset_next(thee->simplices);
606 }
607
608 /*
609 * ***************************************************************************
610 * Routine: Gem_prevSS
611 *
612 * Purpose: Return the previous simplex.
613 *
614 * Author: Michael Holst
615 * ***************************************************************************
616 */
Gem_prevSS(Gem * thee)617 VPUBLIC SS* Gem_prevSS(Gem *thee)
618 {
619 return (SS*)Vset_prev(thee->simplices);
620 }
621
622 /*
623 * ***************************************************************************
624 * Routine: Gem_peekFirstSS
625 *
626 * Purpose: Peek at the first simplex.
627 *
628 * Author: Michael Holst
629 * ***************************************************************************
630 */
Gem_peekFirstSS(Gem * thee)631 VPUBLIC SS* Gem_peekFirstSS(Gem *thee)
632 {
633 return (SS*)Vset_peekFirst(thee->simplices);
634 }
635
636 /*
637 * ***************************************************************************
638 * Routine: Gem_peekLastSS
639 *
640 * Purpose: Peek at the last simplex.
641 *
642 * Author: Michael Holst
643 * ***************************************************************************
644 */
Gem_peekLastSS(Gem * thee)645 VPUBLIC SS* Gem_peekLastSS(Gem *thee)
646 {
647 return (SS*)Vset_peekLast(thee->simplices);
648 }
649
650 /*
651 * ***************************************************************************
652 * Routine: Gem_destroySS
653 *
654 * Purpose: Destroy the last simplex.
655 *
656 * Author: Michael Holst
657 * ***************************************************************************
658 */
Gem_destroySS(Gem * thee)659 VPUBLIC void Gem_destroySS(Gem *thee)
660 {
661 Vset_destroy(thee->simplices);
662 }
663
664 /*
665 * ***************************************************************************
666 * Routine: Gem_resetSS
667 *
668 * Purpose: Destroy all of the simplices.
669 *
670 * Author: Michael Holst
671 * ***************************************************************************
672 */
Gem_resetSS(Gem * thee)673 VPUBLIC void Gem_resetSS(Gem *thee)
674 {
675 Vset_reset(thee->simplices);
676 }
677
678 /*
679 * ***************************************************************************
680 * Routine: Gem_numSQ
681 *
682 * Purpose: Return the number of simplices in a given queue.
683 *
684 * Author: Michael Holst
685 * ***************************************************************************
686 */
Gem_numSQ(Gem * thee,int currentQ)687 VPUBLIC int Gem_numSQ(Gem *thee, int currentQ)
688 {
689 return Vset_num(thee->sQueM[currentQ]);
690 }
691
692 /*
693 * ***************************************************************************
694 * Routine: Gem_resetSQ
695 *
696 * Purpose: Release all of the simplices in a given queue.
697 *
698 * Author: Michael Holst
699 * ***************************************************************************
700 */
Gem_resetSQ(Gem * thee,int currentQ)701 VPUBLIC void Gem_resetSQ(Gem *thee, int currentQ)
702 {
703 Vset_reset(thee->sQueM[currentQ]);
704 }
705
706 /*
707 * ***************************************************************************
708 * Routine: Gem_numBF
709 *
710 * Purpose: Return the number of boundary faces.
711 *
712 * Author: Michael Holst
713 * ***************************************************************************
714 */
Gem_numBF(Gem * thee)715 VPUBLIC int Gem_numBF(Gem *thee)
716 {
717 return thee->numBF;
718 }
719
720 /*
721 * ***************************************************************************
722 * Routine: Gem_numBV
723 *
724 * Purpose: Return the number of boundary vertices.
725 *
726 * Author: Michael Holst
727 * ***************************************************************************
728 */
Gem_numBV(Gem * thee)729 VPUBLIC int Gem_numBV(Gem *thee)
730 {
731 return thee->numBV;
732 }
733
734 /*
735 * ***************************************************************************
736 * Routine: Gem_setNumBF
737 *
738 * Purpose: Set the number of boundary faces.
739 *
740 * Author: Michael Holst
741 * ***************************************************************************
742 */
Gem_setNumBF(Gem * thee,int val)743 VPUBLIC void Gem_setNumBF(Gem *thee, int val)
744 {
745 thee->numBF = val;
746 }
747
748 /*
749 * ***************************************************************************
750 * Routine: Gem_setNumBV
751 *
752 * Purpose: Set the number of boundary vertices.
753 *
754 * Author: Michael Holst
755 * ***************************************************************************
756 */
Gem_setNumBV(Gem * thee,int val)757 VPUBLIC void Gem_setNumBV(Gem *thee, int val)
758 {
759 thee->numBV = val;
760 }
761
762 /*
763 * ***************************************************************************
764 * Routine: Gem_addToNumBF
765 *
766 * Purpose: Increment the number of boundary faces by a given integer.
767 *
768 * Author: Michael Holst
769 * ***************************************************************************
770 */
Gem_addToNumBF(Gem * thee,int val)771 VPUBLIC void Gem_addToNumBF(Gem *thee, int val)
772 {
773 thee->numBF += val;
774 }
775
776 /*
777 * ***************************************************************************
778 * Routine: Gem_addToNumBV
779 *
780 * Purpose: Increment the number of boundary vertices by a given integer.
781 *
782 * Author: Michael Holst
783 * ***************************************************************************
784 */
Gem_addToNumBV(Gem * thee,int val)785 VPUBLIC void Gem_addToNumBV(Gem *thee, int val)
786 {
787 thee->numBV += val;
788 }
789
790 /*
791 * ***************************************************************************
792 * Routine: Gem_numBFpp
793 *
794 * Purpose: Increment the number of boundary faces by 1.
795 *
796 * Author: Michael Holst
797 * ***************************************************************************
798 */
Gem_numBFpp(Gem * thee)799 VPUBLIC void Gem_numBFpp(Gem *thee)
800 {
801 thee->numBF++;
802 }
803
804 /*
805 * ***************************************************************************
806 * Routine: Gem_numBVpp
807 *
808 * Purpose: Increment the number of boundary vertices by 1.
809 *
810 * Author: Michael Holst
811 * ***************************************************************************
812 */
Gem_numBVpp(Gem * thee)813 VPUBLIC void Gem_numBVpp(Gem *thee)
814 {
815 thee->numBV++;
816 }
817
818 /*
819 * ***************************************************************************
820 * Routine: Gem_numBFmm
821 *
822 * Purpose: Decrement the number of boundary faces by 1.
823 *
824 * Author: Michael Holst
825 * ***************************************************************************
826 */
Gem_numBFmm(Gem * thee)827 VPUBLIC void Gem_numBFmm(Gem *thee)
828 {
829 thee->numBF--;
830 }
831
832 /*
833 * ***************************************************************************
834 * Routine: Gem_numBVmm
835 *
836 * Purpose: Decrement the number of boundary vertices by 1.
837 *
838 * Author: Michael Holst
839 * ***************************************************************************
840 */
Gem_numBVmm(Gem * thee)841 VPUBLIC void Gem_numBVmm(Gem *thee)
842 {
843 thee->numBV--;
844 }
845
846 #endif /* if !defined(VINLINE_GEM) */
847 /*
848 * ***************************************************************************
849 * Class Gem: Non-inlineable methods
850 * ***************************************************************************
851 */
852
853 /*
854 * ***************************************************************************
855 * Routine: Gem_ctor
856 *
857 * Purpose: Geometry manager constructor.
858 *
859 * Author: Michael Holst
860 * ***************************************************************************
861 */
Gem_ctor(Vmem * vmem,PDE * tpde)862 VPUBLIC Gem* Gem_ctor(Vmem *vmem, PDE *tpde)
863 {
864 int i;
865 Gem* thee = VNULL;
866
867 thee = Vmem_malloc( VNULL, 1, sizeof(Gem) );
868 if (vmem == VNULL) {
869 thee->vmem = Vmem_ctor( "Gem" );
870 thee->iMadeVmem = 1;
871 } else {
872 thee->vmem = vmem;
873 thee->iMadeVmem = 0;
874 }
875
876 VDEBUGIO("Gem_ctor: CREATING object..");
877 VDEBUGIO("..done.\n");
878
879 thee->xUp = defaultxUpFunc;
880 thee->xUpFlag = 0;
881
882 if (tpde != VNULL) {
883 thee->iMadePDE = 0;
884 thee->pde = tpde;
885 } else {
886 thee->iMadePDE = 1;
887 thee->pde = PDE_ctor_default();
888 }
889
890 thee->vertices = VNULL;
891 thee->edges = VNULL;
892 thee->simplices = VNULL;
893 for (i=0; i<VMAXSQ; i++) {
894 thee->sQueM[i] = VNULL;
895 }
896
897 Gem_reset(thee, 0, 0);
898
899 return thee;
900 }
901
902 /*
903 * ***************************************************************************
904 * Routine: Gem_dtor
905 *
906 * Purpose: Geometry manager destructor.
907 *
908 * Author: Michael Holst
909 * ***************************************************************************
910 */
Gem_dtor(Gem ** thee)911 VPUBLIC void Gem_dtor(Gem **thee)
912 {
913 int i;
914
915 VASSERT( (*thee) != VNULL );
916 if ((*thee) != VNULL) {
917
918 if ((*thee)->iMadePDE) {
919 PDE_dtor_default( &((*thee)->pde) );
920 }
921
922 Vset_dtor( &((*thee)->vertices) );
923 Vset_dtor( &((*thee)->edges) );
924 Vset_dtor( &((*thee)->simplices) );
925 for (i=0; i<VMAXSQ; i++) {
926 Vset_dtor( &((*thee)->sQueM[i]) );
927 }
928
929 VDEBUGIO("Gem_dtor: DESTROYING object..");
930 if ((*thee)->iMadeVmem) Vmem_dtor( &((*thee)->vmem) );
931 Vmem_free( VNULL, 1, sizeof(Gem), (void**)thee );
932 VDEBUGIO("..done.\n");
933
934 (*thee) = VNULL;
935 }
936 }
937
938 /*
939 * ***************************************************************************
940 * Routine: Gem_reset
941 *
942 * Purpose: Reset all of the geometry datastructures.
943 *
944 * Author: Michael Holst
945 * ***************************************************************************
946 */
Gem_reset(Gem * thee,int dim,int dimII)947 VPUBLIC void Gem_reset(Gem *thee, int dim, int dimII)
948 {
949 int i;
950 char name[80];
951 SS* SQ = VNULL;
952
953 if ((dim > 0) && (dimII > 0)) {
954 if ( ! ((2 <= dim) && (dim <= 3)) ) {
955 Vnm_print(2,"Gem_reset: dim=<%d> bad; setting dim=<3>",dim);
956 dim = 3;
957 }
958 if ( ! ((2 <= dimII) && (dimII <= 3)) ) {
959 Vnm_print(2,"Gem_reset: dimII=<%d> bad; setting dimII=<3>",dimII);
960 dimII = 3;
961 }
962 thee->dim = dim;
963 thee->dimII = dimII;
964 thee->dimVV = dim+1;
965 thee->dimEE = 3*(dim-1);
966
967 /* set the possibly new dimensions for the PDE routines to get at */
968 if (thee->pde != VNULL) {
969 PDE_setDim(thee->pde, dim);
970 PDE_setDimII(thee->pde, dimII);
971 }
972
973 } else {
974 thee->dim = 0;
975 thee->dimII = 0;
976 thee->dimVV = 0;
977 thee->dimEE = 0;
978
979 /* set the possibly new dimensions for the PDE routines to get at */
980 if (thee->pde != VNULL) {
981 PDE_setDim(thee->pde, 0);
982 PDE_setDimII(thee->pde, 0);
983 }
984 }
985
986 thee->numVV0 = 0;
987 thee->numVV = 0;
988 thee->numEE = 0;
989 thee->numFF = 0;
990 thee->numSS = 0;
991 thee->numBV = 0;
992 thee->numBF = 0;
993
994 if ( thee->vertices != VNULL ) Vset_dtor( &(thee->vertices) );
995 if ( thee->edges != VNULL ) Vset_dtor( &(thee->edges) );
996 if ( thee->simplices != VNULL ) Vset_dtor( &(thee->simplices) );
997 for (i=0; i<VMAXSQ; i++) {
998 if ( thee->sQueM[i] != VNULL ) {
999 Vset_dtor( &(thee->sQueM[i]) );
1000 }
1001 }
1002
1003 thee->vertices = Vset_ctor( VNULL, "VV", sizeof(VV), VMAX_OBJECTS, 0 );
1004 thee->edges = Vset_ctor( VNULL, "EE", sizeof(EE), VMAX_OBJECTS, 0 );
1005 thee->simplices = Vset_ctor( VNULL, "SS", sizeof(SS), VMAX_OBJECTS, 0 );
1006 for (i=0; i<VMAXSQ; i++) {
1007 sprintf(name,"SQ%d",i);
1008 thee->sQueM[i] = Vset_ctor( VNULL, name, sizeof(SQ),VMAX_OBJECTS, 0 );
1009 }
1010 }
1011
1012 /*
1013 * ***************************************************************************
1014 * Routine: Gem_createAndInitVV
1015 *
1016 * Purpose: Create and initialize a new vertex; return a point to it.
1017 *
1018 * Author: Michael Holst
1019 * ***************************************************************************
1020 */
Gem_createAndInitVV(Gem * thee)1021 VPUBLIC VV* Gem_createAndInitVV(Gem *thee)
1022 {
1023 VV *vx = Gem_createVV(thee);
1024 VV_init(vx, Gem_dim(thee), Gem_numVV(thee)-1 );
1025 return vx;
1026 }
1027
1028 /*
1029 * ***************************************************************************
1030 * Routine: Gem_createAndInitEE
1031 *
1032 * Purpose: Create and initialize a new edge; return a point to it.
1033 *
1034 * Author: Michael Holst
1035 * ***************************************************************************
1036 */
Gem_createAndInitEE(Gem * thee)1037 VPUBLIC EE* Gem_createAndInitEE(Gem *thee)
1038 {
1039 EE *eg = Gem_createEE(thee);
1040 EE_init(eg, Gem_dim(thee), Gem_numEE(thee)-1 );
1041 return eg;
1042 }
1043
1044 /*
1045 * ***************************************************************************
1046 * Routine: Gem_createAndInitSS
1047 *
1048 * Purpose: Create and initialize a new simplex; return a point to it.
1049 *
1050 * Author: Michael Holst
1051 * ***************************************************************************
1052 */
Gem_createAndInitSS(Gem * thee)1053 VPUBLIC SS* Gem_createAndInitSS(Gem *thee)
1054 {
1055 SS *sm = Gem_createSS(thee);
1056 SS_init(sm, Gem_dim(thee), Gem_numSS(thee)-1 );
1057 return sm;
1058 }
1059
1060 /*
1061 * ***************************************************************************
1062 * Routine: Gem_SQ
1063 *
1064 * Purpose: Return the simplex at a particular location in the simplex Q.
1065 *
1066 * Author: Michael Holst
1067 * ***************************************************************************
1068 */
Gem_SQ(Gem * thee,int currentQ,int i)1069 VPUBLIC SS *Gem_SQ(Gem *thee, int currentQ, int i)
1070 {
1071 SS **val = (SS**)Vset_access(thee->sQueM[currentQ],i);
1072 if (val != VNULL) return *val;
1073 return VNULL;
1074 }
1075
1076 /*
1077 * ***************************************************************************
1078 * Routine: Gem_appendSQ
1079 *
1080 * Purpose: Append a simplex to the end of a simplex Q.
1081 *
1082 * Author: Michael Holst
1083 * ***************************************************************************
1084 */
Gem_appendSQ(Gem * thee,int currentQ,SS * qsm)1085 VPUBLIC void Gem_appendSQ(Gem *thee, int currentQ, SS *qsm)
1086 {
1087 SS **val = (SS**)Vset_create(thee->sQueM[currentQ]);
1088 *val = qsm;
1089 }
1090
1091 /*
1092 * ***************************************************************************
1093 * Routine: Gem_createSimplexRings
1094 *
1095 * Purpose: Create all of the simplex rings.
1096 *
1097 * Author: Michael Holst
1098 * ***************************************************************************
1099 */
Gem_createSimplexRings(Gem * thee)1100 VPUBLIC void Gem_createSimplexRings(Gem *thee)
1101 {
1102 int i;
1103 SS *sm;
1104
1105 Vnm_tstart(70, "simplex ring create");
1106 Vnm_print(0,"Gem_createSimplexRings: creating simplex rings..");
1107
1108 /* go through all simplices and create simplex rings */
1109 for (i=0; i<Gem_numSS(thee); i++) {
1110 sm = Gem_SS(thee,i);
1111 SS_buildRing( sm );
1112 }
1113
1114 Vnm_print(0,"..done.\n");
1115 Vnm_tstop(70, "simplex ring create");
1116 }
1117
1118 /*
1119 * ***************************************************************************
1120 * Routine: Gem_destroySimplexRings
1121 *
1122 * Purpose: Destroy all of the simplex rings.
1123 *
1124 * Author: Michael Holst
1125 * ***************************************************************************
1126 */
Gem_destroySimplexRings(Gem * thee)1127 VPUBLIC void Gem_destroySimplexRings(Gem *thee)
1128 {
1129 int i;
1130 VV *vx;
1131 SS *sm;
1132
1133 Vnm_print(0,"Gem_destroySimplexRings: destroying simplex rings..");
1134
1135 /* go through all vertices and reset firstSS pointer */
1136 for (i=0; i<Gem_numVV(thee); i++) {
1137 vx = Gem_VV(thee,i);
1138 VV_setFirstSS( vx, VNULL );
1139 }
1140
1141 /* go through all simplices and reinitialize simplex rings */
1142 for (i=0; i<Gem_numSS(thee); i++) {
1143 sm = Gem_SS(thee,i);
1144 SS_initRing( sm );
1145 }
1146
1147 Vnm_print(0,"..done.\n");
1148 }
1149
1150 /*
1151 * ***************************************************************************
1152 * Routine: Gem_findOrCreateEdge
1153 *
1154 * Purpose: Look for a common edges between two vertices.
1155 * If it doesn't yet exist, we create it, and then note that
1156 * we did so.
1157 *
1158 * Author: Michael Holst
1159 * ***************************************************************************
1160 */
Gem_findOrCreateEdge(Gem * thee,VV * v0,VV * v1,int * iDid)1161 VPUBLIC EE *Gem_findOrCreateEdge(Gem *thee, VV *v0, VV *v1, int *iDid)
1162 {
1163 VV *vxTmp = VNULL;
1164 EE *eg = VNULL;
1165 EE *parent0 = VNULL;
1166 EE *parent1 = VNULL;
1167 *iDid = 0;
1168
1169 eg = VV_commonEdge(v0,v1);
1170 if (eg == VNULL) {
1171 *iDid = 1;
1172 eg=Gem_createAndInitEE(thee);
1173 EE_setVertex(eg, 0, v0);
1174 EE_setVertex(eg, 1, v1);
1175 EE_setVertexOrder(eg,vxTmp);
1176 EE_setParent(eg,VNULL);
1177 EE_setType(eg,0);
1178 EE_buildRing(eg);
1179 parent0 = VV_parentEE(v0);
1180 parent1 = VV_parentEE(v1);
1181 if ( parent0 != VNULL ) {
1182 EE_setParent(eg, parent0);
1183 } else if ( parent1 != VNULL ) {
1184 EE_setParent(eg, parent1);
1185 }
1186 if ( EE_parent(eg) != VNULL ) {
1187 EE_setType(eg, EE_type(EE_parent(eg)));
1188 }
1189 }
1190
1191 return eg;
1192 }
1193
1194 /*
1195 * ***************************************************************************
1196 * Routine: Gem_createEdges
1197 *
1198 * Purpose: Create all of the edges.
1199 *
1200 * Notes: Based on a simplex traversal.
1201 *
1202 * We also set the edge numbers in the simplices while we we
1203 * are doing the edge creation.
1204 *
1205 * Author: Michael Holst
1206 * ***************************************************************************
1207 */
Gem_createEdges(Gem * thee)1208 VPUBLIC void Gem_createEdges(Gem *thee)
1209 {
1210 int i,j,k,l,iDid,edgeCnt;
1211 # if defined(VG_ELEMENT)
1212 int edgeNum;
1213 EE *eg;
1214 # endif
1215 SS *sm;
1216 VV *v0, *v1;
1217
1218 Vnm_tstart(70, "edge create");
1219 Vnm_print(0,"Gem_createEdges: creating edges (simplex traversal)..");
1220
1221 /* go through simplices and create edges if they don't already exist */
1222 if (Gem_numEE(thee) == 0) {
1223 for (i=0; i<Gem_numSS(thee); i++) {
1224 sm = Gem_SS(thee,i);
1225 for (j=0; j<Gem_dimEE(thee); j++) {
1226 k = vmapEI[j][0];
1227 l = vmapEI[j][1];
1228 v0 = SS_vertex(sm,k);
1229 v1 = SS_vertex(sm,l);
1230 # if defined(VG_ELEMENT)
1231 eg = Gem_findOrCreateEdge(thee, v0, v1, &iDid);
1232 edgeNum = EE_id( eg );
1233 SS_setEdgeNumber(sm,j,edgeNum);
1234 # else
1235 (void*)Gem_findOrCreateEdge(thee, v0, v1, &iDid);
1236 # endif
1237 }
1238 }
1239 }
1240 edgeCnt = Gem_numEE(thee);
1241
1242 Vnm_print(0,"..done. [edges=<%d>]\n",edgeCnt);
1243 Vnm_tstop(70, "edge create");
1244
1245 /* set the edge counter and return */
1246 Gem_setNumVirtEE(thee, edgeCnt);
1247 }
1248
1249 /*
1250 * ***************************************************************************
1251 * Routine: Gem_destroyEdges
1252 *
1253 * Purpose: Destroy all of the edges.
1254 *
1255 * Author: Michael Holst
1256 * ***************************************************************************
1257 */
Gem_destroyEdges(Gem * thee)1258 VPUBLIC void Gem_destroyEdges(Gem *thee)
1259 {
1260 int i;
1261 VV *vx;
1262
1263 Vnm_print(0,"Gem_destroyEdges: destroying edges..");
1264
1265 /* destroy edges if they exist */
1266 if (Gem_numEE(thee) > 0) {
1267 /* go through all vertices and reset firstEE pointer */
1268
1269 for (i=0; i<Gem_numVV(thee); i++) {
1270 vx = Gem_VV(thee,i);
1271 VV_setFirstEE( vx, VNULL );
1272 VV_setParentEE( vx, VNULL );
1273 }
1274
1275 /* reset the edges (release the ram) */
1276 Gem_resetEE(thee);
1277 VASSERT( Gem_numEE(thee) == 0 );
1278 }
1279
1280 Vnm_print(0,"..done. [edges=<%d>]\n",Gem_numEE(thee));
1281 }
1282
1283 /*
1284 * ***************************************************************************
1285 * Routine: Gem_countChk
1286 *
1287 * Purpose: Count all vertices, edges, faces, simplices, and do it
1288 * is cheaply as possible. Also do a form check.
1289 *
1290 * Author: Michael Holst
1291 * ***************************************************************************
1292 */
Gem_countChk(Gem * thee)1293 VPUBLIC void Gem_countChk(Gem *thee)
1294 {
1295 /* count vertices */
1296 Gem_setNumVirtVV( thee, Gem_numVV(thee) );
1297
1298 /* count edges */
1299 if ( Gem_numEE(thee) > 0 ) {
1300 /* edges DO exist; just use the current edge count */
1301 Gem_setNumVirtEE( thee, Gem_numEE(thee) );
1302 } else {
1303 /* edges DO NOT exist; create/destroy to get edge nums (fastest way) */
1304 Gem_createEdges( thee );
1305 Gem_destroyEdges( thee );
1306 }
1307
1308 /* count faces -- COSTLY! Only do if you have face DOF in the element */
1309 Gem_countFaces( thee );
1310
1311 /* count simplices */
1312 Gem_setNumVirtSS( thee, Gem_numSS(thee) );
1313
1314 /* check ringed vertex: 0=[v+s],1=[.+sRing],2=[.+eRing],3=[.+conform] */
1315 /* Gem_formChk(thee,2); */
1316 }
1317
1318 /*
1319 * ***************************************************************************
1320 * Routine: Gem_countFaces
1321 *
1322 * Purpose: Count all of the faces without actually creating them.
1323 *
1324 * Notes: Keep track of the global face numbers in each element.
1325 *
1326 * Author: Michael Holst
1327 * ***************************************************************************
1328 */
Gem_countFaces(Gem * thee)1329 VPUBLIC void Gem_countFaces(Gem *thee)
1330 {
1331 int i, j, faceCnt, face;
1332 # if defined(VG_ELEMENT)
1333 int face2;
1334 # endif
1335 SS *sm, *sm2;
1336
1337 Vnm_tstart(70, "face count");
1338 Vnm_print(0,"Gem_countFaces: counting faces..");
1339
1340 /* count the faces (including boundary faces) */
1341 if (Gem_dim(thee) == 2) {
1342 faceCnt = 0;
1343 } else {
1344 faceCnt = 0;
1345 for (i=0; i<Gem_numSS(thee); i++) {
1346 sm = Gem_SS(thee,i);
1347
1348 /* now count all i-j (sm-sm2) faces where i<j */
1349 for (face=0; face<Gem_dimVV(thee); face++) {
1350 sm2 = SS_nabor(sm,face);
1351 if (sm2 == VNULL) {
1352 # if defined(VG_ELEMENT)
1353 SS_setFaceNumber(sm,face,faceCnt);
1354 # endif
1355 faceCnt++;
1356 } else {
1357 j = SS_id(sm2);
1358 if (i < j) {
1359 # if defined(VG_ELEMENT)
1360 face2 = SS_sharedFaceLocNum(sm2,sm);
1361 SS_setFaceNumber(sm,face,faceCnt);
1362 SS_setFaceNumber(sm2,face2,faceCnt);
1363 # endif
1364 faceCnt++;
1365 }
1366 }
1367 }
1368 }
1369 }
1370
1371 Vnm_print(0,"..done. [faces=<%d>]\n",faceCnt);
1372 Vnm_tstop(70, "face count");
1373
1374 /* set the face counter and return */
1375 Gem_setNumVirtFF(thee, faceCnt);
1376 }
1377
1378 /*
1379 * ***************************************************************************
1380 * Routine: Gem_clearEdges
1381 *
1382 * Purpose: Clear all of the edge numbers in each simplex.
1383 *
1384 * Author: Michael Holst
1385 * ***************************************************************************
1386 */
Gem_clearEdges(Gem * thee)1387 VPUBLIC void Gem_clearEdges(Gem *thee)
1388 {
1389 # if defined(VG_ELEMENT)
1390 int i,j;
1391 SS *sm;
1392 # endif
1393
1394 Vnm_tstart(70, "edge clear");
1395 Vnm_print(0,"Gem_clearEdges: clearing edge numbers..");
1396
1397 /* go through simplices and clear edge numbers */
1398 #if defined(VG_ELEMENT)
1399 for (i=0; i<Gem_numSS(thee); i++) {
1400 sm = Gem_SS(thee,i);
1401 for (j=0; j<Gem_dimEE(thee); j++) {
1402 SS_setEdgeNumber(sm,j,-1);
1403 }
1404 }
1405 #endif
1406
1407 Vnm_print(0,"..done.\n");
1408 Vnm_tstop(70, "edge clear");
1409
1410 /* set the edge counter and return */
1411 Gem_setNumVirtEE(thee, 0);
1412 }
1413
1414 /*
1415 * ***************************************************************************
1416 * Routine: Gem_countEdges
1417 *
1418 * Purpose: Count up all of the edges without actually creating them, and
1419 * keep track of the global edge numbers in each element.
1420 *
1421 * Notes: Based on a simplex traversal.
1422 *
1423 * Author: Michael Holst
1424 * ***************************************************************************
1425 */
Gem_countEdges(Gem * thee)1426 VPUBLIC void Gem_countEdges(Gem *thee)
1427 {
1428 int edgeCnt;
1429 # if defined(VG_ELEMENT)
1430 int i,j,k,l,iv,iv2,edgeNum;
1431 SS *sm, *sm0, *sm2;
1432 VV *vx, *vx2;
1433 # endif
1434
1435 Vnm_tstart(70, "edge count");
1436 Vnm_print(0,"Gem_countEdges: counting edges (simplex traversal)..");
1437
1438 /* go through simplices and count edges */
1439 edgeCnt = 0;
1440 #if defined(VG_ELEMENT)
1441 for (i=0; i<Gem_numSS(thee); i++) {
1442 sm = Gem_SS(thee,i);
1443 for (j=0; j<Gem_dimEE(thee); j++) {
1444 k = vmapEI[j][0];
1445 l = vmapEI[j][1];
1446 edgeNum = vmapE[k][l];
1447 if (SS_edgeNumber(sm,edgeNum) < 0) {
1448 vx = SS_vertex(sm,k);
1449 vx2 = SS_vertex(sm,l);
1450 /* tell all simplices using edge what its number is */
1451 for (sm2=VV_firstSS(vx2);sm2!=VNULL;sm2=SS_link(sm2,vx2)){
1452 for (sm0=VV_firstSS(vx);sm0!=VNULL;sm0=SS_link(sm0,vx)){
1453 if (sm0 == sm2) {
1454 iv = SS_vptr2localVnum(sm0, vx);
1455 iv2 = SS_vptr2localVnum(sm0, vx2);
1456 edgeNum = vmapE[iv][iv2];
1457 SS_setEdgeNumber(sm0,edgeNum,edgeCnt);
1458 }
1459 }
1460 }
1461 edgeCnt++;
1462 }
1463 }
1464 }
1465 #endif
1466
1467 Vnm_print(0,"..done. [edges=<%d>]\n",edgeCnt);
1468 Vnm_tstop(70, "edge count");
1469
1470 /* set the edge counter and return */
1471 Gem_setNumVirtEE(thee, edgeCnt);
1472 }
1473
1474 /*
1475 * ***************************************************************************
1476 * Routine: Gem_formFix
1477 *
1478 * Purpose: Make some specified hacked fix to a given mesh.
1479 *
1480 * Notes: key==0 --> ?
1481 *
1482 * Author: Michael Holst
1483 * ***************************************************************************
1484 */
Gem_formFix(Gem * thee,int key)1485 VPUBLIC void Gem_formFix(Gem *thee, int key)
1486 {
1487 int i, j, k, l, m, nabors, btype;
1488 double radk, radl, radm, myTol;
1489 VV *v[4];
1490 SS *sm, *sm0, *sm1, *sm2;
1491
1492 /* input check and some i/o */
1493 btype = key;
1494 VASSERT( (0 <= btype) && (btype <= 2) );
1495
1496 /* go through all simplices and zero all boundary faces */
1497 Vnm_print(0,"Gem_makeBnd: zeroing boundary faces/vertices..");
1498 Gem_setNumBF(thee, 0);
1499 Gem_setNumBV(thee, 0);
1500 for (i=0; i<Gem_numSS(thee); i++) {
1501 sm = Gem_SS(thee,i);
1502 if ( (i>0) && (i % VPRTKEY) == 0 ) Vnm_print(0,"[BS:%d]",i);
1503
1504 /* get local vertices */
1505 for (j=0; j<Gem_dimVV(thee); j++)
1506 v[j] = SS_vertex(sm,j);
1507
1508 /* reset all vertices and faces to interior type */
1509 for (j=0; j<Gem_dimVV(thee); j++) {
1510 /* the other three local vertex/face numbers besides "j" */
1511 k=(j+1) % Gem_dimVV(thee);
1512 l=(k+1) % Gem_dimVV(thee);
1513 m=(l+1) % Gem_dimVV(thee);
1514 SS_setFaceType(sm, j, 0);
1515 VV_setType(v[k], 0);
1516 VV_setType(v[l], 0);
1517 if (Gem_dim(thee) == 3) VV_setType(v[m], 0);
1518 }
1519 }
1520 Vnm_print(0,"..done.\n");
1521
1522 /* are we done */
1523 /* if (btype == 0) return; */
1524
1525 /* okay now make a boundary */
1526 Vnm_print(0,"Gem_makeBnd: rebuilding boundary faces/vertices..");
1527 for (i=0; i<Gem_numSS(thee); i++) {
1528 sm = Gem_SS(thee,i);
1529 if ( (i>0) && (i % VPRTKEY) == 0 ) Vnm_print(0,"[BS:%d]",i);
1530
1531 /* get local vertices */
1532 for (j=0; j<Gem_dimVV(thee); j++)
1533 v[j] = SS_vertex(sm,j);
1534
1535 /* rebuild everything */
1536 for (j=0; j<Gem_dimVV(thee); j++) {
1537
1538 /* the other three local vertex/face numbers besides "j" */
1539 k=(j+1) % Gem_dimVV(thee);
1540 l=(k+1) % Gem_dimVV(thee);
1541 m=(l+1) % Gem_dimVV(thee);
1542
1543 /* look for a face nabor sharing face "j" (opposite vertex "j") */
1544 nabors = 0;
1545 for (sm0=VV_firstSS(v[k]); sm0!=VNULL;sm0=SS_link(sm0,v[k])) {
1546 for (sm1=VV_firstSS(v[l]); sm1!=VNULL; sm1=SS_link(sm1,v[l])) {
1547 if (Gem_dim(thee) == 2) {
1548 if ((sm0!=sm) && (sm0==sm1)) nabors++;
1549 } else {
1550 for (sm2=VV_firstSS(v[m]); sm2!=VNULL;
1551 sm2=SS_link(sm2,v[m])) {
1552 if ((sm0!=sm) && (sm0==sm1) && (sm0==sm2)) {
1553 nabors++;
1554 }
1555 }
1556 }
1557 }
1558 }
1559
1560 /* if no one there, then face "j" is actually a boundary face */
1561 if (nabors == 0) {
1562
1563 myTol = 1.0e-2;
1564
1565 if ( ( VABS(VV_coord(v[k],2) - 0.0) < myTol)
1566 && ( VABS(VV_coord(v[l],2) - 0.0) < myTol)
1567 && ( VABS(VV_coord(v[m],2) - 0.0) < myTol) ) {
1568 btype = 1;
1569 } else if ( ( VABS(VV_coord(v[k],2) - 68.03512) < myTol)
1570 && ( VABS(VV_coord(v[l],2) - 68.03512) < myTol)
1571 && ( VABS(VV_coord(v[m],2) - 68.03512) < myTol) ) {
1572 btype = 3;
1573 } else {
1574 radk = VSQRT( VSQR( VV_coord(v[k],0) )
1575 + VSQR( VV_coord(v[k],1) ) );
1576 radl = VSQRT( VSQR( VV_coord(v[l],0) )
1577 + VSQR( VV_coord(v[l],1) ) );
1578 radm = VSQRT( VSQR( VV_coord(v[m],0) )
1579 + VSQR( VV_coord(v[m],1) ) );
1580 if ( ( VABS(radk - 1.5) < myTol)
1581 && ( VABS(radl - 1.5) < myTol)
1582 && ( VABS(radm - 1.5) < myTol) ) {
1583 btype = 2;
1584 } else if ( ( VABS(radk - 2.0) < myTol)
1585 && ( VABS(radl - 2.0) < myTol)
1586 && ( VABS(radm - 2.0) < myTol) ){
1587 btype = 4;
1588 } else {
1589 btype = 0;
1590 }
1591 }
1592
1593 SS_setFaceType(sm, j, btype);
1594
1595 Gem_numBFpp(thee);
1596 if (VINTERIOR( VV_type(v[k])) ) {
1597 VV_setType(v[k], btype);
1598 Gem_numBVpp(thee);
1599 }
1600 if (VINTERIOR( VV_type(v[l])) ) {
1601 VV_setType(v[l], btype);
1602 Gem_numBVpp(thee);
1603 }
1604 if (Gem_dim(thee) == 3) {
1605 if (VINTERIOR( VV_type(v[m])) ) {
1606 VV_setType(v[m], btype);
1607 Gem_numBVpp(thee);
1608 }
1609 }
1610 }
1611 }
1612 }
1613 Vnm_print(0,"..done.\n");
1614 }
1615
1616 /*
1617 * ***************************************************************************
1618 * Routine: Gem_externalUpdateFlag, Gem_setExternalUpdateFlag,
1619 * Gem_setExternalUpdateFunction
1620 *
1621 * Purpose: Hook for external structure updating.
1622 *
1623 * Author: Michael Holst
1624 * ***************************************************************************
1625 */
Gem_externalUpdateFlag(Gem * thee)1626 VPUBLIC int Gem_externalUpdateFlag(Gem *thee)
1627 {
1628 return thee->xUpFlag;
1629 }
Gem_setExternalUpdateFlag(Gem * thee,int fl)1630 VPUBLIC void Gem_setExternalUpdateFlag(Gem *thee, int fl)
1631 {
1632 thee->xUpFlag = fl;
1633 }
Gem_setExternalUpdateFunction(Gem * thee,void (* xUp)(SS ** sms,int numS))1634 VPUBLIC void Gem_setExternalUpdateFunction(Gem *thee,
1635 void (*xUp)(SS **sms, int numS))
1636 {
1637 thee->xUpFlag = 1;
1638 thee->xUp = xUp;
1639 }
1640
1641