00001 #include "globprep.h"
00002 #include "output.h"
00003 #include "element.h"
00004 #include <string.h>
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 long output(FILE *out, descrip *d)
00018 {
00019
00020 long err;
00021
00022 fprintf(stdout, "\nProblem model output :");
00023 Dbmat->renumber_id();
00024 Dbcrs->renumber_id();
00025 fprintf(stdout, "\n writing nodes . . .");
00026 if (Nlay == 0)
00027 err = wr_nodes(out);
00028 else
00029 err = wr_lay_nodes(out);
00030 fflush(out);
00031 if (err)
00032 return(7);
00033 fprintf(stdout, " O.K.");
00034
00035 fprintf(stdout, "\n writing boundary conditions . . .");
00036 err = wr_bocon(out);
00037 fflush(out);
00038 if (err)
00039 return(7);
00040 fprintf(stdout, " O.K.");
00041
00042 fprintf(stdout, "\n writing elements . . .");
00043 if (Nlay == 0)
00044 err = wr_elements(out, d);
00045 else
00046 err = wr_lay_elements(out, d);
00047 fflush(out);
00048 if (err)
00049 return(7);
00050 fprintf(stdout, " O.K.");
00051
00052 if (d->paral)
00053 {
00054 fprintf(stdout, "\n writing global node numbers . . .");
00055 err = wr_globnodnum(out,d);
00056 if (err)
00057 return(7);
00058 fprintf(stdout, " O.K.");
00059 }
00060
00061
00062
00063 fflush(out);
00064 if (err)
00065 return(7);
00066
00067 fprintf(stdout, "\n writing materials . . .");
00068 err = wr_materials(out, d);
00069 fflush(out);
00070 if (err)
00071 return(7);
00072 fprintf(stdout, " O.K.");
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108 fprintf(stdout, "\n writing cross-sections . . .");
00109 err = wr_crsecs(out, d);
00110 fflush(out);
00111 if (err)
00112 return(7);
00113 fprintf(stdout, " O.K.");
00114
00115 fprintf(stdout, "\n writing loads . . .");
00116 err = wr_load(out);
00117 fflush(out);
00118 if (err)
00119 return(7);
00120 fprintf(stdout, " O.K.");
00121
00122 fprintf(stdout, "\n writing eigenstrains . . .");
00123 err = wr_eigenstrains(out);
00124 fflush(out);
00125 if (err)
00126 return(8);
00127 fprintf(stdout, " O.K.");
00128
00129
00130 long i, j;
00131 long tnlc = Nlc;
00132 if (Tnslc)
00133 tnlc = Tnslc;
00134
00135 if (Mstrc)
00136 {
00137 for (i=0; i<tnlc; i++)
00138 {
00139 delete [] Mstrc[i];
00140 }
00141 delete [] Mstrc;
00142 }
00143
00144 for (i=0; i<Top->nn; i++)
00145 {
00146 if (Nod_hang)
00147 delete Nod_hang[i];
00148 delete Nod_bocon[i];
00149 delete [] Nod_ccn[i];
00150 delete [] Nod_lcs[i];
00151 if (Nod_nsprmat[i])
00152 {
00153 delete [] Nod_nsprmat[i];
00154 for (j=0; j< Nod_ndof[i]; j++)
00155 {
00156 if (Nod_sprmattype[i][j])
00157 delete [] Nod_sprmattype[i][j];
00158 if (Nod_sprmatid[i][j])
00159 delete [] Nod_sprmatid[i][j];
00160 if (Nod_sprmatdbi[i][j])
00161 delete [] Nod_sprmatdbi[i][j];
00162 }
00163 delete [] Nod_sprmattype[i];
00164 delete [] Nod_sprmatid[i];
00165 delete [] Nod_sprmatdbi[i];
00166 }
00167
00168 for (j=0; j< tnlc; j++)
00169 {
00170 delete [] Nod_load[i][j];
00171 delete Nod_temper[i][j];
00172 }
00173 for (j=0; j<Nlc; j++)
00174 {
00175 delete [] Nod_tdload[i][j];
00176 delete Nod_inicd[i][j];
00177 }
00178 delete [] Nod_load[i];
00179 delete [] Nod_tdload[i];
00180 delete [] Nod_inicd[i];
00181 delete [] Nod_temper[i];
00182 }
00183 delete [] Nod_hang;
00184 delete [] Nod_ndof;
00185 delete [] Nod_bocon;
00186 delete [] Nod_ccn;
00187 delete [] Nod_cst;
00188 delete [] Nod_csti;
00189 delete [] Nod_cstdbi;
00190 delete [] Nod_nsprmat;
00191 delete [] Nod_sprmattype;
00192 delete [] Nod_sprmatid;
00193 delete [] Nod_sprmatdbi;
00194 delete [] Nod_lcs;
00195 delete [] Nod_load;
00196 delete [] Nod_tdload;
00197 delete [] Nod_inicd;
00198 delete [] Nod_temper;
00199
00200
00201 for (i=0; i<Top->ne; i++)
00202 {
00203 delete [] El_mattype[i];
00204 delete [] El_matid[i];
00205 delete [] El_matdbi[i];
00206 delete [] El_lcs[i];
00207 for (j=0; j<tnlc; j++)
00208 {
00209 delete El_load[i][j];
00210 delete [] El_loadln[i][j];
00211 delete [] El_loadcol[i][j];
00212 }
00213 delete [] El_load[i];
00214 delete [] El_loadln[i];
00215 delete [] El_loadcol[i];
00216 if (El_eigstr)
00217 delete [] El_eigstr[i];
00218 }
00219 delete [] El_type;
00220 delete [] El_ssst;
00221 delete [] El_nmat;
00222 delete [] El_mattype;
00223 delete [] El_matid;
00224 delete [] El_matdbi;
00225 delete [] El_cst;
00226 delete [] El_csti;
00227 delete [] El_cstdbi;
00228 delete [] El_lcs;
00229 delete [] El_load;
00230 delete [] El_loadln;
00231 delete [] El_loadcol;
00232 delete [] El_eigstr;
00233 delete [] El_tfunc;
00234
00235 for (i=0; i<El_eigstrgf_lst.count(); i++)
00236 delete (gfunct *)El_eigstrgf_lst.at(i);
00237
00238
00239 if (Top) delete Top;
00240 if (Dbmat) delete Dbmat;
00241 if (Dbcrs) delete Dbcrs;
00242 if (Nslc) delete [] Nslc;
00243 if (Nslc_cum) delete [] Nslc_cum;
00244 if (Tlt) delete [] Tlt;
00245 if (Npd)
00246 {
00247 for (i=0; i<Tnslc; i++)
00248 delete [] Spd[i];
00249 delete [] Spd;
00250 delete [] Npd;
00251 }
00252 if (Tf) delete [] Tf;
00253
00254 return (0);
00255 }
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271 long wr_nodes(FILE *out)
00272 {
00273 long i, j, k;
00274
00275 fprintf(out, "# sections of nodes\n");
00276
00277 fprintf(out, "%ld\n", Top->nn);
00278 for (i = 0; i < Top->nn; i++)
00279 {
00280
00281 fprintf(out, "%6ld % .10e % .10e % .10e", i+1, Top->nodes[i].x, Top->nodes[i].y, Top->nodes[i].z);
00282 if (Numhn > 0)
00283 {
00284 if (Nod_hang[i])
00285 Nod_hang[i]->print(out);
00286 else
00287 fprintf(out, " %ld", Nod_ndof[i]);
00288 }
00289 else
00290 fprintf(out, " %ld", Nod_ndof[i]);
00291 fprintf(out, " %d", Nod_cst[i]);
00292 if (Nod_cst[i])
00293 fprintf(out, " %ld", Dbcrs->crs[Nod_cstdbi[i]].ridx[Nod_csti[i]-1]);
00294 if (Nod_lcs[i])
00295 {
00296 fprintf(out, " %ld ", Nod_lcs[i][0].n);
00297 for(j=0; j<Nod_lcs[i][0].n; j++)
00298 {
00299 for(k=0; k<Nod_lcs[i][j].n; k++)
00300 fprintf(out, " %le", Nod_lcs[i][j][k]);
00301 fprintf(out, " ");
00302 }
00303 fprintf(out, "\n");
00304 }
00305 else
00306 fprintf(out, " 0\n");
00307 }
00308 fprintf(out, "\n");
00309 return(0);
00310 }
00311
00312
00313
00314
00315
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325 long wr_lay_nodes(FILE *out)
00326 {
00327 long i, j, k, l;
00328
00329
00330 fprintf(out, "# sections of nodes\n");
00331 fprintf(out, "%ld\n", Top->nn*Nlay);
00332 fprintf(out, "%ld\n", Top->nn);
00333 for (i = 0; i < Top->nn; i++)
00334 {
00335 fprintf (out, "%6ld\n%6ld\n", i+1, Nlay);
00336 for (l = 0; l < Nlay; l++)
00337 {
00338
00339 fprintf(out, "%6ld % e % e % e", Nlay*i+l+1, Top->nodes[i].x, Top->nodes[i].y, Top->nodes[i].z);
00340 fprintf(out, " %ld %d", Nod_ndof[i], Nod_cst[i]);
00341 if (Nod_cst[i])
00342 fprintf(out, " %ld", Dbcrs->crs[Nod_cstdbi[i]].ridx[Nod_csti[i]-1]);
00343 if (Nod_lcs[i])
00344 {
00345 fprintf(out, " %ld ", Nod_lcs[i][0].n);
00346 for(j=0; j<Nod_lcs[i][0].n; j++)
00347 {
00348 for(k=0; k<Nod_lcs[i][j].n; k++)
00349 fprintf(out, " %le", Nod_lcs[i][j][k]);
00350 fprintf(out, " ");
00351 }
00352 fprintf(out, "\n");
00353 }
00354 else
00355 fprintf(out, " 0\n");
00356 }
00357 }
00358 fprintf(out, "\n");
00359 return(0);
00360 }
00361
00362
00363
00364
00365
00366
00367
00368
00369
00370
00371
00372
00373
00374
00375 long wr_bocon(FILE *out)
00376 {
00377 long i, j, k, n, nl, nbc, tnlc, ndofn, pdofw;
00378 char emsg[200];
00379
00380 tnlc = Nlc;
00381 if (Tnslc)
00382 tnlc = Tnslc;
00383
00384 nbc = 0;
00385 Nspd = 0;
00386 Ndpd = 0;
00387 nl = Nlay;
00388 if (nl == 0)
00389 nl = 1;
00390 fprintf(out, "# boundary conditions at nodes\n");
00391 for (i = 0; i < Top->nn; i++)
00392 {
00393 if ((Nod_bocon[i]) || (Nod_ccn[i]))
00394
00395 nbc++;
00396 }
00397 fprintf(out, "%ld\n", nbc*nl);
00398 for (i = 0; i < Top->nn; i++)
00399 {
00400 if ((Nod_bocon[i]) || (Nod_ccn[i]))
00401
00402 {
00403 for (n = 0; n < nl; n++)
00404 {
00405 fprintf(out, "%ld", i*nl+n+1);
00406 ndofn = Nod_ndof[i];
00407 for (k = 0; k < ndofn; k++)
00408 {
00409
00410 if (Nod_bocon[i] && Nod_ccn[i])
00411 {
00412 if ((Nod_bocon[i]->dir[k] > 0) && (Nod_ccn[i][k]))
00413 {
00414 sprintf(emsg, "node %ld has prescribed boundary condition and common code number\n"
00415 " in the same direction\n.", i+1);
00416 print_err(emsg, __FILE__, __LINE__, __func__);
00417 return(1);
00418 }
00419 if ((Nod_bocon[i]->dir[k] < 0) && (Nod_ccn[i][k] == 0))
00420
00421 {
00422 fprintf(out, " 1");
00423 continue;
00424 }
00425 }
00426 if (Nod_bocon[i])
00427 {
00428 if (Nod_bocon[i]->dir[k] < 0)
00429
00430 {
00431 if (Nod_ccn[i] == NULL)
00432 fprintf(out, " 1");
00433 continue;
00434 }
00435
00436 pdofw = 0;
00437 for (j=0; j<tnlc; j++)
00438 {
00439 if (Nod_bocon[i]->con[j*ndofn+k] != 0.0)
00440
00441 {
00442 if (Nod_bocon[i]->expr[j*ndofn+k] == NULL)
00443 {
00444 Nspd++;
00445 fprintf(out, " %ld", -Nspd);
00446 pdofw = 1;
00447 break;
00448 }
00449 else
00450 {
00451 Ndpd++;
00452 fprintf(out, " %ld", -Ndpd);
00453 pdofw = 1;
00454 break;
00455 }
00456 }
00457 }
00458 if (pdofw)
00459 continue;
00460
00461 if (Nod_bocon[i]->con[k] == 0.0)
00462
00463 {
00464 fprintf(out, " 0");
00465 continue;
00466 }
00467 }
00468 if (Nod_ccn[i])
00469
00470 {
00471 if (Nod_ccn[i][k])
00472 {
00473 fprintf(out, " %ld", Nod_ccn[i][k]);
00474 continue;
00475 }
00476 else
00477 {
00478 if (Mp->tprob == growing_mech_structure)
00479 fprintf(out, " 0");
00480 else
00481 fprintf(out, " 1");
00482 continue;
00483 }
00484 }
00485 }
00486 fprintf(out, "\n");
00487 }
00488 }
00489 }
00490 fprintf(out, "\n");
00491 return(0);
00492 }
00493
00494
00495
00496
00497
00498
00499
00500
00501
00502
00503
00504
00505
00506
00507
00508 long wr_elements(FILE *out, descrip *d)
00509 {
00510 long i, j, k, l, nspring, eid;
00511 char emsg[200];
00512 elemtype et;
00513
00514
00515 nspring = get_nspring();
00516 fprintf(out, "# section of elements\n");
00517 fprintf(out, "%ld\n", Top->ne+nspring);
00518 for (i = 0; i < Top->ne; i++)
00519 {
00520 switch (El_type[i])
00521 {
00522 case bar2d:
00523 case beam2d:
00524 case bar3d:
00525 case beam3d:
00526 case beamg3d:
00527 case barq2d:
00528 case barq3d:
00529 case subsoilbeam:
00530 case beam2dsp:
00531 {
00532 if (El_cst[i] == 0)
00533 {
00534 sprintf(emsg, "element %ld has not assigned a cross-section", i+1);
00535 print_err(emsg, __FILE__, __LINE__, __func__);
00536 return 1;
00537 }
00538 break;
00539 }
00540 default :
00541 break;
00542 }
00543 if ((Mp->tprob == growing_mech_structure) && (El_tfunc[i] == 0))
00544 {
00545 sprintf(emsg, "element number %ld has not assigned a time function", i+1);
00546 print_err(emsg, __FILE__, __LINE__, __func__);
00547 return(2);
00548 }
00549
00550
00551 et = El_type[i];
00552 fprintf(out, "%6ld ", i+1);
00553 if ((et >= planeelementlt) && (et <= planeelementsubqt))
00554 fprintf(out, "%3d %3d", et, El_ssst[i]);
00555 else
00556 fprintf(out, "%3d", et);
00557
00558
00559 for (j = 0; j < Top->elements[i].nne; j++)
00560 {
00561
00562
00563
00564
00565 fprintf(out, " %6ld", Top->elements[i].nodes[j]+1);
00566 }
00567
00568
00569
00570
00571
00572
00573
00574 fprintf(out, " 0");
00575
00576
00577 if (Mp->tprob == growing_mech_structure)
00578 fprintf(out, " %ld", El_tfunc[i]);
00579
00580 fprintf(out, " %d", El_cst[i]);
00581 if (El_cst[i] > 0)
00582 fprintf(out, " %ld", Dbcrs->crs[El_cstdbi[i]].ridx[El_csti[i]-1]);
00583
00584 fprintf(out, " %ld", El_nmat[i]);
00585 for (l = 0; l < El_nmat[i]; l++)
00586 fprintf(out, " %d %ld", El_mattype[i][l], Dbmat->mat[El_matdbi[i][l]].ridx[El_matid[i][l]-1]);
00587 fprintf(out, "\n");
00588 }
00589 eid = Top->ne+1;
00590
00591 fprintf(out, "# spring elements\n");
00592 for (i=0; i<Top->nn; i++)
00593 {
00594 for (j=0; j<Nod_ndof[i]; j++)
00595 {
00596 if (Nod_nsprmat[i])
00597 {
00598 if (Nod_nsprmat[i][j])
00599 {
00600 fprintf(out, "%6ld %3ld %ld 0 0 %ld", eid, spring_1+j, i+1, Nod_nsprmat[i][j]);
00601 for (k=0; k<Nod_nsprmat[i][j]; k++)
00602 fprintf(out, " %d %ld", Nod_sprmattype[i][j][k], Dbmat->mat[Nod_sprmatdbi[i][j][k]].ridx[Nod_sprmatid[i][j][k]-1]);
00603 fprintf(out, "\n");
00604 eid++;
00605 }
00606 }
00607 }
00608 }
00609 fprintf(out, "\n");
00610 return(0);
00611 }
00612
00613
00614
00615
00616
00617
00618
00619
00620
00621
00622
00623
00624
00625
00626
00627 long wr_lay_elements(FILE *out, descrip *d)
00628 {
00629 long i, j, l, ln;
00630 char emsg[200];
00631 elemtype et;
00632
00633
00634 fprintf(out, "# section of elements\n");
00635 fprintf(out, "%ld\n", Top->ne*Nlay);
00636 for (i = 0; i < Top->ne; i++)
00637 {
00638 switch (El_type[i])
00639 {
00640 case bar2d:
00641 case beam2d:
00642 case bar3d:
00643 case beam3d:
00644 case beamg3d:
00645 case barq2d:
00646 case barq3d:
00647 case subsoilbeam:
00648 case beam2dsp:
00649 {
00650 if (El_cst[i] == 0)
00651 {
00652 sprintf(emsg, "element %ld has not assigned a cross-section", i+1);
00653 print_err(emsg, __FILE__, __LINE__, __func__);
00654 return 1;
00655 }
00656 break;
00657 }
00658 default :
00659 break;
00660 }
00661 if ((Mp->tprob == growing_mech_structure) && (El_tfunc[i] == 0))
00662 {
00663 sprintf(emsg, "element number %ld has not assigned a time function", i+1);
00664 print_err(emsg, __FILE__, __LINE__, __func__);
00665 return(2);
00666 }
00667 for (ln = 0; ln < Nlay; ln++)
00668 {
00669
00670 et = El_type[i];
00671
00672
00673 fprintf(out, "%6ld ", Nlay*i+ln+1);
00674 if ((et >= planeelementlt) && (et <= planeelementsubqt))
00675 fprintf(out, "%3d %3d", et, El_ssst[i]);
00676 else
00677 fprintf(out, "%3d", et);
00678
00679 for (j = 0; j < Top->elements[i].nne; j++)
00680 {
00681
00682
00683
00684
00685 fprintf(out, " %6ld", (Top->elements[i].nodes[j])*Nlay+ln+1);
00686 }
00687
00688
00689
00690
00691
00692
00693
00694 fprintf(out, " 0");
00695
00696 fprintf(out, " %d", El_cst[i]);
00697 if (El_cst[i] > 0)
00698 fprintf(out, " %ld", Dbcrs->crs[El_cstdbi[i]].ridx[El_csti[i]-1]);
00699
00700 fprintf(out, " %ld", El_nmat[i]);
00701 for (l = 0; l < El_nmat[i]; l++)
00702 fprintf(out, " %d %ld", El_mattype[i][l], Dbmat->mat[El_matdbi[i][l]].ridx[El_matid[i][l]-1]);
00703
00704 fprintf(out, "\n");
00705 }
00706 }
00707 fprintf(out, "\n");
00708 return(0);
00709 }
00710
00711
00712
00713
00714
00715
00716
00717
00718
00719
00720
00721
00722 long wr_globnodnum(FILE *out, descrip *d)
00723 {
00724 long i;
00725
00726 fprintf(out, "# definition of global node numbers\n");
00727 if (d->paral==2){
00728
00729 fprintf (out,"%ld %ld\n",Top->meshtype,Top->nsd);
00730 for (i=0;i<Top->nsd;i++){
00731 fprintf (out,"%ld\n",Top->nnsd[i]);
00732 }
00733 }
00734 fprintf (out,"\n");
00735 for (i = 0; i < Top->nn; i++)
00736 fprintf(out, "%ld\n", Top->gnn[i]);
00737 return(0);
00738 }
00739
00740
00741
00742
00743
00744
00745
00746
00747
00748
00749
00750
00751
00752 long wr_materials(FILE *out, descrip *d)
00753 {
00754 long i, j, wrt;
00755
00756 fprintf(out, "# definition of materials\n");
00757 fprintf(out, "%ld\n", Dbmat->nmatu);
00758 for (i = 0; i < Dbmat->numt; i++)
00759 {
00760 wrt = 1;
00761 for (j = 0; j < Dbmat->mat[i].ninst; j++)
00762 {
00763 if (Dbmat->mat[i].instu[j])
00764 {
00765 if (wrt)
00766 {
00767 fprintf(out, "\n%d %ld\n", Dbmat->mat[i].type, Dbmat->mat[i].ninstu);
00768 wrt = 0;
00769 }
00770 if (d->matstr == yes)
00771
00772 fprintf(out, "%ld %s\n", Dbmat->mat[i].ridx[j], Dbmat->mat[i].inst[j]);
00773 else
00774 {
00775
00776 fprintf(out, "%ld ", Dbmat->mat[i].ridx[j]);
00777 Mm->printmatchar(out, Dbmat->mat[i].type, j);
00778 fprintf(out, "\n");
00779 }
00780 }
00781 }
00782 }
00783 fprintf(out, "\n");
00784 return(0);
00785 }
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799 long wr_crsecs(FILE *out, descrip *d)
00800 {
00801 long i, j, wrt;
00802
00803 fprintf(out, "# definition of cross-sections\n");
00804 fprintf(out, "%ld\n", Dbcrs->ncrsu);
00805 for (i = 0; i < Dbcrs->numt; i++)
00806 {
00807 wrt = 1;
00808 for (j = 0; j < Dbcrs->crs[i].ninst; j++)
00809 {
00810 if (Dbcrs->crs[i].instu[j])
00811 {
00812 if (wrt)
00813 {
00814 fprintf(out, "%d %ld\n", Dbcrs->crs[i].type, Dbcrs->crs[i].ninstu);
00815 wrt = 0;
00816 }
00817 if (d->crsstr == yes)
00818
00819 fprintf(out, "%ld %s\n", Dbcrs->crs[i].ridx[j], Dbcrs->crs[i].inst[j]);
00820 else
00821 {
00822
00823 fprintf(out, "%ld ", Dbcrs->crs[i].ridx[j]);
00824 Mc->printcrschar(out, Dbcrs->crs[i].type, j);
00825 fprintf(out, "\n");
00826 }
00827 }
00828 }
00829 }
00830 fprintf(out, "\n");
00831 return(0);
00832 }
00833
00834
00835
00836
00837
00838
00839
00840
00841
00842
00843
00844
00845
00846 long wr_load(FILE *out)
00847 {
00848 long tnlc, i, j;
00849
00850 switch (Mp->tprob)
00851 {
00852 case linear_statics:
00853 case layered_linear_statics:
00854 case lin_floating_subdomain:
00855 {
00856 fprintf(out, "%ld #number of load cases\n\n\n", Nlc);
00857 tnlc = Nlc;
00858 break;
00859 }
00860 case eigen_dynamics:
00861 tnlc = Nlc;
00862 break;
00863 case forced_dynamics:
00864 fprintf(out, "%ld #number of load cases\n\n\n", Nlc/2);
00865 tnlc = Nlc/2;
00866 break;
00867 case mat_nonlinear_statics:
00868 fprintf(out, "%ld #number of load cases\n\n\n", Nlc/2);
00869 tnlc = Nlc;
00870 break;
00871 case growing_mech_structure:
00872 case mech_timedependent_prob:
00873 fprintf(out, "%ld #number of load cases\n\n\n", Nlc);
00874 tnlc = Nlc;
00875 break;
00876 default:
00877 print_err("unknown problem type is required",__FILE__,__LINE__,__func__);
00878 return 1;
00879 }
00880
00881
00882 for (i = 0; i < tnlc; i++)
00883 {
00884 fprintf(out, "#\n# loadcase number %ld\n#\n", i+1);
00885 switch (Mp->tprob)
00886 {
00887 case linear_statics:
00888 case lin_floating_subdomain:
00889 wr_loadn(out, i);
00890 wr_loadel(out, i);
00891 wr_prescdisp(out, i);
00892 wr_tempload(out, i);
00893 if ((Mp->homog == 3) || (Mp->homog == 4))
00894 wr_macrostrastre(out, i);
00895 fflush(out);
00896 break;
00897 case eigen_dynamics:
00898 break;
00899 case mat_nonlinear_statics:
00900 wr_loadn(out, i);
00901 wr_loadel(out, i);
00902 wr_prescdisp(out, i);
00903 wr_tempload(out, i);
00904 if ((Mp->homog == 3) || (Mp->homog == 4))
00905 wr_macrostrastre(out, i);
00906 if (i%2 == 1)
00907 wr_initcond(out, i);
00908 fflush(out);
00909 break;
00910 case forced_dynamics:
00911 wr_loadn(out, 2*i);
00912 wr_loadel(out, 2*i);
00913 wr_prescdisp(out, 2*i);
00914 wr_tempload(out, 2*i);
00915 fprintf(out, "\n");
00916 if (Tnslc == 0)
00917 {
00918 fprintf(out, "\n %d\n", int(Tdload));
00919 wr_dloadn(out, 2*i+1);
00920 wr_dloadel(out, 2*i+1);
00921 wr_dprescdisp(out, 2*i+1);
00922 wr_initcond(out, 2*i+1);
00923 }
00924 else
00925 {
00926
00927 fprintf(out, "\n 1\n");
00928 fprintf (out,"%ld # number of subloadcases\n", Nslc[2*i+1]);
00929 for (j = 0; j < Nslc[2*i+1]; j++)
00930 {
00931 fprintf(out, "# subloadcase number %ld\n#\n", j+1);
00932
00933 wr_loadn(out, Nslc_cum[2*i+1]+j);
00934
00935 wr_loadel(out, Nslc_cum[2*i+1]+j);
00936
00937 wr_prescdisp(out, Nslc_cum[2*i+1]+j);
00938 wr_tempload(out, Nslc_cum[2*i+1]+j);
00939 fprintf(out, "# time function of subloadcase coefficient\n");
00940 Tf[Nslc_cum[2*i+1]+j].print(out);
00941 }
00942 wr_initcond(out, 2*i+1);
00943 }
00944 fflush(out);
00945 break;
00946 case growing_mech_structure:
00947 case mech_timedependent_prob:
00948 {
00949 if (Tnslc > 0)
00950 {
00951
00952 fprintf (out,"\n1 # type of load is usual load cases\n");
00953 fprintf (out,"%ld # number of subloadcases\n", Nslc[i]);
00954 for (j = 0; j < Nslc[i]; j++)
00955 {
00956 fprintf(out, "\n# subloadcase number %ld\n#\n", j+1);
00957
00958 wr_loadn(out, Nslc_cum[i]+j);
00959
00960 wr_loadel(out, Nslc_cum[i]+j);
00961
00962 wr_prescdisp(out, Nslc_cum[i]+j);
00963 wr_tempload(out, Nslc_cum[i]+j);
00964 fprintf(out, "# time function of subloadcase coefficient\n");
00965 Tf[Nslc_cum[i]+j].print(out);
00966 }
00967 }
00968 else
00969 {
00970 fprintf (out,"\n 20\n");
00971
00972 wr_dloadn(out, i);
00973
00974 wr_dloadel(out, i);
00975
00976 wr_dprescdisp(out, i);
00977 }
00978 wr_initcond(out, i);
00979 fflush(out);
00980 break;
00981 }
00982 default:
00983 print_err("unknown problem type is required",__FILE__,__LINE__,__func__);
00984 return 1;
00985 }
00986 }
00987
00988 return(0);
00989 }
00990
00991
00992
00993
00994
00995
00996
00997
00998
00999
01000
01001
01002
01003 long wr_loadn(FILE *out, long nlc)
01004 {
01005 long i, k, n, nl, nln;
01006 nl = Nlay;
01007 if (nl == 0)
01008 nl = 1;
01009 fprintf(out, "# nodal load\n");
01010 for (i = 0, nln = 0; i < Top->nn; i++)
01011
01012 {
01013 if (Nod_load[i])
01014 {
01015 if (Nod_load[i][nlc])
01016 nln++;
01017 }
01018 }
01019 fprintf(out, "%ld\n", nln*nl);
01020 for (i = 0; i < Top->nn; i++)
01021 {
01022 if (Nod_load[i])
01023 {
01024 if (Nod_load[i][nlc])
01025 {
01026 for (n = 0; n < nl; n++)
01027 {
01028
01029 fprintf(out, "%6ld", i*nl+n+1);
01030 for (k = 0; k < Nod_ndof[i]; k++)
01031
01032 fprintf(out, " % e", Nod_load[i][nlc][k]);
01033 fprintf(out, "\n");
01034 }
01035 }
01036 }
01037 }
01038 fprintf(out, "\n");
01039 return(0);
01040 }
01041
01042
01043
01044
01045
01046
01047
01048
01049
01050
01051
01052
01053
01054 long wr_dloadn(FILE *out, long nlc)
01055 {
01056 long i, j, n, nl, nln;
01057 nl = Nlay;
01058 if (nl == 0)
01059 nl = 1;
01060 fprintf(out, "# nodal load\n");
01061 for (i = 0, nln = 0; i < Top->nn; i++)
01062
01063 {
01064 if (Nod_tdload[i])
01065 {
01066 if (((Mp->tprob == forced_dynamics) && (Nod_tdload[i][nlc+1])) ||
01067 ((Mp->tprob == mech_timedependent_prob) && (Nod_tdload[i][nlc])) ||
01068 ((Mp->tprob == growing_mech_structure) && (Nod_tdload[i][nlc])))
01069 {
01070 nln++;
01071 }
01072 }
01073 }
01074 fprintf(out, "%ld\n", nln);
01075 for (i = 0; i < Top->nn; i++)
01076 {
01077 if (Nod_tdload[i])
01078 {
01079 if (((Mp->tprob == forced_dynamics) && (Nod_tdload[i][nlc+1])) ||
01080 ((Mp->tprob == mech_timedependent_prob) && (Nod_tdload[i][nlc])) ||
01081 ((Mp->tprob == growing_mech_structure) && (Nod_tdload[i][nlc])))
01082 {
01083 for (n = 0; n < nl; n++)
01084 {
01085
01086 fprintf(out, "\n%6ld ", i*nl+n+1);
01087 for (j=0; j<Nod_ndof[i]; j++)
01088 {
01089 Nod_tdload[i][nlc][i].print(out);
01090 fprintf(out, "%7c", ' ');
01091 }
01092 }
01093 }
01094 }
01095 }
01096 fprintf(out, "\n\n");
01097 return(0);
01098 }
01099
01100
01101
01102
01103
01104
01105
01106
01107
01108
01109
01110
01111
01112 long wr_loadel(FILE *out, long nlc)
01113 {
01114 fprintf(out, "# load of elements\n");
01115 long i, n, nl, nle;
01116 nl = Nlay;
01117 if (nl == 0)
01118 nl = 1;
01119 for (i = 0, nle = 0; i < Top->ne; i++)
01120 {
01121 if (El_load[i])
01122 {
01123 if(El_load[i][nlc])
01124 {
01125 if ((El_load[i][nlc]->nodvale) ||
01126 (El_load[i][nlc]->nodvals) ||
01127 (El_load[i][nlc]->nodvalv))
01128 nle++;
01129 }
01130 }
01131 }
01132
01133
01134 fprintf(out, "%ld\n", nle*nl);
01135 for (i = 0; i < Top->ne; i++)
01136 {
01137 for (n = 0; n < nl; n++)
01138 {
01139 if (El_load[i])
01140 {
01141 if (El_load[i][nlc])
01142 {
01143
01144 fprintf(out, "%6ld", nl*i+n+1);
01145
01146 El_load[i][nlc]->print(out, 6);
01147 }
01148 }
01149 }
01150 }
01151 fprintf(out, "\n");
01152 return(0);
01153 }
01154
01155
01156
01157
01158
01159
01160
01161
01162
01163
01164
01165
01166
01167
01168 long wr_dloadel(FILE *out, long nlc)
01169 {
01170 return(0);
01171 }
01172
01173
01174
01175
01176
01177
01178
01179
01180
01181
01182
01183
01184
01185
01186
01187 long wr_prescdisp(FILE *out, long nlc)
01188 {
01189 long i, j, ndofn, n;
01190
01191 fprintf(out, "# prescribed displacements\n");
01192 if (Mp->tprob == growing_mech_structure)
01193 {
01194 fprintf(out, "%ld\n", Npd[nlc]);
01195 if (Npd[nlc] == 0)
01196 return(0);
01197 for (i=0; i<Npd[nlc]; i++)
01198 fprintf(out, "% e\n", Spd[nlc][i]);
01199 return(0);
01200 }
01201
01202
01203 fprintf(out, "%ld\n", Nspd);
01204 if (Nspd == 0)
01205 return(0);
01206 n = 0;
01207 for (i = 0; i < Top->nn; i++)
01208 {
01209 if (Nod_bocon[i])
01210
01211 {
01212 ndofn = Nod_ndof[i];
01213 for (j = 0; j < ndofn; j++)
01214
01215
01216 {
01217 if ((Nod_bocon[i]->dir[j] >= 0) && Nod_bocon[i]->nspd[j])
01218 {
01219 fprintf(out, "% e\n", Nod_bocon[i]->con[ndofn*nlc+j]);
01220 n++;
01221 }
01222 }
01223 }
01224 }
01225 if (Nspd != n)
01226 {
01227 print_err("wrong number of prescribed displacements", __FILE__, __LINE__, __func__);
01228 return 1;
01229 }
01230 fprintf(out, "\n");
01231 return(0);
01232 }
01233
01234
01235
01236
01237
01238
01239
01240
01241
01242
01243
01244
01245
01246
01247
01248 long wr_dprescdisp(FILE *out, long nlc)
01249 {
01250 long i, j, n, ndofn;
01251
01252
01253 fprintf(out, "# prescribed displacements\n");
01254 fprintf(out, "%ld\n", Ndpd);
01255 if (Ndpd == 0)
01256 return(0);
01257 n = 0;
01258 for (i = 0; i < Top->nn; i++)
01259 {
01260 if (Nod_bocon[i])
01261
01262 {
01263 ndofn = Nod_ndof[i];
01264 for (j = 0; j < ndofn; j++)
01265
01266
01267 {
01268 if ((Nod_bocon[i]->dir[j] >= 0) && Nod_bocon[i]->ndpd[j])
01269 {
01270 fprintf(out, "% e %s\n", Nod_bocon[i]->con[ndofn*nlc+j], Nod_bocon[i]->expr[ndofn*nlc+j]);
01271 n++;
01272 }
01273 }
01274 }
01275 }
01276 if (Ndpd != n)
01277 {
01278 print_err("wrong number of prescribed displacements", __FILE__, __LINE__, __func__);
01279 return 1;
01280 }
01281 fprintf(out, "\n");
01282 return(0);
01283 }
01284
01285
01286
01287
01288
01289
01290
01291
01292
01293
01294
01295
01296
01297
01298
01299 long wr_tempload(FILE *out, long nlc)
01300 {
01301 long i, prnzero;
01302
01303 fprintf(out, "# temperature load\n");
01304 if (Tlt)
01305 {
01306 fprintf(out, "%ld\n", Tlt[nlc]);
01307 if ((Tlt[nlc] == 1) || (Tlt[nlc] == 2))
01308 {
01309 for (i = 0; i < Top->nn; i++)
01310 {
01311 prnzero = 1;
01312 if (Nod_temper[i][nlc])
01313 {
01314 fprintf(out, "% g\n", Nod_temper[i][nlc]->val);
01315 prnzero = 0;
01316 }
01317 if (prnzero)
01318 fprintf(out, "0.0\n");
01319 }
01320 fprintf(out, "\n");
01321 }
01322 }
01323 else
01324
01325 fprintf(out, "0\n");
01326
01327 return 0L;
01328 }
01329
01330
01331
01332
01333
01334
01335
01336
01337
01338
01339
01340
01341
01342 long wr_macrostrastre(FILE *out, long nlc)
01343 {
01344 long i;
01345
01346 if (Mp->homog == 3)
01347 fprintf(out, "\n# macro stress components\n");
01348 if (Mp->homog == 4)
01349 fprintf(out, "\n# macro strain components\n");
01350 if (Mstrc[nlc])
01351 {
01352 for (i=0; i<Nmstrc; i++)
01353 fprintf(out, "%le ", Mstrc[nlc][i]);
01354 }
01355 else
01356 {
01357 for (i=0; i<Nmstrc; i++)
01358 fprintf(out, "%le ", 0.0);
01359 }
01360 fprintf(out, "\n");
01361
01362 return (0);
01363 }
01364
01365
01366
01367
01368
01369
01370
01371
01372
01373
01374
01375
01376
01377
01378 long wr_initcond(FILE *out, long nlc)
01379 {
01380 long i, j;
01381
01382 fprintf(out, "# initial conditions\n");
01383 if (Nod_inicd[0][nlc])
01384 {
01385 fprintf(out, "%ld\n", Top->nn);
01386 for (i = 0; i < Top->nn; i++)
01387 {
01388 if (Nod_inicd[i][nlc])
01389 {
01390
01391 fprintf(out, "%6ld ", i+1);
01392 if (Mp->tprob == forced_dynamics)
01393 {
01394
01395 if (Nod_inicd[i][nlc]->type & inidisp)
01396 {
01397 for(j=0; j<Nod_ndof[i]; j++)
01398 fprintf(out, " %e",Nod_inicd[i][nlc]->val[j]);
01399 fprintf(out, "\n");
01400 }
01401 }
01402 else
01403 Nod_inicd[i][nlc]->print(out);
01404 }
01405 }
01406 fprintf(out, "\n");
01407 }
01408 else
01409 fprintf(out, "0\n\n");
01410 return(0);
01411 }
01412
01413
01414
01415
01416
01417
01418
01419
01420
01421
01422
01423
01424 long wr_eigenstrains(FILE *out)
01425 {
01426 long i, j, add_nullgf;
01427 gfunct *tmp;
01428
01429
01430 fprintf(out, "\n#eigenstrains\n");
01431 if (El_eigstr == NULL)
01432 {
01433 fprintf(out, "0\n");
01434 return 0;
01435 }
01436 else
01437 {
01438 fprintf(out, "2\n");
01439 add_nullgf = 0;
01440 for (i=0; i<Top->ne; i++)
01441 {
01442 for (j=0; j<Mt->give_tncomp(i); j++)
01443 {
01444 if (El_eigstr[i])
01445 fprintf(out, "%ld ", El_eigstr[i][j]+1);
01446 else
01447 {
01448 fprintf(out, "%ld ", El_eigstrgf_lst.count()+1);
01449 add_nullgf = 1;
01450 }
01451 }
01452 fprintf(out,"\n");
01453 }
01454
01455
01456 if (add_nullgf)
01457 fprintf(out, "\n#eigenstrain functions\n\n%ld #number of eigenstrains functions\n", El_eigstrgf_lst.count()+1);
01458 else
01459 fprintf(out, "\n#eigenstrain functions\n\n%ld #number of eigenstrains functions\n", El_eigstrgf_lst.count());
01460 for (i=0; i<El_eigstrgf_lst.count(); i++)
01461 {
01462 fprintf(out, "# %ld. time function for eigenstrain\n", i+1);
01463 tmp = (gfunct *)El_eigstrgf_lst.at(i);
01464 tmp->print(out);
01465 }
01466 if (add_nullgf)
01467 {
01468 fprintf(out, "# %ld. time function for eigenstrain - null time function\n", i+1);
01469 fprintf(out, "0 0.0\n");
01470 }
01471 }
01472 return 0;
01473 }
01474
01475
01476
01477
01478
01479
01480
01481
01482
01483
01484 long get_nspring()
01485 {
01486 long i, j, ret;
01487
01488 ret = 0;
01489 for(i=0; i<Top->nn; i++)
01490 {
01491 for(j=0; j<Nod_ndof[i]; j++)
01492 {
01493 if (Nod_nsprmat[i])
01494 {
01495 if (Nod_nsprmat[i][j])
01496 ret++;
01497 }
01498 }
01499 }
01500 return ret;
01501 }
01502
01503
01504
01505
01506
01507
01508
01509
01510
01511
01512
01513
01514 long get_nspd(long nlc)
01515 {
01516 long nspd = 0;
01517 long i, k, ndofn;
01518
01519 for (i = 0; i < Top->nn; i++)
01520 {
01521 if (Nod_bocon[i])
01522
01523 {
01524 ndofn = Nod_ndof[i];
01525 for (k = 0; k < ndofn; k++)
01526 {
01527 if (Nod_bocon[i]->dir[k] < 0)
01528
01529 continue;
01530 if (Nod_bocon[i]->con[ndofn*nlc+k] != 0.0)
01531
01532 {
01533 if (Nod_bocon[i]->expr[ndofn*nlc+k] == NULL)
01534
01535 nspd++;
01536 }
01537 }
01538 }
01539 }
01540 return nspd;
01541 }
01542
01543
01544
01545
01546
01547
01548
01549
01550
01551
01552
01553
01554 long get_ndpd(long nlc)
01555 {
01556 long ndpd = 0;
01557 long i, k, ndofn;
01558
01559 for (i = 0; i < Top->nn; i++)
01560 {
01561 if (Nod_bocon[i])
01562
01563 {
01564 ndofn = Nod_ndof[i];
01565 for (k = 0; k < ndofn; k++)
01566 {
01567 if (Nod_bocon[i]->dir[k] < 0)
01568
01569 continue;
01570 if (Nod_bocon[i]->con[ndofn*nlc+k] != 0.0)
01571
01572 {
01573 if (Nod_bocon[i]->expr[ndofn*nlc+k])
01574
01575 ndpd++;
01576 }
01577 }
01578 }
01579 }
01580 return ndpd;
01581 }