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 "pglobal.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, l;
00110 descrip d;
00111 char *logname;
00112 char *tmp;
00113
00114 fprintf (stdout,"\n\n *** PARMEFEL PREPROCESSOR ***\n");
00115 fprintf (stdout," --------------------------\n");
00116
00117 Mp = new probdesc;
00118 Gtm = new gtopology;
00119 Top = new siftop;
00120 Mt = new mechtop;
00121 Mm = new mechmat;
00122 Mc = new mechcrsec;
00123 Mb = new mechbclc;
00124 Outdm = new outdriverm;
00125
00126 Bar2d = new barel2d;
00127 Bar3d = new barel3d;
00128 Beam2d = new beamel2d;
00129 Beam3d = new beamel3d;
00130 Spring = new springel;
00131 Pelt = new planeelemlt;
00132 Peqt = new planeelemqt;
00133 Perlt = new planeelemrotlt;
00134 Pelq = new planeelemlq;
00135 Peqq = new planeelemqq;
00136 Perlq = new planeelemrotlq;
00137 Pesqt = new planeelemsubqt;
00138 Cct = new cctelem;
00139 Dkt = new dktelem;
00140 Dst = new dstelem;
00141 Q4pl = new q4plate;
00142 Asymlq = new axisymlq;
00143 Asymqq = new axisymqq;
00144 Asymlt = new axisymlt;
00145 Shtr = new shelltr;
00146 Shq = new shellq;
00147 Ltet = new lintet;
00148 Lhex = new linhex;
00149 Qhex = new quadhex;
00150 Spltr = new soilplatetr;
00151 Splq = new soilplateq;
00152 Check_unused_prop = 0;
00153
00154 if (argc < 3){
00155 fprintf (stderr,"\n Wrong number of command line parameters.");
00156 fprintf (stderr,"\n Use : pmechprep input_file_name output_file name\n\n");
00157 delete Mp; delete Mt; delete Mm; delete Mc; delete Mb;
00158 return(1);
00159 }
00160 in = xfopen(argv[1],"r");
00161 if (in == NULL){
00162 fprintf (stderr,"\n Input file has not been specified.");
00163 fprintf (stderr,"\n Try it again!\n\n");
00164 delete Mp; delete Mt; delete Mm; delete Mc; delete Mb;
00165 return(2);
00166 }
00167 logname = new char[strlen(argv[1])+5];
00168 strcpy(logname, argv[1]);
00169 l = strlen(logname);
00170 tmp = strrchr(logname, '.');
00171 if (tmp)
00172 sprintf(tmp+1, "plg");
00173 else
00174 sprintf(logname+l, ".plg");
00175 Log = fopen(logname, "w");
00176 in->warning = 1;
00177 in->kwdmode = sect_mode_seq;
00178
00179 in->ignorecase = 1;
00180
00181 xfdetect_sect(in, bsec_kwdset, esec_kwdset);
00182
00183 check_reqsec(in);
00184
00185
00186 xf_setsec(in, bsec_str[begsec_files]);
00187
00188
00189 xfscanf(in, " %a", d.topf);
00190
00191 xfscanf(in, " %a", d.matf);
00192
00193 xfscanf(in, " %a", d.crf);
00194
00195 xfscanf(in, "%k%m", "mesh_format", &meshform_kwdset, &d.meshfmt);
00196
00197 xfscanf(in, "%k%ld", "edge_numbering", &d.redgn);
00198
00199 d.hangnf[0] = 0;
00200 xfscanf(in, "%+k %a", "hanging_nodes_file", &d.hangnf);
00201
00202
00203 Psolm = new psolver (Nproc,Myrank,proc_name,nameLength);
00204
00205 xf_setsec(in, bsec_str[begsec_probdesc]);
00206 fprintf(stdout, "\n\nReading of problem description . . .");
00207 xfscanf (in,"%k%ld","domain_number",&Ndom);
00208 Mp->read(in);
00209
00210 Psolm->read (in,Gtm,Ndom,Mp->tstorsm,Mespr);
00211
00212
00213
00214 d.paral = 1;
00215 if (Psolm->tdd==layered_plate)
00216 d.paral = 0;
00217
00218
00219 err = input(in, &d);
00220 if(err)
00221 {
00222 xfclose(in);
00223 fclose(Log);
00224 delete Top;
00225 return(err);
00226 }
00227
00228
00229 Mt->alloc_prep(Top->nn, Top->ne, El_type);
00230 if (Mp->tprob == growing_mech_structure)
00231 {
00232 fprintf(stdout, "\n\nReading of section with time functions . . .");
00233 xf_setsec(in, bsec_str[begsec_loadcase]);
00234 in->kwdmode = sect_mode_full;
00235 xfscanf(in, "%k", "time_functions");
00236 in->kwdmode = sect_mode_seq;
00237 Gtm->read_gf (in);
00238 }
00239
00240 in->kwdmode = sect_mode_seq;
00241
00242 xf_setsec(in, bsec_str[begsec_outdrv]);
00243 fprintf(stdout, "\n\nReading of outdriver section . . .");
00244 Outdm->read(in);
00245 xfclose(in);
00246
00247 fprintf(stdout, "\n\nOutput of MEFEL input file %s :", argv[2]);
00248 FILE *out = fopen(argv[2], "wt");
00249 if (out==NULL){
00250 fprintf (stderr,"\n Output file could not be opened.");
00251 fprintf (stderr,"\n Try it again!\n\n");
00252 fclose(Log);
00253 return(7);
00254 }
00255
00256
00257
00258
00259
00260
00261
00262
00263
00264
00265
00266
00267
00268
00269
00270
00271
00272
00273
00274
00275
00276
00277
00278
00279
00280
00281
00282
00283 fprintf(stdout, "\nTopology export . . .");
00284 Top->exporttop(Gtm);
00285 fprintf(stdout, " O.K.\n");
00286
00287
00288 fprintf(stdout, "\nProblem description output . . .");
00289 fprintf (out,"%d\n",Ndom);
00290 Mp->print(out);
00291 Psolm->print (out);
00292 fprintf(stdout, " O.K.\n");
00293
00294
00295 output(out, &d);
00296
00297
00298 if (Mp->tprob == growing_mech_structure)
00299 {
00300 fprintf(stdout, "\nTime function output . . .");
00301 Gtm->print_gf(out);
00302 fprintf(stdout, " O.K.\n");
00303 }
00304
00305 fprintf(stdout, "\nOutdriver description output . . .");
00306 Outdm->print(out);
00307 fprintf(stdout, " O.K.\n");
00308 fclose(out);
00309 fflush(Log);
00310 if (ftell(Log) == 0)
00311 {
00312 fclose(Log);
00313 remove(logname);
00314 }
00315 else
00316 {
00317 fprintf(stdout, "\nSome warnings were registered.\nPlease check the file '%s'\n", logname);
00318 fclose(Log);
00319 }
00320 printf ("\n");
00321 fprintf(stdout, "\n");
00322 fprintf(stderr, "\n");
00323
00324
00325 delete Mp;
00326 delete Psolm;
00327 delete Mt;
00328 delete Gtm;
00329 delete Mm;
00330 delete Mc;
00331 delete Mb;
00332 delete Outdm;
00333
00334 delete Bar2d;
00335 delete Bar3d;
00336 delete Beam2d;
00337 delete Beam3d;
00338 delete Spring;
00339 delete Pelt;
00340 delete Peqt;
00341 delete Perlt;
00342 delete Pelq;
00343 delete Peqq;
00344 delete Perlq;
00345 delete Pesqt;
00346 delete Cct;
00347 delete Dkt;
00348 delete Dst;
00349 delete Q4pl;
00350 delete Asymlq;
00351 delete Asymqq;
00352 delete Asymlt;
00353 delete Shtr;
00354 delete Shq;
00355 delete Ltet;
00356 delete Lhex;
00357 delete Qhex;
00358 delete Spltr;
00359 delete Splq;
00360
00361 return(0);
00362 }
00363