00001 #define EXTERN
00002 #include "prepalias.h"
00003 #include "input.h"
00004 #include "output.h"
00005 #include "globprep.h"
00006 #include "global.h"
00007 #include "globmat.h"
00008 #include "elemhead.h"
00009 #include "genfile.h"
00010 #include "iotools.h"
00011 #include "kwdset.h"
00012 #include "stacktrace.h"
00013 #include <stdio.h>
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 void check_reqsec(XFILE *in)
00027 {
00028 long err;
00029
00030
00031 if (in->index_created != 1)
00032 {
00033 print_err("Index of sections has not beeen created", __FILE__, __LINE__, __func__);
00034 abort();
00035 }
00036
00037
00038 err = xf_setsec(in, bsec_str[begsec_files]);
00039 switch (err)
00040 {
00041 case 1:
00042 print_err("Section with input files has not been detected", __FILE__, __LINE__, __func__);
00043 abort();
00044 default:
00045 break;
00046 }
00047
00048
00049 err = xf_setsec(in, bsec_str[begsec_probdesc]);
00050 switch (err)
00051 {
00052 case 1:
00053 print_err("Section with problem description has not been detected", __FILE__, __LINE__, __func__);
00054 abort();
00055 default:
00056 break;
00057 }
00058
00059
00060 err = xf_setsec(in, bsec_str[begsec_loadcase]);
00061 switch (err)
00062 {
00063 case 1:
00064 print_err("Section with load cases has not been detected", __FILE__, __LINE__, __func__);
00065 abort();
00066 default:
00067 break;
00068 }
00069
00070
00071 err = xf_setsec(in, bsec_str[begsec_nodvertpr]);
00072 err += xf_setsec(in, bsec_str[begsec_nodedgpr]);
00073 err += xf_setsec(in, bsec_str[begsec_nodsurfpr]);
00074 err += xf_setsec(in, bsec_str[begsec_nodvolpr]);
00075 if (err == 4)
00076 {
00077 print_err("No section with nodal properties has been detected", __FILE__, __LINE__, __func__);
00078 abort();
00079 }
00080
00081
00082 err = xf_setsec(in, bsec_str[begsec_eledgpr]);
00083 err += xf_setsec(in, bsec_str[begsec_elsurfpr]);
00084 err += xf_setsec(in, bsec_str[begsec_elvolpr]);
00085 if (err == 3)
00086 {
00087 print_err("No section with properties of elements has been detected", __FILE__, __LINE__, __func__);
00088 abort();
00089 }
00090
00091
00092 err = xf_setsec(in, bsec_str[begsec_outdrv]);
00093 switch (err)
00094 {
00095 case 1:
00096 print_err("Section with outdriver data has not been detected", __FILE__, __LINE__, __func__);
00097 abort();
00098 default:
00099 break;
00100 }
00101 }
00102
00103
00104
00105
00106 int main (int argc,char *argv[])
00107 {
00108 XFILE *in;
00109 long err, i, l;
00110 descrip d;
00111 char *logname;
00112 char *tmp;
00113
00114 set_prgname(argv[0]);
00115 fprintf (stdout,"\n\n *** MEFEL PREPROCESSOR ***\n");
00116 fprintf (stdout," --------------------------\n");
00117
00118 Mp = new probdesc;
00119 Gtm = new gtopology;
00120 Top = new siftop;
00121 Mt = new mechtop;
00122 Mm = new mechmat;
00123 Mc = new mechcrsec;
00124 Mb = new mechbclc;
00125 Outdm = new outdriverm;
00126
00127 Bar2d = new barel2d;
00128 Bar3d = new barel3d;
00129 Beam2d = new beamel2d;
00130 Beam3d = new beamel3d;
00131 Spring = new springel;
00132 Pelt = new planeelemlt;
00133 Peqt = new planeelemqt;
00134 Perlt = new planeelemrotlt;
00135 Pelq = new planeelemlq;
00136 Peqq = new planeelemqq;
00137 Perlq = new planeelemrotlq;
00138 Pesqt = new planeelemsubqt;
00139 Cct = new cctelem;
00140 Dkt = new dktelem;
00141 Dst = new dstelem;
00142 Q4pl = new q4plate;
00143 Asymlq = new axisymlq;
00144 Asymqq = new axisymqq;
00145 Asymlt = new axisymlt;
00146 Shtr = new shelltr;
00147 Shq = new shellq;
00148 Ltet = new lintet;
00149 Lhex = new linhex;
00150 Qhex = new quadhex;
00151 Spltr = new soilplatetr;
00152 Splq = new soilplateq;
00153 Check_unused_prop = 1;
00154
00155 if (argc < 3){
00156 fprintf (stderr,"\n Wrong number of command line parameters.");
00157 fprintf (stderr,"\n Use : mechprep input_file_name output_file name\n\n");
00158 delete Mp; delete Mt; delete Mm; delete Mc; delete Mb;
00159 return(1);
00160 }
00161 in = xfopen(argv[1],"r");
00162 if (in == NULL){
00163 fprintf (stderr,"\n Input file has not been specified.");
00164 fprintf (stderr,"\n Try it again!\n\n");
00165 delete Mp; delete Mt; delete Mm; delete Mc; delete Mb;
00166 return(2);
00167 }
00168 logname = new char[strlen(argv[1])+5];
00169 strcpy(logname, argv[1]);
00170 l = strlen(logname);
00171 tmp = strrchr(logname, '.');
00172 if (tmp)
00173 sprintf(tmp+1, "plg");
00174 else
00175 sprintf(logname+l, ".plg");
00176 Log = fopen(logname, "w");
00177 in->warning = 1;
00178 in->kwdmode = sect_mode_seq;
00179
00180 in->ignorecase = 1;
00181
00182 xfdetect_sect(in, bsec_kwdset, esec_kwdset);
00183
00184 check_reqsec(in);
00185
00186 if (xf_setsec(in, bsec_str[begsec_mater]) == 0)
00187 d.matsec = yes;
00188 else
00189 d.matsec = no;
00190
00191
00192 if (xf_setsec(in, bsec_str[begsec_crsec]) == 0)
00193 d.crssec = yes;
00194 else
00195 d.crssec = no;
00196
00197
00198 xf_setsec(in, bsec_str[begsec_files]);
00199 input_files(in, d);
00200
00201
00202
00203 xf_setsec(in, bsec_str[begsec_probdesc]);
00204 fprintf(stdout, "\n\nReading of problem description . . .");
00205 Mp->read(in);
00206
00207
00208
00209 d.paral=0;
00210
00211
00212 err = input(in, &d);
00213 if(err)
00214 {
00215 xfclose(in);
00216 fclose(Log);
00217 delete Top;
00218 return(err);
00219 }
00220
00221
00222 in->kwdmode = sect_mode_seq;
00223
00224 xf_setsec(in, bsec_str[begsec_outdrv]);
00225 fprintf(stdout, "\n\nReading of outdriver section . . .");
00226 Outdm->read(in);
00227 xfclose(in);
00228 Outdm->conv_sel_prop(Top);
00229
00230 fprintf(stdout, "\n\nOutput of MEFEL input file %s :\n", argv[2]);
00231 l = strlen(argv[2])+29;
00232 for (i=0; i<l; i++)
00233 fprintf(stdout, "-");
00234 FILE *out = fopen(argv[2], "wt");
00235 if (out==NULL){
00236 fprintf (stderr,"\n Output file could not be opened.");
00237 fprintf (stderr,"\n Try it again!\n\n");
00238 fclose(Log);
00239 return(7);
00240 }
00241
00242
00243 fprintf(stdout, "\nTopology export . . .");
00244 Top->exporttop(Gtm);
00245 fprintf(stdout, " O.K.\n");
00246
00247
00248 fprintf(stdout, "\nProblem description output . . .");
00249 Mp->print(out);
00250 fprintf(stdout, " O.K.\n");
00251
00252
00253 output(out, &d);
00254
00255
00256 if (Mp->tprob == growing_mech_structure)
00257 {
00258 fprintf(stdout, "\n\nTime functions output . . .");
00259 fprintf(out, "# Time functions for dofs and elements\n");
00260 Gtm->print_gf(out);
00261 fprintf(stdout, " O.K.\n");
00262 }
00263
00264 fprintf(stdout, "\nOutdriver description output . . .");
00265 Outdm->print(out);
00266 fprintf(stdout, " O.K.\n");
00267 fclose(out);
00268 fflush(Log);
00269 if (ftell(Log) == 0)
00270 {
00271 fclose(Log);
00272 remove(logname);
00273 }
00274 else
00275 {
00276 fprintf(stdout, "\nSome warnings were registered.\nPlease check the file '%s'\n", logname);
00277 fclose(Log);
00278 }
00279 delete [] logname;
00280 printf ("\n");
00281 fprintf(stdout, "\n");
00282 fprintf(stderr, "\n");
00283
00284
00285 delete Mp;
00286 delete Mt;
00287 delete Gtm;
00288 delete Mm;
00289 delete Mc;
00290 delete Mb;
00291 delete Outdm;
00292
00293 delete Bar2d;
00294 delete Bar3d;
00295 delete Beam2d;
00296 delete Beam3d;
00297 delete Spring;
00298 delete Pelt;
00299 delete Peqt;
00300 delete Perlt;
00301 delete Pelq;
00302 delete Peqq;
00303 delete Perlq;
00304 delete Pesqt;
00305 delete Cct;
00306 delete Dkt;
00307 delete Dst;
00308 delete Q4pl;
00309 delete Asymlq;
00310 delete Asymqq;
00311 delete Asymlt;
00312 delete Shtr;
00313 delete Shq;
00314 delete Ltet;
00315 delete Lhex;
00316 delete Qhex;
00317 delete Spltr;
00318 delete Splq;
00319
00320 return(0);
00321 }
00322