00001 #include "nodet.h"
00002 #include "globalt.h"
00003
00004 nodet::nodet (void)
00005 {
00006
00007 ndofn=0;
00008
00009 ncompgrad=0;
00010
00011 ncompother = 0;
00012
00013 ncompeqother=0;
00014
00015
00016 crst = (crsectypet) 0;
00017
00018 idcs=0;
00019
00020
00021 ncontr_grad=NULL;
00022 vol_grad=NULL;
00023
00024 ncontr_flux=NULL;
00025 vol_flux=NULL;
00026
00027 ncontr_other=NULL;
00028 vol_other=NULL;
00029
00030 ncontr_eqother=NULL;
00031 vol_eqother=NULL;
00032
00033
00034 gradient=NULL;
00035
00036 flux=NULL;
00037
00038 other=NULL;
00039
00040 eqother=NULL;
00041
00042
00043
00044 nodval=NULL;
00045
00046 nodvalp=NULL;
00047
00048 nodvali=NULL;
00049
00050 nodvalt=NULL;
00051 }
00052
00053 nodet::~nodet (void)
00054 {
00055 long i;
00056
00057 for (i=0; i<Tp->ntm; i++){
00058 if (gradient != NULL)
00059 delete [] gradient[i];
00060 if (flux != NULL)
00061 delete [] flux[i];
00062 }
00063 delete [] gradient;
00064 delete [] flux;
00065
00066 if (ncontr_grad!=NULL)
00067 delete [] ncontr_grad;
00068 if (ncontr_flux!=NULL)
00069 delete [] ncontr_flux;
00070 if (ncontr_other!=NULL)
00071 delete [] ncontr_other;
00072 if (ncontr_eqother!=NULL)
00073 delete [] ncontr_eqother;
00074 if (other!=NULL)
00075 delete [] other;
00076 if (eqother!=NULL)
00077 delete [] eqother;
00078
00079 if (nodval!=NULL)
00080 delete [] nodval;
00081 if (nodvalp!=NULL)
00082 delete [] nodvalp;
00083 if (nodvali!=NULL)
00084 delete [] nodvali;
00085 if (nodvalt!=NULL)
00086 delete [] nodvalt;
00087 }
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097 void nodet::read (XFILE *in,long ndof)
00098 {
00099
00100 ndofn=ndof;
00101
00102
00103 xfscanf (in,"%d",(int*)&crst);
00104 if (crst!=0){
00105 xfscanf (in,"%ld",&idcs);
00106 idcs--;
00107 }
00108 }
00109
00110
00111
00112
00113
00114
00115 void nodet::print (FILE *out)
00116 {
00117
00118 fprintf (out," %d ",(int)crst);
00119 if (crst!=0){
00120 fprintf (out," %ld\n",idcs+1);
00121 }
00122 }
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132
00133
00134
00135 void nodet::alloc_grad (long ncomp)
00136 {
00137 long i;
00138
00139 ncompgrad=ncomp;
00140 gradient = new double* [Tp->ntm];
00141 if (Tp->gradaver==1)
00142 ncontr_grad = new long [Tp->ntm];
00143 if (Tp->gradaver==2)
00144 vol_grad = new long [Tp->ntm];
00145
00146 for (i=0;i<Tp->ntm;i++){
00147 gradient[i] = new double [ncomp];
00148 }
00149 nullgrad();
00150 }
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160 void nodet::alloc_flux (long ncomp)
00161 {
00162 long i;
00163
00164 ncompgrad=ncomp;
00165 flux = new double* [Tp->ntm];
00166 if (Tp->fluxaver==1)
00167 ncontr_flux = new long [Tp->ntm];
00168 if (Tp->fluxaver==2)
00169 vol_flux = new long [Tp->ntm];
00170
00171 for (i=0;i<Tp->ntm;i++){
00172 flux[i] = new double [ncomp];
00173 }
00174 nullflux();
00175 }
00176
00177
00178
00179
00180
00181
00182
00183
00184
00185 void nodet::alloc_other (long ncompo)
00186 {
00187 ncompother=ncompo;
00188 if (Tp->otheraver==1)
00189 ncontr_other = new long [ncompo];
00190 if (Tp->otheraver==2)
00191 vol_other = new long [ncompo];
00192
00193 other = new double [ncompo];
00194 nullother ();
00195 }
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205 void nodet::alloc_eqother (long ncompeqo)
00206 {
00207 ncompeqother=ncompeqo;
00208 if (Tp->eqotheraver==1)
00209 ncontr_eqother = new long [ncompeqo];
00210 if (Tp->eqotheraver==2)
00211 vol_eqother = new long [ncompeqo];
00212
00213 eqother = new double [ncompeqo];
00214 nulleqother ();
00215 }
00216
00217
00218
00219
00220
00221
00222 void nodet::alloc_nodval ()
00223 {
00224 nodval = new double [ndofn];
00225 nullnodval ();
00226 }
00227
00228
00229
00230
00231
00232
00233 void nodet::alloc_nodvali ()
00234 {
00235 nodvali = new double [ndofn];
00236 nullnodvali ();
00237 }
00238
00239
00240
00241
00242
00243
00244 void nodet::alloc_nodvalp ()
00245 {
00246 nodvalp = new double [ndofn];
00247 nullnodvalp ();
00248 }
00249
00250
00251
00252
00253
00254
00255 void nodet::alloc_nodvalt ()
00256 {
00257 nodvalt = new double [ndofn];
00258 nullnodvalt ();
00259 }
00260
00261
00262
00263
00264
00265
00266
00267
00268 void nodet::nullgrad ()
00269 {
00270 long i,j;
00271
00272 for (i=0;i<Tp->ntm;i++){
00273 if (Tp->gradaver==1)
00274 ncontr_grad[i] = 0.0;
00275 if (Tp->gradaver==2)
00276 vol_grad[i] = 0.0;
00277 for (j=0;j<ncompgrad;j++)
00278 gradient[i][j]=0.0;
00279 }
00280 }
00281
00282
00283
00284
00285
00286
00287
00288 void nodet::nullflux ()
00289 {
00290 long i,j;
00291
00292 for (i=0;i<Tp->ntm;i++){
00293 if (Tp->fluxaver==1)
00294 ncontr_flux[i] = 0.0;
00295 if (Tp->fluxaver==2)
00296 vol_flux[i] = 0.0;
00297 for (j=0;j<ncompgrad;j++)
00298 flux[i][j]=0.0;
00299 }
00300 }
00301
00302
00303
00304
00305
00306 void nodet::nullother ()
00307 {
00308 long i;
00309
00310 for (i=0;i<ncompother;i++){
00311 if (Tp->otheraver==1)
00312 ncontr_other[i]=0;
00313 if (Tp->otheraver==2)
00314 vol_other=0;
00315 }
00316
00317 for (i=0;i<ncompother;i++)
00318 other[i]=0.0;
00319 }
00320
00321
00322
00323
00324
00325
00326 void nodet::nulleqother ()
00327 {
00328 long i;
00329
00330 for (i=0;i<ncompeqother;i++){
00331 if (Tp->eqotheraver==1)
00332 ncontr_eqother[i]=0;
00333 if (Tp->eqotheraver==2)
00334 vol_eqother=0;
00335 }
00336
00337 for (i=0;i<ncompeqother;i++)
00338 eqother[i]=0.0;
00339 }
00340
00341
00342
00343
00344
00345
00346 void nodet::nullnodval ()
00347 {
00348 long i;
00349 for (i=0;i<ndofn;i++){
00350 nodval[i]=0.0;
00351 }
00352 }
00353
00354
00355
00356
00357
00358
00359 void nodet::nullnodvalp ()
00360 {
00361 long i;
00362 for (i=0;i<ndofn;i++){
00363 nodvalp[i]=0.0;
00364 }
00365 }
00366
00367
00368
00369
00370
00371
00372 void nodet::nullnodvali ()
00373 {
00374 long i;
00375 for (i=0;i<ndofn;i++){
00376 nodvali[i]=0.0;
00377 }
00378 }
00379
00380
00381
00382
00383
00384
00385 void nodet::nullnodvalt ()
00386 {
00387 long i;
00388 for (i=0;i<ndofn;i++){
00389 nodvalt[i]=0.0;
00390 }
00391 }
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404 void nodet::storegrad (long lcid,vector &gradv)
00405 {
00406 long i;
00407
00408 ncontr_grad[lcid]++;
00409
00410 for (i=0;i<ncompgrad;i++){
00411 gradient[lcid][i]+=gradv[i];
00412 }
00413 }
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426 void nodet::storegrad (long lcid,double vol,vector &gradv)
00427 {
00428 long i;
00429
00430 vol_grad[lcid]+=vol;
00431
00432 for (i=0;i<ncompgrad;i++){
00433 gradient[lcid][i]+=gradv[i];
00434 }
00435 }
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447 void nodet::storeflux (long lcid,vector &fluxv)
00448 {
00449 long i;
00450
00451 ncontr_flux[lcid]++;
00452
00453 for (i=0;i<ncompgrad;i++){
00454 flux[lcid][i]+=fluxv[i];
00455 }
00456 }
00457
00458
00459
00460
00461
00462
00463
00464
00465
00466
00467
00468 void nodet::storeflux (long lcid,double vol,vector &fluxv)
00469 {
00470 long i;
00471
00472 vol_flux[lcid]+=vol;
00473
00474 for (i=0;i<ncompgrad;i++){
00475 flux[lcid][i]+=fluxv[i];
00476 }
00477 }
00478
00479
00480
00481
00482
00483
00484
00485
00486
00487
00488 void nodet::storeother (long ncomp,double otherv)
00489 {
00490 ncontr_other[ncomp]++;
00491 other[ncomp]+=otherv;
00492 }
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503 void nodet::storeeqother (long ncompeq,double eqotherv)
00504 {
00505 ncontr_eqother[ncompeq]++;
00506 eqother[ncompeq]+=eqotherv;
00507 }
00508
00509
00510
00511
00512
00513
00514
00515 void nodet::grad_averageval ()
00516 {
00517 long i,j;
00518
00519 if (Tp->fluxaver==1){
00520 for (i=0;i<Tp->ntm;i++){
00521 if (ncontr_grad[i]>0){
00522 for (j=0;j<ncompgrad;j++){
00523 gradient[i][j]/=ncontr_grad[i];
00524 }
00525 }
00526 }
00527 }
00528
00529 if (Tp->gradaver==2){
00530 for (i=0;i<Tp->ntm;i++){
00531 if (vol_grad[i]>0){
00532 for (j=0;j<ncompgrad;j++){
00533 gradient[i][j]/=vol_grad[i];
00534 }
00535 }
00536 }
00537 }
00538
00539 }
00540
00541
00542
00543
00544
00545 void nodet::flux_averageval ()
00546 {
00547 long i,j;
00548
00549 if (Tp->fluxaver==1){
00550 for (i=0;i<Tp->ntm;i++){
00551 if (ncontr_flux[i]>0){
00552 for (j=0;j<ncompgrad;j++){
00553 flux[i][j]/=ncontr_flux[i];
00554 }
00555 }
00556 }
00557 }
00558
00559 if (Tp->fluxaver==2){
00560 for (i=0;i<Tp->ntm;i++){
00561 if (vol_flux[i]>0){
00562 for (j=0;j<ncompgrad;j++){
00563 flux[i][j]/=vol_flux[i];
00564 }
00565 }
00566 }
00567 }
00568
00569 }
00570
00571
00572
00573
00574
00575
00576 void nodet::other_averageval ()
00577 {
00578 long i;
00579
00580 if (Tp->otheraver==1){
00581 if (ncontr_other>0){
00582 for (i=0;i<ncompother;i++){
00583 other[i]/=ncontr_other[i];
00584 }
00585 }
00586 }
00587
00588 if (Tp->otheraver==2){
00589 if (vol_other>0){
00590 for (i=0;i<ncompother;i++){
00591 other[i]/=vol_other[i];
00592 }
00593 }
00594 }
00595
00596 }
00597
00598
00599
00600
00601
00602
00603 void nodet::eqother_averageval ()
00604 {
00605 long i;
00606
00607 if (Tp->eqotheraver==1){
00608 if (ncontr_eqother>0){
00609 for (i=0;i<ncompeqother;i++){
00610 eqother[i]/=ncontr_eqother[i];
00611 }
00612 }
00613 }
00614
00615 if (Tp->eqotheraver==2){
00616 if (vol_other>0){
00617 for (i=0;i<ncompeqother;i++){
00618 eqother[i]/=vol_eqother[i];
00619 }
00620 }
00621 }
00622
00623 }
00624
00625
00626
00627
00628
00629
00630
00631
00632
00633 void nodet::give_values (double *in, double *inp, double *ineq)
00634 {
00635 long i;
00636
00637
00638 for (i=0;i<ndofn;i++){
00639 in[i]=nodval[i];
00640 }
00641
00642
00643 for (i=0;i<ndofn;i++){
00644 inp[i]=nodvalp[i];
00645 }
00646
00647
00648
00649
00650 for (i=0;i<5;i++){
00651 ineq[i]=eqother[i];
00652 }
00653 }
00654
00655
00656
00657
00658
00659
00660
00661
00662 void nodet::save_values (double *out)
00663 {
00664 long i;
00665
00666 for (i=0;i<5;i++){
00667 eqother[i]=out[i];
00668 }
00669 }
00670
00671
00672
00673
00674
00675
00676
00677
00678
00679
00680 void nodet::save_nodval (double *nv)
00681 {
00682 long i;
00683
00684 for (i=0;i<ndofn;i++){
00685 nodval[i]=nv[i];
00686 }
00687 }
00688
00689
00690
00691
00692
00693
00694
00695 void nodet::actual_previous_change ()
00696 {
00697 long i;
00698
00699 for (i=0;i<ndofn;i++){
00700 nodvalp[i]=nodval[i];
00701 }
00702 }
00703
00704
00705
00706
00707
00708
00709
00710
00711
00712 void nodet::give_flux (long lcid,double *nv)
00713 {
00714 long i;
00715
00716 for (i=0;i<ndofn;i++){
00717 nv[i]=flux[lcid][i];
00718 }
00719 }
00720