tinpdata.cpp

00001 /*************************************************************************************
00002  * MechSys - A C++ library to simulate (Continuum) Mechanical Systems                *
00003  * Copyright (C) 2005 Dorival de Moraes Pedroso <dorival.pedroso at gmail.com>       *
00004  * Copyright (C) 2005 Raul Dario Durand Farfan  <raul.durand at gmail.com>           *
00005  *                                                                                   *
00006  * This file is part of MechSys.                                                     *
00007  *                                                                                   *
00008  * MechSys is free software; you can redistribute it and/or modify it under the      *
00009  * terms of the GNU General Public License as published by the Free Software         *
00010  * Foundation; either version 2 of the License, or (at your option) any later        *
00011  * version.                                                                          *
00012  *                                                                                   *
00013  * MechSys is distributed in the hope that it will be useful, but WITHOUT ANY        *
00014  * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A   *
00015  * PARTICULAR PURPOSE. See the GNU General Public License for more details.          *
00016  *                                                                                   *
00017  * You should have received a copy of the GNU General Public License along with      *
00018  * MechSys; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, *
00019  * Fifth Floor, Boston, MA 02110-1301, USA                                           *
00020  *************************************************************************************/
00021 
00022 #include <iostream>
00023 #include <iomanip>
00024 
00025 #include "fem/inputdata.h"
00026 #include "fem/filesdata.h"
00027 
00028 using std::cout;
00029 using std::endl;
00030 
00031 int main(int argc, char **argv) try
00032 {
00033     // InputData
00034     FEM::InputData ID;
00035 
00036     // Parse input arguments
00037     String MainFilename;
00038     bool   IsConsole;
00039     bool   IsSilent;
00040     bool   IsHelpMsg;
00041     ID.ParseInputArgs(argc, argv, MainFilename, IsConsole, IsSilent, IsHelpMsg);
00042 
00043     cout << "MainFilename = " <<                   MainFilename << endl;
00044     cout << "IsConsole    = " << std::boolalpha << IsConsole    << endl;
00045     cout << "IsSilent     = " << std::boolalpha << IsSilent     << endl;
00046     cout << "IsHelpMsg    = " << std::boolalpha << IsHelpMsg    << endl;
00047     cout << endl;
00048 
00049     if (IsHelpMsg)
00050     {
00051         cout << ID.HelpMessage();
00052         return 0;
00053     }
00054 
00055     if (IsConsole)
00056     {
00057         // Read file
00058         ID.ReadMainFile(MainFilename);
00059         String out_fn(MainFilename); out_fn.append(String(".out.txt"));
00060 
00061         // write file
00062         bool did_write=false;
00063         try
00064         {
00065             ID.WriteMainFile(out_fn);
00066             did_write=true;
00067         }
00068         catch (Exception * e)
00069         {
00070             if (e->IsFatal()) {e->Cout(); delete e; exit(1);}
00071             cout << "Warning: " << e->Msg() << " => It will be overwritten\n";
00072             delete e;
00073         }
00074         if (!did_write)
00075             ID.WriteMainFile(out_fn, true);
00076 
00077         // Test FilesData
00078         FEM::FilesData FD;
00079         FD.ReadAllFiles(ID);
00080 
00081         FD.WriteNodes         ("tmp.out.node", true);
00082         FD.WriteFaces         ("tmp.out.face", true);
00083         FD.WriteElements      ("tmp.out.ele", true);
00084         FD.WriteNodeBry       ("tmp.out.nbc", true);
00085         FD.WriteFaceBry       ("tmp.out.fbc", true);
00086         FD.WriteAttributes    ("tmp.out.att", true);
00087         FD.WriteInitialValues ("tmp.out.ini", true);
00088     }
00089 
00090     return 0;
00091 }
00092 catch (Exception * e)
00093 {
00094     e->Cout();
00095     if (e->IsFatal()) {delete e; exit(1);}
00096     delete e;
00097 }
00098 catch (...)
00099 {
00100     std::cout << "Some exception (...) ocurred\n";
00101 }

Generated on Wed Jan 24 15:56:26 2007 for MechSys by  doxygen 1.4.7