00001 #define EXTERN
00002
00003 #include "prepalias.h"
00004 #include "inputt.h"
00005 #include "outputt.h"
00006 #include "globprept.h"
00007 #include "globalt.h"
00008 #include "globmatt.h"
00009 #include "elemheadt.h"
00010 #include "genfile.h"
00011 #include "iotools.h"
00012 #include "kwdset.h"
00013 #include "stacktrace.h"
00014 #include <stdio.h>
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027 void check_reqsec_t(XFILE *in)
00028 {
00029 long err;
00030
00031
00032 if (in->index_created != 1)
00033 {
00034 print_err("Index of sections has not beeen created", __FILE__, __LINE__, __func__);
00035 abort();
00036 }
00037
00038
00039 err = xf_setsec(in, bsec_str[begsec_files]);
00040 switch (err)
00041 {
00042 case 1:
00043 print_err("Section with input files has not been detected", __FILE__, __LINE__, __func__);
00044 abort();
00045 default:
00046 break;
00047 }
00048
00049
00050 err = xf_setsec(in, bsec_str[begsec_probdesc]);
00051 switch (err)
00052 {
00053 case 1:
00054 print_err("Section with problem description has not been detected", __FILE__, __LINE__, __func__);
00055 abort();
00056 default:
00057 break;
00058 }
00059
00060
00061 err = xf_setsec(in, bsec_str[begsec_loadcase]);
00062 switch (err)
00063 {
00064 case 1:
00065 print_err("Section with load cases has not been detected", __FILE__, __LINE__, __func__);
00066 abort();
00067 default:
00068 break;
00069 }
00070
00071
00072 err = xf_setsec(in, bsec_str[begsec_nodvertpr]);
00073 err += xf_setsec(in, bsec_str[begsec_nodedgpr]);
00074 err += xf_setsec(in, bsec_str[begsec_nodsurfpr]);
00075 err += xf_setsec(in, bsec_str[begsec_nodvolpr]);
00076 if (err == 4)
00077 {
00078 print_err("No section with nodal properties has been detected", __FILE__, __LINE__, __func__);
00079 abort();
00080 }
00081
00082
00083 err = xf_setsec(in, bsec_str[begsec_elvertpr]);
00084 err += xf_setsec(in, bsec_str[begsec_eledgpr]);
00085 err += xf_setsec(in, bsec_str[begsec_elsurfpr]);
00086 err += xf_setsec(in, bsec_str[begsec_elvolpr]);
00087 if (err == 4)
00088 {
00089 print_err("No section with properties of elements has been detected", __FILE__, __LINE__, __func__);
00090 abort();
00091 }
00092
00093
00094 err = xf_setsec(in, bsec_str[begsec_outdrv]);
00095 switch (err)
00096 {
00097 case 1:
00098 print_err("Section with outdriver data has not been detected", __FILE__, __LINE__, __func__);
00099 abort();
00100 default:
00101 break;
00102 }
00103 }
00104
00105
00106
00107
00108 int main (int argc,char *argv[])
00109 {
00110 XFILE *in;
00111 long err, i, l;
00112 descript d;
00113 char *logname;
00114 char *tmp;
00115
00116 set_prgname(argv[0]);
00117 fprintf (stdout,"\n\n *** TRFEL PREPROCESSOR ***\n");
00118 fprintf (stdout," --------------------------\n");
00119
00120 Tp = new probdesct;
00121 Gtt = new gtopology;
00122 Top = new siftop;
00123 Tt = new transtop;
00124 Tm = new transmat;
00125 Tc = new transcrsec;
00126 Tb = new transbclc;
00127 Outdt = new outdrivert;
00128
00129 if (argc < 3){
00130 fprintf (stderr,"\n Wrong number of command line parameters.");
00131 fprintf (stderr,"\n Use : transprep input_file_name output_file name\n\n");
00132 delete Gtt; delete Top; delete Tt; delete Tm; delete Tc; delete Tb;
00133 delete Tp;
00134 return(1);
00135 }
00136 in = xfopen(argv[1],"r");
00137 if (in == NULL){
00138 fprintf (stderr,"\n Input file has not been specified.");
00139 fprintf (stderr,"\n Try it again!\n\n");
00140 delete Gtt; delete Top; delete Tt; delete Tm; delete Tc; delete Tb;
00141 delete Tp;
00142 return(2);
00143 }
00144
00145 Check_unused_prop = 1;
00146
00147 logname = new char[strlen(argv[1])+5];
00148 strcpy(logname, argv[1]);
00149 l = strlen(logname);
00150 tmp = strrchr(logname, '.');
00151 if (tmp)
00152 sprintf(tmp+1, "plg");
00153 else
00154 sprintf(logname+l, ".plg");
00155 Log = fopen(logname, "w");
00156 in->warning = 1;
00157 in->kwdmode = sect_mode_seq;
00158
00159 in->ignorecase = 1;
00160
00161 xfdetect_sect(in, bsec_kwdset, esec_kwdset);
00162
00163 check_reqsec_t(in);
00164
00165 if (xf_setsec(in, bsec_str[begsec_mater]) == 0)
00166 d.matsec = yes;
00167 else
00168 d.matsec = no;
00169
00170
00171 if (xf_setsec(in, bsec_str[begsec_crsec]) == 0)
00172 d.crssec = yes;
00173 else
00174 d.crssec = no;
00175
00176
00177 xf_setsec(in, bsec_str[begsec_files]);
00178 input_filest(in, d);
00179 if (d.inicdf == yes)
00180 Inicdf = d.icf;
00181 else
00182 Inicdf = NULL;
00183
00184
00185
00186 xf_setsec(in, bsec_str[begsec_probdesc]);
00187 fprintf(stdout, "\n\nReading of problem description . . .");
00188 in->kwdmode = sect_mode_fwd;
00189 if (xfscanf(in,"%+k", "mesprt") == 0)
00190 in->kwdmode = sect_mode_ignore;
00191 xf_resetsec(in);
00192 Tp->read(in);
00193 in->kwdmode = sect_mode_seq;
00194
00195 Lbt = new linbart;
00196 Qbt = new quadbart;
00197 Ltt = new trlineart;
00198 Ltat = new trlinaxisym;
00199 Lqt = new quadlineart;
00200 Qqt = new quadquadrilatt;
00201 Lqat = new quadlinaxisym;
00202 Ltett = new lintett;
00203 Lht = new linhext;
00204 Qht = new quadhext;
00205
00206
00207
00208 d.paral=0;
00209
00210
00211 err = inputt(in, &d);
00212 if(err)
00213 {
00214 xfclose(in);
00215 fclose(Log);
00216 delete Top;
00217 return(err);
00218 }
00219
00220
00221 Tt->alloc_prep(Top->nn, Top->ne);
00222 if ((Tp->tprob == growing_np_problem) || (Tp->tprob == growing_np_problem_nonlin))
00223 {
00224 fprintf(stdout, "\n\nReading of section with time functions . . .");
00225 xf_setsec(in, bsec_str[begsec_loadcase]);
00226 in->kwdmode = sect_mode_full;
00227 xfscanf(in, "%k", "time_functions");
00228 in->kwdmode = sect_mode_seq;
00229 Gtt->read_gf (in);
00230 }
00231 in->kwdmode = sect_mode_seq;
00232
00233 xf_setsec(in, bsec_str[begsec_outdrv]);
00234 fprintf(stdout, "\n\nReading of outdriver section . . .");
00235 if (xfscanf(in,"%+k", "textout") == 0)
00236 in->kwdmode = sect_mode_ignore;
00237 xf_resetsec(in);
00238 Outdt->read(in);
00239 xfclose(in);
00240
00241 fprintf(stdout, "\n\nOutput of TRFEL input file %s :\n", argv[2]);
00242 l = strlen(argv[2])+29;
00243 for (i=0; i<l; i++)
00244 fprintf(stdout, "-");
00245 FILE *out = fopen(argv[2], "wt");
00246 if (out==NULL){
00247 fprintf (stderr,"\n Output file could not be opened.");
00248 fprintf (stderr,"\n Try it again!\n\n");
00249 fclose(Log);
00250 return(7);
00251 }
00252
00253
00254 fprintf(stdout, "\nTopology export . . .");
00255 Top->exporttop(Gtt);
00256 fprintf(stdout, " O.K.\n");
00257
00258
00259 fprintf(stdout, "\nProblem description output . . .");
00260 Tp->print(out);
00261 fprintf(stdout, " O.K.\n");
00262
00263
00264 outputt(out, &d);
00265
00266
00267 if ((Tp->tprob == growing_np_problem) || (Tp->tprob == growing_np_problem_nonlin))
00268 {
00269 fprintf(stdout, "\nTime functions output . . .");
00270 fprintf(out, "# Time functions for dofs and elements\n");
00271 Gtt->print_gf(out);
00272 fprintf(stdout, " O.K.\n");
00273 }
00274
00275 fprintf(stdout, "\nOutdriver description output . . .");
00276 Outdt->print(out);
00277 fprintf(stdout, " O.K.\n");
00278 fclose(out);
00279 fflush(Log);
00280 if (ftell(Log) == 0)
00281 {
00282 fclose(Log);
00283 remove(logname);
00284 }
00285 else
00286 {
00287 fprintf(stdout, "\nSome warnings were registered.\nPlease check the file '%s'\n", logname);
00288 fclose(Log);
00289 }
00290 delete [] logname;
00291 printf ("\n");
00292 fprintf(stdout, "\n");
00293 fprintf(stderr, "\n");
00294
00295
00296
00297 delete Tt;
00298 delete Gtt;
00299 delete Top;
00300 delete Tm;
00301 delete Tc;
00302 delete Tb;
00303 delete Outdt;
00304
00305 delete Lbt;
00306 delete Qbt;
00307 delete Ltt;
00308 delete Ltat;
00309 delete Lqt;
00310 delete Qqt;
00311 delete Lqat;
00312 delete Ltett;
00313 delete Lht;
00314 delete Qht;
00315
00316 delete Tp;
00317 return(0);
00318 }
00319