00001 #include <stdio.h>
00002 #include <stdlib.h>
00003
00004 #include "metrinit.h"
00005
00006 #include "globalc.h"
00007 #include "globmatc.h"
00008 #include "fcsolver.h"
00009 #include "gtopology.h"
00010
00011 #include "seqfilesm.h"
00012 #include "seqfilest.h"
00013
00014 #include "iotools.h"
00015 #include "xfile.h"
00016 #include "outdriverc.h"
00017 #include "stacktrace.h"
00018 #include "libtrace.h"
00019
00020
00021 void metr_init (int argc, const char *argv[])
00022 {
00023 long i,merr,n;
00024 XFILE *in,*inm,*intr;
00025
00026 set_prgname(argv[0]);
00027 fprintf (stderr,"\n\n ******************************************************\n");
00028
00029
00030 if (Bar2d==NULL) Bar2d = new barel2d;
00031 if (Beam2d==NULL) Bar2d = new barel2d;
00032 if (Pelq==NULL) Pelq = new planeelemlq;
00033 if (Peqq==NULL) Peqq = new planeelemqq;
00034 if (Asymlq==NULL) Asymlq = new axisymlq;
00035 if (Lhex==NULL) Lhex = new linhex;
00036
00037 if (Ltet==NULL) Ltet = new lintet;
00038 if (Bar3d==NULL) Bar3d = new barel3d;
00039
00040
00041 Cp = new probdescc;
00042
00043 if (process_argsc(argc, argv)){
00044 delete Cp;
00045 abort();
00046 }
00047
00048
00049 Mp = new probdesc;
00050
00051 Tp = new probdesct;
00052
00053 Gtm = new gtopology;
00054
00055 Gtt = new gtopology;
00056
00057 Gtu = new gtopology;
00058
00059 Mt = new mechtop;
00060
00061 Tt = new transtop;
00062
00063 Ct = new couptop;
00064
00065 Mm = new mechmat;
00066
00067 Tm = new transmat;
00068
00069 Cmu = new coupmatu;
00070
00071 Cml = new coupmatl;
00072
00073 Mc = new mechcrsec;
00074
00075 Tc = new transcrsec;
00076
00077 Cb = new coupbclc;
00078
00079 Mb = new mechbclc;
00080
00081 Tb = new transbclc;
00082
00083 Outdm = new outdriverm;
00084 Outdt = new outdrivert;
00085 Outdc = new outdriverc;
00086
00087 in = xfopen(argv[1],"r");
00088 if (in==NULL){
00089 print_err("input file cannot be opened.", __FILE__, __LINE__, __func__);
00090 abort ();
00091 }
00092 in->warning = 1;
00093 in->ignorecase = 1;
00094 if ((Cp->kwdsw == nokwd) || (Cp->kwdsw == kwd_outd))
00095 in->kwdmode = ignore;
00096 else
00097 in->kwdmode = sequent_mode;
00098
00099
00100 Cp->read (in);
00101
00102
00103 inm = xfopen(Cp->minfile,"r");
00104 if (inm==NULL){
00105 print_err ("input file for mechanical part cannot be opened.", __FILE__, __LINE__, __func__);
00106 abort ();
00107 }
00108
00109
00110 intr = xfopen(Cp->tinfile,"r");
00111 if (intr==NULL){
00112 print_err ("input file for thermo-hydro part cannot be opened.",__FILE__, __LINE__, __func__);
00113 abort ();
00114 }
00115
00116 inm->warning = 1;
00117 inm->ignorecase = 1;
00118 if ((Mp->kwdsw == nokwd) || (Mp->kwdsw == kwd_outd))
00119 inm->kwdmode = ignore;
00120 else
00121 inm->kwdmode = sequent_mode;
00122
00123 intr->warning = 1;
00124 intr->ignorecase = 1;
00125 if ((Tp->kwdsw == nokwd) || (Tp->kwdsw == kwd_outd))
00126 intr->kwdmode = ignore;
00127 else
00128 intr->kwdmode = sequent_mode;
00129
00130
00131 Mp->read (inm);
00132 Tp->read (intr);
00133
00134 if ((Cp->tprob==growing_par_coupl_mech_trans) || (Cp->tprob==par_coupl_mech_trans)){
00135
00136 Cp->time=Cp->timecon.starttime ();
00137 Tp->time=Tp->timecont.starttime ();
00138 Mp->time=Mp->timecon.starttime ();
00139 }
00140
00141
00142 Outc = fopen ("metr.log","wt");
00143 Out = fopen ("mefel.log","wt");
00144 Outt = fopen ("trfel.log","wt");
00145
00146 if (Mp->kwdsw == kwd_full)
00147 inm->kwdmode = sequent_mode;
00148 else
00149 inm->kwdmode = ignore;
00150
00151 if (Tp->kwdsw == kwd_full)
00152 intr->kwdmode = sequent_mode;
00153 else
00154 intr->kwdmode = ignore;
00155
00156 if (Cp->kwdsw == kwd_full)
00157 in->kwdmode = sequent_mode;
00158 else
00159 in->kwdmode = ignore;
00160
00161
00162 Mt->read (inm);
00163 Tt->read (intr);
00164 Ct->read (in);
00165
00166
00167
00168 if (Mp->tprob == growing_mech_structure){
00169 if (Mespr==1){
00170 merr=Mt->mesh_check();
00171 if (merr > 0){
00172 fprintf (stdout,"MEFEL Mesh error = %ld\n\n\n",merr);
00173 exit(0);
00174 }
00175 }
00176 }
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188
00189
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204 if (Cp->tprob==fully_coupled_mech_trans){
00205
00206 Gtu->comptop (Gtm,Gtt);
00207
00208
00209
00210
00211
00212 Gtu->lneso_init ();
00213 }
00214
00215
00216 Ndofm = Gtm->codenum_generation (Out);
00217 if (Mesprc==1)
00218 fprintf (stdout,"\n number of degrees of freedom in mechanics %ld",Ndofm);
00219
00220
00221
00222 Ndoft = Gtt->codenum_generation (Outt);
00223 if (Mesprc==1)
00224 fprintf (stdout,"\n number of degrees of freedom in transports %ld",Ndoft);
00225
00226 if (Cp->tprob==fully_coupled_mech_trans){
00227
00228 Ndofc = Gtu->codenum_generation (Outc);
00229
00230 Gtu->cndistr (Gtm,Gtt);
00231
00232 Ndofm=Ndofc;
00233 Ndoft=Ndofc;
00234
00235 if (Mesprc==1)
00236 fprintf (stdout,"\n total number of degrees of freedom %ld",Ndofc);
00237 }
00238
00239
00240 if (Tp->tprob == growing_np_problem || Tp->tprob == growing_np_problem_nonlin){
00241 Gtt->read_gf (intr);
00242 }
00243
00244
00245 Mm->read (inm);
00246 Tm->read (intr);
00247
00248
00249 Tm->intpointalloc ();
00250 Tm->intpointinit ();
00251 Tm->assemble_dof_nameord(Tp->dofname, Tp->ntm, Tp->var_dofid, Tp->tnkv);
00252
00253
00254 Mm->init_ip_1 ();
00255
00256 if (Cp->tprob==fully_coupled_mech_trans){
00257
00258
00259 Cmu->read (in);
00260 Cml->read (in);
00261 }
00262
00263
00264 Mc->read (inm);
00265 Tc->read (intr);
00266
00267
00268 Mb->read (inm);
00269 Tb->read (intr);
00270
00271
00272 if (Mp->tprob == growing_mech_structure){
00273 Gtm->read_gf (inm);
00274 Mt->alloc_growstr ();
00275 }
00276
00277
00278
00279
00280 Tb->elemsource ();
00281
00282
00283
00284 n = Mm->search_reqnmq(Mm->nmqo);
00285 if (n){
00286 for (i=0; i<n; i++)
00287 Mm->nmqid[Mm->nmqo[i]-1] = i;
00288
00289 Mm->alloc_nonmechq(n);
00290 }
00291
00292 n = Tm->search_reqntq(Tm->ntqo);
00293 if (n){
00294 for (i=0; i<n; i++)
00295 Tm->ntqid[Tm->ntqo[i]-1] = i;
00296
00297 Tm->alloc_nontransq(n);
00298 }
00299
00300
00301 TM_ip = new long[Tm->tnip];
00302 MT_ip = new long[Mm->tnip];
00303 mefel_trfel_ip_mapping(TM_ip, MT_ip);
00304
00305 if (Cp->tprob==fully_coupled_mech_trans){
00306 if (Mp->pore_press)
00307 Mp->pore_press = 3;
00308
00309
00310 Lsrsc = new lhsrhsc;
00311 Lsrsc->alloc ();
00312
00313
00314 Lsrs = new lhsrhs;
00315 Lsrs->lhsi=Lsrsc->lhsi;
00316 Lsrs->initcond (inm);
00317
00318 Lsrst = new lhsrhst;
00319 Lsrst->lhsi=Lsrsc->lhsi;
00320 Lsrst->initcond (intr);
00321 }
00322
00323
00324 if ((Cp->tprob==par_coupl_mech_trans) || (Cp->tprob==growing_par_coupl_mech_trans)){
00325 if (Mp->pore_press)
00326 Mp->pore_press = 2;
00327
00328
00329 Lsrs = new lhsrhs;
00330 Lsrs->alloc ();
00331 Lsrs->initcond (inm);
00332
00333
00334 Lsrst = new lhsrhst;
00335 Lsrst->alloc ();
00336 Lsrst->initcond (intr);
00337 }
00338
00339 Mb->alloc_sumcomp ();
00340 if (Mm->csol)
00341 Gtm->comp_domain_sizes ();
00342
00343
00344
00345 if ((Cp->kwdsw == nokwd) || (Cp->kwdsw == kwd_pd))
00346 in->kwdmode = ignore;
00347 else
00348 in->kwdmode = sequent_mode;
00349
00350 Outdc->read(in);
00351
00352
00353 if ((Mp->kwdsw == nokwd) || (Mp->kwdsw == kwd_pd))
00354 inm->kwdmode = ignore;
00355 else
00356 inm->kwdmode = sequent_mode;
00357
00358 Outdm->read(inm);
00359
00360
00361 if ((Tp->kwdsw == nokwd) || (Tp->kwdsw == kwd_pd))
00362 intr->kwdmode = ignore;
00363 else
00364 intr->kwdmode = sequent_mode;
00365
00366 Outdt->read(intr);
00367
00368 fclose (Outc);
00369 fclose (Outt);
00370 fclose (Out);
00371
00372 char fname[1020];
00373 if (*Outdc->outfn)
00374 filename_decomposition(Outdc->outfn,Cp->path,Cp->filename,Cp->suffix);
00375 else
00376 filename_decomposition(argv[1],Cp->path,Cp->filename,Cp->suffix);
00377 sprintf(fname, "%s%s.log", Cp->path, Cp->filename);
00378 Outc = fopen(fname,"wt");
00379
00380 if (*Outdt->outfn)
00381 filename_decomposition(Outdt->outfn,Tp->path,Tp->filename,Tp->suffix);
00382 else
00383 filename_decomposition(Cp->tinfile,Tp->path,Tp->filename,Tp->suffix);
00384 if ((strlen(Tp->path) == 0) && (strlen(Tp->filename) == 0))
00385 {
00386 sprintf(fname, "trfel.log");
00387 Outt = fopen(fname,"at");
00388 }
00389 else
00390 {
00391 sprintf(fname, "%s%s.log", Tp->path, Tp->filename);
00392 Outt = fopen(fname,"wt");
00393 }
00394
00395 if (*Outdm->outfn)
00396 filename_decomposition(Outdm->outfn,Mp->path,Mp->filename,Mp->suffix);
00397 else
00398 filename_decomposition(Cp->minfile,Mp->path,Mp->filename,Mp->suffix);
00399 if ((strlen(Mp->path) == 0) && (strlen(Mp->filename) == 0))
00400 {
00401 sprintf(fname, "mefel.log");
00402 Out = fopen(fname,"at");
00403 }
00404 else
00405 {
00406 sprintf(fname, "%s%s.log", Mp->path, Mp->filename);
00407 Out = fopen(fname,"wt");
00408 }
00409 fprintf(stdout, "\n Log file name : '%s'", fname);
00410
00411
00412
00413
00414
00415 Mm->init_ip_2 ();
00416
00417
00418 Tt->alloc_nodes ();
00419
00420 Mt->alloc_nodes_arrays ();
00421
00422
00423 Mt->give_maxncompstr(Mm->max_ncompstrn, Mm->max_ncompstre);
00424
00425 Mt->give_maxncompo(Mm->max_nncompo, Mm->max_encompo);
00426
00427
00428 Mt->elemprescdisp ();
00429
00430 if (Mp->reactcomp==1){
00431 Mt->comreac ();
00432 }
00433
00434
00435 if (Mb->ico > 0)
00436 Mb->inicipval();
00437
00438 if (Mp->matmodel == nonlocal){
00439
00440 Gtm->adjacelem (Out);
00441
00442
00443 if (restore_adjacip() == 0)
00444 adjacip ();
00445 save_adjacip();
00446 ipvolume ();
00447 }
00448
00449
00450
00451 if (Mp->eigstrains!=0){
00452 Mm->alloceigstrains ();
00453 Mm->alloceigstresses ();
00454 }
00455
00456 if (Mp->pore_press!=0){
00457 Mm->alloceigstresses ();
00458 }
00459
00460
00461 if (Mp->temperature!=0)
00462 {
00463 Mm->alloctempstrains ();
00464 Mm->alloceigstresses ();
00465 }
00466
00467
00468
00469 xfclose (in);
00470 xfclose (inm);
00471 xfclose (intr);
00472 }
00473
00474 void print_helpc(FILE *out, const char *prgname)
00475 {
00476 fflush(out);
00477 fprintf(out, "\nInput file has not been specified\n");
00478 fprintf(out, " use : %s infile [-kwd=i]\n", prgname);
00479 fprintf(out, " where :\n * infile is input file name\n");
00480 fprintf(out, " * -kwd={0,1,2,3,4} is optional switch which controls keyword usage in the input file\n");
00481 fprintf(out, " 0 means no keywords (default value)\n");
00482 fprintf(out, " 1 means keywords only in the problem description section\n");
00483 fprintf(out, " 2 means keywords only in the outdriver section\n");
00484 fprintf(out, " 3 means keywords in the problem description and outdriver sections\n");
00485 fprintf(out, " 4 means full usage of keywords\n\n");
00486 abort();
00487 }
00488
00489
00490 long process_argsc(int argc, const char *argv[])
00491 {
00492 const char *pkwd;
00493
00494 switch (argc)
00495 {
00496 case 0:
00497 fflush(stdout);
00498 fprintf(stderr, "\n\nError - too few arguments are used\n\n");
00499 print_helpc(stderr, "pmetr|metr");
00500 return 1;
00501 case 1:
00502 fflush(stdout);
00503 fprintf(stderr, "\n\nError - too few arguments are used\n\n");
00504 print_helpc(stderr,argv[0]);
00505 return 1;
00506 case 2:
00507 Cp->kwdsw = nokwd;
00508 break;
00509 case 3:
00510
00511 pkwd = strstrcis(argv[2], "-kwd=");
00512 if (pkwd)
00513 {
00514 Cp->kwdsw = pkwd_sw(-1);
00515 sscanf(pkwd+5, "%d", (int *)&Cp->kwdsw);
00516 if ((Cp->kwdsw < 0) || (Cp->kwdsw > 4))
00517 {
00518 fflush(stdout);
00519 fprintf(stderr, "\n\nError - unknown -kwd value %d is obtained\n\n", Cp->kwdsw);
00520 print_helpc(stderr,argv[0]);
00521 return 1;
00522 }
00523 }
00524 else
00525 {
00526 fflush(stdout);
00527 fprintf(stderr, "\n\nError - unknown switch is used\n\n");
00528 print_helpc(stderr,argv[0]);
00529 return 1;
00530 }
00531 break;
00532 default:
00533 fflush(stdout);
00534 fprintf(stderr, "\n\nError - too many arguments is used\n\n");
00535 print_helpc(stderr,argv[0]);
00536 return 1;
00537 }
00538 return 0;
00539 }