forked from goma/brkfix
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbbb.c
1193 lines (1000 loc) · 28.4 KB
/
bbb.c
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
/************************************************************************ *
* Goma - Multiphysics finite element software *
* Sandia National Laboratories *
* *
* Copyright (c) 2014 Sandia Corporation. *
* *
* Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation, *
* the U.S. Government retains certain rights in this software. *
* *
* This software is distributed under the GNU General Public License. *
\************************************************************************/
/* bbb -- build_big_bones, construct monolith skeleton from polylith dpi
*
* For symmetry with the other chunks, lets only allocate the space and
* fill in what is known unambiguously about the global problem.
*
* The largest bulk of information will be incorporated in a 2nd phase
* as we traverse the polyliths. This may be done more than once, depending
* on the number of timeplanes of data that must be reconstituted.
*
* While the first polylith is used in this routine for some purposes, that
* part of the information that we also want from OTHER polyliths is deferred
* so that the 1st polylith may be treated just like any other during the
* 2nd phase.
*
*
* Created: 1998/08/07 09:29 MDT pasacki@sandia.gov
*
* Revised: 1998/08/11 06:49 MDT pasacki@sandia.gov
*/
#define _BBB_C
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <stdio.h>
#include <sys/types.h>
#include <sys/stat.h>
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#ifdef STDC_HEADERS
#include <stdlib.h>
#endif
#include <string.h>
#include "std.h" /* useful general stuff */
#include "eh.h" /* error handling */
#include "aalloc.h" /* multi-dim array allocation */
#include "exo_struct.h" /* some definitions for EXODUS II */
#include "dpi.h" /* distributed processing information */
#include "nodesc.h" /* node descriptions */
#include "bbb.h"
static const int sc = sizeof(char);
static const int si = sizeof(int);
static const int sd = sizeof(dbl);
static const int spc = sizeof(char *);
static const int spi = sizeof(int *);
static const int spd = sizeof(dbl *);
static Spfrtn sr=0; /* sprintf() return type */
static char err_msg[MAX_CHAR_ERR_MSG];
/*
* Function definitions.
*/
void
build_big_bones(Exo_DB *p, /* EXODUS info from representative polylith */
Dpi *d, /* distributed processing info from polylith */
Exo_DB *m) /* ptr to monolithic EXODUS II database */
{
int i;
int j;
int len;
int len_conn_i; /* Length of connectivity data for a block */
/*
* Check for reasonable state of polylith...
*/
if ( p->state == EXODB_STATE_GRND )
{
EH(-1, "Polylith only in ground state.");
}
m->state = EXODB_STATE_GRND;
/*
* All the ex_open() type of information...
*/
m->path = (char *) smalloc(FILENAME_MAX_ACK*sizeof(char));
for ( i=0; i<FILENAME_MAX_ACK; i++)
{
m->path[i] = '\0';
}
/*
* Output monolith filename may well be overriden, but fill in a likely
* placeholder name until such time.
*/
mononame(p->path, m->path);
m->mode = EX_WRITE;
m->comp_wordsize = p->comp_wordsize;
m->io_wordsize = 0; /* for now...anyway */
m->version = p->version;
/*
* Basic ex_get_init() quantitites...
*/
m->title = (char *) smalloc(MAX_LINE_LENGTH*sc);
strcpy(m->title, p->title);
m->num_dim = p->num_dim;
m->num_nodes = d->num_nodes_global;
m->num_elems = d->num_elems_global;
m->num_elem_blocks = d->num_elem_blocks_global;
m->num_node_sets = d->num_node_sets_global;
m->num_side_sets = d->num_side_sets_global;
/*
* Miscellaneous information from ex_inquire()...
*/
/*
* QA Records...
*/
m->num_qa_rec = p->num_qa_rec;
if ( m->num_qa_rec > 0 )
{
m->qa_record = (QA_Record *) smalloc(m->num_qa_rec*sizeof(QA_Record));
for ( i=0; i<m->num_qa_rec; i++)
{
for ( j=0; j<4; j++)
{
m->qa_record[i][j] = (char *) smalloc(MAX_STR_LENGTH*sc);
strcpy(m->qa_record[i][j], p->qa_record[i][j]);
}
}
}
/*
* Info Records...
*/
m->num_info = p->num_info;
if ( m->num_info > 0 )
{
m->info = (INFO_Record *) smalloc(m->num_info*sizeof(INFO_Record));
for ( i=0; i<m->num_info; i++)
{
m->info[i] = (char *) smalloc(MAX_LINE_LENGTH * sc);
strcpy(m->info[i], p->info[i]);
}
}
m->api_version = p->api_version;
m->db_version = p->db_version;
m->ns_node_len = d->ns_node_len_global;
m->ns_distfact_len = d->ns_distfact_len_global;
m->ss_elem_len = d->ss_elem_len_global;
m->ss_distfact_len = d->ss_distfact_len_global;
/*
* m->ss_node_len = d->ss_node_len_global;
*/
/*
* Protective measures against rampant replications of the EXODUS II
* "ID" property virus in old versions of GOMA...
*/
m->eb_num_props = MIN(p->eb_num_props, d->num_props_eb);
m->ns_num_props = MIN(p->ns_num_props, d->num_props_ns);
m->ss_num_props = MIN(p->ss_num_props, d->num_props_ss);
m->num_times = p->num_times;
/*
* Make space for spatial coordinates...
*/
if ( m->num_dim > 0 )
{
m->x_coord = (dbl *) smalloc(m->num_nodes * sd);
for ( i=0; i<m->num_nodes; i++)
{
m->x_coord[i] = -9e12;
}
}
if ( m->num_dim > 1 )
{
m->y_coord = (dbl *) smalloc(m->num_nodes * sd);
for ( i=0; i<m->num_nodes; i++)
{
m->y_coord[i] = -9e12;
}
}
if ( m->num_dim > 2 )
{
m->z_coord = (dbl *) smalloc(m->num_nodes * sd);
for ( i=0; i<m->num_nodes; i++)
{
m->z_coord[i] = -9e12;
}
}
if ( m->num_dim > 0 )
{
m->coord_names = (char **) smalloc(m->num_dim * spc);
for ( i=0; i<m->num_dim; i++ )
{
m->coord_names[i] = (char *) smalloc(MAX_STR_LENGTH*sc);
strcpy(m->coord_names[i], p->coord_names[i]);
}
}
/*
* Node map...PASS!
*/
/*
* Element map...PASS!
*/
/*
* Element order map...PASS!
*/
/*
* Element blocks...
*/
if ( m->num_elem_blocks > 0 )
{
m->eb_id = (int *) smalloc(m->num_elem_blocks*si);
m->eb_elem_type = (char **) smalloc(m->num_elem_blocks*spc);
m->eb_num_elems = (int *) smalloc(m->num_elem_blocks*si);
m->eb_num_nodes_per_elem = (int *) smalloc(m->num_elem_blocks*si);
m->eb_num_attr = (int *) smalloc(m->num_elem_blocks*si);
m->eb_conn = (int **) smalloc(m->num_elem_blocks*spi);
m->eb_attr = (dbl **) smalloc((m->num_elem_blocks)*spd);
m->eb_ptr = (int *) smalloc((m->num_elem_blocks+1)*si);
m->eb_ptr[0] = 0;
for ( i = 0; i < m->num_elem_blocks; i++)
{
m->eb_id[i] = d->eb_id_global[i];
m->eb_elem_type[i] = smalloc((MAX_STR_LENGTH+1)*sc);
strcpy(m->eb_elem_type[i], d->eb_elem_type_global[i]);
m->eb_num_elems[i] = d->eb_num_elems_global[i];
m->eb_num_nodes_per_elem[i] = d->eb_num_nodes_per_elem_global[i];
m->eb_num_attr[i] = d->eb_num_attr_global[i];
m->eb_ptr[i+1] = m->eb_ptr[i] + m->eb_num_elems[i];
len_conn_i = ( m->eb_num_elems[i] *
m->eb_num_nodes_per_elem[i] );
if ( len_conn_i > 0 )
{
m->eb_conn[i] = (int *) smalloc(len_conn_i * si);
for ( j=0; j<len_conn_i; j++)
{
m->eb_conn[i][j] = -1; /* Initialize as "undefined". */
}
}
len = MAX(1, m->eb_num_attr[i] * m->eb_num_elems[i]);
if ( len > 0 )
{
m->eb_attr[i] = (dbl *) smalloc(len * sd);
for ( j=0; j<len; j++)
{
m->eb_attr[i][j] = -9.0e12; /* Initialize as "undefined". */
}
}
}
}
/*
* Node sets...
*/
if ( m->num_node_sets > 0 )
{
m->ns_id = (int *) smalloc(m->num_node_sets* si);
m->ns_num_nodes = (int *) smalloc(m->num_node_sets* si);
m->ns_num_distfacts = (int *) smalloc(m->num_node_sets* si);
m->ns_node_index = (int *) smalloc(m->num_node_sets* si);
m->ns_distfact_index = (int *) smalloc(m->num_node_sets* si);
if ( m->ns_node_len > 0 )
{
m->ns_node_list = (int *) smalloc(m->ns_node_len* si);
for ( j=0; j<m->ns_node_len; j++)
{
m->ns_node_list[j] = -1; /* Initialize as "undefined". */
}
}
if ( m->ns_distfact_len > 0 )
{
m->ns_distfact_list = (dbl *) smalloc(m->ns_distfact_len* sd);
for ( j=0; j<m->ns_distfact_len; j++)
{
m->ns_distfact_list[j] = -9e12; /* Initialize as "undefined". */
}
}
for ( i=0; i<m->num_node_sets; i++)
{
m->ns_id[i] = d->ns_id_global[i];
m->ns_num_nodes[i] = d->ns_num_nodes_global[i];
m->ns_num_distfacts[i] = d->ns_num_distfacts_global[i];
m->ns_node_index[i] = d->ns_node_index_global[i];
m->ns_distfact_index[i] = d->ns_distfact_index_global[i];
}
/*
* The m->ns_..._list[] arrays will be populated as the individual
* polyliths are traversed...
*/
}
/*
* Side sets...
*/
if ( m->num_side_sets > 0 )
{
m->ss_id = (int *) smalloc(m->num_side_sets* si);
m->ss_num_sides = (int *) smalloc(m->num_side_sets* si);
m->ss_num_distfacts = (int *) smalloc(m->num_side_sets* si);
m->ss_elem_index = (int *) smalloc(m->num_side_sets* si);
m->ss_distfact_index = (int *) smalloc(m->num_side_sets* si);
/*
m->ss_node_cnt_list = (int **) smalloc(m->num_side_sets* spi);
m->ss_node_list = (int **) smalloc(m->num_side_sets* spi);
m->ss_node_side_index = (int **) smalloc(m->num_side_sets* spi);
*/
if ( m->ss_elem_len > 0 )
{
m->ss_elem_list = (int *) smalloc(m->ss_elem_len* si);
m->ss_side_list = (int *) smalloc(m->ss_elem_len* si);
for ( j=0; j<m->ss_elem_len; j++)
{
m->ss_elem_list[j] = -1; /* Initialize as "undefined". */
m->ss_side_list[j] = -1; /* Initialize as "undefined". */
}
}
if ( m->ss_distfact_len > 0 )
{
m->ss_distfact_list = (dbl *) smalloc(m->ss_distfact_len* sd);
for ( j=0; j<m->ss_distfact_len; j++)
{
m->ss_distfact_list[j] = -9e12; /* Initialize as "undefined". */
}
}
for ( i=0; i<m->num_side_sets; i++)
{
m->ss_id[i] = d->ss_id_global[i];
m->ss_num_sides[i] = d->ss_num_sides_global[i];
m->ss_num_distfacts[i] = d->ss_num_distfacts_global[i];
m->ss_elem_index[i] = d->ss_elem_index_global[i];
m->ss_distfact_index[i] = d->ss_distfact_index_global[i];
}
/*
* Forget about the ss_node_cnt_list[], etc. for now. They're
* not required for ex_put_concat_side_set(), so don't bother
* reconstructing them, at least for now...
*/
m->ss_node_list_exists = FALSE;
}
/*
* Properties of node sets...
*/
if ( m->ns_num_props > 1 )
{
m->ns_prop_name = (char **) smalloc(m->ns_num_props* spc);
for ( i=0; i<m->ns_num_props; i++)
{
m->ns_prop_name[i] = (char *) smalloc(MAX_STR_LENGTH* sc);
strcpy(m->ns_prop_name[i], p->ns_prop_name[i]);
}
m->ns_prop = (int **) smalloc(m->ns_num_props* spi);
for ( i=0; i<m->ns_num_props; i++)
{
m->ns_prop[i] = (int *)smalloc(m->num_node_sets* si);
for ( j=0; j<m->num_node_sets; j++)
{
m->ns_prop[i][j] = d->ns_prop_global[i][j];
}
}
}
/*
* Properties of side sets...
*/
if ( m->ss_num_props > 1 )
{
m->ss_prop_name = (char **) smalloc(m->ss_num_props* spc);
for ( i=0; i<m->ss_num_props; i++)
{
m->ss_prop_name[i] = (char *) smalloc(MAX_STR_LENGTH* sc);
strcpy(m->ss_prop_name[i], p->ss_prop_name[i]);
}
m->ss_prop = (int **) smalloc(m->ss_num_props* spi);
for ( i=0; i<m->ss_num_props; i++)
{
m->ss_prop[i] = (int *)smalloc(m->num_side_sets* si);
for ( j=0; j<m->num_side_sets; j++)
{
m->ss_prop[i][j] = d->ss_prop_global[i][j];
}
}
}
/*
* Properties of element blocks...
*/
if ( m->eb_num_props > 1 )
{
m->eb_prop_name = (char **) smalloc(m->eb_num_props* spc);
for ( i=0; i<m->eb_num_props; i++)
{
m->eb_prop_name[i] = (char *) smalloc(MAX_STR_LENGTH* sc);
strcpy(m->eb_prop_name[i], p->eb_prop_name[i]);
}
m->eb_prop = (int **) smalloc(m->eb_num_props* spi);
for ( i=0; i<m->eb_num_props; i++)
{
m->eb_prop[i] = (int *)smalloc(m->num_elem_blocks* si);
for ( j=0; j<m->num_elem_blocks; j++)
{
m->eb_prop[i][j] = d->eb_prop_global[i][j];
}
}
}
/*
* Results data...how many of each kind.
*/
m->num_glob_vars = p->num_glob_vars;
m->num_elem_vars = p->num_elem_vars;
m->num_node_vars = p->num_node_vars;
/*
* Results data...their names...
*/
if ( m->num_glob_vars > 0 )
{
m->glob_var_names = (char **) smalloc(m->num_glob_vars* spc);
for ( i=0; i<m->num_glob_vars; i++)
{
m->glob_var_names[i] = (char *) smalloc(MAX_STR_LENGTH* sc);
strcpy(m->glob_var_names[i], p->glob_var_names[i]);
}
}
if ( m->num_elem_vars > 0 )
{
m->elem_var_names = (char **) smalloc(m->num_elem_vars* spc);
for ( i=0; i<m->num_elem_vars; i++)
{
m->elem_var_names[i] = (char *) smalloc(MAX_STR_LENGTH* sc);
strcpy(m->elem_var_names[i], p->elem_var_names[i]);
}
}
if ( m->num_node_vars > 0 )
{
m->node_var_names = (char **) smalloc(m->num_node_vars* spc);
for ( i=0; i<m->num_node_vars; i++)
{
m->node_var_names[i] = (char *) smalloc(MAX_STR_LENGTH* sc);
strcpy(m->node_var_names[i], p->node_var_names[i]);
}
}
/*
* Time values...polyliths are assumed to simulate synchronously...
*/
if ( m->num_times > 0 )
{
m->time_vals = (dbl *) smalloc(m->num_times* sizeof(dbl));
for ( i=0; i<m->num_times; i++)
{
m->time_vals[i] = p->time_vals[i];
}
}
/*
* Element variable truth table.
*
* Implicit in the definition of the element variable truth table
* is an indexing of the element blocks that are known, whether they
* are the full set of element blocks in the global problem or whether
* they are some subset in which this processor participates.
*
* For now, take the easy route out for distributed problems. That is,
* assume that each processor will be able to know what the global
* problem's element_var_tab will be. Store that information in
* the Dpi...
*/
if ( m->num_elem_vars > 0 )
{
m->elem_var_tab = (int *) smalloc(m->num_elem_vars *
m->num_elem_blocks * si);
for ( i=0; i<(m->num_elem_vars*m->num_elem_blocks); i++)
{
m->elem_var_tab[i] = d->elem_var_tab_global[i];
}
}
m->state |= EXODB_STATE_MESH;
m->state |= EXODB_STATE_RES0;
return;
}
/*
* build_global_conn() - contribute to monolithic connectivity from a polylith
*
* - Assumes polylith mesh, monolith mesh and Dpi are in good shape.
*
* Created: 1998/08/11 08:13 MDT pasacki@sandia.gov
*
* Revised:
*/
void
build_global_conn(Exo_DB *p, /* EXODUS info from representative polylith */
Dpi *d, /* distributed processing info from polylith */
Exo_DB *m) /* ptr to monolithic EXODUS II database */
{
int e; /* element index */
int ebi; /* element block index */
int ebi_global; /* element block index in global problem */
int elem_global;
int elem_global_this_block;
int l;
int nd; /* node name (local) */
int nd_global; /* node name (global) */
int node;
int node_global;
int npe; /* number of Nodes Per Element this block */
/*
* A few checks to throw out nonsense...
*/
if ( p->state <= EXODB_STATE_GRND )
{
EH(-1, "Polylith needs to be constructed.");
}
if ( m->state <= EXODB_STATE_GRND )
{
EH(-1, "Basic monolith needs to be constructed.");
}
if ( d == NULL )
{
EH(-1, "Need to pass in a reasonable set of distributed proc info.");
}
/*
* Now comes less serious cases that ought not to happen too frequently...
*/
if ( p->num_elems == 0 )
{
return;
}
if ( m->num_elems == 0 )
{
return;
}
for ( ebi=0; ebi<p->num_elem_blocks; ebi++)
{
ebi_global = d->eb_index_global[ebi];
npe = p->eb_num_nodes_per_elem[ebi]; /* local & global ! */
for ( e=0; e<p->eb_num_elems[ebi]; e++)
{
/*
* The global element number is not enough. The connectivity
* arrays are based on the number of elements in a block, so
* subtract off the number of elements in all of the preceding
* blocks to get the element index within this block from the
* global perspective.
*/
elem_global = d->elem_index_global[p->eb_ptr[ebi]+e];
elem_global_this_block = elem_global - m->eb_ptr[ebi_global];
nd_global = npe*(elem_global_this_block);
nd = npe*e;
for ( l=0; l<npe; l++)
{
node = p->eb_conn[ebi][nd+l];
node_global = d->node_index_global[node];
m->eb_conn[ebi_global][nd_global+l] = node_global;
}
}
}
return;
}
/*
* build_global_attr() - contribute to monolithic eb attributes from a polylith
*
* - Assumes polylith mesh, monolith mesh and Dpi are in good shape.
*
* Created: 1998/08/12 14:40 MDT pasacki@sandia.gov
*
* Revised:
*/
void
build_global_attr(Exo_DB *p, /* EXODUS info from representative polylith */
Dpi *d, /* distributed processing info from polylith */
Exo_DB *m) /* ptr to monolithic EXODUS II database */
{
int e;
int ebi;
int ebi_global;
int l;
int nattr; /* num element block attributes this block */
int na; /* attribute index locally */
/*
* A few checks to throw out nonsense...
*/
if ( p->state <= EXODB_STATE_GRND )
{
EH(-1, "Polylith needs to be constructed.");
}
if ( m->state <= EXODB_STATE_GRND )
{
EH(-1, "Basic monolith needs to be constructed.");
}
if ( d == NULL )
{
EH(-1, "Need to pass in a reasonable set of distributed proc info.");
}
/*
* Now comes less serious cases that ought not to happen too frequently...
*/
if ( p->num_elems == 0 )
{
return;
}
if ( m->num_elems == 0 )
{
return;
}
for ( ebi=0; ebi<p->num_elem_blocks; ebi++)
{
ebi_global = d->eb_index_global[ebi];
nattr = p->eb_num_attr[ebi]; /* same for local & global */
for ( e=0; e<p->eb_num_elems[ebi]; e++)
{
/*
* The global element number is not enough. The attributes
* arrays are based on the number of elements in a block, so
* subtract off the number of elements in all of the preceding
* blocks to get the element index within this block from the
* global perspective.
*/
na = nattr * e;
for ( l=0; l<nattr; l++)
{
m->eb_attr[ebi_global][l] =
p->eb_attr[ebi][na+l];
}
}
}
return;
}
/*
* build_global_coords() - contribute to monolith coordinates from a polylith
*
* - Assumes polylith mesh, monolith mesh and Dpi are in good shape.
*
* Created: 1998/08/12 08:04 MDT pasacki@sandia.gov
*
* Revised:
*/
void
build_global_coords(Exo_DB *p, /* EXODUS info from representative polylith */
Dpi *d, /* distributed processing info from polylith */
Exo_DB *m) /* ptr to monolithic EXODUS II database */
{
int dim;
int n;
int n_global; /* node number in global problem */
/*
* A few checks to throw out nonsense...
*/
if ( p->state <= EXODB_STATE_GRND )
{
EH(-1, "Polylith needs to be constructed.");
}
if ( m->state <= EXODB_STATE_GRND )
{
EH(-1, "Basic monolith needs to be constructed.");
}
if ( d == NULL )
{
EH(-1, "Need to pass in a reasonable set of distributed proc info.");
}
if ( m->num_dim != p->num_dim )
{
EH(-1, "Monolith and polylith with mismatched spatial dimensions.");
}
if ( m->num_dim > 0 )
{
if ( m->x_coord == NULL )
{
EH(-1, "Memory for coordinates must be allocated.");
}
if ( p->x_coord == NULL )
{
EH(-1, "Transcribing coordinates from a null polylith!");
}
}
if ( m->num_dim > 1 )
{
if ( m->y_coord == NULL )
{
EH(-1, "Memory for coordinates must be allocated.");
}
if ( p->y_coord == NULL )
{
EH(-1, "Transcribing coordinates from a null polylith!");
}
}
if ( m->num_dim > 2 )
{
if ( m->z_coord == NULL )
{
EH(-1, "Memory for coordinates must be allocated.");
}
if ( p->z_coord == NULL )
{
EH(-1, "Transcribing coordinates from a null polylith!");
}
}
dim = m->num_dim;
for ( n=0; n<p->num_nodes; n++)
{
n_global = d->node_index_global[n];
if ( dim > 0 )
{
m->x_coord[n_global] = p->x_coord[n];
}
if ( dim > 1 )
{
m->y_coord[n_global] = p->y_coord[n];
}
if ( dim > 2 )
{
m->z_coord[n_global] = p->z_coord[n];
}
}
return;
}
/*
* build_global_ns() - contribute to monolith node sets from a polylith
*
* - Assumes polylith mesh, monolith mesh and Dpi are in good shape.
*
* Created: 1998/08/12 16:03 MDT pasacki@sandia.gov
*
* Revised:
*/
void
build_global_ns(Exo_DB *p, /* EXODUS info from representative polylith */
Dpi *d, /* distributed processing info from polylith */
Exo_DB *m) /* ptr to monolithic EXODUS II database */
{
int i;
/*
* A few checks to throw out nonsense...
*/
if ( p->state <= EXODB_STATE_GRND )
{
EH(-1, "Polylith needs to be constructed.");
}
if ( m->state <= EXODB_STATE_GRND )
{
EH(-1, "Basic monolith needs to be constructed.");
}
if ( d == NULL )
{
EH(-1, "Need to pass in a reasonable set of distributed proc info.");
}
if ( m->num_node_sets == 0 )
{
return;
}
if ( p->num_node_sets == 0 )
{
return;
}
for ( i=0; i<p->ns_node_len; i++)
{
m->ns_node_list[ d->ns_node_list_index_global[i] ] =
d->node_index_global[ p->ns_node_list[i] ];
}
for ( i=0; i<p->ns_distfact_len; i++)
{
m->ns_distfact_list[ d->ns_distfact_list_index_global[i] ] =
p->ns_distfact_list[i];
}
return;
}
/*
* build_global_ss() - contribute to monolith side sets from a polylith
*
* - Assumes polylith mesh, monolith mesh and Dpi are in good shape.
*
* Created: 1998/08/12 17:15 MDT pasacki@sandia.gov
*
* Revised:
*/
void
build_global_ss(Exo_DB *p, /* EXODUS info from representative polylith */
Dpi *d, /* distributed processing info from polylith */
Exo_DB *m) /* ptr to monolithic EXODUS II database */
{
int i;
/*
* A few checks to throw out nonsense...
*/
if ( p->state <= EXODB_STATE_GRND )
{
EH(-1, "Polylith needs to be constructed.");
}
if ( m->state <= EXODB_STATE_GRND )
{
EH(-1, "Basic monolith needs to be constructed.");
}
if ( d == NULL )
{
EH(-1, "Need to pass in a reasonable set of distributed proc info.");
}
if ( m->num_side_sets == 0 )
{
return;
}
if ( p->num_side_sets == 0 )
{
return;
}
for ( i=0; i<p->ss_elem_len; i++)
{
m->ss_elem_list[ d->ss_elem_list_index_global[i] ] =
d->elem_index_global[ p->ss_elem_list[i] ];
m->ss_side_list[ d->ss_elem_list_index_global[i] ] =
p->ss_side_list[i]; /* Sides are the same. */
}
for ( i=0; i<p->ss_distfact_len; i++)
{
m->ss_distfact_list[ d->ss_distfact_list_index_global[i] ] =
p->ss_distfact_list[i]; /* Same, local or global. */
}
return;
}
/*
* build_global_res() - contribute to monolith results from a polylith
*
* - Assumes polylith mesh, monolith mesh and Dpi are in good shape.
*
* - Any global variables are directly overwritten - the last one
* is what you get.
*
* - Also, transcribe the results descriptions in ev_time_indeces[], etc.
*
* Created: 1998/08/14 12:21 MDT pasacki@sandia.gov
*
* Revised:
*/
void
build_global_res(Exo_DB *p, /* EXODUS info from representative polylith */
Dpi *d, /* distributed processing info from polylith */
Exo_DB *m) /* ptr to monolithic EXODUS II database */
{
int b; /* element block index - local */
int b_global; /* element block index - global */
int e;
int eg;
int elem_local;
int elem_global;
int index;
int index_global;
int n;
int node_global;
int t; /* time plane counter */
int v; /* variable counter */
int m_var;