00001 #include "pmefelinit.h"
00002 #include "pglobal.h"
00003 #include "xfile.h"
00004 #include "stacktrace.h"
00005
00006 void pmefel_init (int argc, const char *argv[], stochdriver *stochd)
00007 {
00008 long i, merr;
00009 char name[1100], emsg[1000];
00010 char *dot;
00011 XFILE *in;
00012
00013 set_prgname(argv[0]);
00014
00015 Pmp = new pprobdesc;
00016
00017 Mp = new probdesc;
00018 Gtm = new gtopology;
00019 Mt = new mechtop;
00020 Mm = new mechmat;
00021 Mc = new mechcrsec;
00022 Mb = new mechbclc;
00023 Outdm = new outdriverm;
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033 if (process_args(argc, argv))
00034 {
00035 delete Mp;
00036 delete Gtm;
00037 delete Mt;
00038 delete Mm;
00039 delete Mc;
00040 delete Mb;
00041 delete Outdm;
00042 delete stochd;
00043 abort();
00044 }
00045
00046 strcpy (name,argv[1]);
00047 sprintf (&name[strlen (argv[1])],"%d.in",Myrank+1);
00048 in = xfopen (name,"r");
00049 if (in==NULL){
00050 par_print_err(Myrank+1, proc_name, "input file cannot be opened.",__FILE__, __LINE__, __func__);
00051 delete Mp;
00052 delete Gtm;
00053 delete Mt;
00054 delete Mm;
00055 delete Mc;
00056 delete Mb;
00057 delete Outdm;
00058 delete stochd;
00059 abort();
00060 }
00061 in->warning = 1;
00062 if ((Mp->kwdsw == nokwd) || (Mp->kwdsw == kwd_outd))
00063 in->kwdmode = ignore;
00064 else
00065 in->kwdmode = sequent_mode;
00066 in->ignorecase = 1;
00067
00068
00069 xfscanf (in,"%k%ld","domain_num", &Ndom);
00070 Ndom--;
00071
00072
00073
00074
00075
00076 Mp->read (in);
00077
00078 Psolm = new psolver (Nproc,Myrank,proc_name,nameLength);
00079
00080 Psolm->read (in,Gtm,Ndom,Mp->tstorsm,Mespr);
00081
00082 if (Mp->kwdsw == kwd_full)
00083 in->kwdmode = sequent_mode;
00084 else
00085 in->kwdmode = ignore;
00086
00087
00088 char buf[1001];
00089 strcpy (buf,argv[1]);
00090 sprintf (&buf[strlen (argv[1])],"%d.log",Myrank+1);
00091 Out = fopen (buf,"w");
00092 if (Out==NULL){
00093 par_print_err (Myrank+1,proc_name,"log file cannot be opened",__FILE__, __LINE__, __func__);
00094 }
00095
00096
00097
00098 Psolm->procdomcorr ();
00099
00100 if (Myrank==0){
00101 fflush(stdout);
00102 fprintf (stdout,"\n\n kontrola domproc \n");
00103 fprintf (Out,"\n\n kontrola domproc \n");
00104 for (long i=0;i<Nproc;i++){
00105 fprintf (Out,"\n %ld %ld",i,Psolm->domproc[i]);
00106 fprintf (stdout,"\n %ld %ld",i,Psolm->domproc[i]);
00107 }
00108 fflush(stdout);
00109 }
00110
00111
00112
00113
00114
00115
00116
00117 Mt->read (in);
00118 Pmp->shift_indices ();
00119
00120
00121 if (Mp->tprob == growing_mech_structure){
00122 if (Mespr==1){
00123 merr=Mt->mesh_check();
00124 if (merr > 0){
00125 sprintf(emsg, "mesh error = %ld", merr);
00126 par_print_err(Myrank+1,proc_name,emsg, __FILE__, __LINE__, __func__);
00127 abort();
00128 }
00129 }
00130 }
00131
00132
00133 Psolm->initiate (Gtm,argc,argv);
00134
00135 Psolm->read_ltg (in,Gtm,Out);
00136
00137
00138
00139
00140
00141
00142
00143
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161 fprintf (Out,"\n Nproc %d",Nproc);
00162 fprintf (Out,"\n Ndom %d",Ndom);
00163 fprintf (Out,"\n Myrank %d",Myrank);
00164 fprintf (Out,"\n Name of processor %s",proc_name);
00165
00166
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176 Ndofm=Psolm->ordering (Gtm,Out,proc_name);
00177
00178
00179
00180
00181
00182
00183
00184
00185
00186
00187
00188 if (Mespr==1)
00189 fprintf (stdout,"\n number of DOFs %ld",Ndofm);
00190
00191
00192
00193
00194
00195
00196
00197
00198
00199
00200
00201 Mm->read (in);
00202
00203
00204 Mm->init_ip_1 ();
00205
00206
00207
00208
00209
00210 Mc->read (in);
00211
00212
00213
00214
00215
00216 Mb->read (in);
00217
00218
00219
00220
00221
00222
00223 if (Mp->tprob == growing_mech_structure){
00224 Gtm->read_gf (in);
00225 Mt->alloc_growstr ();
00226 }
00227
00228
00229
00230
00231
00232 Lsrs = new lhsrhs;
00233
00234 Lsrs->alloc ();
00235
00236 Lsrs->initcond (in);
00237
00238 if (Mp->tprob == mech_timedependent_prob)
00239 {
00240 Mb->alloc_sumcomp ();
00241 if (Mm->csol)
00242 Gtm->comp_domain_sizes ();
00243 }
00244
00245
00246
00247
00248 if ((Mp->kwdsw == nokwd) || (Mp->kwdsw == kwd_pd))
00249 in->kwdmode = ignore;
00250 else
00251 in->kwdmode = sequent_mode;
00252
00253 Outdm->read(in);
00254
00255
00256 if (Mp->kwdsw == kwd_full)
00257 in->kwdmode = sequent_mode;
00258 else
00259 in->kwdmode = ignore;
00260
00261
00262
00263
00264
00265
00266
00267 if (Mp->hdbcont.restore_stat())
00268 {
00269 strcpy (name,Mp->hdbcont.hdbnamer);
00270 dot = strchr (name,'.');
00271 if (dot == NULL)
00272 {
00273 print_err("cannot locate '.' in the backup file name '%s'", __FILE__, __LINE__, __func__, name);
00274 abort();
00275 }
00276 sprintf (dot,"%d",Myrank+1);
00277 sprintf (&name[strlen(name)], "%s", Mp->hdbcont.hdbnamer+int(dot-name));
00278 strcpy (Mp->hdbcont.hdbnamer, name);
00279 }
00280 if (Mp->hdbcont.save_stat())
00281 {
00282 strcpy (name,Mp->hdbcont.hdbnames);
00283 sprintf (&name[strlen(Mp->hdbcont.hdbnames)],"%d",Myrank+1);
00284 strcpy (Mp->hdbcont.hdbnames, name);
00285 }
00286
00287
00288 strcpy (name,Outdm->outfn);
00289 sprintf (&name[strlen (Outdm->outfn)],"%d.out",Myrank+1);
00290 strcpy (Outdm->outfn, name);
00291 if (Outdm->gf != grfmt_no)
00292 {
00293 strcpy (name,Outdm->outgrfn);
00294 sprintf (&name[strlen (Outdm->outgrfn)],"%d",Myrank+1);
00295 strcpy (Outdm->outgrfn, name);
00296 }
00297 if (Outdm->ndiag > 0)
00298 {
00299 strcpy (name,Outdm->outdiagfn);
00300 sprintf (&name[strlen (Outdm->outdiagfn)],"%d.dat",Myrank+1);
00301 strcpy (Outdm->outdiagfn, name);
00302 }
00303
00304
00305
00306
00307
00308
00309
00310
00311
00312
00313
00314 Gtm->adjacnodes (Out);
00315 Gtm->adjacelem (Out);
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326 Mm->init_ip_2 ();
00327
00328
00329
00330 Mt->alloc_nodes_arrays ();
00331
00332
00333
00334 Mt->give_maxncompstr(Mm->max_ncompstrn, Mm->max_ncompstre);
00335
00336 Mt->give_maxncompo(Mm->max_nncompo, Mm->max_encompo);
00337
00338
00339
00340
00341
00342
00343
00344
00345
00346
00347
00348 Mt->elemprescdisp ();
00349
00350 if (Mp->tprob == linear_statics){
00351 Mt->elempresctemp (0);
00352 }
00353
00354 if (Mp->reactcomp==1){
00355 Mt->comreac ();
00356 }
00357
00358
00359 if (Mb->ico > 0)
00360 Mb->inicipval();
00361
00362
00363 if (Mp->matmodel == nonlocal){
00364
00365 Gtm->adjacelem (Out);
00366
00367
00368 if (restore_adjacip() == 0)
00369 adjacip ();
00370 save_adjacip();
00371 ipvolume ();
00372 }
00373
00374
00375 if (Mp->adaptivityflag)
00376 Ada = new adaptivity ();
00377 else
00378 Ada = NULL;
00379
00380
00381 if (Mp->stochasticcalc){
00382 stochd->read (in);
00383 St = stochd;
00384 }
00385 else
00386 St = NULL;
00387
00388
00389 if (Mp->temperature==1){
00390 Mm->alloceigstrains ();
00391 Mm->alloctempstrains ();
00392 Mm->alloceigstresses ();
00393
00394
00395
00396
00397
00398
00399
00400
00401 }
00402
00403
00404
00405 fflush(stdout);
00406 fflush(stderr);
00407
00408 Pmp->shift_indices ();
00409
00410 xfclose (in);
00411
00412 }