00001 #include <string.h>
00002 #include "iotools.h"
00003 #include "kwdset.h"
00004 #include "vector.h"
00005 #include "siftop.h"
00006 #include "gfunct.h"
00007 #include "aliast.h"
00008 #include "globalt.h"
00009
00010 #include "globprept.h"
00011 #include "prepalias.h"
00012 #include "inputt.h"
00013 #include "bocont.h"
00014 #include "dbcrst.h"
00015 #include "dbmatt.h"
00016 #include "entitybocon.h"
00017 #include "aggregator.h"
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 long inputt(XFILE *in, descript *d)
00038 {
00039 long err;
00040 XFILE *itop;
00041
00042
00043 err = input_lct(in);
00044 if (err)
00045 return(2);
00046
00047
00048 itop = xfopen(d->topf, "rt");
00049 if (itop == NULL)
00050 return(3);
00051 itop->warning = 1;
00052 itop->kwdmode = ignore;
00053
00054 itop->ignorecase = 1;
00055
00056
00057 if (Tp->ssle->prec.pt==boss){
00058
00059 if (Tp->ssle->prec.agg->impl==2){
00060
00061 d->paral=2;
00062 }
00063 }
00064
00065 if (Tp->ssle->tlinsol==sfeti){
00066
00067 d->paral=2;
00068 }
00069
00070
00071 err = input_siftopt(itop, d);
00072 xfclose(itop);
00073 if (err)
00074 return(3);
00075
00076
00077
00078
00079
00080
00081
00082 if (d->matsec == no)
00083 err = input_materialst(d->matf, d);
00084 else
00085 err = input_materialst(in, d);
00086 if (err)
00087 return(4);
00088
00089
00090 if (d->crssec == no)
00091 err = input_crst(d->crf, d);
00092 else
00093 err = input_crst(in, d);
00094 if (err)
00095 return(5);
00096
00097
00098 input_lct(in);
00099
00100
00101 err = input_nodpropt(in);
00102 switch (err)
00103 {
00104 case 0 :
00105 break;
00106 case 1 :
00107 print_err("reading of nodal boundary conditions failed", __FILE__, __LINE__, __func__);
00108 return(6);
00109 case 2 :
00110 print_err("reading of coupled dofs at nodes failed", __FILE__, __LINE__, __func__);
00111 return(6);
00112 case 3 :
00113 print_err("reading of dof time functions at nodes failed", __FILE__, __LINE__, __func__);
00114 return(6);
00115 case 4 :
00116 print_err("reading of cross-sections at nodes failed", __FILE__, __LINE__, __func__);
00117 return(6);
00118 case 5 :
00119 print_err("reading of nodal initial conditions failed", __FILE__, __LINE__, __func__);
00120 return(6);
00121 default :
00122 print_err("unknown error code in nodal sections", __FILE__, __LINE__, __func__);
00123 return(6);
00124 }
00125
00126 err = input_elempropt(in);
00127 switch (err)
00128 {
00129 case 0 :
00130 break;
00131 case 1 :
00132 print_err("reading of element types failed", __FILE__, __LINE__, __func__);
00133 return(7);
00134 case 2 :
00135 print_err("reading of element material types failed", __FILE__, __LINE__, __func__);
00136 return(7);
00137 case 3 :
00138 print_err("reading of element cross-section failed", __FILE__, __LINE__, __func__);
00139 return(7);
00140 case 4 :
00141 print_err("reading of element vertex boundary condition record failed", __FILE__, __LINE__, __func__);
00142 return(7);
00143 case 5 :
00144 print_err("reading of element edge boundary condition record failed", __FILE__, __LINE__, __func__);
00145 return(7);
00146 case 6 :
00147 print_err("reading of element surface boundary condition record failed", __FILE__, __LINE__, __func__);
00148 return(7);
00149 case 7 :
00150 print_err("reading of time functions for elements failed", __FILE__, __LINE__, __func__);
00151 return(7);
00152 default :
00153 print_err("unknown error code in element sections", __FILE__, __LINE__, __func__);
00154 return(7);
00155 }
00156 return(0);
00157 }
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167
00168
00169
00170
00171
00172
00173 long input_filest(XFILE *in, descript &d)
00174 {
00175
00176 xfscanf(in, " %a", d.topf);
00177
00178 xfscanf(in, " %a", d.matf);
00179
00180 xfscanf(in, " %a", d.crf);
00181
00182 xfscanf(in, "%k%m", "mesh_format", &meshform_kwdset, &d.meshfmt);
00183
00184 xfscanf(in, "%k%ld", "edge_numbering", &d.redgn);
00185
00186
00187
00188 d.inicdf = no;
00189 xfscanf(in, "%+k %m", "inicd_file", &answertype_kwdset, &d.inicdf);
00190 if (d.inicdf == yes)
00191
00192 xfscanf(in, " %a", d.icf);
00193
00194
00195 d.matstr = yes;
00196 xfscanf(in, "%+k %m", "read_mat_strings", &answertype_kwdset, &d.matstr);
00197 if (d.matstr == no)
00198 xfscanf(in, "%k %m", "read_mat_kwd", &answertype_kwdset, &d.matkwd);
00199 else
00200 d.matkwd = no;
00201
00202
00203 d.crsstr = yes;
00204 xfscanf(in, "%+k %m", "read_crs_strings", &answertype_kwdset, &d.crsstr);
00205 if (d.crsstr == no)
00206 xfscanf(in, "%k %m", "read_crs_kwd", &answertype_kwdset, &d.crskwd);
00207 else
00208 d.crskwd = no;
00209
00210 return 0;
00211 }
00212
00213
00214
00215
00216
00217
00218
00219
00220
00221
00222
00223
00224
00225 long input_lct(XFILE *in)
00226 {
00227
00228 if ((Tp->tprob == growing_np_problem) || (Tp->tprob == growing_np_problem_nonlin))
00229 {
00230 fprintf(stdout, "\n\nReading of section with time functions . . .");
00231 xf_setsec(in, bsec_str[begsec_loadcase]);
00232 in->kwdmode = sect_mode_full;
00233 xfscanf(in, "%k", "time_functions");
00234 in->kwdmode = sequent_mode;
00235 Gtt->read_gf (in);
00236 }
00237 return 0;
00238 }
00239
00240
00241
00242
00243
00244
00245
00246
00247
00248
00249
00250
00251
00252
00253
00254
00255
00256
00257
00258
00259
00260 long input_siftopt(XFILE *in, descript *d)
00261 {
00262 long ret;
00263
00264 fprintf(stdout, "\n\nReading of mesh topology . . .");
00265 switch (d->meshfmt)
00266 {
00267 case t3d:
00268 Top->import_t3d(in, d->paral);
00269 break;
00270 case sifel:
00271 ret = Top->read(in, d->paral, d->redgn);
00272 return(ret);
00273 default:
00274 print_err("unknown mesh format is required", __FILE__, __LINE__, __func__);
00275 return(4);
00276 }
00277 return(0);
00278 }
00279
00280
00281
00282
00283
00284
00285
00286
00287
00288
00289
00290
00291
00292
00293
00294
00295 long input_materialst(char *fname, descript *d)
00296 {
00297 long ret;
00298 long mpb = Mesprt;
00299 XFILE *in = NULL;
00300
00301 fprintf(stdout, "\n\nReading of material database form %s . . .", fname);
00302 in = xfopen(fname, "rt");
00303 if (in == NULL)
00304 return(1);
00305
00306 in->warning = 1;
00307 in->kwdmode = sequent_mode;
00308 in->ignorecase = 1;
00309 Dbmatt = new dbmatt;
00310 if (d->matstr == yes)
00311
00312 ret = Dbmatt->read(in);
00313 else
00314 {
00315
00316 Mesprt = 0;
00317 ret = Dbmatt->readtm(in, Tm, d);
00318 Mesprt = mpb;
00319 }
00320
00321 xfclose(in);
00322 if (ret)
00323 return(2);
00324
00325 return(0);
00326 }
00327
00328
00329
00330
00331
00332
00333
00334
00335
00336
00337
00338
00339
00340
00341
00342
00343 long input_materialst(XFILE *in, descript *d)
00344 {
00345 long ret;
00346 long mpb = Mesprt;
00347
00348 fprintf(stdout, "\n\nReading of material database . . .");
00349 if (xf_setsec(in, bsec_str[begsec_mater]))
00350 return(1);
00351
00352 in->warning = 1;
00353 in->ignorecase = 1;
00354 in->kwdmode = sect_mode_seq;
00355 Dbmatt = new dbmatt;
00356 if (d->matstr == yes)
00357
00358 ret = Dbmatt->read(in);
00359 else
00360 {
00361
00362 Mesprt = 0;
00363 Dbmatt->readtm(in, Tm, d);
00364 Mesprt = mpb;
00365 }
00366 xfclose(in);
00367 if (ret)
00368 return(2);
00369
00370 return(0);
00371 }
00372
00373
00374
00375
00376
00377
00378
00379
00380
00381
00382
00383
00384
00385
00386
00387 long input_crst(char *fname, descript *d)
00388 {
00389 long ret;
00390 long mpb = Mesprt;
00391 XFILE *in = NULL;
00392
00393 fprintf(stdout, "\n\nReading of cross-section database from %s . . .", fname);
00394 in = xfopen(fname, "rt");
00395 if (in == NULL)
00396 return(1);
00397
00398 in->warning = 1;
00399 in->ignorecase = 1;
00400 in->kwdmode = sequent_mode;
00401 Dbcrst = new dbcrst;
00402 if (d->crsstr == yes)
00403
00404 ret = Dbcrst->read(in);
00405 else
00406 {
00407
00408 Mesprt = 0;
00409 ret = Dbcrst->readtc(in, Tc, d);
00410 Mesprt = mpb;
00411 }
00412 xfclose(in);
00413 if (ret)
00414 return(2);
00415
00416 return(0);
00417 }
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430
00431
00432
00433
00434 long input_crst(XFILE *in, descript *d)
00435 {
00436 long ret;
00437 long mpb = Mesprt;
00438
00439 fprintf(stdout, "\n\nReading of cross-section database . . .");
00440 if (xf_setsec(in, bsec_str[begsec_crsec]))
00441 return(1);
00442
00443 in->warning = 1;
00444 in->kwdmode = sect_mode_seq;
00445 in->ignorecase = 1;
00446 Dbcrst = new dbcrst;
00447 if (d->crsstr == yes)
00448
00449 ret = Dbcrst->read(in);
00450 else
00451 {
00452
00453 Mesprt = 0;
00454 Dbcrst->readtc(in, Tc, d);
00455 Mesprt = mpb;
00456 }
00457 xfclose(in);
00458 if (ret)
00459 return(2);
00460
00461 return(0);
00462 }
00463
00464
00465
00466
00467
00468
00469
00470
00471
00472
00473
00474
00475
00476
00477
00478
00479
00480 long input_nodpropt(XFILE *in)
00481 {
00482 long err;
00483 const enumstr nodsects[] = {{"begsec_nodvertpr",3}, {"begsec_nodedgpr",4},
00484 {"begsec_nodsurfpr", 5}, {"begsec_nodvolpr",6}};
00485 long nsect = sizeof(nodsects)/sizeof(*nodsects);
00486
00487 Nod_ccn = NULL;
00488
00489 fprintf(stdout, "\n\nReading of nodal properties . . .");
00490 in->kwdmode = sequent_mode;
00491
00492
00493 err = input_nod_bocont(in, nodsects, nsect);
00494 if (err)
00495 return 1;
00496
00497 err = input_nod_coupl_dofst(in, nodsects, nsect);
00498 if (err)
00499 return 2;
00500
00501 err = input_nod_dof_tfunct(in, nodsects, nsect);
00502 if (err)
00503 return 3;
00504
00505 err = input_nod_crsect(in, nodsects, nsect);
00506 if (err)
00507 return 4;
00508
00509 err = input_nod_initcondt(in, nodsects, nsect);
00510 if (err)
00511 return 5;
00512 return 0;
00513 }
00514
00515
00516
00517
00518
00519
00520
00521
00522
00523
00524
00525
00526
00527
00528
00529
00530
00531
00532
00533 long input_elempropt(XFILE *in)
00534 {
00535 long err;
00536
00537
00538 const enumstr elemsects[] = {{bsec_str[begsec_elvertpr].alias, bsec_str[begsec_elvertpr].id},
00539 {bsec_str[begsec_eledgpr].alias, bsec_str[begsec_eledgpr].id},
00540 {bsec_str[begsec_elsurfpr].alias, bsec_str[begsec_elsurfpr].id},
00541 {bsec_str[begsec_elvolpr].alias, bsec_str[begsec_elvolpr].id}};
00542 long nsect = sizeof(elemsects)/sizeof(*elemsects);
00543
00544
00545 const enumstr vertsect[] = {{bsec_str[begsec_elvertpr].alias, bsec_str[begsec_elvertpr].id}};
00546 long nvertsect = sizeof(vertsect)/sizeof(*vertsect);
00547
00548
00549 const enumstr edgesect[] = {{bsec_str[begsec_eledgpr].alias, bsec_str[begsec_eledgpr].id}};
00550 long nedgesect = sizeof(edgesect)/sizeof(*edgesect);
00551
00552
00553 const enumstr surfsect[] = {{bsec_str[begsec_elsurfpr].alias, bsec_str[begsec_elsurfpr].id}};
00554 long nsurfsect = sizeof(surfsect)/sizeof(*surfsect);
00555
00556 El_loadt = NULL;
00557 fprintf(stdout, "\n\nReading of element properties . . .");
00558 in->kwdmode = sequent_mode;
00559
00560 err = input_elem_typet(in, elemsects, nsect);
00561 if (err)
00562 return 1;
00563
00564 err = input_elem_matt(in, elemsects, nsect);
00565 if (err)
00566 return 2;
00567
00568 err = input_elem_crsect(in, elemsects, nsect);
00569 if (err)
00570 return 3;
00571
00572 err = input_elem_vertbc(in, vertsect, nvertsect);
00573 if (err)
00574 return 4;
00575
00576 err = input_elem_edgebc(in, edgesect, nedgesect);
00577 if (err)
00578 return 5;
00579
00580 err = input_elem_surfbc(in, surfsect, nsurfsect);
00581 if (err)
00582 return 6;
00583
00584 err = input_elem_eltimefunct(in, elemsects, nsect);
00585 if (err)
00586 return 7;
00587
00588 return 0;
00589 }
00590
00591
00592
00593
00594
00595
00596
00597
00598
00599
00600
00601
00602
00603
00604
00605
00606
00607
00608
00609
00610
00611
00612
00613
00614
00615
00616 long input_nod_bocont(XFILE *in, const enumstr nodsects[], long nsect)
00617 {
00618 char *aptr;
00619 long nkwd;
00620 char errmsg[1001];
00621 long *line;
00622 long *col;
00623 long aline, acol;
00624 gentity ent;
00625 kwd_handling bkwdmode;
00626 long *setnodes;
00627 bocont *tbc;
00628 bocont *aux;
00629 long i, j, k, lcid, bcid;
00630 long prop, ndof, nnp;
00631 long errcode;
00632
00633
00634 ndof = Tp->ntm;
00635 Nod_bocon = new long*[Top->nn];
00636 memset(Nod_bocon, 0, sizeof(*Nod_bocon)*Top->nn);
00637 setnodes = new long[Top->nn];
00638 memset(setnodes, 0, sizeof(*setnodes)*Top->nn);
00639 line = new long[Top->nn];
00640 memset(line, 0, sizeof(*line)*Top->nn);
00641 col = new long[Top->nn];
00642 memset(col, 0, sizeof(*col)*Top->nn);
00643
00644 bkwdmode = in->kwdmode;
00645 in->ignorecase = 1;
00646
00647 fprintf(stdout, "\n reading of nodal boundary conditions");
00648 for (i=nsect-1, ent=gregion; i>=0; i--, ent--)
00649 {
00650
00651 if (xf_setsec(in, nodsects[i]) == 1)
00652 continue;
00653
00654 in->kwdmode = sect_mode_full;
00655 nkwd = getkwd_sect(in, NULL, aptr, "bocon", 1);
00656 if (nkwd && ((Tp->tprob == growing_np_problem) || (Tp->tprob == growing_np_problem_nonlin)))
00657 {
00658 sprintf(errmsg, "Problem type 'growing_np_problem|(_nonlin)' is required.\n"
00659 " Nodal dofs have to be controlled by time functions.\n"
00660 " Use 'nod_tfunc' preprocessor keyword for dof control.\n"
00661 " Invalid keyword 'bocon' found at line %ld, column %ld, file %s",
00662 in->line, in->col, in->fname);
00663 print_err(errmsg, __FILE__, __LINE__, __func__);
00664 delete [] setnodes;
00665 delete [] line;
00666 delete [] col;
00667 return 4;
00668 }
00669 in->kwdmode = bkwdmode;
00670
00671 for(j=0; j < nkwd; j++)
00672 {
00673
00674 in->kwdmode = sect_mode_fwd;
00675 getkwd_sect(in, NULL, aptr, "bocon", 0);
00676 in->kwdmode = bkwdmode;
00677
00678 aline = in->line;
00679 acol = in->col;
00680 in->kwdmode = sect_mode_seq;
00681
00682 xfscanf(in, "%k%k%ld", "bocon", "propid", &prop);
00683
00684
00685 nnp = Top->get_propent_nodes(prop, ent, setnodes);
00686 if (nnp == 0)
00687 {
00688 if (Check_unused_prop == 0)
00689
00690 continue;
00691 sprintf(errmsg, "Nodes with property %ld belonging to entity %s have not been found.\n"
00692 " Boundary condition (line %ld, column %ld, file %s) cannot be assigned correctly.",
00693 prop, entitypstr[ent-1].alias, aline, acol, in->fname);
00694 print_err(errmsg, __FILE__, __LINE__, __func__);
00695 delete [] setnodes;
00696 delete [] line;
00697 delete [] col;
00698 return 5;
00699 }
00700
00701 tbc = new bocont;
00702 errcode = tbc->read(in, ndof);
00703 if (errcode)
00704 {
00705 if (errcode < 3)
00706 {
00707 sprintf(errmsg, "Boundary condition or load case id is invalid\n"
00708 " in file %s, line %ld, col %ld", in->fname, aline, acol);
00709 }
00710 else
00711 sprintf(errmsg, "Expression for boundary condition could not be parsed\n"
00712 " in file %s, line %ld, col %ld", in->fname, aline, acol);
00713 print_err(errmsg, __FILE__, __LINE__, __func__);
00714 delete [] setnodes;
00715 delete tbc;
00716 delete [] line;
00717 delete [] col;
00718 return 2;
00719 }
00720
00721 in->kwdmode = bkwdmode;
00722
00723 lcid = tbc->lcid;
00724 bcid = 0;
00725
00726 for (k=0; k<Top->nn; k++)
00727 {
00728 if (setnodes[k] < 0)
00729 continue;
00730 if (Nod_bocon[k])
00731 {
00732 if (Nod_bocon[k][lcid])
00733 {
00734 aux = (bocont *)(Nod_bclst.at(Nod_bocon[k][lcid]-1));
00735 if (tbc->compare(*aux))
00736 {
00737 sprintf(errmsg, "Conflict in merging of boundary condition at line %ld, col %ld\n"
00738 "with previous boundary condition at line %ld, col %ld in file %s", aline, acol, line[k], col[k], in->fname);
00739 print_err(errmsg, __FILE__, __LINE__, __func__);
00740 delete [] setnodes;
00741 delete tbc;
00742 delete [] line;
00743 delete [] col;
00744 return 3;
00745 }
00746 else
00747 fprintf(Log, "Line %ld, col %ld, file %s: Node %ld has already had assigned boundary condition at line %ld, col %ld, file: %s\n",
00748 aline, acol, in->fname, k+1, line[k], col[k], in->fname);
00749 }
00750 else
00751 {
00752 if (bcid == 0)
00753 {
00754 Nod_bclst.append(tbc);
00755 bcid = Nod_bclst.count();
00756 }
00757 Nod_bocon[k][lcid] = bcid;
00758
00759 line[k] = aline;
00760 col[k] = acol;
00761 }
00762 }
00763 else
00764 {
00765 Nod_bocon[k] = new long[ndof];
00766 memset(Nod_bocon[k], 0, sizeof(Nod_bocon[k])*ndof);
00767 if (bcid == 0)
00768 {
00769 Nod_bclst.append(tbc);
00770 bcid = Nod_bclst.count();
00771 }
00772 Nod_bocon[k][lcid] = bcid;
00773
00774 line[k] = aline;
00775 col[k] = acol;
00776 }
00777 }
00778 }
00779 }
00780 delete [] setnodes;
00781 delete [] line;
00782 delete [] col;
00783 return 0;
00784 }
00785
00786
00787
00788
00789
00790
00791
00792
00793
00794
00795
00796
00797
00798
00799
00800
00801
00802
00803
00804
00805
00806
00807
00808
00809
00810
00811
00812
00813 long input_nod_coupl_dofst(XFILE *in, const enumstr nodsects[], long nsect)
00814 {
00815 char *aptr;
00816 long nkwd;
00817 char errmsg[1001];
00818 long *line;
00819 long *col;
00820 long aline, acol;
00821 gentity ent;
00822 kwd_handling bkwdmode;
00823 long *setnodes;
00824 long i, j, k, l;
00825 long prop, ndof, lcid, nnp, nbc;
00826 long ccn, accn;
00827
00828 Nod_ccn = NULL;
00829 setnodes = new long[Top->nn];
00830 memset(setnodes, 0, sizeof(*setnodes)*Top->nn);
00831 line = new long[Top->nn];
00832 memset(line, 0, sizeof(*line)*Top->nn);
00833 col = new long[Top->nn];
00834 memset(col, 0, sizeof(*col)*Top->nn);
00835 ccn = accn = 0;
00836
00837 ndof = Tp->ntm;
00838
00839 bkwdmode = in->kwdmode;
00840 in->ignorecase = 1;
00841 fprintf(stdout, "\n reading of coupled dofs at nodes");
00842
00843 for (i=nsect-1, ent=gregion; i>=0; i--, ent--)
00844 {
00845
00846 if (xf_setsec(in, nodsects[i]) == 1)
00847 continue;
00848
00849 in->kwdmode = sect_mode_full;
00850 nkwd = getkwd_sect(in, NULL, aptr, "dof_coupl", 1);
00851 if (nkwd && ((Tp->tprob == growing_np_problem) || (Tp->tprob == growing_np_problem_nonlin)))
00852 {
00853 sprintf(errmsg, "Problem type 'growing_np_problem|(_nonlin)' is required.\n"
00854 " Nodal dofs have to be controlled by time functions.\n"
00855 " Use 'nod_tfunc' preprocessor keyword for dof control.\n"
00856 " Invalid keyword 'dof_coupl' found at line %ld, column %ld, file %s",
00857 in->line, in->col, in->fname);
00858 print_err(errmsg, __FILE__, __LINE__, __func__);
00859 delete [] setnodes;
00860 delete [] line;
00861 delete [] col;
00862 return 4;
00863 }
00864 if (Nod_ccn == NULL)
00865 {
00866 Nod_ccn = new long*[Top->nn];
00867 memset(Nod_ccn, 0, sizeof(*Nod_ccn)*Top->nn);
00868 }
00869 in->kwdmode = bkwdmode;
00870
00871 for(j=0; j < nkwd; j++)
00872 {
00873
00874 in->kwdmode = sect_mode_fwd;
00875 getkwd_sect(in, NULL, aptr, "dof_coupl", 0);
00876 in->kwdmode = bkwdmode;
00877
00878 aline = in->line;
00879 acol = in->col;
00880 in->kwdmode = sect_mode_seq;
00881
00882 xfscanf(in, "%k%k%ld", "dof_coupl", "propid", &prop);
00883
00884 nnp = Top->get_propent_nodes(prop, ent, setnodes);
00885 if (nnp == 0)
00886 {
00887 if (Check_unused_prop == 0)
00888
00889 continue;
00890 sprintf(errmsg, "Nodes with property %ld belonging to entity %s have not been found.\n"
00891 " Coupled dofs (line %ld, column %ld, file %s) cannot be assigned correctly.",
00892 prop, entitypstr[ent-1].alias, aline, acol, in->fname);
00893 print_err(errmsg, __FILE__, __LINE__, __func__);
00894 delete [] setnodes;
00895 delete [] line;
00896 delete [] col;
00897 return 5;
00898 }
00899 xfscanf(in, "%k%ld", "nbc", &nbc);
00900 if ((nbc < 1) || (nbc > ndof))
00901 {
00902 sprintf(errmsg, "Nodes with property %ld belonging to entity %s\n"
00903 " have number of coupled dofs out of range <1,%ld>"
00904 " (line %ld, column %ld, file %s)",
00905 prop, entitypstr[ent-1].alias, ndof, aline, acol, in->fname);
00906 print_err(errmsg, __FILE__, __LINE__, __func__);
00907 delete [] setnodes;
00908 delete [] line;
00909 delete [] col;
00910 return 2;
00911 }
00912 for (k = 0; k < nbc; k++)
00913 {
00914 xfscanf(in, "%k%ld", "lc_id", &lcid);
00915 if ((lcid < 1) || (lcid > ndof))
00916 {
00917 sprintf(errmsg, "Nodes with property %ld belonging to entity %s\n"
00918 " have coupled dof number out of range <1,%ld>"
00919 " (line %ld, column %ld, file %s)",
00920 prop, entitypstr[ent-1].alias, ndof, aline, acol, in->fname);
00921 print_err(errmsg, __FILE__, __LINE__, __func__);
00922 delete [] setnodes;
00923 delete [] line;
00924 delete [] col;
00925 return 3;
00926 }
00927 ccn++;
00928 accn = ccn;
00929
00930 for (l=0; l<Top->nn; l++)
00931 {
00932
00933 if (setnodes[l] < 0)
00934 continue;
00935 if (Nod_ccn[l] == NULL)
00936 continue;
00937 if (Nod_ccn[l][lcid-1] != 0)
00938 {
00939 accn = Nod_ccn[l][lcid-1];
00940 ccn--;
00941 fprintf(Log, "Line %ld, col %ld, file %s: Node %ld has already had coupled dofs at line %ld, col %ld, file: %s\n", aline, acol, in->fname, l+1, line[l], col[l], in->fname);
00942 break;
00943 }
00944 }
00945 for (l=0; l<Top->nn; l++)
00946 {
00947 if (setnodes[l] < 0)
00948 continue;
00949 if (Nod_ccn[l] == NULL)
00950 {
00951 Nod_ccn[l] = new long[ndof];
00952 memset(Nod_ccn[l], 0, sizeof(*Nod_ccn[l])*ndof);
00953
00954 line[l] = aline;
00955 col[l] = acol;
00956 }
00957 Nod_ccn[l][lcid-1] = accn;
00958 }
00959 }
00960 in->kwdmode = bkwdmode;
00961 }
00962 }
00963 delete [] setnodes;
00964 delete [] line;
00965 delete [] col;
00966 return 0;
00967 }
00968
00969
00970
00971
00972
00973
00974
00975
00976
00977
00978
00979
00980
00981
00982
00983
00984
00985
00986
00987
00988
00989
00990
00991
00992
00993
00994
00995 long input_nod_dof_tfunct(XFILE *in, const enumstr nodsects[], long nsect)
00996 {
00997 char *aptr;
00998 long nkwd;
00999 char errmsg[1001];
01000 long *line;
01001 long *col;
01002 long aline, acol;
01003 gentity ent;
01004 kwd_handling bkwdmode;
01005 long *setnodes;
01006 long tf_id;
01007 long i, j, k, l;
01008 long prop, ndof, nbc, nnp, lcid;
01009
01010 if (Nod_ccn == NULL)
01011 {
01012 Nod_ccn = new long*[Top->nn];
01013 memset(Nod_ccn, 0, sizeof(*Nod_ccn)*Top->nn);
01014 }
01015 setnodes = new long[Top->nn];
01016 memset(setnodes, 0, sizeof(*setnodes)*Top->nn);
01017 line = new long[Top->nn];
01018 memset(line, 0, sizeof(*line)*Top->nn);
01019 col = new long[Top->nn];
01020 memset(col, 0, sizeof(*col)*Top->nn);
01021
01022 ndof = Tp->ntm;
01023
01024 bkwdmode = in->kwdmode;
01025 in->ignorecase = 1;
01026
01027 fprintf(stdout, "\n reading of dof time functions at nodes");
01028
01029 for (i=nsect-1, ent=gregion; i>=0; i--, ent--)
01030 {
01031
01032 if (xf_setsec(in, nodsects[i]) == 1)
01033 continue;
01034
01035 in->kwdmode = sect_mode_full;
01036 nkwd = getkwd_sect(in, NULL, aptr, "nod_tfunc", 1);
01037 in->kwdmode = bkwdmode;
01038
01039 for(j=0; j < nkwd; j++)
01040 {
01041
01042 in->kwdmode = sect_mode_fwd;
01043 getkwd_sect(in, NULL, aptr, "nod_tfunc", 0);
01044 in->kwdmode = bkwdmode;
01045
01046 aline = in->line;
01047 acol = in->col;
01048 in->kwdmode = sect_mode_seq;
01049
01050 xfscanf(in, "%k%k%ld", "nod_tfunc", "propid", &prop);
01051
01052 nnp = Top->get_propent_nodes(prop, ent, setnodes);
01053 if (nnp == 0)
01054 {
01055 if (Check_unused_prop == 0)
01056
01057 continue;
01058 sprintf(errmsg, "Nodes with property %ld belonging to entity %s have not been found.\n"
01059 " Nodal time functions (line %ld, column %ld, file %s) cannot be assigned correctly.",
01060 prop, entitypstr[ent-1].alias, aline, acol, in->fname);
01061 print_err(errmsg, __FILE__, __LINE__, __func__);
01062 delete [] setnodes;
01063 delete [] line;
01064 delete [] col;
01065 return 4;
01066 }
01067 xfscanf(in, "%k%ld", "nbc", &nbc);
01068 if ((nbc < 1) || (nbc > ndof))
01069 {
01070 sprintf(errmsg, "Nodes with property %ld belonging to entity %s\n"
01071 " have number of dof out of range <1,%ld>"
01072 " (line %ld, column %ld, file %s)",
01073 prop, entitypstr[ent-1].alias, ndof, aline, acol, in->fname);
01074 print_err(errmsg, __FILE__, __LINE__, __func__);
01075 delete [] setnodes;
01076 delete [] line;
01077 delete [] col;
01078 return 2;
01079 }
01080 for (k = 0; k < nbc; k++)
01081 {
01082 xfscanf(in, "%k%ld", "lc_id", &lcid);
01083 if ((lcid < 1) || (lcid > ndof))
01084 {
01085 sprintf(errmsg, "Nodes with property %ld belonging to entity %s\n"
01086 " have time function dof number out of range <1,%ld>"
01087 " (line %ld, column %ld, file %s)",
01088 prop, entitypstr[ent-1].alias, ndof, aline, acol, in->fname);
01089 print_err(errmsg, __FILE__, __LINE__, __func__);
01090 delete [] setnodes;
01091 delete [] line;
01092 delete [] col;
01093 return 3;
01094 }
01095 xfscanf(in, "%k%ld", "tfunc_id", &tf_id);
01096 if (tf_id < 1)
01097 {
01098 sprintf(errmsg, "Invalid time function index");
01099 print_err(errmsg, __FILE__, __LINE__, __func__);
01100 delete [] line;
01101 delete [] col;
01102 return 5;
01103 }
01104
01105 for (l=0; l<Top->nn; l++)
01106 {
01107 if (setnodes[l] < 0)
01108 continue;
01109 if (Nod_ccn[l] == NULL)
01110 {
01111 Nod_ccn[l] = new long[ndof];
01112 memset(Nod_ccn[l], 0, sizeof(*Nod_ccn[l])*ndof);
01113 Nod_ccn[l][lcid-1] = tf_id;
01114
01115 line[l] = aline;
01116 col[l] = acol;
01117 }
01118 else
01119 {
01120
01121
01122 if ((Nod_ccn[l][k] != 0) && (Nod_ccn[l][k] != tf_id))
01123 {
01124 fprintf(Log, "Line %ld, col %ld, file %s: Node %ld has already had assigned different "
01125 "time function at line %ld, col %ld, file: %s\n", aline, acol, in->fname,
01126 l+1, line[l], col[l], in->fname);
01127 }
01128 Nod_ccn[l][lcid-1] = tf_id;
01129 }
01130 }
01131 }
01132 in->kwdmode = bkwdmode;
01133 }
01134 }
01135 delete [] setnodes;
01136 delete [] line;
01137 delete [] col;
01138 return 0;
01139 }
01140
01141
01142
01143
01144
01145
01146
01147
01148
01149
01150
01151
01152
01153
01154
01155
01156
01157
01158
01159
01160
01161
01162
01163
01164 long input_nod_crsect(XFILE *in, const enumstr nodsects[], long nsect)
01165 {
01166 char *aptr;
01167 long nkwd;
01168 char errmsg[1001];
01169 long *line;
01170 long *col;
01171 long aline, acol;
01172 gentity ent;
01173 kwd_handling bkwdmode;
01174 long *setnodes;
01175 crsectypet cst;
01176 long csti;
01177 long i, j, k, ic;
01178 long prop;
01179 long nnp;
01180
01181 Nod_cst = new crsectypet[Top->nn];
01182 memset(Nod_cst, 0, sizeof(*Nod_cst)*Top->nn);
01183 Nod_csti = new long[Top->nn];
01184 memset(Nod_csti, 0, sizeof(*Nod_csti)*Top->nn);
01185 Nod_cstdbi = new long[Top->nn];
01186 memset(Nod_cstdbi, 0, sizeof(*Nod_cstdbi)*Top->nn);
01187 setnodes = new long[Top->nn];
01188 memset(setnodes, 0, sizeof(*setnodes)*Top->nn);
01189 line = new long[Top->nn];
01190 memset(line, 0, sizeof(*line)*Top->nn);
01191 col = new long[Top->nn];
01192 memset(col, 0, sizeof(*col)*Top->nn);
01193
01194 bkwdmode = in->kwdmode;
01195 in->ignorecase = 1;
01196
01197 fprintf(stdout, "\n reading of cross-sections at nodes");
01198
01199 for (i=nsect-1, ent=gregion; i>=0; i--, ent--)
01200 {
01201
01202 if (xf_setsec(in, nodsects[i]) == 1)
01203 continue;
01204
01205 in->kwdmode = sect_mode_full;
01206 nkwd = getkwd_sect(in, NULL, aptr, "nod_crsec", 1);
01207 in->kwdmode = bkwdmode;
01208
01209 for(j=0; j < nkwd; j++)
01210 {
01211
01212 in->kwdmode = sect_mode_fwd;
01213 getkwd_sect(in, NULL, aptr, "nod_crsec", 0);
01214 in->kwdmode = bkwdmode;
01215
01216 aline = in->line;
01217 acol = in->col;
01218 in->kwdmode = sect_mode_seq;
01219
01220 xfscanf(in, "%k%k%ld", "nod_crsec", "propid", &prop);
01221 xfscanf(in, "%k%m%k%ld", "type", &crsectypet_kwdset, &cst, "type_id", &csti);
01222
01223 ic = Dbcrst->search_crs(cst, csti-1);
01224 if (ic < 0)
01225 {
01226 sprintf(errmsg, "Line %ld, col %ld, file %s: cannot find required cross-section in the database", in->line, in->col, in->fname);
01227 print_err(errmsg, __FILE__, __LINE__, __func__);
01228 delete [] setnodes;
01229 delete [] line;
01230 delete [] col;
01231 return 1;
01232 }
01233 else
01234 Dbcrst->mark_used(ic, csti-1);
01235
01236 in->kwdmode = bkwdmode;
01237
01238 nnp = Top->get_propent_nodes(prop, ent, setnodes);
01239 if (nnp == 0)
01240 {
01241 if (Check_unused_prop == 0)
01242
01243 continue;
01244
01245 sprintf(errmsg, "Nodes with property %ld belonging to entity %s have not been found.\n"
01246 " Nodal cross-section type (line %ld, column %ld, file %s) cannot be assigned correctly.",
01247 prop, entitypstr[ent-1].alias, aline, acol, in->fname);
01248 print_err(errmsg, __FILE__, __LINE__, __func__);
01249 delete [] line;
01250 delete [] col;
01251 return 3;
01252 }
01253
01254
01255 for (k=0; k<Top->nn; k++)
01256 {
01257 if (setnodes[k] < 0)
01258 continue;
01259 if ((Nod_cst[k] != nocrosssectiont) && ((Nod_cst[k] != cst) || (Nod_csti[k] != csti)))
01260 {
01261 sprintf(errmsg, "Line %ld, col %ld, file %s: Node %ld has already had assigned different"
01262 "cross-section type at line %ld, col %ld, file: %s\n", aline, acol, in->fname,
01263 k+1, line[k], col[k], in->fname);
01264 print_err(errmsg, __FILE__, __LINE__, __func__);
01265 delete [] setnodes;
01266 delete [] line;
01267 delete [] col;
01268 return 2;
01269 }
01270 Nod_cst[k] = cst;
01271 Nod_csti[k] = csti;
01272 Nod_cstdbi[k] = ic;
01273
01274 line[k] = aline;
01275 col[k] = acol;
01276 }
01277 }
01278 }
01279 delete [] setnodes;
01280 delete [] line;
01281 delete [] col;
01282 return 0;
01283 }
01284
01285
01286
01287
01288
01289
01290
01291
01292
01293
01294
01295
01296
01297
01298
01299
01300
01301
01302
01303
01304
01305
01306
01307
01308
01309 long input_nod_initcondt(XFILE *in, const enumstr nodsects[], long nsect)
01310 {
01311 char *aptr;
01312 long nkwd;
01313 char emsg[1001];
01314 long *line;
01315 long *col;
01316 long aline, acol;
01317 gentity ent;
01318 kwd_handling bkwdmode;
01319 long *setnodes;
01320 long check;
01321 long i, j, k, l, prop;
01322 long nini;
01323 long ndof, nnp;
01324 double *con;
01325 prepcondtype cndt;
01326
01327
01328 Nod_inicd = new double*[Top->nn];
01329 memset(Nod_inicd, 0, sizeof(*Nod_inicd)*Top->nn);
01330
01331 ndof = Tp->ntm;
01332 if (Inicdf)
01333 {
01334 if (read_inicd_file(Inicdf, ndof))
01335 return 1;
01336 }
01337
01338 setnodes = new long[Top->nn];
01339 memset(setnodes, 0, sizeof(*setnodes)*Top->nn);
01340 line = new long[Top->nn];
01341 memset(line, 0, sizeof(*line)*Top->nn);
01342 col = new long[Top->nn];
01343 memset(col, 0, sizeof(*col)*Top->nn);
01344 con = new double[ndof];
01345
01346 bkwdmode = in->kwdmode;
01347 in->ignorecase = 1;
01348
01349 fprintf(stdout, "\n reading of nodal initial conditions");
01350
01351 for (i=nsect-1, ent=gregion; i>=0; i--, ent--)
01352 {
01353
01354 if (xf_setsec(in, nodsects[i]) == 1)
01355 continue;
01356
01357 in->kwdmode = sect_mode_full;
01358 nkwd = getkwd_sect(in, NULL, aptr, "nod_inicond", 1);
01359 in->kwdmode = bkwdmode;
01360
01361 for(j=0; j < nkwd; j++)
01362 {
01363
01364 in->kwdmode = sect_mode_fwd;
01365 getkwd_sect(in, NULL, aptr, "nod_inicond", 0);
01366 in->kwdmode = bkwdmode;
01367
01368 aline = in->line;
01369 acol = in->col;
01370 in->kwdmode = sect_mode_seq;
01371
01372 xfscanf(in, "%k%k%ld", "nod_inicond", "propid", &prop);
01373 xfscanf(in, "%m", &prepcondtype_kwdset, &cndt);
01374 switch (cndt)
01375 {
01376 case cond:
01377 for (l=0; l<ndof; l++)
01378 xfscanf(in, "%le", con+l);
01379 break;
01380 case file:
01381 break;
01382 default:
01383 print_err("Unknown type of initial condition setup.", __FILE__, __LINE__, __func__);
01384 }
01385
01386 in->kwdmode = bkwdmode;
01387
01388
01389 nnp = Top->get_propent_nodes(prop, ent, setnodes);
01390 if (nnp == 0)
01391 {
01392 if (Check_unused_prop == 0)
01393
01394 continue;
01395 else
01396 {
01397
01398 sprintf(emsg, "Nodes with property %ld belonging to entity %s have not been found.\n"
01399 " Nodal intial conditions (line %ld, column %ld, file %s) cannot be assigned correctly.",
01400 prop, entitypstr[ent-1].alias, aline, acol, in->fname);
01401 print_err(emsg, __FILE__, __LINE__, __func__);
01402 delete [] con;
01403 delete [] line;
01404 delete [] col;
01405 return 3;
01406 }
01407 }
01408 for (k=0; k<Top->nn; k++)
01409 {
01410 if (setnodes[k] < 0)
01411 continue;
01412 if (Nod_inicd[k] == NULL)
01413 {
01414 Nod_inicd[k] = new double[ndof];
01415 for(l=0; l<ndof; l++)
01416 Nod_inicd[k][l] = con[l];
01417
01418 line[k] = aline;
01419 col[k] = acol;
01420 }
01421 else
01422 {
01423 check = 0;
01424 if (cndt == cond)
01425 {
01426 for(l=0; l<ndof; l++)
01427 {
01428 if (con[l] != Nod_inicd[k][l])
01429 check ++;
01430 }
01431 }
01432 if ((cndt == cond) && (line[k] != 0) && check)
01433 {
01434 sprintf(emsg, "Line %ld, col %ld, file %s: Node %ld has already had assigned different "
01435 "initial condition at line %ld, col %ld, file: %s\n", aline, acol, in->fname, k+1, line[k], col[k], in->fname);
01436 print_err(emsg, __FILE__, __LINE__, __func__);
01437 delete [] setnodes;
01438 delete [] line;
01439 delete [] col;
01440 return 2;
01441 }
01442 else
01443 {
01444 if (line[k])
01445 fprintf(Log, "Line %ld, col %ld, file %s: Node %ld has already had assigned initial condition at line %ld, col %ld, file: %s\n", aline, acol, in->fname, k+1, line[k], col[k], in->fname);
01446 else
01447 {
01448 if (check)
01449 {
01450 fprintf(Log, "Line %ld, col %ld, file %s: Initial condition for node %ld specified in file '%s'\n"
01451 " has been replaced by new one from the above mentioned line\n",
01452 aline, acol, in->fname, k+1, Inicdf);
01453 }
01454 else
01455 fprintf(Log, "Line %ld, col %ld, file %s: Node %ld has already had assigned the same initial condition in file: %s\n", aline, acol, in->fname, k+1, Inicdf);
01456 line[k] = aline;
01457 col[k] = acol;
01458 }
01459 }
01460 }
01461 }
01462 }
01463 }
01464
01465
01466
01467 nini = 0;
01468 for (j=0; j<Top->nn; j++)
01469 {
01470 if (Nod_inicd[j])
01471 nini++;
01472 }
01473 if ((nini > 0) && (nini < Top->nn))
01474 {
01475 sprintf(emsg, "number of initial conditions is less then number of nodes");
01476 print_err(emsg, __FILE__, __LINE__, __func__);
01477 delete [] con;
01478 delete [] setnodes;
01479 delete [] line;
01480 delete [] col;
01481 return 3;
01482 }
01483 delete [] con;
01484 delete [] setnodes;
01485 delete [] line;
01486 delete [] col;
01487 return 0;
01488 }
01489
01490
01491
01492
01493
01494
01495
01496
01497
01498
01499
01500
01501
01502
01503
01504
01505
01506
01507
01508 long read_inicd_file(char *cndfname, long ndof)
01509 {
01510 long i, j, nid;
01511 XFILE *inif;
01512 long nn = Top->nn;
01513 char label[10];
01514
01515 inif = xfopen(cndfname, "rt");
01516 if (inif == NULL)
01517 {
01518 print_err("Cannot open initial condition file '%s'",
01519 __FILE__, __LINE__, __func__, cndfname);
01520 return (1);
01521 }
01522 inif->warning = 1;
01523
01524 inif->kwdmode = sequent_mode;
01525 inif->ignorecase = 1;
01526 Nod_inicd = new double*[nn];
01527 memset(Nod_inicd, 0, sizeof(*Nod_inicd)*nn);
01528 for (i=0; i<nn; i++)
01529 {
01530 Nod_inicd[i] = new double[ndof];
01531 memset(Nod_inicd[i], 0, sizeof(*Nod_inicd[i])*ndof);
01532 }
01533
01534 xfscanf(inif,"%* a%* a%* a%* a%* a");
01535
01536 xfscanf(inif,"%* a");
01537
01538 xfscanf(inif,"%* a%* a%* a");
01539
01540 xfscanf(inif,"%* a");
01541 for (i=0; i<nn; i++)
01542 {
01543 xfscanf(inif, " %k%ld", "Node", &nid);
01544 if ((nid < 1) && (nid > nn))
01545 {
01546 print_err("Node number is out of range <1,%ld>.\n"
01547 "Initial condition file '%s', line=%ld, col=%ld",
01548 __FILE__, __LINE__, __func__, nn, cndfname, inif->line, inif->col);
01549 return(1);
01550 }
01551 for (j=0; j<ndof; j++)
01552 {
01553 snprintf(label, 10, "r_%ld=", j+1);
01554 xfscanf(inif, " %k%le", label, Nod_inicd[i]+j);
01555 }
01556 }
01557 return(0);
01558 }
01559
01560
01561
01562
01563
01564
01565
01566
01567
01568
01569
01570
01571
01572
01573
01574
01575
01576
01577
01578
01579
01580
01581
01582
01583
01584
01585
01586
01587
01588
01589
01590 long input_nod_sourcet(XFILE *in, const enumstr nodsects[], long nsect)
01591 {
01592 char *aptr;
01593 long nkwd;
01594 char errmsg[1001];
01595 long *line;
01596 long *col;
01597 long aline, acol;
01598 gentity ent;
01599 kwd_handling bkwdmode;
01600 long *setnodes;
01601 sourcet *tsrc, *aux;
01602 long lcid;
01603 long i, j, k;
01604 long prop, ndof, nnp;
01605 long srcid;
01606
01607 Nod_sourcet = new long*[Top->nn];
01608 memset(Nod_sourcet, 0, sizeof(*Nod_sourcet)*Top->nn);
01609 setnodes = new long[Top->nn];
01610 memset(setnodes, 0, sizeof(*setnodes)*Top->nn);
01611 line = new long[Top->nn];
01612 memset(line, 0, sizeof(*line)*Top->nn);
01613 col = new long[Top->nn];
01614 memset(col, 0, sizeof(*col)*Top->nn);
01615
01616 ndof = Tp->ntm;
01617
01618 bkwdmode = in->kwdmode;
01619 in->ignorecase = 1;
01620
01621 fprintf(stdout, "\n reading of nodal sources");
01622 for (i=nsect-1, ent=gregion; i>=0; i--, ent--)
01623 {
01624
01625 if (xf_setsec(in, nodsects[i]) == 1)
01626 continue;
01627
01628 in->kwdmode = sect_mode_full;
01629 nkwd = getkwd_sect(in, NULL, aptr, "nod_src", 1);
01630 in->kwdmode = bkwdmode;
01631
01632 for(j=0; j < nkwd; j++)
01633 {
01634
01635 in->kwdmode = sect_mode_fwd;
01636 getkwd_sect(in, NULL, aptr, "nod_src", 0);
01637 in->kwdmode = bkwdmode;
01638
01639 aline = in->line;
01640 acol = in->col;
01641 in->kwdmode = sect_mode_seq;
01642
01643 xfscanf(in, "%k%k%ld", "nod_src", "propid", &prop);
01644
01645 nnp = Top->get_propent_nodes(prop, ent, setnodes);
01646 if (nnp == 0)
01647 {
01648 if (Check_unused_prop == 0)
01649
01650 continue;
01651 sprintf(errmsg, "Nodes with property %ld belonging to entity %s have not been found.\n"
01652 " Nodal source (line %ld, column %ld, file %s) cannot be assigned correctly.",
01653 prop, entitypstr[ent-1].alias, aline, acol, in->fname);
01654 print_err(errmsg, __FILE__, __LINE__, __func__);
01655 delete [] setnodes;
01656 delete [] line;
01657 delete [] col;
01658 return 3;
01659 }
01660
01661 xfscanf(in, "%k%ld", "lc_id", &lcid);
01662 if ((lcid < 1) || (lcid > ndof))
01663 {
01664 sprintf(errmsg, "Load case index is out of range <1, %ld>\n"
01665 " in file %s, line %ld, col %ld", ndof, in->fname, aline, acol);
01666 print_err(errmsg, __FILE__, __LINE__, __func__);
01667 delete [] setnodes;
01668 delete [] line;
01669 delete [] col;
01670 return 1;
01671 }
01672 lcid--;
01673
01674 tsrc = new sourcet;
01675
01676 tsrc->read(in);
01677 srcid = 0;
01678
01679 in->kwdmode = bkwdmode;
01680
01681
01682 for (k=0; k<Top->nn; k++)
01683 {
01684 if (setnodes[k] < 0)
01685 continue;
01686 if (Nod_sourcet[k])
01687 {
01688 if (Nod_sourcet[k][lcid])
01689 {
01690
01691 fprintf(Log, "Line %ld, col %ld, file %s: Node %ld has already had assigned nodal source at line %ld, col %ld, file: %s\n",
01692 aline, acol, in->fname, k+1, line[k], col[k], in->fname);
01693 aux = (sourcet *)(Nod_srclst.at(Nod_sourcet[k][lcid]-1));
01694 if (tsrc->compare(*aux))
01695 {
01696 sprintf(errmsg, "Conflict in assignment of nodal source at line %ld, col %ld\n"
01697 "with previous nodal source at line %ld, col %ld in file %s", aline, acol, line[k], col[k], in->fname);
01698 print_err(errmsg, __FILE__, __LINE__, __func__);
01699 delete tsrc;
01700 delete [] setnodes;
01701 delete [] line;
01702 delete [] col;
01703 return 2;
01704 }
01705 }
01706 }
01707
01708 if (Nod_sourcet[k] == NULL)
01709 {
01710 Nod_sourcet[k] = new long[ndof];
01711 memset(Nod_sourcet[k], 0, sizeof(*Nod_sourcet[k])*ndof);
01712 }
01713
01714
01715 if (srcid == 0)
01716 {
01717 Nod_srclst.append(tsrc);
01718 srcid = Nod_srclst.count();
01719 }
01720 Nod_sourcet[k][lcid] = srcid;
01721
01722 line[k] = aline;
01723 col[k] = acol;
01724 }
01725 }
01726 }
01727 delete [] setnodes;
01728 delete [] line;
01729 delete [] col;
01730 return 0;
01731 }
01732
01733
01734
01735
01736
01737
01738
01739
01740
01741
01742
01743
01744
01745
01746
01747
01748
01749
01750
01751
01752
01753
01754
01755
01756
01757
01758
01759
01760
01761
01762 long input_elem_typet(XFILE *in, const enumstr elemsects[], long nsect)
01763 {
01764 char *aptr;
01765 long nkwd;
01766 char errmsg[1001];
01767 long *line;
01768 long *col;
01769 long aline, acol;
01770 gentity ent;
01771 kwd_handling bkwdmode;
01772 long i, j, k;
01773 elemtypet tmp_type;
01774 long prop, prop_used;
01775 long sres;
01776 long *entid;
01777 long nentid;
01778
01779 fprintf(stdout, "\n reading of element types");
01780 El_type = new elemtypet[Top->ne];
01781 memset(El_type, 0, sizeof(*El_type)*Top->ne);
01782 line = new long[Top->ne];
01783 memset(line, 0, sizeof(*line)*Top->ne);
01784 col = new long[Top->ne];
01785 memset(col, 0, sizeof(*col)*Top->ne);
01786
01787 bkwdmode = in->kwdmode;
01788 in->ignorecase = 1;
01789
01790 for (i=nsect-1, ent=gregion; i>=0; i--, ent--)
01791 {
01792
01793 if (xf_setsec(in, elemsects[i]) == 1)
01794 continue;
01795
01796 in->kwdmode = sect_mode_full;
01797 nkwd = getkwd_sect(in, NULL, aptr, "el_type", 1);
01798 in->kwdmode = bkwdmode;
01799
01800 for(j=0; j < nkwd; j++)
01801 {
01802
01803 in->kwdmode = sect_mode_fwd;
01804 getkwd_sect(in, NULL, aptr, "el_type", 0);
01805 in->kwdmode = bkwdmode;
01806
01807 aline = in->line;
01808 acol = in->col;
01809 in->kwdmode = sect_mode_seq;
01810
01811 xfscanf(in, "%k%k%ld%m", "el_type", "propid", &prop, &elemtypet_kwdset, &tmp_type);
01812
01813 in->kwdmode = bkwdmode;
01814
01815 prop_used = 0;
01816
01817 for(k=0; k<Top->ne; k++)
01818 {
01819 entid = NULL;
01820 nentid = 0;
01821 sres = Top->elements[k].searchprop(prop, ent, Top->nodes, k, Top->edges, Top->surfaces, entid, nentid);
01822 if (sres > 0)
01823 {
01824 if ((El_type[k] != 0) && (El_type[k] != tmp_type))
01825 {
01826 sprintf(errmsg, "Different types have been assigned at element %ld\n"
01827 "see input file %s, line %ld, column %ld", k+1, in->fname, aline, acol);
01828 print_err(errmsg, __FILE__, __LINE__, __func__);
01829 delete [] line;
01830 delete [] col;
01831 return 1;
01832 }
01833 if (El_type[k] == tmp_type)
01834 fprintf(Log, "Line %ld, col %ld, file %s: Element %ld has already had assigned type at line %ld, col %ld, file: %s\n", aline, acol, in->fname, k+1, line[k], col[k], in->fname);
01835 El_type[k] = tmp_type;
01836 prop_used = 1;
01837 }
01838 if (sres < 0)
01839 {
01840 sprintf(errmsg, "Element %ld has not read property numbers of %s,\n"
01841 " required property cannot be assigned.\n"
01842 " see input file %s, line %ld, column %ld", k+1, entitypstr[ent-1].alias, in->fname, aline, acol);
01843 print_err(errmsg, __FILE__, __LINE__, __func__);
01844 delete [] line;
01845 delete [] col;
01846 return 3;
01847 }
01848 }
01849 if (Check_unused_prop && (prop_used == 0))
01850 {
01851
01852 sprintf(errmsg, "Elements with property %ld belonging to entity %s have not been found.\n"
01853 " Element type (line %ld, column %ld, file %s) cannot be assigned correctly.",
01854 prop, entitypstr[ent-1].alias, aline, acol, in->fname);
01855 print_err(errmsg, __FILE__, __LINE__, __func__);
01856 delete [] line;
01857 delete [] col;
01858 return 4;
01859 }
01860 }
01861 }
01862
01863
01864 for(i=0; i<Top->ne; i++)
01865 {
01866 if (El_type[i] == 0)
01867 {
01868 sprintf(errmsg, "Element %ld has not assigned a type", i+1);
01869 print_err(errmsg, __FILE__, __LINE__, __func__);
01870 delete [] line;
01871 delete [] col;
01872 return 2;
01873 }
01874 }
01875 delete [] line;
01876 delete [] col;
01877
01878 return 0;
01879 }
01880
01881
01882
01883
01884
01885
01886
01887
01888
01889
01890
01891
01892
01893
01894
01895
01896
01897
01898
01899
01900
01901
01902
01903
01904
01905
01906
01907 long input_elem_matt(XFILE *in, const enumstr elemsects[], long nsect)
01908 {
01909 char *aptr;
01910 long nkwd;
01911 char errmsg[1001];
01912 long *line;
01913 long *col;
01914 long aline, acol;
01915 gentity ent;
01916 kwd_handling bkwdmode;
01917 long i, j, k, l, err;
01918 mattypet *tmp_type;
01919 long *tmp_id, *ic;
01920 long prop, ndof, nmat;
01921 long sres;
01922 long prop_used;
01923 long *entid;
01924 long nentid;
01925
01926 fprintf(stdout, "\n reading of element material types");
01927 El_nmat = new long[Top->ne];
01928 memset(El_nmat, 0, sizeof(*El_nmat)*Top->ne);
01929 El_mattype = new mattypet*[Top->ne];
01930 memset(El_mattype, 0, sizeof(*El_mattype)*Top->ne);
01931 El_matid = new long*[Top->ne];
01932 memset(El_matid, 0, sizeof(*El_matid)*Top->ne);
01933 El_matdbi = new long*[Top->ne];
01934 memset(El_matdbi, 0, sizeof(*El_matdbi)*Top->ne);
01935 line = new long[Top->ne];
01936 memset(line, 0, sizeof(*line)*Top->ne);
01937 col = new long[Top->ne];
01938 memset(col, 0, sizeof(*col)*Top->ne);
01939
01940 ndof = Tp->ntm;
01941
01942 bkwdmode = in->kwdmode;
01943 in->ignorecase = 1;
01944
01945 for (i=nsect-1, ent=gregion; i>=0; i--, ent--)
01946 {
01947
01948 if (xf_setsec(in, elemsects[i]) == 1)
01949 continue;
01950
01951 in->kwdmode = sect_mode_full;
01952 nkwd = getkwd_sect(in, NULL, aptr, "el_mat", 1);
01953 in->kwdmode = bkwdmode;
01954
01955 for(j=0; j < nkwd; j++)
01956 {
01957
01958 in->kwdmode = sect_mode_fwd;
01959 getkwd_sect(in, NULL, aptr, "el_mat", 0);
01960 in->kwdmode = bkwdmode;
01961
01962 aline = in->line;
01963 acol = in->col;
01964 in->kwdmode = sect_mode_seq;
01965
01966 xfscanf(in, "%k%k%ld", "el_mat", "propid", &prop);
01967 nmat = ndof*ndof;
01968 tmp_type = new mattypet[nmat];
01969 memset(tmp_type, 0, sizeof(*tmp_type)*nmat);
01970 tmp_id = new long[nmat];
01971 memset(tmp_id, 0, sizeof(*tmp_id)*nmat);
01972 ic = new long[nmat];
01973 memset(ic, 0, sizeof(*ic)*nmat);
01974
01975 for (k=0; k<nmat; k++)
01976 {
01977 xfscanf(in, "%k%m%k%ld", "type", &mattypet_kwdset, tmp_type+k, "type_id", tmp_id+k);
01978
01979 ic[k] = Dbmatt->search_mat(tmp_type[k], tmp_id[k]-1);
01980 if (ic[k] < 0)
01981 {
01982 sprintf(errmsg, "Line %ld, col %ld, file %s: cannot find %ld. required material in the database", in->line, in->col, in->fname, k+1);
01983 print_err(errmsg, __FILE__, __LINE__, __func__);
01984 delete [] tmp_type;
01985 delete [] tmp_id;
01986 delete [] ic;
01987 delete [] line;
01988 delete [] col;
01989 return 1;
01990 }
01991 else
01992 Dbmatt->mark_used(ic[k], tmp_id[k]-1);
01993 }
01994
01995 in->kwdmode = bkwdmode;
01996
01997 prop_used = 0;
01998
01999
02000 for(k=0; k<Top->ne; k++)
02001 {
02002 entid = NULL;
02003 nentid = 0;
02004 sres = Top->elements[k].searchprop(prop, ent, Top->nodes, k, Top->edges, Top->surfaces, entid, nentid);
02005 if (sres > 0)
02006 {
02007 prop_used = 1;
02008 if (El_nmat[k] != 0)
02009 {
02010 err = 0;
02011 if (nmat != El_nmat[k])
02012 err = 1;
02013 for (l=0; (l<nmat) && (err==0); l++)
02014 {
02015 if ((tmp_type[l] != El_mattype[k][l]) || (tmp_id[l] != El_matid[k][l]))
02016 err = 1;
02017 }
02018 if (err)
02019 {
02020 sprintf(errmsg, "Different material types have been assigned at element %ld\n"
02021 "see input file %s, line %ld, column %ld", k+1, in->fname, aline, acol);
02022 print_err(errmsg, __FILE__, __LINE__, __func__);
02023 delete [] tmp_type;
02024 delete [] tmp_id;
02025 delete [] ic;
02026 delete [] line;
02027 delete [] col;
02028 return 2;
02029 }
02030 else
02031 fprintf(Log, "Line %ld, col %ld, file %s: Element %ld has already had assigned material type at line %ld, col %ld, file: %s\n", aline, acol, in->fname, k+1, line[k], col[k], in->fname);
02032 }
02033 else
02034 {
02035 El_mattype[k] = new mattypet[nmat];
02036 El_matid[k] = new long[nmat];
02037 El_matdbi[k] = new long[nmat];
02038 El_nmat[k] = nmat;
02039 for(l=0; l<nmat; l++)
02040 {
02041 El_mattype[k][l] = tmp_type[l];
02042 El_matid[k][l] = tmp_id[l];
02043 El_matdbi[k][l] = ic[l];
02044 }
02045
02046 line[k] = aline;
02047 col[k] = acol;
02048 }
02049 }
02050 if (sres < 0)
02051 {
02052 sprintf(errmsg, "Element %ld has not read property numbers of %s,\n"
02053 " required property cannot be assigned.\n"
02054 " see input file %s, line %ld, column %ld", k+1, entitypstr[ent-1].alias, in->fname, aline, acol);
02055 print_err(errmsg, __FILE__, __LINE__, __func__);
02056 delete [] tmp_type;
02057 delete [] tmp_id;
02058 delete [] ic;
02059 delete [] line;
02060 delete [] col;
02061 return 3;
02062 }
02063 }
02064 delete [] tmp_type;
02065 delete [] tmp_id;
02066 delete [] ic;
02067 if (Check_unused_prop && (prop_used == 0))
02068 {
02069
02070 sprintf(errmsg, "Elements with property %ld belonging to entity %s have not been found.\n"
02071 " Element material type (line %ld, column %ld, file %s) cannot be assigned correctly.",
02072 prop, entitypstr[ent-1].alias, aline, acol, in->fname);
02073 print_err(errmsg, __FILE__, __LINE__, __func__);
02074 delete [] line;
02075 delete [] col;
02076 return 4;
02077 }
02078 }
02079 }
02080
02081
02082 for(i=0; i<Top->ne; i++)
02083 {
02084 if (El_mattype[i] == NULL)
02085 {
02086 sprintf(errmsg, "Element %ld has not assigned a material type", i+1);
02087 print_err(errmsg, __FILE__, __LINE__, __func__);
02088 delete [] line;
02089 delete [] col;
02090 return 2;
02091 }
02092 }
02093 delete [] line;
02094 delete [] col;
02095
02096 return 0;
02097 }
02098
02099
02100
02101
02102
02103
02104
02105
02106
02107
02108
02109
02110
02111
02112
02113
02114
02115
02116
02117
02118
02119
02120
02121
02122
02123
02124 long input_elem_crsect(XFILE *in, const enumstr elemsects[], long nsect)
02125 {
02126 char *aptr;
02127 long nkwd;
02128 char errmsg[1001];
02129 long *line;
02130 long *col;
02131 long aline, acol;
02132 gentity ent;
02133 kwd_handling bkwdmode;
02134 long i, j, k, ic;
02135 crsectypet tmp_type;
02136 long prop, tmp_id;
02137 long sres;
02138 long prop_used;
02139 long *entid;
02140 long nentid;
02141
02142 fprintf(stdout, "\n reading of element cross-section types");
02143 El_cst = new crsectypet[Top->ne];
02144 memset(El_cst, 0, sizeof(*El_cst)*Top->ne);
02145 El_csti = new long[Top->ne];
02146 memset(El_csti, 0, sizeof(*El_csti)*Top->ne);
02147 El_cstdbi = new long[Top->ne];
02148 memset(El_cstdbi, 0, sizeof(*El_cstdbi)*Top->ne);
02149 line = new long[Top->ne];
02150 memset(line, 0, sizeof(*line)*Top->ne);
02151 col = new long[Top->ne];
02152 memset(col, 0, sizeof(*col)*Top->ne);
02153
02154 bkwdmode = in->kwdmode;
02155 in->ignorecase = 1;
02156
02157 for (i=nsect-1, ent=gregion; i>=0; i--, ent--)
02158 {
02159
02160 if (xf_setsec(in, elemsects[i]) == 1)
02161 continue;
02162
02163 in->kwdmode = sect_mode_full;
02164 nkwd = getkwd_sect(in, NULL, aptr, "el_crsec", 1);
02165 in->kwdmode = bkwdmode;
02166
02167 for(j=0; j < nkwd; j++)
02168 {
02169
02170 in->kwdmode = sect_mode_fwd;
02171 getkwd_sect(in, NULL, aptr, "el_crsec", 0);
02172 in->kwdmode = bkwdmode;
02173
02174 aline = in->line;
02175 acol = in->col;
02176 in->kwdmode = sect_mode_seq;
02177
02178 xfscanf(in, "%k%k%ld%k%m%k%ld", "el_crsec", "propid", &prop, "type", &crsectypet_kwdset, &tmp_type, "type_id", &tmp_id);
02179
02180 ic = Dbcrst->search_crs(tmp_type, tmp_id-1);
02181 if (ic < 0)
02182 {
02183 sprintf(errmsg, "Line %ld, col %ld, file %s: cannot find required cross-section in the database", in->line, in->col, in->fname);
02184 print_err(errmsg, __FILE__, __LINE__, __func__);
02185 delete [] line;
02186 delete [] col;
02187 return 1;
02188 }
02189 else
02190 Dbcrst->mark_used(ic, tmp_id-1);
02191
02192 in->kwdmode = bkwdmode;
02193
02194 prop_used = 0;
02195
02196 for(k=0; k<Top->ne; k++)
02197 {
02198 entid = NULL;
02199 nentid = 0;
02200 sres = Top->elements[k].searchprop(prop, ent, Top->nodes, k, Top->edges, Top->surfaces, entid, nentid);
02201 if (sres > 0)
02202 {
02203 if ((El_cst[k] != 0) && ((El_cst[k] != tmp_type) || (El_csti[k] != tmp_id)))
02204 {
02205 sprintf(errmsg, "Different cross-section types have been assigned at element %ld\n"
02206 "see input file %s, line %ld, column %ld", k+1, in->fname, aline, acol);
02207 print_err(errmsg, __FILE__, __LINE__, __func__);
02208 delete [] line;
02209 delete [] col;
02210 return 2;
02211 }
02212 prop_used = 1;
02213 if (El_cst[k] == tmp_type)
02214 fprintf(Log, "Line %ld, col %ld, file %s: Element %ld has already had assigned cross-section type at line %ld, col %ld, file: %s\n", aline, acol, in->fname, k+1, line[k], col[k], in->fname);
02215 else
02216 {
02217 El_cst[k] = tmp_type;
02218 El_csti[k] = tmp_id;
02219 El_cstdbi[k] = ic;
02220
02221 line[k] = aline;
02222 col[k] = acol;
02223 }
02224 }
02225 if (sres < 0)
02226 {
02227 sprintf(errmsg, "Element %ld has not read property numbers of %s,\n"
02228 " required property cannot be assigned.\n"
02229 " see input file %s, line %ld, column %ld", k+1, entitypstr[ent-1].alias, in->fname, aline, acol);
02230 print_err(errmsg, __FILE__, __LINE__, __func__);
02231 delete [] line;
02232 delete [] col;
02233 return 3;
02234 }
02235
02236 }
02237 if (Check_unused_prop && (prop_used == 0))
02238 {
02239
02240 sprintf(errmsg, "Elements with property %ld belonging to entity %s have not been found.\n"
02241 " Element cross-section type (line %ld, column %ld, file %s) cannot be assigned correctly.",
02242 prop, entitypstr[ent-1].alias, aline, acol, in->fname);
02243 print_err(errmsg, __FILE__, __LINE__, __func__);
02244 delete [] line;
02245 delete [] col;
02246 return 4;
02247 }
02248 }
02249 }
02250 delete [] line;
02251 delete [] col;
02252
02253 return 0;
02254 }
02255
02256
02257
02258
02259
02260
02261
02262
02263
02264
02265
02266
02267
02268
02269
02270
02271
02272
02273
02274
02275
02276
02277
02278
02279
02280
02281
02282
02283
02284
02285
02286
02287 long input_elem_sourcet(XFILE *in, const enumstr elemsects[], long nsect)
02288 {
02289 char *aptr;
02290 long nkwd;
02291 char errmsg[1001];
02292 long *line;
02293 long *col;
02294 long aline, acol;
02295 gentity ent;
02296 kwd_handling bkwdmode;
02297 sourcet *tsrc, *aux;
02298 long lcid;
02299 long i, j, k;
02300 long prop, ndof;
02301 long prop_used;
02302 long sres, srcid;
02303 long *entid;
02304 long nentid;
02305
02306 El_sourcet = new long*[Top->ne];
02307 memset(El_sourcet, 0, sizeof(*El_sourcet)*Top->ne);
02308 line = new long[Top->ne];
02309 memset(line, 0, sizeof(*line)*Top->ne);
02310 col = new long[Top->ne];
02311 memset(col, 0, sizeof(*col)*Top->ne);
02312
02313 ndof = Tp->ntm;
02314
02315 bkwdmode = in->kwdmode;
02316 in->ignorecase = 1;
02317
02318 fprintf(stdout, "\n reading of sources on elements");
02319 for (i=nsect-1, ent=gregion; i>=0; i--, ent--)
02320 {
02321
02322 if (xf_setsec(in, elemsects[i]) == 1)
02323 continue;
02324
02325 in->kwdmode = sect_mode_full;
02326 nkwd = getkwd_sect(in, NULL, aptr, "el_src", 1);
02327 in->kwdmode = bkwdmode;
02328
02329 for(j=0; j < nkwd; j++)
02330 {
02331
02332 in->kwdmode = sect_mode_fwd;
02333 getkwd_sect(in, NULL, aptr, "el_src", 0);
02334 in->kwdmode = bkwdmode;
02335
02336 aline = in->line;
02337 acol = in->col;
02338 in->kwdmode = sect_mode_seq;
02339
02340 xfscanf(in, "%k%k%ld", "el_src", "propid", &prop);
02341
02342 xfscanf(in, "%k%ld", "lc_id", &lcid);
02343 if ((lcid < 1) || (lcid > ndof))
02344 {
02345 sprintf(errmsg, "Load case index is out of range <1, %ld>\n"
02346 " in file %s, line %ld, col %ld", ndof, in->fname, aline, acol);
02347 print_err(errmsg, __FILE__, __LINE__, __func__);
02348 delete [] line;
02349 delete [] col;
02350 return 1;
02351 }
02352 lcid--;
02353
02354 tsrc = new sourcet;
02355
02356 tsrc->read(in);
02357
02358 in->kwdmode = bkwdmode;
02359
02360 prop_used = 0;
02361 srcid = 0;
02362
02363
02364 for (k=0; k<Top->ne; k++)
02365 {
02366 entid = NULL;
02367 nentid = 0;
02368 sres = Top->elements[k].searchprop(prop, ent, Top->nodes, k, Top->edges, Top->surfaces, entid, nentid);
02369 if (sres == 0)
02370 continue;
02371 if (El_sourcet[k])
02372 {
02373 if (El_sourcet[k][lcid])
02374 {
02375
02376 fprintf(Log, "Line %ld, col %ld, file %s: Element %ld has already had assigned source at line %ld, col %ld, file: %s\n",
02377 aline, acol, in->fname, k+1, line[k], col[k], in->fname);
02378 aux = (sourcet *)(El_srclst.at(El_sourcet[k][lcid]-1));
02379 if (tsrc->compare(*aux))
02380 {
02381 sprintf(errmsg, "Conflict in assignment of source on element at line %ld, col %ld\n"
02382 "with previous source on element at line %ld, col %ld in file %s", aline, acol, line[k], col[k], in->fname);
02383 print_err(errmsg, __FILE__, __LINE__, __func__);
02384 delete [] line;
02385 delete [] col;
02386 return 2;
02387 }
02388 }
02389 }
02390 if (El_sourcet[k] == NULL)
02391
02392 {
02393 El_sourcet[k] = new long[ndof];
02394 memset(El_sourcet[k], 0, sizeof(*El_sourcet[k])*ndof);
02395 }
02396 if (srcid == 0)
02397 {
02398
02399 El_srclst.append(tsrc);
02400 srcid = El_srclst.count();
02401 }
02402 El_sourcet[k][lcid] = srcid;
02403
02404 line[k] = aline;
02405 col[k] = acol;
02406 }
02407
02408
02409 if (Check_unused_prop && (prop_used == 0))
02410 {
02411
02412 continue;
02413 sprintf(errmsg, "Elements with property %ld belonging to entity %s have not been found.\n"
02414 " Element source (line %ld, column %ld, file %s) cannot be assigned correctly.",
02415 prop, entitypstr[ent-1].alias, aline, acol, in->fname);
02416 print_err(errmsg, __FILE__, __LINE__, __func__);
02417 delete tsrc;
02418 delete [] line;
02419 delete [] col;
02420 return 4;
02421 }
02422 }
02423 }
02424 delete [] line;
02425 delete [] col;
02426 return 0;
02427 }
02428
02429
02430
02431
02432
02433
02434
02435
02436
02437
02438
02439
02440
02441
02442
02443
02444
02445
02446
02447
02448
02449
02450
02451
02452
02453
02454
02455
02456
02457 long input_elem_vertbc(XFILE *in, const enumstr elemsects[], long nsect)
02458 {
02459 char *aptr;
02460 long nkwd;
02461 char errmsg[1001];
02462 char *coeff_desc[3] = {"nodal values", "transmission coeff.", "radiation coeff."};
02463 long aline, acol;
02464 gentity ent;
02465 kwd_handling bkwdmode;
02466 long i, j, k, l, m;
02467 entitybocon **tmp;
02468 climatcond *tmpcc;
02469 climatcond2 *tmpcc2;
02470 char *tmpccf;
02471 long appendcc;
02472 answertype *trcc;
02473 list *cclst;
02474
02475 loadelt *tmp2;
02476 long check;
02477 long prop, lcid;
02478 long sres;
02479 long ndof;
02480 long prop_used, err;
02481 bocontypet bc;
02482 long **bnid;
02483 long aux, nbo, nbce;
02484 long minid_nv, minid_trc, minid_trr;
02485 long *entid;
02486 long nentid;
02487
02488 fprintf(stdout, "\n reading of vertex boundary conditions applied on elements");
02489
02490
02491 ndof = Tp->ntm;
02492 if (El_loadt == NULL)
02493 {
02494 El_loadt = new loadelt**[Top->ne];
02495 memset(El_loadt, 0, sizeof(*El_loadt)*Top->ne);
02496 El_loadtln = new long *[Top->ne];
02497 memset(El_loadtln, 0, sizeof(*El_loadtln)*Top->ne);
02498 El_loadtcol = new long *[Top->ne];
02499 memset(El_loadtcol, 0, sizeof(*El_loadtcol)*Top->ne);
02500 for(i=0; i<Top->ne; i++)
02501 {
02502 El_loadt[i] = new loadelt*[ndof];
02503 memset(El_loadt[i], 0, sizeof(*El_loadt[i])*ndof);
02504 El_loadtln[i] = new long[ndof];
02505 memset(El_loadtln[i], 0, sizeof(*El_loadtln[i])*ndof);
02506 El_loadtcol[i] = new long[ndof];
02507 memset(El_loadtcol[i], 0, sizeof(*El_loadtcol[i])*ndof);
02508 }
02509 El_nv_lst = new list[ndof];
02510 El_trc_lst = new list[ndof];
02511 El_trr_lst = new list[ndof];
02512 El_cc_lst = new list[ndof];
02513 El_ccf_lst = new list[ndof];
02514 El_trcc_lst = new list[ndof];
02515 El_gcc_lst = new list[ndof];
02516 El_gccf_lst = new list[ndof];
02517 El_gtrcc_lst = new list[ndof];
02518 }
02519
02520 bkwdmode = in->kwdmode;
02521 in->ignorecase = 1;
02522
02523 for (i=nsect-1, ent=gvertex; i>=0; i--, ent--)
02524 {
02525
02526 if (xf_setsec(in, elemsects[i]) == 1)
02527 continue;
02528
02529 in->kwdmode = sect_mode_full;
02530 nkwd = getkwd_sect(in, NULL, aptr, "vertex_bc", 1);
02531 in->kwdmode = bkwdmode;
02532
02533 for(j=0; j < nkwd; j++)
02534 {
02535
02536 in->kwdmode = sect_mode_fwd;
02537 getkwd_sect(in, NULL, aptr, "vertex_bc", 0);
02538 in->kwdmode = bkwdmode;
02539
02540 aline = in->line;
02541 acol = in->col;
02542 in->kwdmode = sect_mode_seq;
02543
02544 xfscanf(in, "%k%k%ld%k%ld%k%m", "vertex_bc", "propid", &prop, "lc_id", &lcid, "bc_type", &bocontype_kwdset, &bc);
02545 if ((lcid < 1) && (lcid > ndof))
02546 {
02547 print_err("load case id is out range <1,%ld>", __FILE__, __LINE__, __func__, ndof);
02548 return 1;
02549 }
02550 lcid--;
02551
02552
02553 if (bc < presc_trmiss)
02554 nbce = 1;
02555 else
02556 nbce = 3;
02557
02558 appendcc = 0;
02559 trcc = NULL;
02560 tmpcc = NULL;
02561 tmpcc2 = NULL;
02562 tmpccf = NULL;
02563 tmp = NULL;
02564 if ((bc == det_climcond) || (bc == gen_climcond))
02565 {
02566 trcc = new answertype;
02567 xfscanf(in, "%k%m", "file_climcond", &answertype_kwdset, trcc);
02568 if (*trcc == no)
02569 {
02570 if (bc == det_climcond)
02571 {
02572 tmpcc = new climatcond;
02573 tmpcc->read(in, 0);
02574 cclst = El_cc_lst+lcid;
02575 }
02576 else
02577 {
02578 tmpcc2 = new climatcond2;
02579 tmpcc2->read(in, 0);
02580 cclst = El_gcc_lst+lcid;
02581 }
02582 }
02583 else
02584 {
02585 tmpccf = new char[in->give_maxlnsize()+1];
02586 xfscanf(in, "%a", &tmpccf);
02587 if (bc == det_climcond)
02588 cclst = El_ccf_lst+lcid;
02589 else
02590 cclst = El_gccf_lst+lcid;
02591 }
02592 appendcc = 1;
02593 }
02594 else
02595 {
02596 tmp = new entitybocon*[nbce];
02597 memset(tmp, 0, sizeof(*tmp)*nbce);
02598
02599 for(k=0; k<nbce; k++)
02600 {
02601 tmp[k] = new entitybocon;
02602
02603 check = tmp[k]->read(in);
02604 switch(check)
02605 {
02606 case 0:
02607 break;
02608 case 1:
02609 print_err("cannot detect coordinates nor time in the expression\n for %s of the given BC",
02610 __FILE__, __LINE__, __func__, coeff_desc[k]);
02611 for(l=0; l<=k; l++)
02612 delete tmp[l];
02613 delete [] tmp;
02614 return 2;
02615 default:
02616 print_err("unknown error of BC reading", __FILE__, __LINE__, __func__);
02617 return 2;
02618 }
02619 }
02620 }
02621
02622 in->kwdmode = bkwdmode;
02623
02624 bnid = new long*[nbce];
02625 memset(bnid, 0, sizeof(*bnid)*nbce);
02626 nbo = 0;
02627 prop_used = 0;
02628
02629 minid_nv = El_nv_lst[lcid].count();
02630 minid_trc = El_trc_lst[lcid].count();
02631 minid_trr = El_trr_lst[lcid].count();
02632
02633
02634 for(k=0; k<Top->ne; k++)
02635 {
02636
02637 if (Top->elements[k].type >= trianglelinear)
02638 continue;
02639
02640 entid = NULL;
02641 nentid = 0;
02642 sres = Top->elements[k].searchprop(prop, ent, Top->nodes, k, Top->edges, Top->surfaces, entid, nentid);
02643 if (sres > 0)
02644 {
02645
02646
02647 aux = get_nbo(Top->elements[k], gvertex);
02648 if (nbo != aux)
02649 {
02650
02651 nbo = aux;
02652 for (l=0; l<nbce; l++)
02653 {
02654 if (bnid[l])
02655 delete [] bnid[l];
02656 bnid[l] = new long[nbo];
02657 }
02658 }
02659
02660
02661 if (El_loadt[k][lcid])
02662 {
02663 if (El_loadtln[k][lcid])
02664 fprintf(Log, "Line %ld, col %ld, file %s: Element %ld has already assigned load at line %ld, col %ld, file: %s\n", aline, acol, in->fname, k+1, El_loadtln[k][lcid], El_loadtcol[k][lcid], in->fname);
02665 else
02666 {
02667 El_loadtln[k][lcid] = aline;
02668 El_loadtcol[k][lcid] = acol;
02669 }
02670 }
02671 else
02672 {
02673 El_loadt[k][lcid] = new loadelt(k, nbo);
02674
02675 El_loadtln[k][lcid] = aline;
02676 El_loadtcol[k][lcid] = acol;
02677 }
02678
02679
02680 for (l=0; l< nbce; l++)
02681 {
02682
02683 if (l==0)
02684 {
02685 if ((bc == det_climcond) || (bc == gen_climcond))
02686 {
02687 if (appendcc)
02688 {
02689 if (bc == det_climcond)
02690 El_trcc_lst[lcid].append(trcc);
02691 else
02692 El_gtrcc_lst[lcid].append(trcc);
02693
02694 if (*trcc == no)
02695 {
02696 if (bc == det_climcond)
02697 {
02698 El_cc_lst[lcid].append(tmpcc);
02699 El_ccf_lst[lcid].append(NULL);
02700 }
02701 else
02702 {
02703 El_gcc_lst[lcid].append(tmpcc2);
02704 El_gccf_lst[lcid].append(NULL);
02705 }
02706 }
02707 else
02708 {
02709 if (bc == det_climcond)
02710 {
02711 El_ccf_lst[lcid].append(tmpccf);
02712 El_cc_lst[lcid].append(NULL);
02713 }
02714 else
02715 {
02716 El_gccf_lst[lcid].append(tmpccf);
02717 El_gcc_lst[lcid].append(NULL);
02718 }
02719 }
02720 appendcc = 0;
02721 }
02722 assemble_bclimcond(Top->elements[k], Top->nodes, prop, *cclst, gvertex, bnid[0], entid, nentid);
02723 }
02724 else
02725 {
02726 err = assemble_bnodvalt(Top->elements[k], Top->nodes, prop, *tmp[0], El_nv_lst[lcid], gvertex, minid_nv, bnid[0], entid, nentid);
02727 if (err)
02728 {
02729 print_err("cannot assemble nodal values for element %ld", __FILE__, __LINE__, __func__, k+1);
02730 for (m=0; m<nbce; m++)
02731 {
02732 delete tmp[m];
02733 delete [] bnid[m];
02734 }
02735 delete [] bnid;
02736 delete [] tmp;
02737 return 3;
02738 }
02739 }
02740 }
02741
02742 if (l==1)
02743 {
02744 err = assemble_bnodvalt(Top->elements[k], Top->nodes, prop, *tmp[1], El_trc_lst[lcid], gvertex, minid_trc, bnid[1], entid, nentid);
02745 if (err)
02746 {
02747 print_err("cannot assemble transmission coefficients for element %ld", __FILE__, __LINE__, __func__, k+1);
02748 for (m=0; m<nbce; m++)
02749 {
02750 delete tmp[m];
02751 delete [] bnid[m];
02752 }
02753 delete [] bnid;
02754 delete [] tmp;
02755 return 3;
02756 }
02757 }
02758
02759 if (l==2)
02760 {
02761 err = assemble_bnodvalt(Top->elements[k], Top->nodes, prop, *tmp[2], El_trr_lst[lcid], gvertex, minid_trr, bnid[2], entid, nentid);
02762 if (err)
02763 {
02764 print_err("cannot assemble radiation coefficients for element %ld", __FILE__, __LINE__, __func__, k+1);
02765 for (m=0; m<nbce; m++)
02766 {
02767 delete tmp[m];
02768 delete [] bnid[m];
02769 }
02770 delete [] bnid;
02771 delete [] tmp;
02772 return 3;
02773 }
02774 }
02775 }
02776
02777
02778 tmp2 = bc2loadelt(k, Top->elements[k], Top->nodes, prop, bc, bnid, gvertex, entid, nentid);
02779 if (tmp2 == NULL)
02780 {
02781 print_err("unknown type of entity or problem is required", __FILE__, __LINE__, __func__);
02782 for (l=0; l<nbce; l++)
02783 {
02784 if (tmp)
02785 delete tmp[l];
02786 delete [] bnid[l];
02787 }
02788 delete [] bnid;
02789 if (tmp)
02790 delete [] tmp;
02791 return 3;
02792 }
02793
02794 check = El_loadt[k][lcid]->merge(*tmp2);
02795 prop_used = 1;
02796 switch(check)
02797 {
02798 case 0:
02799 break;
02800 case 1:
02801
02802 sprintf(errmsg, "Line %ld, col %ld, file %s:\n Element %ld has already had assigned boundary condition"
02803 "with different values at line %ld, col %ld, file: %s\n",
02804 aline, acol, in->fname, k+1, El_loadtln[k][lcid], El_loadtcol[k][lcid], in->fname);
02805 print_err(errmsg, __FILE__, __LINE__, __func__);
02806 for (l=0; l<nbce; l++)
02807 {
02808 if (tmp)
02809 delete tmp[l];
02810 delete [] bnid[l];
02811 }
02812 delete [] bnid;
02813 if (tmp)
02814 delete [] tmp;
02815 delete tmp2;
02816 return 4;
02817 case 2:
02818
02819 sprintf(errmsg, "Line %ld, col %ld, file %s:\n Element %ld has already had assigned different "
02820 "type of boundary condition at line %ld, col %ld, file: %s\n", aline, acol, in->fname,
02821 k+1, El_loadtln[k][lcid], El_loadtcol[k][lcid], in->fname);
02822 print_err(errmsg, __FILE__, __LINE__, __func__);
02823 for (l=0; l<nbce; l++)
02824 {
02825 if (tmp)
02826 delete tmp[l];
02827 delete [] bnid[l];
02828 }
02829 delete [] bnid;
02830 if (tmp)
02831 delete [] tmp;
02832 delete tmp2;
02833 return 4;
02834 default:
02835
02836 sprintf(errmsg, "Line %ld, col %ld, file %s:\n Element %ld has already had assigned boundary condition "
02837 "which cannot be merged at line %ld, col %ld, file: %s\n", aline, acol, in->fname,
02838 k+1, El_loadtln[k][lcid], El_loadtcol[k][lcid], in->fname);
02839 print_err(errmsg, __FILE__, __LINE__, __func__);
02840 for (l=0; l<nbce; l++)
02841 {
02842 if (tmp)
02843 delete tmp[l];
02844 delete [] bnid[l];
02845 }
02846 delete [] bnid;
02847 if (tmp)
02848 delete [] tmp;
02849 delete tmp2;
02850 return 4;
02851 }
02852 delete tmp2;
02853 }
02854 if (sres < 0)
02855 {
02856 sprintf(errmsg, "Element %ld has not read property numbers of %s,\n"
02857 " required property cannot be assigned.\n"
02858 " see input file %s, line %ld, column %ld", k+1, entitypstr[ent-1].alias, in->fname, aline, acol);
02859 print_err(errmsg, __FILE__, __LINE__, __func__);
02860 return 5;
02861 }
02862 }
02863 for (l=0; l<nbce; l++)
02864 {
02865 if (tmp)
02866 delete tmp[l];
02867 delete [] bnid[l];
02868 }
02869 delete [] bnid;
02870 if (tmp)
02871 delete [] tmp;
02872 if (Check_unused_prop && (prop_used == 0))
02873 {
02874
02875 sprintf(errmsg, "Elements with property %ld belonging to entity %s have not been found.\n"
02876 " Element edge boundary condition (line %ld, column %ld, file %s) cannot be assigned correctly.",
02877 prop, entitypstr[ent-1].alias, aline, acol, in->fname);
02878 print_err(errmsg, __FILE__, __LINE__, __func__);
02879 return 6;
02880 }
02881 }
02882 }
02883
02884 return 0;
02885 }
02886
02887
02888
02889
02890
02891
02892
02893
02894
02895
02896
02897
02898
02899
02900
02901
02902
02903
02904
02905
02906
02907
02908
02909
02910
02911
02912
02913
02914
02915 long input_elem_edgebc(XFILE *in, const enumstr elemsects[], long nsect)
02916 {
02917 char *aptr;
02918 long nkwd;
02919 char errmsg[1001];
02920 char *coeff_desc[3] = {"nodal values", "transmission coeff.", "radiation coeff."};
02921 long aline, acol;
02922 gentity ent;
02923 kwd_handling bkwdmode;
02924 long i, j, k, l, m;
02925 entitybocon **tmp;
02926 climatcond *tmpcc;
02927 climatcond2 *tmpcc2;
02928 char *tmpccf;
02929 long appendcc;
02930 answertype *trcc;
02931 list *cclst;
02932
02933 loadelt *tmp2;
02934 long check;
02935 long prop, lcid;
02936 long sres;
02937 long ndof;
02938 long prop_used, err;
02939 bocontypet bc;
02940 long **bnid;
02941 long aux, nbo, nbce;
02942 long minid_nv, minid_trc, minid_trr;
02943 long *entid;
02944 long nentid;
02945
02946 fprintf(stdout, "\n reading of edge boundary conditions applied on elements");
02947
02948
02949 ndof = Tp->ntm;
02950
02951
02952 if (El_loadt == NULL)
02953 {
02954 El_loadt = new loadelt**[Top->ne];
02955 memset(El_loadt, 0, sizeof(*El_loadt)*Top->ne);
02956 El_loadtln = new long *[Top->ne];
02957 memset(El_loadtln, 0, sizeof(*El_loadtln)*Top->ne);
02958 El_loadtcol = new long *[Top->ne];
02959 memset(El_loadtcol, 0, sizeof(*El_loadtcol)*Top->ne);
02960 for(i=0; i<Top->ne; i++)
02961 {
02962 El_loadt[i] = new loadelt*[ndof];
02963 memset(El_loadt[i], 0, sizeof(*El_loadt[i])*ndof);
02964 El_loadtln[i] = new long[ndof];
02965 memset(El_loadtln[i], 0, sizeof(*El_loadtln[i])*ndof);
02966 El_loadtcol[i] = new long[ndof];
02967 memset(El_loadtcol[i], 0, sizeof(*El_loadtcol[i])*ndof);
02968 }
02969 El_nv_lst = new list[ndof];
02970 El_trc_lst = new list[ndof];
02971 El_trr_lst = new list[ndof];
02972 El_cc_lst = new list[ndof];
02973 El_ccf_lst = new list[ndof];
02974 El_trcc_lst = new list[ndof];
02975 El_gcc_lst = new list[ndof];
02976 El_gccf_lst = new list[ndof];
02977 El_gtrcc_lst = new list[ndof];
02978 }
02979
02980 bkwdmode = in->kwdmode;
02981 in->ignorecase = 1;
02982
02983 for (i=nsect-1, ent=gcurve; i>=0; i--, ent--)
02984 {
02985
02986 if (xf_setsec(in, elemsects[i]) == 1)
02987 continue;
02988
02989 in->kwdmode = sect_mode_full;
02990 nkwd = getkwd_sect(in, NULL, aptr, "edge_bc", 1);
02991 in->kwdmode = bkwdmode;
02992
02993 for(j=0; j < nkwd; j++)
02994 {
02995
02996 in->kwdmode = sect_mode_fwd;
02997 getkwd_sect(in, NULL, aptr, "edge_bc", 0);
02998 in->kwdmode = bkwdmode;
02999
03000 aline = in->line;
03001 acol = in->col;
03002 in->kwdmode = sect_mode_seq;
03003
03004 xfscanf(in, "%k%k%ld%k%ld%k%m", "edge_bc", "propid", &prop, "lc_id", &lcid, "bc_type", &bocontype_kwdset, &bc);
03005 if ((lcid < 1) && (lcid > ndof))
03006 {
03007 print_err("load case id is out range <1,%ld>", __FILE__, __LINE__, __func__, ndof);
03008 return 1;
03009 }
03010 lcid--;
03011
03012
03013 if (bc < presc_trmiss)
03014 nbce = 1;
03015 else
03016 nbce = 3;
03017
03018 appendcc = 0;
03019 trcc = NULL;
03020 tmpcc = NULL;
03021 tmpcc2 = NULL;
03022 tmpccf = NULL;
03023 tmp = NULL;
03024 if ((bc == det_climcond) || (bc == gen_climcond))
03025 {
03026 trcc = new answertype;
03027 xfscanf(in, "%k%m", "file_climcond", &answertype_kwdset, trcc);
03028 if (*trcc == no)
03029 {
03030 if (bc == det_climcond)
03031 {
03032 tmpcc = new climatcond;
03033 tmpcc->read(in, 0);
03034 cclst = El_cc_lst+lcid;
03035 }
03036 else
03037 {
03038 tmpcc2 = new climatcond2;
03039 tmpcc2->read(in, 0);
03040 cclst = El_gcc_lst+lcid;
03041 }
03042 }
03043 else
03044 {
03045 tmpccf = new char[in->give_maxlnsize()+1];
03046 xfscanf(in, "%a", &tmpccf);
03047 if (bc == det_climcond)
03048 cclst = El_ccf_lst+lcid;
03049 else
03050 cclst = El_gccf_lst+lcid;
03051 }
03052 appendcc = 1;
03053 }
03054 else
03055 {
03056 tmp = new entitybocon*[nbce];
03057 memset(tmp, 0, sizeof(*tmp)*nbce);
03058
03059 for(k=0; k<nbce; k++)
03060 {
03061 tmp[k] = new entitybocon;
03062
03063 check = tmp[k]->read(in);
03064 switch(check)
03065 {
03066 case 0:
03067 break;
03068 case 1:
03069 print_err("cannot detect coordinates nor time in the expression\n for %s of the given BC",
03070 __FILE__, __LINE__, __func__, coeff_desc[k]);
03071 for(l=0; l<=k; l++)
03072 delete tmp[l];
03073 delete [] tmp;
03074 return 2;
03075 default:
03076 print_err("unknown error of BC reading", __FILE__, __LINE__, __func__);
03077 return 2;
03078 }
03079 }
03080 }
03081
03082 in->kwdmode = bkwdmode;
03083
03084 bnid = new long*[nbce];
03085 memset(bnid, 0, sizeof(*bnid)*nbce);
03086 nbo = 0;
03087 prop_used = 0;
03088
03089 minid_nv = El_nv_lst[lcid].count();
03090 minid_trc = El_trc_lst[lcid].count();
03091 minid_trr = El_trr_lst[lcid].count();
03092
03093
03094 for(k=0; k<Top->ne; k++)
03095 {
03096
03097 if (Top->elements[k].type >= tetrahedronlinear)
03098 continue;
03099
03100 entid = NULL;
03101 nentid = 0;
03102 sres = Top->elements[k].searchprop(prop, ent, Top->nodes, k, Top->edges, Top->surfaces, entid, nentid);
03103 if (sres > 0)
03104 {
03105
03106
03107 aux = get_nbo(Top->elements[k], gcurve);
03108 if (nbo != aux)
03109 {
03110
03111 nbo = aux;
03112 for (l=0; l<nbce; l++)
03113 {
03114 if (bnid[l])
03115 delete [] bnid[l];
03116 bnid[l] = new long[nbo];
03117 }
03118 }
03119
03120
03121 if (El_loadt[k][lcid])
03122 {
03123 if (El_loadtln[k][lcid])
03124 fprintf(Log, "Line %ld, col %ld, file %s: Element %ld has already assigned load at line %ld, col %ld, file: %s\n", aline, acol, in->fname, k+1, El_loadtln[k][lcid], El_loadtcol[k][lcid], in->fname);
03125 else
03126 {
03127 El_loadtln[k][lcid] = aline;
03128 El_loadtcol[k][lcid] = acol;
03129 }
03130 }
03131 else
03132 {
03133 El_loadt[k][lcid] = new loadelt(k, nbo);
03134
03135 El_loadtln[k][lcid] = aline;
03136 El_loadtcol[k][lcid] = acol;
03137 }
03138
03139
03140 for (l=0; l< nbce; l++)
03141 {
03142
03143 if (l==0)
03144 {
03145 if ((bc == det_climcond) || (bc == gen_climcond))
03146 {
03147 if (appendcc)
03148 {
03149 if (bc == det_climcond)
03150 El_trcc_lst[lcid].append(trcc);
03151 else
03152 El_gtrcc_lst[lcid].append(trcc);
03153
03154 if (*trcc == no)
03155 {
03156 if (bc == det_climcond)
03157 {
03158 El_cc_lst[lcid].append(tmpcc);
03159 El_ccf_lst[lcid].append(NULL);
03160 }
03161 else
03162 {
03163 El_gcc_lst[lcid].append(tmpcc2);
03164 El_gccf_lst[lcid].append(NULL);
03165 }
03166 }
03167 else
03168 {
03169 if (bc == det_climcond)
03170 {
03171 El_ccf_lst[lcid].append(tmpccf);
03172 El_cc_lst[lcid].append(NULL);
03173 }
03174 else
03175 {
03176 El_gccf_lst[lcid].append(tmpccf);
03177 El_gcc_lst[lcid].append(NULL);
03178 }
03179 }
03180 appendcc = 0;
03181 }
03182 assemble_bclimcond(Top->elements[k], Top->nodes, prop, *cclst, gcurve, bnid[0], entid, nentid);
03183 }
03184 else
03185 {
03186 err = assemble_bnodvalt(Top->elements[k], Top->nodes, prop, *tmp[0], El_nv_lst[lcid], gcurve, minid_nv, bnid[0], entid, nentid);
03187 if (err)
03188 {
03189 print_err("cannot assemble nodal values for element %ld", __FILE__, __LINE__, __func__, k+1);
03190 for (m=0; m<nbce; m++)
03191 {
03192 delete tmp[m];
03193 delete [] bnid[m];
03194 }
03195 delete [] bnid;
03196 delete [] tmp;
03197 return 3;
03198 }
03199 }
03200 }
03201
03202 if (l==1)
03203 {
03204 err = assemble_bnodvalt(Top->elements[k], Top->nodes, prop, *tmp[1], El_trc_lst[lcid], gcurve, minid_trc, bnid[1], entid, nentid);
03205 if (err)
03206 {
03207 print_err("cannot assemble transmission coefficients for element %ld", __FILE__, __LINE__, __func__, k+1);
03208 for (m=0; m<nbce; m++)
03209 {
03210 delete tmp[m];
03211 delete [] bnid[m];
03212 }
03213 delete [] bnid;
03214 delete [] tmp;
03215 return 3;
03216 }
03217 }
03218
03219 if (l==2)
03220 {
03221 err = assemble_bnodvalt(Top->elements[k], Top->nodes, prop, *tmp[2], El_trr_lst[lcid], gcurve, minid_trr, bnid[2], entid, nentid);
03222 if (err)
03223 {
03224 print_err("cannot assemble radiation coefficients for element %ld", __FILE__, __LINE__, __func__, k+1);
03225 for (m=0; m<nbce; m++)
03226 {
03227 delete tmp[m];
03228 delete [] bnid[m];
03229 }
03230 delete [] bnid;
03231 delete [] tmp;
03232 return 3;
03233 }
03234 }
03235 }
03236
03237
03238 tmp2 = bc2loadelt(k, Top->elements[k], Top->nodes, prop, bc, bnid, gcurve, entid, nentid);
03239 if (tmp2 == NULL)
03240 {
03241 print_err("unknown type of entity or problem is required", __FILE__, __LINE__, __func__);
03242 for (l=0; l<nbce; l++)
03243 {
03244 if (tmp)
03245 delete tmp[l];
03246 delete [] bnid[l];
03247 }
03248 delete [] bnid;
03249 if (tmp)
03250 delete [] tmp;
03251 return 3;
03252 }
03253
03254 check = El_loadt[k][lcid]->merge(*tmp2);
03255 prop_used = 1;
03256 switch(check)
03257 {
03258 case 0:
03259 break;
03260 case 1:
03261
03262 sprintf(errmsg, "Line %ld, col %ld, file %s:\n Element %ld has already had assigned boundary condition"
03263 "with different values at line %ld, col %ld, file: %s\n",
03264 aline, acol, in->fname, k+1, El_loadtln[k][lcid], El_loadtcol[k][lcid], in->fname);
03265 print_err(errmsg, __FILE__, __LINE__, __func__);
03266 for (l=0; l<nbce; l++)
03267 {
03268 if (tmp)
03269 delete tmp[l];
03270 delete [] bnid[l];
03271 }
03272 delete [] bnid;
03273 if (tmp)
03274 delete [] tmp;
03275 delete tmp2;
03276 return 4;
03277 case 2:
03278
03279 sprintf(errmsg, "Line %ld, col %ld, file %s:\n Element %ld has already had assigned different "
03280 "type of boundary condition at line %ld, col %ld, file: %s\n", aline, acol, in->fname,
03281 k+1, El_loadtln[k][lcid], El_loadtcol[k][lcid], in->fname);
03282 print_err(errmsg, __FILE__, __LINE__, __func__);
03283 for (l=0; l<nbce; l++)
03284 {
03285 if (tmp)
03286 delete tmp[l];
03287 delete [] bnid[l];
03288 }
03289 delete [] bnid;
03290 if (tmp)
03291 delete [] tmp;
03292 delete tmp2;
03293 return 4;
03294 default:
03295
03296 sprintf(errmsg, "Line %ld, col %ld, file %s:\n Element %ld has already had assigned boundary condition "
03297 "which cannot be merged at line %ld, col %ld, file: %s\n", aline, acol, in->fname,
03298 k+1, El_loadtln[k][lcid], El_loadtcol[k][lcid], in->fname);
03299 print_err(errmsg, __FILE__, __LINE__, __func__);
03300 for (l=0; l<nbce; l++)
03301 {
03302 if (tmp)
03303 delete tmp[l];
03304 delete [] bnid[l];
03305 }
03306 delete [] bnid;
03307 if (tmp)
03308 delete [] tmp;
03309 delete tmp2;
03310 return 4;
03311 }
03312 delete tmp2;
03313 }
03314 if (sres < 0)
03315 {
03316 sprintf(errmsg, "Element %ld has not read property numbers of %s,\n"
03317 " required property cannot be assigned.\n"
03318 " see input file %s, line %ld, column %ld", k+1, entitypstr[ent-1].alias, in->fname, aline, acol);
03319 print_err(errmsg, __FILE__, __LINE__, __func__);
03320 return 5;
03321 }
03322 }
03323 for (l=0; l<nbce; l++)
03324 {
03325 if (tmp)
03326 delete tmp[l];
03327 delete [] bnid[l];
03328 }
03329 delete [] bnid;
03330 if (tmp)
03331 delete [] tmp;
03332 if (Check_unused_prop && (prop_used == 0))
03333 {
03334
03335 sprintf(errmsg, "Elements with property %ld belonging to entity %s have not been found.\n"
03336 " Element edge boundary condition (line %ld, column %ld, file %s) cannot be assigned correctly.",
03337 prop, entitypstr[ent-1].alias, aline, acol, in->fname);
03338 print_err(errmsg, __FILE__, __LINE__, __func__);
03339 return 6;
03340 }
03341 }
03342 }
03343
03344 return 0;
03345 }
03346
03347
03348
03349
03350
03351
03352
03353
03354
03355
03356
03357
03358
03359
03360
03361
03362
03363
03364
03365
03366
03367
03368
03369
03370
03371
03372
03373
03374
03375 long input_elem_surfbc(XFILE *in, const enumstr elemsects[], long nsect)
03376 {
03377 char *aptr;
03378 long nkwd;
03379 char errmsg[1001];
03380 char *coeff_desc[3] = {"nodal values", "transmission coeff.", "radiation coeff."};
03381 long aline, acol;
03382 gentity ent;
03383 kwd_handling bkwdmode;
03384 long i, j, k, l, m;
03385 entitybocon **tmp;
03386 climatcond *tmpcc;
03387 climatcond2 *tmpcc2;
03388 char *tmpccf;
03389 long appendcc;
03390 answertype *trcc;
03391 list *cclst;
03392
03393 loadelt *tmp2;
03394 long check;
03395 long prop, lcid;
03396 long sres;
03397 long ndof;
03398 long prop_used;
03399 bocontypet bc;
03400 long **bnid;
03401 long aux, nbo, nbce, err;
03402 long minid_nv, minid_trc, minid_trr;
03403 long *entid;
03404 long nentid;
03405
03406 fprintf(stdout, "\n reading of surface boundary conditions applied on elements");
03407
03408
03409 ndof = Tp->ntm;
03410 if (El_loadt == NULL)
03411 {
03412 El_loadt = new loadelt**[Top->ne];
03413 memset(El_loadt, 0, sizeof(*El_loadt)*Top->ne);
03414 El_loadtln = new long *[Top->ne];
03415 memset(El_loadtln, 0, sizeof(*El_loadtln)*Top->ne);
03416 El_loadtcol = new long *[Top->ne];
03417 memset(El_loadtcol, 0, sizeof(*El_loadtcol)*Top->ne);
03418 for(i=0; i<Top->ne; i++)
03419 {
03420 El_loadt[i] = new loadelt*[ndof];
03421 memset(El_loadt[i], 0, sizeof(*El_loadt[i])*ndof);
03422 El_loadtln[i] = new long[ndof];
03423 memset(El_loadtln[i], 0, sizeof(*El_loadtln[i])*ndof);
03424 El_loadtcol[i] = new long[ndof];
03425 memset(El_loadtcol[i], 0, sizeof(*El_loadtcol[i])*ndof);
03426 }
03427 El_nv_lst = new list[ndof];
03428 El_trc_lst = new list[ndof];
03429 El_trr_lst = new list[ndof];
03430 El_cc_lst = new list[ndof];
03431 El_ccf_lst = new list[ndof];
03432 El_trcc_lst = new list[ndof];
03433 El_gcc_lst = new list[ndof];
03434 El_gccf_lst = new list[ndof];
03435 El_gtrcc_lst = new list[ndof];
03436 }
03437
03438 bkwdmode = in->kwdmode;
03439 in->ignorecase = 1;
03440
03441 for (i=nsect-1, ent=gsurface; i>=0; i--, ent--)
03442 {
03443
03444 if (xf_setsec(in, elemsects[i]) == 1)
03445 continue;
03446
03447 in->kwdmode = sect_mode_full;
03448 nkwd = getkwd_sect(in, NULL, aptr, "surf_bc", 1);
03449 in->kwdmode = bkwdmode;
03450
03451 for(j=0; j < nkwd; j++)
03452 {
03453
03454 in->kwdmode = sect_mode_fwd;
03455 getkwd_sect(in, NULL, aptr, "surf_bc", 0);
03456 in->kwdmode = bkwdmode;
03457
03458 aline = in->line;
03459 acol = in->col;
03460 in->kwdmode = sect_mode_seq;
03461
03462 xfscanf(in, "%k%k%ld%k%ld%k%m", "surf_bc", "propid", &prop, "lc_id", &lcid, "bc_type", &bocontype_kwdset, &bc);
03463 if ((lcid < 1) && (lcid > ndof))
03464 {
03465 print_err("load case id is out range <1,%ld>", __FILE__, __LINE__, __func__, ndof);
03466 return 1;
03467 }
03468 lcid--;
03469
03470
03471 if (bc < presc_trmiss)
03472 nbce = 1;
03473 else
03474 nbce = 3;
03475
03476 appendcc = 0;
03477 if ((bc == det_climcond) || (bc == gen_climcond))
03478 {
03479 tmp = NULL;
03480 trcc = new answertype;
03481 xfscanf(in, "%k%m", "file_climcond", &answertype_kwdset, trcc);
03482 if (*trcc == no)
03483 {
03484 if (bc == det_climcond)
03485 {
03486 tmpcc = new climatcond;
03487 tmpcc->read(in, 0);
03488 cclst = &El_cc_lst[lcid];
03489 }
03490 else
03491 {
03492 tmpcc2 = new climatcond2;
03493 tmpcc2->read(in, 0);
03494 cclst = &El_gcc_lst[lcid];
03495 }
03496 }
03497 else
03498 {
03499 tmpccf = new char[in->give_maxlnsize()];
03500 xfscanf(in, "%a", &tmpccf);
03501 if (bc == det_climcond)
03502 cclst = El_ccf_lst+lcid;
03503 else
03504 cclst = El_gccf_lst+lcid;
03505 }
03506 appendcc = 1;
03507 }
03508 else
03509 {
03510 tmp = new entitybocon*[nbce];
03511 memset(tmp, 0, sizeof(*tmp)*nbce);
03512
03513 for(k=0; k<nbce; k++)
03514 {
03515 tmp[k] = new entitybocon;
03516
03517 check = tmp[k]->read(in);
03518 switch(check)
03519 {
03520 case 0:
03521 break;
03522 case 1:
03523 print_err("cannot detect coordinates nor time in the expression\n for %s of the given BC",
03524 __FILE__, __LINE__, __func__, coeff_desc[k]);
03525 for(l=0; l<=k; l++)
03526 delete tmp[l];
03527 delete [] tmp;
03528 return 2;
03529 default:
03530 print_err("unknown error of BC reading", __FILE__, __LINE__, __func__);
03531 return 2;
03532 }
03533 }
03534 }
03535
03536 in->kwdmode = bkwdmode;
03537
03538 bnid = new long*[nbce];
03539 memset(bnid, 0, sizeof(*bnid)*nbce);
03540 nbo = 0;
03541 prop_used = 0;
03542
03543 minid_nv = El_nv_lst[lcid].count();
03544 minid_trc = El_trc_lst[lcid].count();
03545 minid_trr = El_trr_lst[lcid].count();
03546
03547
03548 for(k=0; k<Top->ne; k++)
03549 {
03550
03551 if (Top->elements[k].type < tetrahedronlinear)
03552 continue;
03553
03554 entid = NULL;
03555 nentid = 0;
03556 sres = Top->elements[k].searchprop(prop, ent, Top->nodes, k, Top->edges, Top->surfaces, entid, nentid);
03557 if (sres > 0)
03558 {
03559
03560
03561
03562
03563 aux = get_nbo(Top->elements[k], gsurface);
03564 if (nbo != aux)
03565 {
03566
03567 nbo = aux;
03568 for (l=0; l<nbce; l++)
03569 {
03570 if (bnid[l])
03571 delete [] bnid[l];
03572 bnid[l] = new long[nbo];
03573 }
03574 }
03575
03576 if (El_loadt[k][lcid])
03577 {
03578 if (El_loadtln[k][lcid])
03579 fprintf(Log, "Line %ld, col %ld, file %s: Element %ld has already assigned load at line %ld, col %ld, file: %s\n", aline, acol, in->fname, k+1, El_loadtln[k][lcid], El_loadtcol[k][lcid], in->fname);
03580 else
03581 {
03582 El_loadtln[k][lcid] = aline;
03583 El_loadtcol[k][lcid] = acol;
03584 }
03585 }
03586 else
03587 {
03588 El_loadt[k][lcid] = new loadelt(k, nbo);
03589
03590 El_loadtln[k][lcid] = aline;
03591 El_loadtcol[k][lcid] = acol;
03592 }
03593
03594
03595 for (l=0; l<nbce; l++)
03596 {
03597
03598 if (l==0)
03599 {
03600 if ((bc == det_climcond) || (bc == gen_climcond))
03601 {
03602 if (appendcc)
03603 {
03604 if (bc == det_climcond)
03605 El_trcc_lst[lcid].append(trcc);
03606 else
03607 El_gtrcc_lst[lcid].append(trcc);
03608
03609 if (*trcc == no)
03610 {
03611
03612 if (bc == det_climcond)
03613 {
03614 El_cc_lst[lcid].append(tmpcc);
03615 El_ccf_lst[lcid].append(NULL);
03616 }
03617 else
03618 {
03619 El_gcc_lst[lcid].append(tmpcc2);
03620 El_gccf_lst[lcid].append(NULL);
03621 }
03622 }
03623 else
03624 {
03625 if (bc == det_climcond)
03626 {
03627 El_ccf_lst[lcid].append(tmpccf);
03628 El_cc_lst[lcid].append(NULL);
03629 }
03630 else
03631 {
03632 El_gccf_lst[lcid].append(tmpccf);
03633 El_gcc_lst[lcid].append(NULL);
03634 }
03635 }
03636 appendcc = 0;
03637 }
03638 assemble_bclimcond(Top->elements[k], Top->nodes, prop, *cclst, gsurface, bnid[0], entid, nentid);
03639 }
03640 else
03641 {
03642 err = assemble_bnodvalt(Top->elements[k], Top->nodes, prop, *tmp[0], El_nv_lst[lcid], gsurface, minid_nv, bnid[0], entid, nentid);
03643 if (err)
03644 {
03645 print_err("cannot assemble nodal values for element %ld", __FILE__, __LINE__, __func__, k+1);
03646 for (m=0; m<nbce; m++)
03647 {
03648 delete tmp[m];
03649 delete [] bnid[m];
03650 }
03651 delete [] bnid;
03652 delete [] tmp;
03653 return 3;
03654 }
03655 }
03656 }
03657
03658 if (l==1)
03659 {
03660 err = assemble_bnodvalt(Top->elements[k], Top->nodes, prop, *tmp[1], El_trc_lst[lcid], gsurface, minid_trc, bnid[1], entid, nentid);
03661 if (err)
03662 {
03663 print_err("cannot assemble transmission coefficients for element %ld", __FILE__, __LINE__, __func__, k+1);
03664 for (m=0; m<nbce; m++)
03665 {
03666 delete tmp[m];
03667 delete [] bnid[m];
03668 }
03669 delete [] bnid;
03670 delete [] tmp;
03671 return 3;
03672 }
03673 }
03674
03675 if (l==2)
03676 {
03677 err = assemble_bnodvalt(Top->elements[k], Top->nodes, prop, *tmp[2], El_trr_lst[lcid], gsurface, minid_trr, bnid[2], entid, nentid);
03678 if (err)
03679 {
03680 print_err("cannot assemble radiation coefficients for element %ld", __FILE__, __LINE__, __func__, k+1);
03681 for (m=0; m<nbce; m++)
03682 {
03683 delete tmp[m];
03684 delete [] bnid[m];
03685 }
03686 delete [] bnid;
03687 delete [] tmp;
03688 return 3;
03689 }
03690 }
03691 }
03692
03693 tmp2 = bc2loadelt(k, Top->elements[k], Top->nodes, prop, bc, bnid, gsurface, entid, nentid);
03694 if (tmp2 == NULL)
03695 {
03696 print_err("unknown type of entity or problem is required", __FILE__, __LINE__, __func__);
03697 for (l=0; l<nbce; l++)
03698 {
03699 if (tmp)
03700 delete tmp[l];
03701 delete [] bnid[l];
03702 }
03703 delete [] bnid;
03704 if (tmp)
03705 delete [] tmp;
03706 return 3;
03707 }
03708
03709 check = El_loadt[k][lcid]->merge(*tmp2);
03710 prop_used = 1;
03711 switch(check)
03712 {
03713 case 0:
03714 break;
03715 case 1:
03716
03717 sprintf(errmsg, "Line %ld, col %ld, file %s:\n Element %ld has already had assigned boundary condition"
03718 "with different values at line %ld, col %ld, file: %s\n",
03719 aline, acol, in->fname, k+1, El_loadtln[k][lcid], El_loadtcol[k][lcid], in->fname);
03720 print_err(errmsg, __FILE__, __LINE__, __func__);
03721 for (l=0; l<nbce; l++)
03722 {
03723 if (tmp)
03724 delete tmp[l];
03725 delete [] bnid[l];
03726 }
03727 delete [] bnid;
03728 if (tmp)
03729 delete [] tmp;
03730 delete tmp2;
03731 return 4;
03732 case 2:
03733
03734 sprintf(errmsg, "Line %ld, col %ld, file %s:\n Element %ld has already had assigned different "
03735 "type of boundary condition at line %ld, col %ld, file: %s\n", aline, acol, in->fname,
03736 k+1, El_loadtln[k][lcid], El_loadtcol[k][lcid], in->fname);
03737 print_err(errmsg, __FILE__, __LINE__, __func__);
03738 for (l=0; l<nbce; l++)
03739 {
03740 if (tmp)
03741 delete tmp[l];
03742 delete [] bnid[l];
03743 }
03744 delete [] bnid;
03745 if (tmp)
03746 delete [] tmp;
03747 delete tmp2;
03748 return 4;
03749 default:
03750
03751 sprintf(errmsg, "Line %ld, col %ld, file %s:\n Element %ld has already had assigned boundary condition "
03752 "which cannot be merged at line %ld, col %ld, file: %s\n", aline, acol, in->fname,
03753 k+1, El_loadtln[k][lcid], El_loadtcol[k][lcid], in->fname);
03754 print_err(errmsg, __FILE__, __LINE__, __func__);
03755 for (l=0; l<nbce; l++)
03756 {
03757 if (tmp)
03758 delete tmp[l];
03759 delete [] bnid[l];
03760 }
03761 delete [] bnid;
03762 if (tmp)
03763 delete [] tmp;
03764 delete tmp2;
03765 return 4;
03766 }
03767 delete tmp2;
03768 }
03769 if (sres < 0)
03770 {
03771 sprintf(errmsg, "Element %ld has not read property numbers of %s,\n"
03772 " required property cannot be assigned.\n"
03773 " see input file %s, line %ld, column %ld", k+1, entitypstr[ent-1].alias, in->fname, aline, acol);
03774 print_err(errmsg, __FILE__, __LINE__, __func__);
03775 return 5;
03776 }
03777 }
03778 for (l=0; l<nbce; l++)
03779 {
03780 if (tmp)
03781 delete tmp[l];
03782 delete [] bnid[l];
03783 }
03784 delete [] bnid;
03785 if (tmp)
03786 delete [] tmp;
03787 if (Check_unused_prop && (prop_used == 0))
03788 {
03789
03790 sprintf(errmsg, "Elements with property %ld belonging to entity %s have not been found.\n"
03791 " Element surface boundary condition (line %ld, column %ld, file %s) cannot be assigned correctly.",
03792 prop, entitypstr[ent-1].alias, aline, acol, in->fname);
03793 print_err(errmsg, __FILE__, __LINE__, __func__);
03794 return 6;
03795 }
03796 }
03797 }
03798
03799 return 0;
03800 }
03801
03802
03803
03804
03805
03806
03807
03808
03809
03810
03811
03812
03813
03814
03815
03816
03817
03818
03819
03820
03821
03822
03823
03824
03825
03826 long input_elem_eltimefunct(XFILE *in, const enumstr elemsects[], long nsect)
03827 {
03828 char *aptr;
03829 long nkwd;
03830 char errmsg[1001];
03831 long *line;
03832 long *col;
03833 long aline, acol;
03834 gentity ent;
03835 kwd_handling bkwdmode;
03836 long tf_id, prop;
03837 long i, j, k;
03838 long sres;
03839 long prop_used;
03840 long *entid;
03841 long nentid;
03842
03843 El_tfunc = new long[Top->ne];
03844 memset(El_tfunc, 0, sizeof(*El_tfunc)*Top->ne);
03845 line = new long[Top->ne];
03846 memset(line, 0, sizeof(*line)*Top->ne);
03847 col = new long[Top->ne];
03848 memset(col, 0, sizeof(*col)*Top->ne);
03849
03850 bkwdmode = in->kwdmode;
03851 in->ignorecase = 1;
03852
03853 fprintf(stdout, "\n reading of dof time functions at nodes");
03854
03855 for (i=nsect-1, ent=gregion; i>=0; i--, ent--)
03856 {
03857
03858 if (xf_setsec(in, elemsects[i]) == 1)
03859 continue;
03860
03861 in->kwdmode = sect_mode_full;
03862 nkwd = getkwd_sect(in, NULL, aptr, "el_tfunc", 1);
03863 in->kwdmode = bkwdmode;
03864
03865 for(j=0; j < nkwd; j++)
03866 {
03867
03868 in->kwdmode = sect_mode_fwd;
03869 getkwd_sect(in, NULL, aptr, "el_tfunc", 0);
03870 in->kwdmode = bkwdmode;
03871
03872 aline = in->line;
03873 acol = in->col;
03874 in->kwdmode = sect_mode_seq;
03875
03876 xfscanf(in, "%k%k%ld", "el_tfunc", "propid", &prop);
03877 xfscanf(in, "%k%ld", "tfunc_id", &tf_id);
03878 if ((tf_id <= 0) || (tf_id > Gtt->ngf))
03879 {
03880 sprintf(errmsg, "Line %ld, col %ld, file %s:\n Time function index has to be in range <1,%ld>"
03881 "time function at line %ld, col %ld, file: %s\n", aline, acol, in->fname, Gtt->ngf,
03882 line[k], col[k], in->fname);
03883 print_err(errmsg, __FILE__, __LINE__, __func__);
03884 delete [] line;
03885 delete [] col;
03886 return 3;
03887 }
03888
03889 in->kwdmode = bkwdmode;
03890
03891 prop_used = 0;
03892
03893 for(k=0; k<Top->ne; k++)
03894 {
03895 entid = NULL;
03896 nentid = 0;
03897 sres = Top->elements[k].searchprop(prop, ent, Top->nodes, k, Top->edges, Top->surfaces, entid, nentid);
03898 if (sres > 0)
03899 {
03900 if (El_tfunc[k] && (El_tfunc[k]!=tf_id))
03901 {
03902 sprintf(errmsg, "Line %ld, col %ld, file %s:\n Element %ld has already had assigned different"
03903 "time function at line %ld, col %ld, file: %s\n", aline, acol, in->fname,
03904 k+1, line[k], col[k], in->fname);
03905 print_err(errmsg, __FILE__, __LINE__, __func__);
03906 delete [] line;
03907 delete [] col;
03908 return 1;
03909 }
03910 else
03911 {
03912 El_tfunc[k] = tf_id;
03913 prop_used = 1;
03914
03915 line[k] = aline;
03916 col[k] = acol;
03917 }
03918 }
03919 if (sres < 0)
03920 {
03921 sprintf(errmsg, "Element %ld has not read property numbers of %s,\n"
03922 " required property cannot be assigned.\n"
03923 " see input file %s, line %ld, column %ld", k+1, entitypstr[ent-1].alias, in->fname, aline, acol);
03924 print_err(errmsg, __FILE__, __LINE__, __func__);
03925 delete [] line;
03926 delete [] col;
03927 return 2;
03928 }
03929 }
03930 if (Check_unused_prop && (prop_used == 0))
03931 {
03932
03933 sprintf(errmsg, "Elements with property %ld belonging to entity %s have not been found.\n"
03934 " Element time function (line %ld, column %ld, file %s) cannot be assigned correctly.",
03935 prop, entitypstr[ent-1].alias, aline, acol, in->fname);
03936 print_err(errmsg, __FILE__, __LINE__, __func__);
03937 delete [] line;
03938 delete [] col;
03939 return 4;
03940 }
03941 }
03942 }
03943
03944
03945 if ((Tp->tprob == growing_np_problem) || (Tp->tprob == growing_np_problem_nonlin))
03946 {
03947 for (i=0; i< Top->ne; i++)
03948 {
03949 if (El_tfunc[i] < 1)
03950 {
03951 sprintf(errmsg, "Element %ld has not assigned a time function.\n"
03952 "All elements have to have assigned some time function\n"
03953 "in case of growing transport problem", i+1);
03954 print_err(errmsg, __FILE__, __LINE__, __func__);
03955 delete [] line;
03956 delete [] col;
03957 return 3;
03958 }
03959 }
03960 }
03961 delete [] line;
03962 delete [] col;
03963 return 0;
03964 }
03965
03966
03967
03968
03969
03970
03971
03972
03973 const gentity operator --(gentity &a, int)
03974 {
03975 gentity old;
03976 switch (a)
03977 {
03978 case gvertex:
03979 old = a;
03980 a = gregion;
03981 return old;
03982 case gcurve:
03983 old = a;
03984 a = gvertex;
03985 return old;
03986 case gsurface:
03987 old = a;
03988 a = gcurve;
03989 return old;
03990 case gregion:
03991 old = a;
03992 a = gsurface;
03993 return old;
03994 default:
03995 print_err("decreasing of invalid gentity value is required", __FILE__, __LINE__, __func__);
03996 }
03997 return gentity(0);
03998 }
03999
04000
04001
04002
04003
04004
04005
04006
04007
04008
04009
04010
04011
04012
04013
04014
04015
04016
04017
04018
04019
04020
04021
04022
04023
04024
04025 long assemble_bnodvalt(selement &el, snode *nodes, long prop, entitybocon &ebc, list &bnvl, gentity ent,
04026 long minid, long *bnid, long *entid, long nentid)
04027 {
04028 long i, j, l, nbo, nnbo, *propent, **entnodes;
04029 bnodvalt *tmp;
04030 long err, rm_ent = 0;
04031
04032 switch (ent)
04033 {
04034 case gvertex:
04035 nbo = el.nne;
04036 nnbo = 1;
04037 rm_ent = 1;
04038 propent = new long[nbo];
04039 el.searchnodprop(prop, ent, nodes, NULL, NULL, propent);
04040 entnodes = new long*[nbo];
04041 for (i=0; i<el.nne; i++)
04042 {
04043 entnodes[i] = new long[1];
04044 entnodes[i][0] = i;
04045 }
04046 break;
04047 case gcurve:
04048 nbo = el.ned;
04049 if (nbo == 1)
04050 {
04051 nbo = 2;
04052 nnbo = 1;
04053 rm_ent = 1;
04054 propent = new long[nbo];
04055
04056 propent[0] = prop;
04057 propent[1] = prop;
04058 entnodes = new long*;
04059 entnodes[0] = new long[nbo];
04060
04061 entnodes[0][0] = el.nodes[0];
04062 entnodes[0][1] = el.nodes[el.nne];
04063 }
04064 else
04065 {
04066 nnbo = el.nned[0];
04067 propent = el.propedg;
04068 entnodes = el.edgenod;
04069 }
04070 break;
04071 case gsurface:
04072 nbo = el.nsurf;
04073 nnbo = el.nnsurf[0];
04074 propent = el.propsurf;
04075 entnodes = el.surfnod;
04076 break;
04077 default:
04078 print_err("unknown boundary object is required", __FILE__, __LINE__, __func__);
04079 abort();
04080 }
04081 if ((propent == NULL) && (entid == NULL))
04082 {
04083 print_err("boundary properties of elements are not read", __FILE__, __LINE__, __func__);
04084 abort();
04085 }
04086
04087 for (i=0; i<nbo; i++)
04088 bnid[i] = -1;
04089
04090 if (propent)
04091 {
04092 for (i=0; i<nbo; i++)
04093 {
04094 if (propent[i] != prop)
04095 continue;
04096
04097 if (ebc.dc == 0)
04098 {
04099
04100 for (j=minid; j<bnvl.count(); j++)
04101 {
04102 tmp = (bnodvalt *)(bnvl.at(j));
04103 if (tmp->nsc == nnbo)
04104 {
04105
04106 bnid[i] = j;
04107 break;
04108 }
04109 }
04110 if (bnid[i] >= 0)
04111 continue;
04112 }
04113 if (ebc.dc || bnid[i] < 0)
04114
04115
04116
04117 {
04118 tmp = new bnodvalt;
04119 tmp->nsc = nnbo;
04120 tmp->nodval = new gfunct[nnbo];
04121 for (j=0; j<nnbo; j++)
04122 {
04123 err = ebc.getval(nodes[el.nodes[entnodes[i][j]]], tmp->nodval[j]);
04124 if (err)
04125 return 1;
04126 }
04127 bnvl.append(tmp);
04128 bnid[i] = bnvl.count()-1;
04129 }
04130 }
04131 }
04132
04133 if (entid)
04134 {
04135
04136 l = 0;
04137 for (i=0; i<nbo; i++)
04138 {
04139 if (i != entid[l])
04140 continue;
04141
04142 if (ebc.dc == 0)
04143 {
04144
04145 for (j=minid; j<bnvl.count(); j++)
04146 {
04147 tmp = (bnodvalt *)(bnvl.at(j));
04148 if (tmp->nsc == nnbo)
04149 {
04150
04151 bnid[i] = j;
04152 break;
04153 }
04154 }
04155 }
04156 if (ebc.dc || bnid[i] < 0)
04157
04158
04159
04160 {
04161 tmp = new bnodvalt;
04162 tmp->nsc = nnbo;
04163 tmp->nodval = new gfunct[nnbo];
04164 for (j=0; j<nnbo; j++)
04165 {
04166 err = ebc.getval(nodes[el.nodes[entnodes[i][j]]], tmp->nodval[j]);
04167 if (err)
04168 return 1;
04169 }
04170 bnvl.append(tmp);
04171 bnid[i] = bnvl.count()-1;
04172 }
04173 if (l < nentid-1)
04174 l++;
04175 else
04176 break;
04177 }
04178 }
04179
04180 if (rm_ent)
04181 {
04182 delete [] propent;
04183 if (ent == gvertex)
04184 {
04185 for(i=0; i<nbo; i++)
04186 delete [] entnodes[i];
04187 delete [] entnodes;
04188 }
04189 else
04190 {
04191 delete [] entnodes[0];
04192 delete entnodes;
04193 }
04194 }
04195 return 0;
04196 }
04197
04198
04199
04200
04201
04202
04203
04204
04205
04206
04207
04208
04209
04210
04211
04212
04213
04214
04215
04216
04217
04218 void assemble_bclimcond(selement &el, snode *nodes, long prop, list &bclimc, gentity ent,
04219 long *bnid, long *entid, long nentid)
04220 {
04221 long i, l, nbo, *propent;
04222 long rm_ent = 0;
04223
04224 switch (ent)
04225 {
04226 case gvertex:
04227 nbo = el.nne;
04228 rm_ent = 1;
04229 propent = new long[nbo];
04230 el.searchnodprop(prop, ent, nodes, NULL, NULL, propent);
04231 break;
04232 case gcurve:
04233 nbo = el.ned;
04234 if (nbo == 1)
04235 {
04236 nbo = 2;
04237 rm_ent = 1;
04238 propent = new long[nbo];
04239
04240 propent[0] = prop;
04241 propent[1] = prop;
04242 }
04243 else
04244 {
04245 propent = el.propedg;
04246 }
04247 break;
04248 case gsurface:
04249 nbo = el.nsurf;
04250 propent = el.propsurf;
04251 break;
04252 default:
04253 print_err("unknown boundary object is required", __FILE__, __LINE__, __func__);
04254 abort();
04255 }
04256 if ((propent == NULL) && (entid == NULL))
04257 {
04258 print_err("boundary properties of elements are not read", __FILE__, __LINE__, __func__);
04259 abort();
04260 }
04261
04262 for (i=0; i<nbo; i++)
04263 bnid[i] = -1;
04264
04265 if (propent)
04266 {
04267 for (i=0; i<nbo; i++)
04268 {
04269 if (propent[i] != prop)
04270 continue;
04271 else
04272 bnid[i] = bclimc.count()-1;
04273 }
04274 }
04275
04276 if (entid)
04277 {
04278
04279 l = 0;
04280 for (i=0; i<nbo; i++)
04281 {
04282 if (i != entid[l])
04283 continue;
04284 else
04285 bnid[i] = bclimc.count()-1;
04286
04287 if (l < nentid-1)
04288 l++;
04289 else
04290 break;
04291 }
04292 }
04293
04294 if (rm_ent)
04295 delete [] propent;
04296
04297 return;
04298 }
04299
04300
04301
04302
04303
04304
04305
04306
04307
04308
04309
04310
04311
04312
04313
04314
04315
04316
04317
04318
04319
04320
04321
04322 loadelt *bc2loadelt(long eid, selement &el, snode *nodes, long prop, bocontypet bc, long **bnid, gentity ent, long *entid, long nentid)
04323 {
04324 long i, l, nbo, nnbo;
04325 loadelt *ret = NULL;
04326 long *propent, rm_propent;
04327
04328 if ((Tp->tprob == growing_np_problem) || (Tp->tprob == growing_np_problem_nonlin))
04329 return NULL;
04330
04331
04332
04333 rm_propent = 0;
04334
04335 switch (ent)
04336 {
04337 case gvertex:
04338 nbo = el.nne;
04339 nnbo = 1;
04340 rm_propent = 1;
04341 propent = new long[nbo];
04342 el.searchnodprop(prop, ent, nodes, NULL, NULL, propent);
04343 break;
04344 case gcurve:
04345 nbo = el.ned;
04346 if (nbo == 1)
04347 {
04348 nbo = 2;
04349 nnbo = 1;
04350 propent = new long[nbo];
04351 rm_propent = 1;
04352 for(i=0; i<nbo; i++)
04353 {
04354
04355 propent[i] = prop;
04356 }
04357 }
04358 else
04359 {
04360 nnbo = el.nned[0];
04361 propent = el.propedg;
04362 }
04363 break;
04364 case gsurface:
04365 nbo = el.nsurf;
04366 nnbo = el.nnsurf[0];
04367 propent = el.propsurf;
04368 break;
04369 default:
04370 return NULL;
04371 }
04372
04373 if ((propent == NULL) && (entid == NULL))
04374 return NULL;
04375
04376 ret = new loadelt;
04377 ret->eid = eid;
04378 ret->nbo = nbo;
04379 ret->nnbo = nnbo;
04380
04381
04382 ret->bc = new bocontypet[nbo];
04383 memset(ret->bc, 0, sizeof(*ret->bc)*nbo);
04384
04385 ret->nvid = new long[nbo];
04386
04387 ret->trcid = new long[nbo];
04388
04389 ret->trrid = new long[nbo];
04390
04391 for(i=0; i<nbo; i++)
04392 ret->nvid[i] = ret->trcid[i] = ret->trrid[i] = -1;
04393
04394 if (propent)
04395 {
04396 for(i=0; i<nbo; i++)
04397 {
04398 if (propent[i] == prop)
04399 {
04400 ret->bc[i] = bc;
04401 ret->nvid[i] = bnid[0][i];
04402 if (bc >= presc_trmiss)
04403 {
04404 ret->trcid[i] = bnid[1][i];
04405 ret->trrid[i] = bnid[2][i];
04406 }
04407 }
04408 }
04409 }
04410
04411 if (entid)
04412 {
04413
04414 l = 0;
04415 for(i=0; i<nbo; i++)
04416 {
04417 if (i != entid[l])
04418 continue;
04419
04420 ret->bc[i] = bc;
04421 ret->nvid[i] = bnid[0][i];
04422 if (bc >= presc_trmiss)
04423 {
04424 ret->trcid[i] = bnid[1][i];
04425 ret->trrid[i] = bnid[2][i];
04426 }
04427 if (l < nentid-1)
04428 l++;
04429 else
04430 break;
04431 }
04432 }
04433
04434 if (rm_propent)
04435 delete [] propent;
04436
04437 return ret;
04438 }
04439
04440
04441
04442
04443
04444
04445
04446
04447
04448
04449
04450
04451
04452
04453 long get_nbo(selement &el, gentity ent)
04454 {
04455 long nbo=-1;
04456
04457 switch (ent)
04458 {
04459 case gvertex:
04460 nbo = el.nne;
04461 break;
04462 case gcurve:
04463 nbo = el.ned;
04464 if (nbo == 1)
04465 nbo = 2;
04466 break;
04467 case gsurface:
04468 nbo = el.nsurf;
04469 break;
04470 default:
04471 break;
04472 }
04473 return nbo;
04474 }