00001 #include <stdio.h>
00002 #include <stdlib.h>
00003 #include <string.h>
00004 #include "trfelinit.h"
00005 #include "globalt.h"
00006 #include "globmatt.h"
00007 #include "intpointst.h"
00008 #include "gtopology.h"
00009 #include "transprint.h"
00010 #include "iotools.h"
00011 #include "xfile.h"
00012 #include "stacktrace.h"
00013 #include "libtrace.h"
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 void trfel_init (int argc, const char *argv[], stochdrivert *stochd)
00025 {
00026 long i;
00027 XFILE *in;
00028
00029 set_prgname(argv[0]);
00030 fprintf (stderr,"\n\n ******************************************************\n");
00031
00032 Tp = new probdesct;
00033 Gtt = new gtopology;
00034 Tt = new transtop;
00035 Tm = new transmat;
00036
00037 Tc = new transcrsec;
00038 Tb = new transbclc;
00039 Outdt = new outdrivert;
00040 Kmat = NULL;
00041 Cmat = NULL;
00042 Jmat = NULL;
00043 Bmat = NULL;
00044
00045 if (process_argst(argc, argv))
00046 {
00047 delete Tp;
00048 delete Gtt;
00049 delete Tt;
00050 delete Tm;
00051 delete Tc;
00052 delete Tb;
00053 delete Outdt;
00054 abort();
00055 }
00056
00057 in = xfopen(argv[1],"r");
00058 if (in==NULL){
00059 fprintf (stderr,"\n Input file has not been specified.");
00060 fprintf (stderr,"\n Try it again!\n\n");
00061 abort ();
00062 }
00063 in->warning = 1;
00064 in->ignorecase = 1;
00065 if ((Tp->kwdsw == nokwd) || (Tp->kwdsw == kwd_outd))
00066 in->kwdmode = ignore;
00067 else
00068 in->kwdmode = sequent_mode;
00069
00070
00071
00072 Outt = fopen ("trfel.log","wt");
00073
00074
00075 Tp->read (in);
00076
00077 if (Tp->tprob == growing_np_problem || Tp->tprob == growing_np_problem_nonlin){
00078
00079 Tp->time=Tp->timecont.starttime ();
00080 }
00081
00082 if (Tp->kwdsw == kwd_full)
00083 in->kwdmode = sequent_mode;
00084 else
00085 in->kwdmode = ignore;
00086
00087
00088 Tt->read (in);
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103 if (Tp->tprob == growing_np_problem || Tp->tprob == growing_np_problem_nonlin){
00104 Gtt->read_gf (in);
00105 }
00106
00107
00108 Tm->read (in);
00109
00110
00111 radiation_init ();
00112
00113
00114 if (Tp->tprob == discont_nonstat_problem || Tp->tprob == discont_nonlin_nonstat_problem || Gtt->edtype==mater){
00115 Gtt->auto_subdom_detection (Outt);
00116 Tt->alloc_enodes ();
00117 Tt->alloc_edges ();
00118 Tt->edge_init_edval ();
00119
00120 Tt->view_factors (Outt);
00121 Tt->mod_view_factors (Outt);
00122 }
00123
00124
00125
00126
00127
00128
00129 Ndoft = Gtt->codenum_generation (Outt);
00130 if (Mesprt==1)
00131 fprintf (stdout,"\n the number of degrees of freedom %ld",Ndoft);
00132
00133
00134
00135 Tm->intpointalloc ();
00136 Tm->intpointinit ();
00137 Tm->assemble_dof_nameord(Tp->dofname, Tp->ntm, Tp->var_dofid, Tp->tnkv);
00138
00139
00140 Tc->read (in);
00141
00142
00143 Tb->read (in);
00144
00145
00146
00147
00148 Tb->elemsource ();
00149
00150
00151 Lsrst = new lhsrhst;
00152 Lsrst->alloc ();
00153 Lsrst->initcond (in);
00154
00155 if (Tp->stochasticcalc){
00156 stochd->read (in);
00157 Stt = stochd;
00158 };
00159
00160 if (Tp->tprob == discont_nonstat_problem || Tp->tprob == discont_nonlin_nonstat_problem){
00161
00162 Tt->enodes_init ();
00163 Tt->edge_init ();
00164
00165
00166
00167 }
00168
00169 if ((Tp->kwdsw == nokwd) || (Tp->kwdsw == kwd_pd))
00170 in->kwdmode = ignore;
00171 else
00172 in->kwdmode = sequent_mode;
00173
00174
00175 Outdt->read(in);
00176
00177 if (Tp->kwdsw == kwd_full)
00178 in->kwdmode = sequent_mode;
00179 else
00180 in->kwdmode = ignore;
00181
00182 fclose (Outt);
00183
00184 char fname[1020];
00185 if (*Outdt->outfn)
00186 filename_decomposition(Outdt->outfn,Tp->path,Tp->filename,Tp->suffix);
00187 else
00188 filename_decomposition(argv[1],Tp->path,Tp->filename,Tp->suffix);
00189
00190 sprintf(fname, "%s%s.log", Tp->path, Tp->filename);
00191 Outt = fopen(fname,"wt");
00192
00193
00194 Tt->alloc_nodes ();
00195
00196
00197
00198
00199
00200
00201 Tp->ssle->prepare_data (&Ndoft,Gtt,Outt);
00202
00203
00204
00205
00206
00207
00208
00209
00210 if (Tm->initval==NULL)
00211 Tm->initval = new double [Tm->tnip];
00212
00213 for (i=0;i<Tm->tnip;i++){
00214 Tm->initval[i]=0.0;
00215 }
00216
00217 xfclose (in);
00218 }
00219
00220 void print_helpt(FILE *out, const char *prgname)
00221 {
00222 fflush(out);
00223 fprintf(out, "\nInput file has not been specified\n");
00224 fprintf(out, " use : %s infile [-kwd=i]\n", prgname);
00225 fprintf(out, " where :\n * infile is input file name\n");
00226 fprintf(out, " * -kwd={0,1,2,3,4} is optional switch which controls keyword usage in the input file\n");
00227 fprintf(out, " 0 means no keywords (default value)\n");
00228 fprintf(out, " 1 means keywords only in the problem description section\n");
00229 fprintf(out, " 2 means keywords only in the outdriver section\n");
00230 fprintf(out, " 3 means keywords in the problem description and outdriver sections\n");
00231 fprintf(out, " 4 means full usage of keywords\n\n");
00232 abort();
00233 }
00234
00235
00236 long process_argst(int argc, const char *argv[])
00237 {
00238 const char *pkwd;
00239
00240 switch (argc)
00241 {
00242 case 0:
00243 fflush(stdout);
00244 fprintf(stderr, "\n\nError - too few arguments are used\n\n");
00245 print_helpt(stderr, "ptrfel|trfel");
00246 return 1;
00247 case 1:
00248 fflush(stdout);
00249 fprintf(stderr, "\n\nError - too few arguments are used\n\n");
00250 print_helpt(stderr, argv[0]);
00251 return 1;
00252 case 2:
00253 Tp->kwdsw = nokwd;
00254 break;
00255 case 3:
00256
00257 pkwd = strstrcis(argv[2], "-kwd=");
00258 if (pkwd)
00259 {
00260 Tp->kwdsw = pkwd_sw(-1);
00261 sscanf(pkwd+5, "%d", (int *)&Tp->kwdsw);
00262 if ((Tp->kwdsw < 0) || (Tp->kwdsw > 4))
00263 {
00264 fflush(stdout);
00265 fprintf(stderr, "\n\nError - unknown -kwd value %d is obtained\n\n", Tp->kwdsw);
00266 print_helpt(stderr, argv[0]);
00267 return 1;
00268 }
00269 }
00270 else
00271 {
00272 fflush(stdout);
00273 fprintf(stderr, "\n\nError - unknown switch is used\n\n");
00274 print_helpt(stderr, argv[0]);
00275 return 1;
00276 }
00277 break;
00278 default:
00279 fflush(stdout);
00280 fprintf(stderr, "\n\nError - too many arguments is used\n\n");
00281 print_helpt(stderr, argv[0]);
00282 return 1;
00283 }
00284 return 0;
00285 }
00286
00287
00288
00289
00290
00291
00292
00293 void radiation_init ()
00294 {
00295 long i,j,k,nmt;
00296
00297
00298 nmt=Tp->ntm*Tp->ntm;
00299
00300 k=0;
00301
00302 for (i=0;i<Tt->ne;i++){
00303 for (j=0;j<nmt;j++){
00304 if (Tt->elements[i].tm[j]==radiationmater){
00305 k=1;
00306 Gtt->edtype=mater;
00307 break;
00308 }
00309 }
00310 if (k==1){
00311 break;
00312 }
00313 }
00314
00315
00316 for (i=0;i<Tt->ne;i++){
00317 for (j=0;j<nmt;j++){
00318 if (Tt->elements[i].tm[j]==radiationmater){
00319 Gtt->gelements[i].auxinf=251;
00320 break;
00321 }
00322 }
00323 }
00324
00325 }
00326