-
Notifications
You must be signed in to change notification settings - Fork 0
/
mm_as_alloc.c
1986 lines (1696 loc) · 55 KB
/
mm_as_alloc.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. *
\************************************************************************/
/*
*$Id: mm_as_alloc.c,v 5.19 2010-04-07 22:27:00 prschun Exp $
*/
#include <stdio.h>
#include <string.h>
#include "std.h"
#include "el_elm.h" /* Has shape, element type stuff for bf_init */
#include "rf_allo.h"
#include "rf_fem_const.h"
#include "rf_fem.h"
#include "rf_io_const.h"
#include "rf_io.h"
#include "rf_mp.h"
#include "el_geom.h" /* Has info I'd like to replicate into the */
/* Problem_Description structure... */
#include "rf_vars_const.h"
#include "mm_mp_const.h"
#include "mm_as_const.h"
#include "mm_as_structs.h"
#include "mm_as.h"
#include "mm_mp_structs.h"
#define _MM_AS_ALLOC_C
#include "goma.h"
static void init_Viscoelastic_Nonmodal
PROTO((struct Viscoelastic_Nonmodal *));
static void init_Viscoelastic_Constitutive
PROTO((struct Viscoelastic_Constitutive *));
static void init_Generalized_Newtonian PROTO((GEN_NEWT_STRUCT *));
static void init_Elastic_Constitutive
PROTO((struct Elastic_Constitutive *));
static void init_Viscoplastic_Constitutive
PROTO((struct Viscoplastic_Constitutive *));
static int shape_list
PROTO((Exo_DB *));
// Definitions and initializations of global pointers
/*
* This is the single location where these are defined.
*/
UPD_STRUCT *upd = NULL;
PROBLEM_DESCRIPTION_STRUCT **pd_glob = NULL, *pd = NULL;
struct Element_Indices *ei = NULL;
struct Element_Indices **eiRelated = {NULL};
struct Element_Stiffness_Pointers *esp = NULL;
struct Element_Quality_Metrics *eqm = NULL;
struct Element_Variable_Pointers *esp_old = NULL, *esp_dot = NULL, *esp_dbl_dot = NULL, *evp = NULL;
struct Action_Flags *af = NULL;
BASIS_FUNCTIONS_STRUCT **bf = NULL;
BASIS_FUNCTIONS_STRUCT **bfd = NULL;
BASIS_FUNCTIONS_STRUCT **bfi = NULL;
BASIS_FUNCTIONS_STRUCT **bfex = NULL;
struct Shell_Block **shell_blocks = NULL;
struct Field_Variables *fv = NULL, *fv_sens = NULL;
struct Diet_Field_Variables *fv_dot_dot = NULL, *fv_dot_dot_old=NULL;
struct Diet_Field_Variables *fv_old = NULL, *fv_dot = NULL;
struct Diet_Field_Variables *fv_dot_old = NULL;
struct Constitutive_Relations **cr_glob = NULL, *cr = NULL;
struct Local_Element_Contributions *lec = NULL;
struct Porous_Media_Variables *pmv = NULL, *pmv_old = NULL;
PMV_ML_STRUCT *pmv_ml = NULL, *pmv_ml_old = NULL;
struct Material_Properties *mp = NULL, **mp_glob = NULL, *mp_old = NULL;
GEN_NEWT_STRUCT *gn = NULL;
GEN_NEWT_STRUCT **gn_glob = NULL;
struct Viscoelastic_Constitutive **ve = NULL, ***ve_glob = NULL;
struct Viscoelastic_Nonmodal *vn = NULL, **vn_glob = NULL;
struct Elastic_Constitutive *elc = NULL, **elc_glob = NULL,
*elc_rs = NULL, **elc_rs_glob = NULL;
struct Viscoplastic_Constitutive *evpl = NULL, **evpl_glob = NULL;
struct Transient_Information *tran = NULL;
struct Library_IO *libio = NULL;
struct Eigensolver_Info *eigen = NULL;
struct Continuation_Information *cont = NULL;
struct Loca_Input *loca_in = NULL;
struct AC_Information *augc = NULL;
struct HC_Information *huntc = NULL;
struct External_Field_Variables *efv = NULL;
STABILIZATION_PARAMS_STRUCT *Stab = NULL;
struct Lubrication_Auxiliaries *LubAux = NULL;
struct Lubrication_Auxiliaries *LubAux_old = NULL;
/*
* This is where these are declared. The pointer is loaded with the
* address of a double zero that will be used when element degree of freedom
* pointers need to be assigned to point to something harmless.
*/
dbl *p0;
dbl zero = 0.0;
/*
* In this memory allocation routine, "pd", etc. have one level of indirection
* greater than their usual meaning. The main driver "main" calls these
* routines to make sure that "pd", "ei" point to places with enough
* space to hold the relevent information.
*/
#include "mm_eh.h"
/****************************************************************************/
/****************************************************************************/
/****************************************************************************/
int
pd_alloc(void)
/******************************************************************
*
* pd_alloc():
* Assign space for and initialize the uniform problem
* description structure and the problem description structures.
******************************************************************/
{
int status = 0;
int mn;
static char yo[] = "pd_alloc";
upd = alloc_struct_1(struct Uniform_Problem_Description, 1);
upd->Species_Var_Type = SPECIES_UNDEFINED_FORM;
pd_glob = (struct Problem_Description **) alloc_ptr_1(MAX_NUMBER_MATLS);
for (mn = 0; mn < MAX_NUMBER_MATLS; mn++) {
pd_glob[mn] = alloc_struct_1(struct Problem_Description, 1);
pd_glob[mn]->Species_Var_Type = SPECIES_UNDEFINED_FORM;
}
if (Debug_Flag) {
DPRINTF(stdout, "%s: Problem_Description @ %p has %ld bytes",
yo, pd_glob, (long int)sizeof(struct Problem_Description));
}
if (upd == NULL) {
status = -1;
EH(status,
"Hay un problema conseguiendo la memoria para Uniform_Problem_Description");
}
if (pd_glob == NULL) {
status = -1;
EH(status, "Problem getting memory for Problem_Description");
}
return(status);
}
/****************************************************************************/
/****************************************************************************/
/****************************************************************************/
int
efv_alloc()
{
int sz;
int status = 0;
static char yo[] = "efv_alloc";
/*
* External_Field_Variables___________________________________________________
*/
sz = sizeof(struct External_Field_Variables);
efv = (struct External_Field_Variables *) array_alloc(1, 1, sz);
if ( Debug_Flag )
{
DPRINTF(stdout, "%s: External_Field_Variables @ %p has %d bytes",
yo, efv, sz);
}
if ( efv == NULL )
{
status = -1;
EH( status, "Problem getting memory for External_Field_Variables");
}
return(status);
}
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
int
mp_alloc(void)
/***********************************************************************
*
* mp_alloc()
*
* Allocate Material_Properties structures and also allocate
* substructures underneath the main structure (there are none as
* of yet).
*
* Right now, we allocate a fixed number of material property
* structures given by the constant, MAX_NUMBER_MATLS, plus an
* additional Material_Property structure, mp_old, which I don't know
* the reason for.
*
* Return
* 0 -> Everything went well
* fatal error -> Can't malloc enough memory
***********************************************************************/
{
int mn;
static char yo[] = "mp_alloc";
mp_glob = (MATRL_PROP_STRUCT **) alloc_ptr_1(MAX_NUMBER_MATLS);
if (mp_glob == NULL) {
EH( -1, "Problem getting memory for Material_Properties");
}
for (mn = 0; mn < MAX_NUMBER_MATLS; mn++) {
mp_glob[mn] = (MATRL_PROP_STRUCT *)
alloc_void_struct_1(sizeof(MATRL_PROP_STRUCT), 1);
}
mp_old = (MATRL_PROP_STRUCT *)
alloc_void_struct_1(sizeof(MATRL_PROP_STRUCT), 1);
if (Debug_Flag) {
DPRINTF(stdout, "%s: Material_Properties @ %p has %lu bytes",
yo, mp, (long unsigned int)sizeof(MATRL_PROP_STRUCT));
}
return 0;
}
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
int
cr_alloc(void)
/******************************************************************
*
* cr_alloc:
*
* Initializes the global structure, cr_glob.
******************************************************************/
{
int sz;
int mn;
int status;
static char yo[] = "cr_alloc";
status = 0;
/*
* Constitutive_Relations____________________________________________________
*/
sz = sizeof(struct Constitutive_Relations *);
cr_glob = (struct Constitutive_Relations **) array_alloc(1, MAX_NUMBER_MATLS, sz);
sz = sizeof(struct Constitutive_Relations);
for(mn = 0; mn < MAX_NUMBER_MATLS; mn++)
{
cr_glob[mn] = (struct Constitutive_Relations *) array_alloc(1, 1, sz);
}
if ( Debug_Flag )
{
DPRINTF(stdout, "%s: Constitutive_Relations @ %p has %d bytes",
yo, cr, sz);
}
if ( cr_glob == NULL )
{
status = -1;
EH( status, "Problem getting memory for Constitutive_Relations");
}
return(status);
}
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
int gn_alloc(void)
{
int sz;
int mn;
int status;
static char yo[] = "gn_alloc";
status = 0;
/*
* Generalized_Newtonian______________________________________________________
*/
sz = sizeof(struct Generalized_Newtonian *);
gn_glob = (struct Generalized_Newtonian **) array_alloc(1, MAX_NUMBER_MATLS, sz);
sz = sizeof(struct Generalized_Newtonian);
for(mn = 0; mn < MAX_NUMBER_MATLS; mn++)
{
gn_glob[mn] = (struct Generalized_Newtonian *) array_alloc(1, 1, sz);
}
if ( Debug_Flag )
{
DPRINTF(stdout, "%s: Generalized_Newtonian @ %p has %d bytes",
yo, gn, sz);
}
if ( gn_glob == NULL)
{
status = -1;
EH( status, "Problem getting memory for Generalized_Newtonian");
}
return(status);
}
int ve_alloc(void)
{
int sz;
int mn;
int mode;
int status;
static char yo[] = "ve_alloc";
status = 0;
/*
* Viscoelastic_Constitutive_________________________________________________
*/
sz = sizeof(struct Viscoelastic_Nonmodal *);
vn_glob = (struct Viscoelastic_Nonmodal **) smalloc(MAX_NUMBER_MATLS*sz);
sz = sizeof(struct Viscoelastic_Nonmodal);
for(mn = 0; mn < MAX_NUMBER_MATLS; mn++)
{
vn_glob[mn] = (struct Viscoelastic_Nonmodal *) smalloc(sz);
init_Viscoelastic_Nonmodal(vn_glob[mn]);
}
sz = sizeof(struct Viscoelastic_Constitutive *);
ve = (struct Viscoelastic_Constitutive **) smalloc(MAX_MODES*sz);
sz = sizeof(struct Viscoelastic_Constitutive *);
ve_glob = (struct Viscoelastic_Constitutive ***) array_alloc(2, MAX_NUMBER_MATLS, MAX_MODES, sz);
sz = sizeof(struct Viscoelastic_Constitutive);
for(mn = 0; mn < MAX_NUMBER_MATLS; mn++)
{
for ( mode=0; mode<MAX_MODES; mode++)
{
ve_glob[mn][mode] = (struct Viscoelastic_Constitutive *) smalloc(sz);
init_Viscoelastic_Constitutive(ve_glob[mn][mode]);
}
}
for(mn = 0; mn < MAX_NUMBER_MATLS; mn++)
{
for ( mode=0; mode<MAX_MODES; mode++)
{
ve_glob[mn][mode]->gn = alloc_struct_1(GEN_NEWT_STRUCT, 1);
init_Generalized_Newtonian(ve_glob[mn][mode]->gn);
}
}
if ( Debug_Flag )
{
DPRINTF(stdout, "%s: Viscoelastic_Constitutive @ %p has %d bytes",
yo, ve_glob, sz);
}
if ( ve_glob == NULL)
{
status = -1;
EH( status, "Problem getting memory for Viscoelastic_Constitutive");
}
return(status);
}
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
int
elc_alloc(void)
{
int sz;
int mn;
int status;
static char yo[] = "elc_alloc";
status = 0;
/*
* Elastic_Constitutive______________________________________________________
*/
sz = sizeof(struct Elastic_Constitutive *);
elc_glob = (struct Elastic_Constitutive **) smalloc(MAX_NUMBER_MATLS*sz);
sz = sizeof(struct Elastic_Constitutive);
for(mn = 0; mn < MAX_NUMBER_MATLS; mn++)
{
elc_glob[mn] = (struct Elastic_Constitutive *) smalloc(sz);
init_Elastic_Constitutive(elc_glob[mn]);
}
if ( Debug_Flag )
{
DPRINTF(stdout, "%s: Elastic Constitutive @ %p has %d bytes",
yo, gn_glob, sz);
}
if ( elc_glob == NULL )
{
status = -1;
EH( status, "Problem getting memory for Elastic_Constitutive");
}
return(status);
}
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
int
evp_alloc(void)
{
int sz;
int mn;
int status;
static char yo[] = "evp_alloc";
status = 0;
/*
* Viscoplastic_Constitutive_________________________________________________
*/
sz = sizeof(struct Viscoplastic_Constitutive *);
evpl_glob = (struct Viscoplastic_Constitutive **) smalloc(MAX_NUMBER_MATLS*sz);
sz = sizeof(struct Viscoplastic_Constitutive);
for(mn = 0; mn < MAX_NUMBER_MATLS; mn++)
{
evpl_glob[mn] = (struct Viscoplastic_Constitutive *) smalloc(sz);
init_Viscoplastic_Constitutive(evpl_glob[mn]);
}
if ( Debug_Flag )
{
DPRINTF(stdout, "%s: Viscoplastic Constitutive @ %p has %d bytes",
yo, gn_glob, sz);
}
if ( evpl_glob == NULL )
{
status = -1;
EH( status, "Problem getting memory for Viscoplastic_Constitutive");
}
return(status);
}
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
int
evp_tensor_alloc(Exo_DB *exo)
{
int status;
int ielem_type, ip_total, ielem0, mn;
int i, ip, a, b, c, k, w;
#ifdef DEBUG
static char yo[] = "evp_alloc";
#endif
status = 0;
/*
* Viscoplastic global tensors_______________________________________________
*/
for (mn = 0; mn < upd->Num_Mat; mn++)
{
/*Don't bother with allocation if we are not solving an EVP model */
if(evpl_glob[mn]->ConstitutiveEquation == EVP_HYPER)
{
pd_glob[mn]->Num_Dim = Num_Dim; /* from "el_geom.h" */
ielem0 = exo->eb_ptr[mn];
ielem_type = Elem_Type(exo, ielem0); /* element type */
ip_total = elem_info(NQUAD, ielem_type); /* number of */
/* quadrature points */
if ( evpl_glob[mn] == NULL )
{
status = -1;
EH( status, "Problem getting memory for Viscoplastic_Constitutive");
}
evpl_glob[mn]->F_vp_glob =(dbl ****)array_alloc(4,exo->num_elems,ip_total,DIM,DIM, sizeof(dbl));
evpl_glob[mn]->F_vp_old_glob =(dbl ****)array_alloc(4,exo->num_elems,ip_total,DIM,DIM, sizeof(dbl));
evpl_glob[mn]->TT_glob =(dbl ****)array_alloc(4,exo->num_elems,ip_total,DIM,DIM, sizeof(dbl));
evpl_glob[mn]->TT_old_glob =(dbl ****)array_alloc(4,exo->num_elems,ip_total,DIM,DIM, sizeof(dbl));
evpl_glob[mn]->dTT_dx_glob =(dbl ******)array_alloc(6,exo->num_elems,ip_total,DIM,DIM,DIM,MDE, sizeof(dbl));
evpl_glob[mn]->dTT_dx_old_glob =(dbl ******)array_alloc(6,exo->num_elems,ip_total,DIM,DIM,DIM,MDE, sizeof(dbl));
evpl_glob[mn]->dTT_dc_glob =(dbl ******)array_alloc(6,exo->num_elems,ip_total,DIM,DIM,MAX_CONC,MDE, sizeof(dbl));
evpl_glob[mn]->dTT_dc_old_glob =(dbl ******)array_alloc(6,exo->num_elems,ip_total,DIM,DIM,MAX_CONC,MDE, sizeof(dbl));
for(i = 0; i < exo->num_elems; i++)
{
for(ip=0; ip<ip_total; ip++)
{
for(a=0; a< DIM; a++)
{
for(b=0; b < DIM; b++)
{
evpl_glob[mn]->F_vp_old_glob[i][ip][a][b] = 0.;
evpl_glob[mn]->F_vp_glob[i][ip][a][b] = 0.;
evpl_glob[mn]->TT_glob[i][ip][a][b] = 0.;
evpl_glob[mn]->TT_old_glob[i][ip][a][b] = 0.;
for(k = 0; k < MDE; k++)
{
for(c=0; c < DIM; c++)
{
evpl_glob[mn]->dTT_dx_glob[i][ip][a][b][c][k] = 0.;
evpl_glob[mn]->dTT_dx_old_glob[i][ip][a][b][c][k] = 0.;
}
for(w = 0; w < MAX_CONC; w++)
{
evpl_glob[mn]->dTT_dc_glob[i][ip][a][b][w][k] = 0.;
evpl_glob[mn]->dTT_dc_old_glob[i][ip][a][b][w][k] = 0.;
}
}
}
}
}
}
}
}
return(status);
}
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
int
elc_rs_alloc(void)
{
int sz;
int mn;
int status;
static char yo[] = "elc_alloc";
status = 0;
/*
* Elastic_Constitutive____________________________________________________
*/
sz = sizeof(struct Elastic_Constitutive *);
elc_rs_glob = (struct Elastic_Constitutive **) smalloc(MAX_NUMBER_MATLS*sz);
sz = sizeof(struct Elastic_Constitutive);
for(mn = 0; mn < MAX_NUMBER_MATLS; mn++)
{
elc_rs_glob[mn] = (struct Elastic_Constitutive *) smalloc(sz);
init_Elastic_Constitutive(elc_rs_glob[mn]);
}
if ( Debug_Flag )
{
DPRINTF(stdout, "%s: Elastic Constitutive RS @ %p has %d bytes",
yo, gn_glob, sz);
}
if ( elc_rs_glob == NULL )
{
status = -1;
EH( status, "Problem getting memory for Elastic_Constitutive");
}
return(status);
}
int tran_alloc()
{
int sz;
int status;
static char yo[] = "tran_alloc";
status = 0;
/*
* Transient_Information______________________________________________________
*/
sz = sizeof(struct Transient_Information);
tran = (struct Transient_Information*) array_alloc(1, 1, sz);
if ( Debug_Flag )
{
DPRINTF(stdout, "%s: Transient_Information @ %p has %d bytes",
yo, tran, sz);
}
if ( tran == NULL )
{
status = -1;
EH( status, "Problem getting memory for Transient_Information");
}
/*
* Element_Quality_Metrics___________________________________________________
*/
sz = sizeof(struct Element_Quality_Metrics);
eqm = alloc_struct_1(struct Element_Quality_Metrics, 1);
#ifdef DEBUG
fprintf(stderr, "%s allocating eqm of size %d\n", yo,sz);
#endif
if ( Debug_Flag )
{
P0PRINTF("%s: Element_Quality_Metrics @ %p has %d bytes",
yo, eqm, sz);
}
if ( eqm == NULL )
{
status = -1;
EH( status, "Problem getting memory for Element_Quality_Metrics");
}
return(status);
}
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
int
libio_alloc(void)
{
int sz;
int status;
static char yo[] = "libio_alloc";
status = 0;
/*
* Library_IO
*/
sz = sizeof(struct Library_IO);
libio = (struct Library_IO*) array_alloc(1, 1, sz);
if ( Debug_Flag )
{
DPRINTF(stdout, "%s: Library_IO @ %p has %d bytes",
yo, libio, sz);
}
if ( libio == NULL )
{
status = -1;
EH(status,
"Problem getting memory for Library_IO");
}
return(status);
}
/*****************************************************************************/
/*****************************************************************************/
/*****************************************************************************/
int
eigen_alloc(void)
{
int sz;
int status;
static char yo[] = "eigen_alloc";
status = 0;
/*
* Eigensolver_Info
*/
sz = sizeof(struct Eigensolver_Info);
eigen = (struct Eigensolver_Info*) array_alloc(1, 1, sz);
if ( Debug_Flag )
{
DPRINTF(stdout, "%s: Eigensolver_Info @ %p has %d bytes",
yo, eigen, sz);
}
if ( eigen == NULL )
{
status = -1;
EH(status,
"Problem getting memory for Eigensolver_Info");
}
return(status);
}
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
int
cont_alloc(void)
{
int sz;
int status;
static char yo[] = "cont_alloc";
status = 0;
/*
* Continuation_Information
*/
sz = sizeof(struct Continuation_Information);
cont = (struct Continuation_Information*) array_alloc(1, 1, sz);
if ( Debug_Flag )
{
DPRINTF(stdout, "%s: Continuation_Information @ %p has %d bytes",
yo, cont, sz);
}
if ( cont == NULL )
{
status = -1;
EH(status,
"Problem getting memory for Continuation_Information");
}
return(status);
}
/*************************************************************************/
/*************************************************************************/
/*************************************************************************/
int loca_alloc()
{
int sz;
int status;
static char yo[] = "loca_alloc";
status = 0;
/*
* Loca_Input
*/
sz = sizeof(struct Loca_Input);
loca_in = (struct Loca_Input*) array_alloc(1, 1, sz);
if ( Debug_Flag )
{
DPRINTF(stdout, "%s: Loca_Input @ %p has %d bytes",
yo, cont, sz);
}
if ( loca_in == NULL )
{
status = -1;
EH( status, "Problem getting memory for Loca_Input");
}
return(status);
}
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
static void
Element_Indices_alloc(struct Element_Indices *ei_ptr) {
ei_ptr->Num_Lvdesc_Per_Var_Type = alloc_int_1(MAX_VARIABLE_TYPES + MAX_CONC, 0);
ei_ptr->Lvdesc_First_Var_Type = alloc_int_1(MAX_VARIABLE_TYPES + MAX_CONC, -1);
ei_ptr->Lvdesc_to_ledof = alloc_int_2(MAX_LOCAL_VAR_DESC, MDE, -1);
ei_ptr->Lvdesc_to_lvdof = alloc_int_2(MAX_LOCAL_VAR_DESC, MDE, -1);
ei_ptr->Lvdesc_to_Var_Type = alloc_int_1(MAX_LOCAL_VAR_DESC, -1);
ei_ptr->Lvdesc_to_MatID = alloc_int_1(MAX_LOCAL_VAR_DESC, -1);
ei_ptr->Lvdesc_Numdof = alloc_int_1(MAX_LOCAL_VAR_DESC, 0);
ei_ptr->Lvdesc_to_Gnn = alloc_int_2(MAX_LOCAL_VAR_DESC, MDE, -1);
ei_ptr->Lvdesc_to_Gun = alloc_int_2(MAX_LOCAL_VAR_DESC, MDE, -1);
ei_ptr->Lvdesc_to_MFSubvar = alloc_int_1(MAX_LOCAL_VAR_DESC, 0);
ei_ptr->Lvdesc_to_Lnn = alloc_int_2(MAX_LOCAL_VAR_DESC, MDE, -1);
ei_ptr->Lvdesc_Lnn_to_Offset = alloc_int_2(MAX_LOCAL_VAR_DESC, MDE, -1);
ei_ptr->Lvdesc_Lnn_to_lvdof = alloc_int_2(MAX_LOCAL_VAR_DESC, MDE, -1);
ei_ptr->lvdof_to_lvdesc = alloc_int_2(MAX_VARIABLE_TYPES + MAX_CONC,
MDE, -1);
ei_ptr->lvdof_to_lvdesc_dof = alloc_int_2(MAX_VARIABLE_TYPES + MAX_CONC,
MDE, -1);
ei_ptr->Lvdesc_Lnn_Numdof = alloc_int_2(MAX_LOCAL_VAR_DESC, MDE, -1);
ei_ptr->Lvdesc_vd_ptr = (VARIABLE_DESCRIPTION_STRUCT **) alloc_ptr_1(MAX_LOCAL_VAR_DESC);
/*
* At this point we don't know the value of Num_Var_Info_Records
* so we can't malloc the following:
* ei_ptr->VDindex_to_Lvdesc = alloc_int_1(Num_Var_Info_Records, -1);
*/
ei_ptr->owningElementForColVar = alloc_int_1(MAX_VARIABLE_TYPES + MAX_CONC, 0);
/*
* For each equation/variable, tell how many dofs must be accounted for
* in this element and their names(nodes)...
*
*/
ei_ptr->dof = alloc_int_1(MAX_VARIABLE_TYPES, 0);
ei_ptr->dof_ext = alloc_int_1(MAX_EXTERNAL_FIELD, 0);
ei_ptr->Baby_Dolphin = alloc_int_2(MAX_VARIABLE_TYPES, MDE, -1);
/*
* In more detail, tell the list of nodes associated with those dofs
* for each variable.
*/
ei_ptr->dof_list = alloc_int_2(MAX_VARIABLE_TYPES, MDE, -1);
/*
* Finally, pointers into the global unknown arrays for each dof in this
* element...
*/
ei_ptr->gnn_list = alloc_int_2(MAX_VARIABLE_TYPES, MDE, -1);
/*
* Finally, pointers into the global unknown arrays for each dof in this
* element...
*/
ei_ptr->gun_list = alloc_int_2(MAX_VARIABLE_TYPES, MDE, -1);
ei_ptr->ln_to_dof = alloc_int_2(MAX_VARIABLE_TYPES, MDE, -1);
ei_ptr->ln_to_first_dof = alloc_int_2(MAX_VARIABLE_TYPES, MDE, -1);
ei_ptr->lvdof_to_row_lvdof = alloc_int_2(MAX_VARIABLE_TYPES, MDE, -1);
ei_ptr->lvdof_to_ledof = alloc_int_2(MAX_VARIABLE_TYPES, MDE, -1);
ei_ptr->owned_ledof = alloc_int_1(MDE * MAX_PROB_VAR, 1);
ei_ptr->ieqn_ledof = alloc_int_1(MDE * MAX_PROB_VAR, -1);
ei_ptr->matID_ledof = alloc_int_1(MDE * MAX_PROB_VAR, -1);
ei_ptr->active_interp_ledof = alloc_int_1(MDE * MAX_PROB_VAR, -1);
ei_ptr->MFsubvar_Offset = alloc_int_2(MAX_CONC, MDE, 0);
}
/***************************************************************************/
/***************************************************************************/
/***************************************************************************/
int
assembly_alloc(Exo_DB *exo)
/********************************************************************
*
* assembly_alloc:
*
*
********************************************************************/
{
int vi, sz;
int type; /* index for unique basis functions */
int status = 0;
int interp; /* index for interpolation order */
int si; /* index for element shape */
int mn;
int vim, dim, wim; /* problem dimension */
int num_species_eqn; /* active number of species eqn */
/*
* The problem description has already been set up. But we need to access
* it here...
*/
static char yo[] = "assembly_alloc";
#ifdef DEBUG
fprintf(stderr, "%s begins\n", yo);
#endif
/*
* These are critical for the element dof pointers...
*/
p0 = &zero;
if ( Debug_Flag )
{
DPRINTF(stderr, "%s...\n", yo);
}
/*
* Element_Indices___________________________________________________________
*/
ei = alloc_struct_1(struct Element_Indices, 1);
Element_Indices_alloc(ei);
eiRelated = (struct Element_Indices **) alloc_ptr_1(MAX_ELEMENT_INDICES_RELATED);
for (mn = 0; mn < MAX_ELEMENT_INDICES_RELATED; mn++) {
eiRelated[mn] = alloc_struct_1(struct Element_Indices, 1);
Element_Indices_alloc(eiRelated[mn]);
}
/*
* Element_Variable_Pointers________________________________________________
*/
sz = sizeof(struct Element_Variable_Pointers);
esp_old = (struct Element_Variable_Pointers *) array_alloc(1, 1, sz);
esp_dot = (struct Element_Variable_Pointers *) array_alloc(1, 1, sz);
esp_dbl_dot = (struct Element_Variable_Pointers *) array_alloc(1, 1, sz);
evp = (struct Element_Variable_Pointers *) array_alloc(1, 1, sz);
if ( Debug_Flag )
{
DPRINTF(stdout, "%s: Element_Variable_Pointers @ %p has %d bytes",
yo, esp_old, sz);
}
if ( (esp_old == NULL) || (esp_dot == NULL) )
{
status = -1;
EH( status, "Problem getting memory for Element_Variable_Pointers");
}
/*
* Element_Stiffness_Pointers________________________________________________
*/
sz = sizeof(struct Element_Stiffness_Pointers);
esp = alloc_struct_1(struct Element_Stiffness_Pointers, 1);
#ifdef DEBUG
fprintf(stderr, "%s allocating esp of size %d\n", yo,sz);
#endif
if ( Debug_Flag )
{
P0PRINTF("%s: Element_Stiffness_Pointers @ %p has %d bytes",
yo, esp, sz);
}
/*
* Dynamically allocate space for only the pointers needed for a
* given problem.
*/
dim = pd_glob[0]->Num_Dim;
vim = dim;
wim = dim;
if(pd_glob[0]->CoordinateSystem == CYLINDRICAL ||
pd_glob[0]->CoordinateSystem == SWIRLING ||
pd_glob[0]->CoordinateSystem == PROJECTED_CARTESIAN)
vim = vim + 1;
if(pd_glob[0]->CoordinateSystem == SWIRLING ||
pd_glob[0]->CoordinateSystem == PROJECTED_CARTESIAN)
wim = wim + 1;
/*
* num_species_eqn is equal to the maximum number of species equations
* in any one domain
*/
num_species_eqn = upd->Max_Num_Species_Eqn;
#ifdef DEBUG
fprintf(stderr, "%s allocating esp with dim=%d, vim=%d\n", yo, dim, vim);
#endif
sz = MDE;
/* MMH I have included some coupling between particle velocity and
* other things. I have skipped over a bunch (like energy) b/c there
* are no models, yet, that include both energy/temperature and
* particle velocity
*/