00001 #include <stdio.h>
00002 #include <stdlib.h>
00003 #include <string.h>
00004
00005 #include "mefelinit.h"
00006 #include "global.h"
00007 #include "globmat.h"
00008 #include "sequent.h"
00009 #include "intpoints.h"
00010 #include "gtopology.h"
00011 #include "meshtransfer.h"
00012 #include "adaptivity.h"
00013 #include "mechprint.h"
00014 #include "nssolver.h"
00015 #include "element.h"
00016 #include "elemswitch.h"
00017 #include "iotools.h"
00018 #include "xfile.h"
00019 #include "saddpoint.h"
00020 #include "stacktrace.h"
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 void mefel_init (int argc, const char *argv[], stochdriver *stochd)
00040 {
00041 XFILE *in;
00042
00043 set_prgname(argv[0]);
00044 fprintf (stdout,"\n\n ******************************************************\n");
00045 fprintf (stderr,"\n\n ******************************************************\n");
00046
00047 Mp = new probdesc;
00048 Gtm = new gtopology;
00049 Mt = new mechtop;
00050 Mm = new mechmat;
00051 Mc = new mechcrsec;
00052 Mb = new mechbclc;
00053 Outdm = new outdriverm;
00054 Smat = NULL;
00055 Mmat = NULL;
00056 Dmat = NULL;
00057 Amat = NULL;
00058 Ismat = NULL;
00059
00060 if (process_args(argc, argv))
00061 {
00062 delete Mp;
00063 delete Gtm;
00064 delete Mt;
00065 delete Mm;
00066 delete Mc;
00067 delete Mb;
00068 delete Outdm;
00069 delete stochd;
00070 abort();
00071 }
00072
00073 in = xfopen(argv[1],"r");
00074 if (in==NULL){
00075 print_err("input file cannot be opened.",__FILE__,__LINE__,__func__);
00076 delete Mp;
00077 delete Gtm;
00078 delete Mt;
00079 delete Mm;
00080 delete Mc;
00081 delete Mb;
00082 delete Outdm;
00083 delete stochd;
00084 abort();
00085 }
00086
00087 in->warning = 1;
00088 if ((Mp->kwdsw == nokwd) || (Mp->kwdsw == kwd_outd))
00089 in->kwdmode = ignore;
00090 else
00091 in->kwdmode = sequent_mode;
00092 in->ignorecase = 1;
00093
00094
00095
00096
00097 Mp->read (in);
00098
00099 if (Mp->kwdsw == kwd_full)
00100 in->kwdmode = sequent_mode;
00101 else
00102 in->kwdmode = ignore;
00103
00104
00105
00106
00107 Mt->read (in);
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122
00123
00124 if (Mp->tprob == earth_pressure)
00125 {
00126 Gtm->bckcn = new long*[Gtm->nn];
00127 memset(Gtm->bckcn, 0, sizeof(*Gtm->bckcn)*Gtm->nn);
00128 Gtm->backup_codnum();
00129 }
00130
00131
00132 Out = fopen ("mefel.log","wt");
00133
00134 if (Mp->tprob==hemivar_inequal || Mp->tprob==lin_floating_subdomain){
00135 Gtm->auto_subdom_detection (Out);
00136 Mt->alloc_enodes ();
00137 Mt->alloc_edges ();
00138 }
00139
00140
00141
00142
00143
00144
00145 Ndofm = Gtm->codenum_generation (Out);
00146
00147
00148 if (Mespr==1)
00149 fprintf (stdout,"\n number of degrees of freedom %ld",Ndofm);
00150
00151
00152
00153
00154
00155 if (Mp->tprob==layered_linear_statics){
00156
00157 if (Mt->elements[0].te<20) Mp->tlm=1;
00158 if (Mt->elements[0].te>20) Mp->tlm=2;
00159
00160
00161 Mt->gencodnumlagrmult (Ndofm);
00162 Gtm->initiate_elemmult ();
00163 if (Mespr==1)
00164 fprintf (stdout,"\n total number of degrees of freedom %ld",Ndofm);
00165 }
00166
00167
00168 if (Mp->tprob==lin_floating_subdomain){
00169
00170 Gtm->flsub.ndof_subdom (Gtm->gnodes);
00171 }
00172
00173 if (Mp->homog==3){
00174
00175
00176
00177 long ncomp;
00178 ncomp = Mt->give_ncomp (0,0);
00179
00180
00181 Gtm->code_num_mod (ncomp,Ndofm,Out);
00182
00183 Mt->domvol = Mt->give_domain_vol();
00184 fprintf (stdout,"\n domain volume %le",Mt->domvol);
00185 }
00186 if (Mp->homog==4){
00187
00188
00189
00190 Mt->domvol = Mt->give_domain_vol();
00191 fprintf (stdout,"\n domain volume %le",Mt->domvol);
00192 }
00193
00194
00195
00196
00197
00198
00199
00200
00201
00202
00203
00204
00205 Mm->read (in);
00206
00207
00208
00209 Mm->init_ip_1 ();
00210
00211
00212
00213
00214 Mc->read (in);
00215
00216
00217
00218
00219 Mb->read (in);
00220
00221
00222
00223
00224
00225 if (Mp->tprob == growing_mech_structure){
00226 Gtm->read_gf (in);
00227 Gtm->alloc_growstr();
00228 Mt->alloc_growstr();
00229 }
00230
00231
00232
00233
00234
00235 Mp->ssle->prepare_data (&Ndofm,Gtm,Out);
00236
00237
00238
00239
00240
00241
00242
00243 Lsrs = new lhsrhs;
00244
00245 Lsrs->alloc ();
00246
00247 Lsrs->initcond (in);
00248
00249 if ((Mp->tprob == mech_timedependent_prob)||(Mp->tprob == growing_mech_structure))
00250 {
00251 Mb->alloc_sumcomp ();
00252 if (Mm->csol)
00253 Gtm->comp_domain_sizes ();
00254 }
00255
00256
00257
00258
00259 if ((Mp->kwdsw == nokwd) || (Mp->kwdsw == kwd_pd))
00260 in->kwdmode = ignore;
00261 else
00262 in->kwdmode = sequent_mode;
00263
00264 Outdm->read(in);
00265
00266 if (Mp->kwdsw == kwd_full)
00267 in->kwdmode = sequent_mode;
00268 else
00269 in->kwdmode = ignore;
00270
00271
00272
00273
00274
00275 fclose (Out);
00276 char fname[1020];
00277 if (*Outdm->outfn)
00278 filename_decomposition (Outdm->outfn,Mp->path,Mp->filename,Mp->suffix);
00279 else
00280 filename_decomposition (argv[1],Mp->path,Mp->filename,Mp->suffix);
00281
00282 sprintf(fname, "%s%s.log", Mp->path, Mp->filename);
00283
00284
00285 Out = fopen(fname,"wt");
00286 if (Out == NULL)
00287 print_err("cannot open log file", __FILE__, __LINE__, __func__);
00288
00289
00290
00291
00292 Gtm->adjacnodes (NULL);
00293 Gtm->adjacelem (NULL);
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304 Mm->init_ip_2 ();
00305
00306
00307
00308
00309 Mt->alloc_nodes_arrays ();
00310
00311
00312
00313 Mt->give_maxncompstr(Mm->max_ncompstrn, Mm->max_ncompstre);
00314
00315 Mt->give_maxncompo(Mm->max_nncompo, Mm->max_encompo);
00316
00317
00318
00319
00320
00321
00322
00323
00324
00325
00326
00327
00328
00329 Mt->elemprescdisp ();
00330
00331 if (Mp->tprob == linear_statics){
00332 Mt->elempresctemp (0);
00333 }
00334
00335 if (Mp->reactcomp==1){
00336 Mt->comreac ();
00337 }
00338
00339
00340
00341
00342 if (Mb->ico > 0)
00343 Mb->inicipval();
00344
00345
00346
00347 if (Mp->matmodel == nonlocal){
00348
00349 Gtm->adjacelem (Out);
00350
00351
00352 if (restore_adjacip() == 0)
00353 adjacip ();
00354 save_adjacip();
00355 ipvolume ();
00356 }
00357
00358
00359
00360
00361
00362
00363
00364 if (Mp->stochasticcalc){
00365 stochd->read (in);
00366 St = stochd;
00367 }
00368
00369
00370 if (Mp->eigstrains!=0){
00371 Mm->alloceigstrains ();
00372 Mm->alloceigstresses ();
00373 }
00374
00375
00376 if (Mp->temperature > 0)
00377 {
00378 Mm->alloctempstrains ();
00379 Mm->alloceigstresses ();
00380 }
00381
00382
00383
00384
00385
00386 xfclose (in);
00387
00388
00389
00390
00391 }
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402 void print_help(FILE *out, const char *prgname)
00403 {
00404 fflush(out);
00405 fprintf(out, "\nInput file has not been specified\n");
00406 fprintf(out, " use: %s infile [-kwd=i]\n",prgname);
00407 fprintf(out, " where:\n * infile is input file name\n");
00408 fprintf(out, " * -kwd={0,1,2,3,4} is optional switch which controls keyword usage in the input file\n");
00409 fprintf(out, " 0 means no keywords (default value)\n");
00410 fprintf(out, " 1 means keywords only in the problem description section\n");
00411 fprintf(out, " 2 means keywords only in the outdriver section\n");
00412 fprintf(out, " 3 means keywords in the problem description and outdriver sections\n");
00413 fprintf(out, " 4 means full usage of keywords\n\n");
00414 abort();
00415 }
00416
00417
00418
00419
00420
00421
00422
00423
00424
00425
00426
00427
00428
00429
00430 long process_args(int argc, const char *argv[])
00431 {
00432 const char *pkwd;
00433
00434 switch (argc)
00435 {
00436 case 0:
00437 fflush(stderr);
00438 fflush(stdout);
00439 print_help(stderr,"pmefel|mefel");
00440 return 1;
00441 case 1:
00442 fflush(stderr);
00443 fflush(stdout);
00444 print_help(stderr,argv[0]);
00445 return 1;
00446 case 2:
00447 Mp->kwdsw = nokwd;
00448 break;
00449 case 3:
00450
00451 pkwd = strstrcis(argv[2], "-kwd=");
00452 if (pkwd)
00453 {
00454 Mp->kwdsw = pkwd_sw(-1);
00455 sscanf(pkwd+5, "%d", (int *)&Mp->kwdsw);
00456 if ((Mp->kwdsw < 0) || (Mp->kwdsw > 4))
00457 {
00458 fflush(stderr);
00459 fflush(stdout);
00460 fprintf(stderr, "\n\nError: unknown -kwd value is required\n");
00461 print_help(stderr,argv[0]);
00462 return 1;
00463 }
00464 }
00465 else
00466 {
00467 fflush(stderr);
00468 fflush(stdout);
00469 fprintf(stderr, "\n\nError: unknown switch is used\n");
00470 print_help(stderr,argv[0]);
00471 return 1;
00472 }
00473 break;
00474 default:
00475 fflush(stderr);
00476 fflush(stdout);
00477 fprintf(stderr, "\n\nError: too many arguments is used\n");
00478 print_help(stderr,argv[0]);
00479 return 1;
00480 }
00481 return 0;
00482 }