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