![]() |
MechSys
1.0
Computing library for simulations in continuum and discrete mechanics
|
00001 /************************************************************************ 00002 * MechSys - Open Library for Mechanical Systems * 00003 * Copyright (C) 2005 Dorival M. Pedroso, Raúl D. D. Farfan * 00004 * * 00005 * This program is free software: you can redistribute it and/or modify * 00006 * it under the terms of the GNU General Public License as published by * 00007 * the Free Software Foundation, either version 3 of the License, or * 00008 * any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License * 00016 * along with this program. If not, see <http://www.gnu.org/licenses/> * 00017 ************************************************************************/ 00018 00019 #ifndef MECHSYS_INPFILE_H 00020 #define MECHSYS_INPFILE_H 00021 00022 // Std Lib 00023 #include <fstream> 00024 00025 // wxWidgets 00026 #ifdef USE_WXWIDGETS 00027 #include <mechsys/gui/common.h> 00028 #include <mechsys/gui/wxdict.h> 00029 #include <mechsys/gui/wxsipair.h> 00030 #include <mechsys/gui/wxarrayint.h> 00031 #endif 00032 00033 // MechSys 00034 #include <mechsys/util/maps.h> 00035 #include <mechsys/util/fatal.h> 00036 #include <mechsys/util/util.h> 00037 #include <mechsys/linalg/matvec.h> 00038 #include <mechsys/fem/element.h> // for PROB 00039 #include <mechsys/fem/geomelem.h> // for GEOM 00040 #include <mechsys/matfile.h> 00041 #include <mechsys/models/model.h> 00042 00043 /* 00044 struct PathIncs 00045 { 00046 double dsx, dsy, dsz, dsxy, dsyz, dszx; // stress increments 00047 double dex, dey, dez, dexy, deyz, dezx; // strain increments (percentage) 00048 double lode, dp; // path given Lode angle (deg), dpoct and dez (percentage) 00049 bool zPath; // use lode, dp and dez ? 00050 int ninc; // number of increments for this path. -1 => use general 00051 double k; // path given Lode, k=dqoct/dpoct, and dez 00052 bool kPath; // with k=Dq/Dp 00053 double dpw, dSw; // increment of pore-water pressure and water saturation 00054 bool HasDpw, HasDSw; // has dpw or dSw ? 00055 PathIncs () : dsx(0.),dsy(0.),dsz(0.),dsxy(0.),dsyz(0.),dszx(0.), 00056 dex(0.),dey(0.),dez(0.),dexy(0.),deyz(0.),dezx(0.), 00057 lode(0.),dp(0.),zPath(false),ninc(-1),k(0.),kPath(false), 00058 dpw(0.),dSw(0.),HasDpw(false),HasDSw(false) {} 00059 }; 00060 */ 00061 00062 #ifdef USE_WXWIDGETS 00063 class InpFile : public wxWindow 00064 #else 00065 class InpFile 00066 #endif 00067 { 00068 public: 00069 // Constructor & Destructor 00070 #ifdef USE_WXWIDGETS 00071 InpFile (wxFrame * Parent); 00072 #else 00073 InpFile (); 00074 #endif 00075 ~InpFile (); 00076 00077 // Methods 00078 void Defaults (); 00079 void Read (char const * FileName); 00080 void SetPrmsInis (MatFile const & Mat, bool ForceGTY=false); 00081 void GetIncs (int PathKey, double Div, Vec_t & dsig, Vec_t & deps, Array<bool> & PrescDeps, double & dpw, double & dSw, bool & PrescDpw, bool & PrescDSw) const; 00082 void SetSUp (Model const * Mdl, Model::StressUpdate::pDbgFun pFun=NULL, void * UserData=NULL) const; 00083 void SetSolFlags (SDPair & Flags) const; 00084 00085 // Data 00086 int ninc; 00087 bool cdrift; 00088 double stol; 00089 bool ssout; 00090 bool ctetg; 00091 bool fem; 00092 bool dyn; 00093 bool hm; 00094 double tf; 00095 double dt; 00096 double dtout; 00097 double tsw; 00098 int ndiv; 00099 int nip; 00100 bool o2; 00101 bool ray; 00102 double am; 00103 double ak; 00104 bool rk; 00105 String rkscheme; 00106 double rkstol; 00107 String refdat; 00108 String refsim; 00109 String refana; 00110 int idxvert1; 00111 int idxvert2; 00112 int idxvert3; 00113 double optdbl1; 00114 double optdbl2; 00115 double optdbl3; 00116 bool hasoptdbl1, hasoptdbl2, hasoptdbl3; 00117 int nldt_nsml; 00118 int nldt_nn; 00119 int nldt_n; 00120 double nldt_ll; 00121 int nldt_sch; 00122 double nldt_m; 00123 int maxit; 00124 double tolr; 00125 String fnkey; 00126 double pcam0; 00127 bool haspcam0; 00128 String scheme; 00129 bool vtufile; 00130 String suscheme; 00131 double sustol; 00132 String surkscheme; 00133 size_t dcmaxit; 00134 double dcftol; 00135 double pw0; 00136 bool haspw0; 00137 bool rkdyncte; 00138 bool uwp; 00139 00140 Array<String> AllUKeys, AllUKeysBCF; 00141 Array<String> AllFKeys, AllFKeysBCF; 00142 Array<String> AllEKeys, AllEKeysBCF; 00143 00144 // Additional data 00145 Dict * Prms; 00146 Dict * Inis; 00147 00148 #ifdef USE_WXWIDGETS 00149 // Methods 00150 void Sync (bool Dat2Ctrl=false) { if (Dat2Ctrl) TransferDataToWindow(); else TransferDataFromWindow(); } 00151 00152 // Data 00153 wxAuiManager Aui; 00154 wxString LstDir; 00155 String FName; 00156 GUI::WxDictTable * Path; 00157 GUI::WxDict * GPath; 00158 00159 // Additional data 00160 GUI::WxDictTable * Prps; 00161 GUI::WxArrayIntTable * OutNods; 00162 GUI::WxDict * GPrps; 00163 GUI::WxArrayInt * GOutNods; 00164 GUI::WxSIPairTable * Tag2MatID; 00165 GUI::WxSIPairTable * Tag2XMatID; 00166 GUI::WxSIPair * GMatId2Tag; 00167 00168 // Boundary conditions 00169 Array<GUI::WxDictTable*> Stages; 00170 //Array<GUI::WxDict*> GStages; ///< grid: boundary conditions 00171 00172 // Events 00173 void OnLoad (wxCommandEvent & Event); 00174 void OnSave (wxCommandEvent & Event); 00175 DECLARE_EVENT_TABLE(); 00176 00177 #else 00178 // Data 00179 Dict * Path; 00180 00181 // Additional data 00182 Dict * Prps; 00183 Array<int> * OutNods; 00184 SIPair * Tag2MatID; 00185 SIPair * Tag2XMatID; 00186 00187 // Boundary conditions 00188 Array<Dict*> Stages; 00189 #endif 00190 00191 #ifdef USE_BOOST_PYTHON 00192 BPy::tuple PyReadPrmIni (char const * MatFN, char const * InpFN, int Tag) 00193 { 00194 BPy::dict prm, ini; 00195 MatFile mat; 00196 mat.Read (MatFN); 00197 Read (InpFN); 00198 SetPrmsInis (mat); 00199 Prms->PyGet (Tag, prm); 00200 Inis->PyGet (Tag, ini); 00201 return BPy::make_tuple (prm, ini); 00202 } 00203 #endif 00204 }; 00205 00206 00208 00209 00210 #ifdef USE_WXWIDGETS 00211 00212 inline InpFile::~InpFile () 00213 { 00214 Aui.UnInit (); 00215 delete Prms; 00216 delete Inis; 00217 } 00218 00219 #else 00220 00221 inline InpFile::InpFile () 00222 { 00223 Defaults (); 00224 Path = new Dict; 00225 Prps = new Dict; 00226 OutNods = new Array<int>; 00227 Tag2MatID = new SIPair; 00228 Tag2XMatID = new SIPair; 00229 Prms = new Dict; 00230 Inis = new Dict; 00231 } 00232 00233 inline InpFile::~InpFile () 00234 { 00235 delete Path; 00236 delete Prps; 00237 delete OutNods; 00238 delete Tag2MatID; 00239 delete Tag2XMatID; 00240 delete Prms; 00241 delete Inis; 00242 for (size_t i=0; i<Stages.Size(); ++i) delete Stages[i]; 00243 } 00244 00245 #endif 00246 00247 inline void InpFile::Defaults () 00248 { 00249 ninc = -1; // 1 00250 cdrift = false; // 2 00251 stol = -1; // 3 00252 ssout = false; // 4 00253 ctetg = false; // 5 00254 fem = false; // 6 00255 dyn = false; // 7 00256 hm = false; // 8 00257 tf = -1; // 9 00258 dt = -1; // 10 00259 dtout = -1; // 11 00260 tsw = -1; // 12 00261 ndiv = -1; // 13 00262 nip = -1; // 14 00263 o2 = false; // 15 00264 ray = false; // 16 00265 am = -1; // 17 00266 ak = -1; // 18 00267 rk = false; // 19 00268 rkscheme = ""; // 20 00269 rkstol = -1; // 21 00270 refdat = ""; // 22 00271 refsim = ""; // 23 00272 refana = ""; // 24 00273 idxvert1 = -1; // 25 00274 idxvert2 = -1; // 26 00275 idxvert3 = -1; // 27 00276 optdbl1 = 0; // 28 00277 optdbl2 = 0; // 29 00278 optdbl3 = 0; // 30 00279 hasoptdbl1 = false; hasoptdbl2=false; hasoptdbl3=false; 00280 nldt_nsml = -1; // 31 00281 nldt_nn = -1; // 32 00282 nldt_n = -1; // 33 00283 nldt_ll = -1; // 34 00284 nldt_sch = -1; // 35 00285 nldt_m = -1; // 36 00286 maxit = -1; // 37 00287 tolr = -1; // 38 00288 fnkey = ""; // 39 00289 pcam0 = 0; // 40 00290 haspcam0 = false; 00291 scheme = ""; // 41 00292 vtufile = false; // 42 00293 suscheme = ""; // 43 00294 sustol = -1; // 44 00295 surkscheme = ""; // 45 00296 dcmaxit = 0; // 46 00297 dcftol = -1; // 47 00298 pw0 = 0; // 48 00299 haspw0 = false; 00300 rkdyncte = true; // 49 00301 uwp = false; // 50 00302 00303 // U and F keys 00304 for (FEM::ElementVarKeys_t::const_iterator it=FEM::ElementVarKeys.begin(); it!=FEM::ElementVarKeys.end(); ++it) 00305 { 00306 // U keys 00307 Array<String> keys; 00308 Util::Keys2Array (it->second.first, keys); 00309 for (size_t i=0; i<keys.Size(); ++i) 00310 { 00311 AllUKeys.XPush (keys[i]); 00312 keys[i].ToUpper(); 00313 AllUKeysBCF.XPush (keys[i]); 00314 } 00315 00316 // F keys 00317 keys.Clear(); 00318 Util::Keys2Array (it->second.second, keys); 00319 for (size_t i=0; i<keys.Size(); ++i) 00320 { 00321 AllFKeys.XPush (keys[i]); 00322 keys[i].ToUpper(); 00323 AllFKeysBCF.XPush (keys[i]); 00324 } 00325 } 00326 /* 00327 std::cout << "AllUKeys = " << AllUKeys << std::endl; 00328 std::cout << "AllUKeysBCF = " << AllUKeysBCF << std::endl; 00329 std::cout << "AllFKeys = " << AllFKeys << std::endl; 00330 std::cout << "AllFKeysBCF = " << AllFKeysBCF << std::endl; 00331 */ 00332 00333 // Extra keys 00334 for (FEM::ElementExtraKeys_t::const_iterator it=FEM::ElementExtraKeys.begin(); it!=FEM::ElementExtraKeys.end(); ++it) 00335 { 00336 for (size_t i=0; i<it->second.Size(); ++i) 00337 { 00338 AllEKeys .XPush (it->second[i]); 00339 AllEKeysBCF.XPush (it->second[i].ToUpperCpy()); 00340 } 00341 } 00342 } 00343 00344 inline void InpFile::Read (char const * FileName) 00345 { 00346 // parse input file 00347 std::fstream inp_file(FileName, std::ios::in); 00348 if (!inp_file.is_open()) throw new Fatal("InpFile::Read: Could not open file <%s>",FileName); 00349 bool reading_path = false; 00350 bool reading_eprps = false; 00351 bool reading_stages = false; 00352 bool reading_bcs = false; 00353 int npath = 0; 00354 int nelemprps = 0; 00355 int nstages = 0; 00356 int nbcs = -1; 00357 int ndat = -1; 00358 size_t line_num = 1; 00359 int idxdat = 0; 00360 int idxbcs = 0; 00361 int idxpath = 0; 00362 int idxeprps = 0; 00363 int idxstage = 0; 00364 int elemtag = -1; 00365 int bcstag = 0; 00366 SDPair elemprps; 00367 SDPair bcs; 00368 Path -> clear(); 00369 Prps -> clear(); 00370 OutNods -> Resize(0); 00371 Tag2MatID -> clear(); 00372 Tag2XMatID-> clear(); 00373 Prms -> clear(); 00374 Inis -> clear(); 00375 for (size_t i=0; i<Stages.Size(); ++i) delete Stages[i]; 00376 Stages.Resize(0); 00377 while (!inp_file.eof()) 00378 { 00379 String line,key,equal,str_val; 00380 double val; 00381 std::getline (inp_file,line); 00382 std::istringstream iss(line); 00383 if (iss >> key >> equal >> str_val) 00384 { 00385 val = atof(str_val.CStr()); 00386 if (key[0]=='#') { line_num++; continue; } 00387 if (reading_path) 00388 { 00389 if (key=="ndat") ndat = atoi(str_val.CStr()); 00390 else if (ndat<0) throw new Fatal("InpFile::Read: Reading path. Error in file <%s> at line # %d: key 'ndat' must come before data. '%s' is in the wrong place",FileName,line_num,key.CStr()); 00391 else if (key=="kcam") { Path->Set(idxpath, "kcam" , val ); idxdat++; } 00392 else if (key=="dpcam") { Path->Set(idxpath, "dpcam", val ); idxdat++; } 00393 else if (key=="lode") { Path->Set(idxpath, "lode" , val ); idxdat++; if (val<30. || val>90.) throw new Fatal("InpFile::Read: Error in file <%s> at line # %d: Lode angle alpha must be inside [30,90]. Alpha==%g is invalid",FileName,line_num,val); } 00394 else if (key=="dex") { Path->Set(idxpath, "dex" , val/100.); idxdat++; } 00395 else if (key=="dey") { Path->Set(idxpath, "dey" , val/100.); idxdat++; } 00396 else if (key=="dez") { Path->Set(idxpath, "dez" , val/100.); idxdat++; } 00397 else if (key=="dexy") { Path->Set(idxpath, "dexy" , val/100.); idxdat++; } 00398 else if (key=="deyz") { Path->Set(idxpath, "deyz" , val/100.); idxdat++; } 00399 else if (key=="dezx") { Path->Set(idxpath, "dezx" , val/100.); idxdat++; } 00400 else if (key=="dsx") { Path->Set(idxpath, "dsx" , val ); idxdat++; } 00401 else if (key=="dsy") { Path->Set(idxpath, "dsy" , val ); idxdat++; } 00402 else if (key=="dsz") { Path->Set(idxpath, "dsz" , val ); idxdat++; } 00403 else if (key=="dsxy") { Path->Set(idxpath, "dsxy" , val ); idxdat++; } 00404 else if (key=="dsyz") { Path->Set(idxpath, "dsyz" , val ); idxdat++; } 00405 else if (key=="dszx") { Path->Set(idxpath, "dszx" , val ); idxdat++; } 00406 else if (key=="dpw") { Path->Set(idxpath, "dpw" , val ); idxdat++; } 00407 else if (key=="dSw") { Path->Set(idxpath, "dSw" , val ); idxdat++; } 00408 else if (key=="ninc") { Path->Set(idxpath, "ninc" , val ); idxdat++; } 00409 else throw new Fatal("InpFile::Read: Reading path. Error in file <%s> at line # %d when reading data of Path # %d. Key==%s is invalid or in the wrong place",FileName,line_num,idxpath,key.CStr()); 00410 if (idxdat==ndat) 00411 { 00412 ndat = -1; 00413 idxdat = 0; 00414 idxpath++; 00415 if (idxpath==npath) reading_path = false; 00416 } 00417 } 00418 else if (reading_eprps) 00419 { 00420 if (key=="ndat") ndat = atoi(str_val.CStr()); 00421 else if (ndat<0) throw new Fatal("InpFile::Read: Reading elements properties. Error in file <%s> at line # %d: key 'ndat' must come before data. '%s' is in the wrong place",FileName,line_num,key.CStr()); 00422 else if (key=="elemtag") { elemtag = atoi(str_val.CStr()); idxdat++; } 00423 else if (key=="prob") { elemprps.Set (key.CStr(), FEM::PROB(str_val.CStr())); idxdat++; } 00424 else if (key=="geom") { elemprps.Set (key.CStr(), FEM::GEOM(str_val.CStr())); idxdat++; } 00425 else if (key=="psa") { elemprps.Set (key.CStr(), atof(str_val.CStr())); idxdat++; } 00426 else if (key=="pse") { elemprps.Set (key.CStr(), atof(str_val.CStr())); idxdat++; } 00427 else if (key=="fra") { elemprps.Set (key.CStr(), atof(str_val.CStr())); idxdat++; } 00428 else if (key=="d2d") { elemprps.Set (key.CStr(), atof(str_val.CStr())); idxdat++; } 00429 else if (key=="d3d") { elemprps.Set (key.CStr(), atof(str_val.CStr())); idxdat++; } 00430 else if (key=="rho") { elemprps.Set (key.CStr(), atof(str_val.CStr())); idxdat++; } 00431 else if (key=="geosta") { elemprps.Set (key.CStr(), atof(str_val.CStr())); idxdat++; } 00432 else if (key=="pospw") { elemprps.Set (key.CStr(), atof(str_val.CStr())); idxdat++; } 00433 else if (key=="K0") { elemprps.Set (key.CStr(), atof(str_val.CStr())); idxdat++; } 00434 else if (key=="surf") { elemprps.Set (key.CStr(), atof(str_val.CStr())); idxdat++; } 00435 else if (key=="water") { elemprps.Set (key.CStr(), atof(str_val.CStr())); idxdat++; } 00436 else if (key=="E") { elemprps.Set (key.CStr(), atof(str_val.CStr())); idxdat++; } 00437 else if (key=="A") { elemprps.Set (key.CStr(), atof(str_val.CStr())); idxdat++; } 00438 else if (key=="Izz") { elemprps.Set (key.CStr(), atof(str_val.CStr())); idxdat++; } 00439 else throw new Fatal("InpFile::Read: Reading elements properties. Error in file <%s> at line # %d when reading data of Properties # %d. Key==%s is invalid or in the wrong place",FileName,line_num,idxeprps,key.CStr()); 00440 if (idxdat==ndat) 00441 { 00442 Prps->Set (elemtag, elemprps); 00443 ndat = -1; 00444 idxdat = 0; 00445 elemtag = -1; 00446 elemprps.clear(); 00447 idxeprps++; 00448 if (idxeprps==nelemprps) reading_eprps = false; 00449 } 00450 } 00451 else if (reading_stages && !reading_bcs) 00452 { 00453 #ifdef USE_WXWIDGETS 00454 if (key=="nbcs") { nbcs = atoi(str_val.CStr()); Stages.Push(new GUI::WxDictTable); reading_bcs=true; } 00455 #else 00456 if (key=="nbcs") { nbcs = atoi(str_val.CStr()); Stages.Push(new Dict); reading_bcs=true; } 00457 #endif 00458 else throw new Fatal("InpFile::Read: Reading boundary conditions (stages). Error in file <%s> at line # %d: key '%s' is in the wrong place",FileName,line_num,key.CStr()); 00459 } 00460 else if (reading_bcs) 00461 { 00462 if (key=="ndat") ndat = atoi(str_val.CStr()); 00463 else if (ndat<0) throw new Fatal("InpFile::Read: Reading boundary conditions (stages). Error in file <%s> at line # %d: key 'ndat' must come after 'nbcs' and before data. '%s' is in the wrong place",FileName,line_num,key.CStr()); 00464 else if (key=="tag") { bcstag = atoi(str_val.CStr()); idxdat++; } 00465 else if (AllUKeys .Has(key)) { bcs.Set (key.CStr(), atof(str_val.CStr())); idxdat++; } 00466 else if (AllFKeys .Has(key)) { bcs.Set (key.CStr(), atof(str_val.CStr())); idxdat++; } 00467 else if (AllEKeys .Has(key)) { bcs.Set (key.CStr(), atof(str_val.CStr())); idxdat++; } 00468 else if (AllUKeysBCF.Has(key)) { bcs.Set (key.CStr(), atof(str_val.CStr())); idxdat++; } 00469 else if (AllFKeysBCF.Has(key)) { bcs.Set (key.CStr(), atof(str_val.CStr())); idxdat++; } 00470 else if (AllEKeysBCF.Has(key)) { bcs.Set (key.CStr(), atof(str_val.CStr())); idxdat++; } 00471 else if (key=="fgrav") { bcs.Set (key.CStr(), atof(str_val.CStr())); idxdat++; } 00472 else throw new Fatal("InpFile::Read: Reading boundary conditions (stages). Error in file <%s> at line # %d when reading data of Stage # %d. Key==%s is invalid or in the wrong place",FileName,line_num,idxstage,key.CStr()); 00473 if (idxdat==ndat) 00474 { 00475 Stages[idxstage]->Set (bcstag, bcs); 00476 ndat = -1; 00477 idxdat = 0; 00478 bcstag = 0; 00479 bcs.clear (); 00480 idxbcs++; 00481 if (idxbcs==nbcs) 00482 { 00483 reading_bcs = false; 00484 nbcs = -1; 00485 idxbcs = 0; 00486 idxstage++; 00487 if (idxstage==nstages) reading_stages = false; 00488 } 00489 } 00490 } 00491 else 00492 { 00493 if (key=="ninc") ninc = atoi(str_val.CStr()); // 1 00494 else if (key=="cdrift") cdrift = (bool)atoi(str_val.CStr()); // 2 00495 else if (key=="stol") stol = val; // 3 00496 else if (key=="ssout") ssout = (bool)atoi(str_val.CStr()); // 4 00497 else if (key=="ctetg") ctetg = (bool)atoi(str_val.CStr()); // 5 00498 else if (key=="fem") fem = val; // 6 00499 else if (key=="dyn") dyn = (bool)atoi(str_val.CStr()); // 7 00500 else if (key=="hm") hm = (bool)atoi(str_val.CStr()); // 8 00501 else if (key=="tf") tf = val; // 9 00502 else if (key=="dt") dt = val; // 10 00503 else if (key=="dtout") dtout = val; // 11 00504 else if (key=="tsw") tsw = val; // 12 00505 else if (key=="ndiv") ndiv = atoi(str_val.CStr()); // 13 00506 else if (key=="nip") nip = atoi(str_val.CStr()); // 14 00507 else if (key=="o2") o2 = (bool)atoi(str_val.CStr()); // 15 00508 else if (key=="ray") ray = (bool)atoi(str_val.CStr()); // 16 00509 else if (key=="am") am = val; // 17 00510 else if (key=="ak") ak = val; // 18 00511 else if (key=="rk") rk = (bool)atoi(str_val.CStr()); // 19 00512 else if (key=="rkscheme") rkscheme = str_val; // 20 00513 else if (key=="rkstol") rkstol = val; // 21 00514 else if (key=="refdat") refdat = str_val; // 22 00515 else if (key=="refsim") refsim = str_val; // 23 00516 else if (key=="refana") refana = str_val; // 24 00517 else if (key=="idxvert1") idxvert1 = atoi(str_val.CStr()); // 25 00518 else if (key=="idxvert2") idxvert2 = atoi(str_val.CStr()); // 26 00519 else if (key=="idxvert3") idxvert3 = atoi(str_val.CStr()); // 27 00520 else if (key=="optdbl1") { optdbl1 = val; hasoptdbl1=true; } // 28 00521 else if (key=="optdbl2") { optdbl2 = val; hasoptdbl2=true; } // 29 00522 else if (key=="optdbl3") { optdbl3 = val; hasoptdbl3=true; } // 30 00523 else if (key=="nldt_nsml") nldt_nsml = atoi(str_val.CStr()); // 31 00524 else if (key=="nldt_nn") nldt_nn = atoi(str_val.CStr()); // 32 00525 else if (key=="nldt_n") nldt_n = atoi(str_val.CStr()); // 33 00526 else if (key=="nldt_ll") nldt_ll = val; // 34 00527 else if (key=="nldt_sch") nldt_sch = atoi(str_val.CStr()); // 35 00528 else if (key=="nldt_m") nldt_m = val; // 36 00529 else if (key=="maxit") maxit = atoi(str_val.CStr()); // 37 00530 else if (key=="tolr") tolr = val; // 38 00531 else if (key=="fnkey") fnkey = str_val; // 39 00532 else if (key=="pcam0") { pcam0 = val; haspcam0 = true; } // 40 00533 else if (key=="scheme") scheme = str_val; // 41 00534 else if (key=="vtufile") vtufile = (int)val; // 42 00535 else if (key=="suscheme") suscheme = str_val; // 43 00536 else if (key=="sustol") sustol = val; // 44 00537 else if (key=="surkscheme") surkscheme= str_val; // 45 00538 else if (key=="dcmaxit") dcmaxit = (int)val; // 46 00539 else if (key=="dcftol") dcftol = val; // 47 00540 else if (key=="pw0") { pw0 = val; haspw0 = true; } // 48 00541 else if (key=="rkdyncte") rkdyncte = (bool)atoi(str_val.CStr()); // 49 00542 else if (key=="uwp") uwp = (bool)atoi(str_val.CStr()); // 50 00543 else if (key=="npath") { npath = (int)val; reading_path = true; } 00544 else if (key=="nelemprps"){ nelemprps = (int)val; reading_eprps = true; } 00545 else if (key=="nstages") { nstages = (int)val; reading_stages = true; } 00546 else if (key=="matids" || key=="xmatids") 00547 { 00548 String left, right, str_id, str_tag; 00549 line.Split (left, right, "="); 00550 std::istringstream subiss(right); 00551 bool pair_found = false; 00552 while (subiss >> str_id >> str_tag) 00553 { 00554 pair_found = true; 00555 int id = atoi(str_id.CStr()); 00556 int tag = atoi(str_tag.CStr()); 00557 if (id<0 || tag>=0) throw new Fatal("InpFile::Read: Error in file <%s> @ line # %d with Key==%s. Material ids must be zero or positive and element tags must be negative. Ex.: matids = 0 -1 1 -2 2 -3",FileName,line_num,key.CStr()); 00558 if (key=="xmatids") Tag2XMatID->Set (str_tag.CStr(), id); 00559 else Tag2MatID ->Set (str_tag.CStr(), id); 00560 } 00561 if (!pair_found) throw new Fatal("InpFile::Read: Error in file <%s> @ line # %d with Key==%s. Material ids must be zero or positive and element tags must be negative. Ex.: matids = 0 -1 1 -2 2 -3",FileName,line_num,key.CStr()); 00562 } 00563 else if (key=="outnods") 00564 { 00565 String left, right, nod; 00566 line.Split (left, right, "="); 00567 std::istringstream subiss(right); 00568 while (subiss >> nod) OutNods->Push (atoi(nod.CStr())); 00569 } 00570 else throw new Fatal("InpFile::Read: Error in file <%s> @ line # %d: Key==%s in invalid (as general data)",FileName,line_num,key.CStr()); 00571 } 00572 } 00573 line_num++; 00574 } 00575 if ((size_t)idxpath!=Path->Keys.Size()) throw new Fatal("InpFile::Read: Error in file <%s>: Not all Path data could be read for npath==%zd",FileName,npath); 00576 00577 // filename key 00578 if (fnkey=="") 00579 { 00580 String buf(FileName); 00581 buf.GetFNKey (fnkey); 00582 } 00583 00584 #ifdef USE_WXWIDGETS 00585 Sync (/*Dat2Ctrl*/true); 00586 GPath -> ReBuild (); 00587 GPrps -> ReBuild (); 00588 GOutNods -> ReBuild (); 00589 GMatId2Tag -> ReBuild (); 00590 #endif 00591 } 00592 00593 inline void InpFile::SetPrmsInis (MatFile const & Mat, bool ForceGTY) 00594 { 00595 for (size_t i=0; i<Tag2MatID->Keys.Size(); ++i) 00596 { 00597 int tag = atoi(Tag2MatID->Keys[i].CStr()); 00598 int id = (*Tag2MatID)(Tag2MatID->Keys[i]); 00599 SDPair const & prms = (*Mat.ID2Prms)(id); 00600 SDPair const & inis = (*Mat.ID2Inis)(id); 00601 Prms->Set (tag, prms); 00602 Inis->Set (tag, inis); 00603 if (ForceGTY) 00604 { 00605 if (Prps->Keys.Size()==0) throw new Fatal("InpFile::SetPrmsInis: Dictionary of properties (Prps) is empty => ForceGTY (geometry type) cannot be applied. You may have to specify 'nelemprps = 1' in your Input file."); 00606 SDPair const & prps = (*Prps)(tag); 00607 Array<String> gtypes("d3d", "d2d", "psa", "pse", "fra"); 00608 for (size_t i=0; i<gtypes.Size(); ++i) 00609 { 00610 if (prps.HasKey(gtypes[i])) (*Prms)(tag).Set (gtypes[i].CStr(), 1.0); 00611 } 00612 } 00613 if (haspcam0) (*Inis)(tag).Set ("sx sy sz", -pcam0, -pcam0, -pcam0); 00614 } 00615 for (size_t i=0; i<Tag2XMatID->Keys.Size(); ++i) 00616 { 00617 int tag = atoi(Tag2XMatID->Keys[i].CStr()); 00618 int id = (*Tag2XMatID)(Tag2XMatID->Keys[i]); 00619 SDPair prms = (*Mat.ID2Prms)(id); 00620 SDPair const & inis = (*Mat.ID2Inis)(id); 00621 double nam = prms("name"); 00622 prms.Del("name"); 00623 prms.Set("xname", nam); 00624 Prms->Set (tag, prms); 00625 Inis->Set (tag, inis); 00626 if (haspw0) (*Inis)(tag).Set ("pw", pw0); 00627 } 00628 } 00629 00630 inline void InpFile::GetIncs (int PathKey, double Div, Vec_t & dsig, Vec_t & deps, Array<bool> & PrescDeps, double & dpw, double & dSw, bool & PrescDpw, bool & PrescDSw) const 00631 { 00632 // number of increments 00633 SDPair const & path = (*Path)(Path->Keys[PathKey]); 00634 00635 // set prescribed increments 00636 set_to_zero (dsig); 00637 set_to_zero (deps); 00638 PrescDeps = false,false,false, false,false,false; 00639 dpw = 0.0; 00640 dSw = 0.0; 00641 PrescDpw = false; 00642 PrescDSw = false; 00643 if (path.HasKey("dsx")) { dsig(0) = path("dsx")/Div; } 00644 if (path.HasKey("dsy")) { dsig(1) = path("dsy")/Div; } 00645 if (path.HasKey("dsz")) { dsig(2) = path("dsz")/Div; } 00646 if (path.HasKey("dex")) { deps(0) = path("dex")/Div; } 00647 if (path.HasKey("dey")) { deps(1) = path("dey")/Div; PrescDeps[1] = true; } 00648 if (path.HasKey("dez")) { deps(2) = path("dez")/Div; PrescDeps[2] = true; } 00649 if (path.HasKey("dpw")) { dpw = path("dpw")/Div; PrescDpw = true; } 00650 if (path.HasKey("dSw")) { dSw = path("dSw")/Div; PrescDSw = true; } 00651 } 00652 00653 //inline void InpFile::SetSolver (FEM::Solver & Sol) const 00654 //{ 00655 //if (ssout ) Sol.SSOut = ssout; 00656 //if (ctetg ) Sol.CteTg = ctetg; 00657 //if (hm ) Sol.DampTy = FEM::Solver::HMCoup_t; 00658 //if (ray ) Sol.DampTy = FEM::Solver::Rayleigh_t; 00659 //if (am >=0) Sol.DampAm = am; 00660 //if (ak >=0) Sol.DampAk = ak; 00661 //if (rk ) 00662 //{ 00663 //Sol.DScheme = FEM::Solver::RK_t; 00664 //if (rkscheme!="") Sol.RKScheme = rkscheme; 00665 //if (rkstol >=0) Sol.RKSTOL = rkstol; 00666 //} 00667 //if (maxit >0 ) Sol.MaxIt = maxit; 00668 //if (tolr >=0) Sol.TolR = tolr; 00669 //if (scheme!="") Sol.SetScheme (scheme.CStr()); 00670 // 00671 //Sol.NLSteps.clear(); 00672 //if (nldt_nsml>0) Sol.NLSteps.Set("nsml",(double)nldt_nsml); 00673 //if (nldt_nn >0) Sol.NLSteps.Set("nn" ,(double)nldt_nn ); 00674 //if (nldt_n >0) Sol.NLSteps.Set("n" ,(double)nldt_n ); 00675 //if (nldt_ll >0) Sol.NLSteps.Set("ll" ,(double)nldt_ll ); 00676 //if (nldt_sch >0) Sol.NLSteps.Set("sch" ,(double)nldt_sch ); 00677 //if (nldt_m >0) Sol.NLSteps.Set("m" ,(double)nldt_m ); 00678 //} 00679 // 00680 //inline void InpFile::SetSolver (FEM::RKSolver & Sol) const 00681 //{ 00682 //if (ctetg ) Sol.LinProb = ctetg; 00683 //if (hm ) Sol.DampTy = FEM::RKSolver::HMCoup_t; 00684 //if (ray ) Sol.DampTy = FEM::RKSolver::Rayleigh_t; 00685 //if (am >=0 ) Sol.DampAm = am; 00686 //if (ak >=0 ) Sol.DampAk = ak; 00687 //if (rkscheme!="") Sol.Scheme = rkscheme; 00688 //if (rkstol >=0) Sol.STOL = rkstol; 00689 //Sol.DynCteM = rkdyncte; 00690 //} 00691 00692 inline void InpFile::SetSUp (Model const * Mdl, Model::StressUpdate::pDbgFun pFun, void * UserData) const 00693 { 00694 Mdl->SUp.CDrift = cdrift; 00695 Mdl->SUp.DbgFun = pFun; 00696 Mdl->SUp.DbgDat = UserData; 00697 if (suscheme !="") Mdl->SUp.SetScheme (suscheme); 00698 if (surkscheme!="") Mdl->SUp.RKScheme = surkscheme; 00699 if (sustol >0) Mdl->SUp.STOL = sustol; 00700 } 00701 00702 inline void InpFile::SetSolFlags (SDPair & Flags) const 00703 { 00704 } 00705 00706 std::ostream & operator<< (std::ostream & os, InpFile const & IF) 00707 { 00708 if (IF.ninc >=0) os << "ninc = " << IF.ninc << "\n"; // 1 00709 if (IF.cdrift ) os << "cdrift = " << IF.cdrift << "\n"; // 2 00710 if (IF.stol >=0) os << "stol = " << IF.stol << "\n"; // 3 00711 if (IF.ssout ) os << "ssout = " << IF.ssout << "\n"; // 4 00712 if (IF.ctetg ) os << "ctetg = " << IF.ctetg << "\n"; // 5 00713 if (IF.fem ) os << "fem = " << IF.fem << "\n"; // 6 00714 if (IF.dyn ) os << "dyn = " << IF.dyn << "\n"; // 7 00715 if (IF.hm ) os << "hm = " << IF.hm << "\n"; // 8 00716 if (IF.tf >=0) os << "tf = " << IF.tf << "\n"; // 9 00717 if (IF.dt >=0) os << "dt = " << IF.dt << "\n"; // 10 00718 if (IF.dtout >=0) os << "dtout = " << IF.dtout << "\n"; // 11 00719 if (IF.tsw >=0) os << "tsw = " << IF.tsw << "\n"; // 12 00720 if (IF.ndiv >=0) os << "ndiv = " << IF.ndiv << "\n"; // 13 00721 if (IF.nip >=0) os << "nip = " << IF.nip << "\n"; // 14 00722 if (IF.o2 ) os << "o2 = " << IF.o2 << "\n"; // 15 00723 if (IF.ray ) os << "ray = " << IF.ray << "\n"; // 16 00724 if (IF.am >=0) os << "am = " << IF.am << "\n"; // 17 00725 if (IF.ak >=0) os << "ak = " << IF.ak << "\n"; // 18 00726 if (IF.rk ) os << "rk = " << IF.rk << "\n"; // 19 00727 if (IF.rkscheme !="") os << "rkscheme = " << IF.rkscheme << "\n"; // 20 00728 if (IF.rkstol >=0) os << "rkstol = " << IF.rkstol << "\n"; // 21 00729 if (IF.refdat !="") os << "refdat = " << IF.refdat << "\n"; // 22 00730 if (IF.refsim !="") os << "refsim = " << IF.refsim << "\n"; // 23 00731 if (IF.refana !="") os << "refana = " << IF.refana << "\n"; // 24 00732 if (IF.idxvert1 >=0) os << "idxvert1 = " << IF.idxvert1 << "\n"; // 25 00733 if (IF.idxvert2 >=0) os << "idxvert2 = " << IF.idxvert2 << "\n"; // 26 00734 if (IF.idxvert3 >=0) os << "idxvert3 = " << IF.idxvert3 << "\n"; // 27 00735 if (IF.hasoptdbl1 ) os << "optdbl1 = " << IF.optdbl1 << "\n"; // 28 00736 if (IF.hasoptdbl2 ) os << "optdbl2 = " << IF.optdbl2 << "\n"; // 29 00737 if (IF.hasoptdbl3 ) os << "optdbl3 = " << IF.optdbl3 << "\n"; // 30 00738 if (IF.nldt_nsml >0 ) os << "nldt_nsml = " << IF.nldt_nsml << "\n"; // 31 00739 if (IF.nldt_nn >0 ) os << "nldt_nn = " << IF.nldt_nn << "\n"; // 32 00740 if (IF.nldt_n >0 ) os << "nldt_n = " << IF.nldt_n << "\n"; // 33 00741 if (IF.nldt_ll >0 ) os << "nldt_ll = " << IF.nldt_ll << "\n"; // 34 00742 if (IF.nldt_sch >0 ) os << "nldt_sch = " << IF.nldt_sch << "\n"; // 35 00743 if (IF.nldt_m >0 ) os << "nldt_m = " << IF.nldt_m << "\n"; // 36 00744 if (IF.maxit >0 ) os << "maxit = " << IF.maxit << "\n"; // 37 00745 if (IF.tolr >=0) os << "tolr = " << IF.tolr << "\n"; // 38 00746 if (IF.fnkey.size()>0 ) os << "fnkey = " << IF.fnkey << "\n"; // 39 00747 if (IF.haspcam0 ) os << "pcam0 = " << IF.pcam0 << "\n"; // 40 00748 if (IF.scheme !="") os << "scheme = " << IF.scheme << "\n"; // 41 00749 if (IF.vtufile ) os << "vtufile = " << IF.vtufile << "\n"; // 42 00750 if (IF.suscheme !="") os << "suscheme = " << IF.suscheme << "\n"; // 43 00751 if (IF.sustol >=0) os << "sustol = " << IF.sustol << "\n"; // 44 00752 if (IF.surkscheme !="") os << "surkscheme= " << IF.surkscheme<< "\n"; // 45 00753 if (IF.dcmaxit >0) os << "dcmaxit = " << IF.dcmaxit << "\n"; // 46 00754 if (IF.dcftol >0) os << "dcftol = " << IF.dcftol << "\n"; // 47 00755 if (IF.haspw0 ) os << "pw0 = " << IF.pw0 << "\n"; // 48 00756 if (IF.rkdyncte ) os << "rkdyncte = " << IF.rkdyncte << "\n"; // 49 00757 if (IF.uwp ) os << "uwp = " << IF.uwp << "\n"; // 50 00758 os << "\nPath:\n" << (*IF.Path) << "\n"; 00759 os << "\nElements properties:\n" << (*IF.Prps) << "\n"; 00760 os << "\nOutput nodes:\n" << (*IF.OutNods) << "\n"; 00761 os << "\nTags => Material IDs:\n" << (*IF.Tag2MatID) << "\n"; 00762 os << "\nTags => E(x)tra Material IDs:\n"<< (*IF.Tag2XMatID)<< "\n"; 00763 os << "\nParameters:\n" << (*IF.Prms) << "\n"; 00764 os << "\nInitial values:\n" << (*IF.Inis) << "\n"; 00765 os << "\nBoundary conditions (stages):\n"; 00766 for (size_t i=0; i<IF.Stages.Size(); ++i) 00767 { 00768 os << "Stage # " << i << ":\n"; 00769 os << (*IF.Stages[i]) << "\n"; 00770 } 00771 return os; 00772 } 00773 00774 #ifdef USE_WXWIDGETS 00775 00776 enum 00777 { 00778 ID_INPFILE_LOAD = wxID_HIGHEST+1000, 00779 ID_INPFILE_SAVE, 00780 }; 00781 00782 BEGIN_EVENT_TABLE(InpFile, wxWindow) 00783 EVT_BUTTON (ID_INPFILE_LOAD, InpFile::OnLoad) 00784 EVT_BUTTON (ID_INPFILE_SAVE, InpFile::OnSave) 00785 END_EVENT_TABLE() 00786 00787 inline InpFile::InpFile (wxFrame * Parent) 00788 : wxWindow (Parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE) 00789 { 00790 // default values 00791 Defaults(); 00792 00793 // force validation of child controls 00794 SetExtraStyle (wxWS_EX_VALIDATE_RECURSIVELY); 00795 00796 // tell wxAuiManager to manage this window 00797 Aui.SetManagedWindow (this); 00798 00799 // control panel 00800 ADD_WXPANEL (pnl, szt, szr, 1, 2); 00801 ADD_WXBUTTON (pnl, szr, ID_INPFILE_LOAD, c0, "Load"); 00802 ADD_WXBUTTON (pnl, szr, ID_INPFILE_SAVE, c1, "Save"); 00803 00804 // main 00805 ADD_WXPANEL (p_mai, sz_mai_t, sz_mai, 7, 2); 00806 ADD_WXNUMINPUT2 (p_mai, sz_mai, wxID_ANY, c_ninc , "ninc ", ninc ); // 1 00807 ADD_WXCHECKBOX2 (p_mai, sz_mai, wxID_ANY, c_fem , "fem ", fem ); // 6 00808 ADD_WXCHECKBOX2 (p_mai, sz_mai, wxID_ANY, c_dyn , "dyn ", dyn ); // 7 00809 ADD_WXCHECKBOX2 (p_mai, sz_mai, wxID_ANY, c_hm , "hm ", hm ); // 8 00810 ADD_WXNUMINPUT2 (p_mai, sz_mai, wxID_ANY, c_pcam0 , "pcam0 ", pcam0 ); // 40 00811 00812 // local integration 00813 ADD_WXPANEL (p_loc, sz_loc_t, sz_loc, 2, 2); 00814 ADD_WXCHECKBOX2 (p_loc, sz_loc, wxID_ANY, c_cdrift , "cdrift ", cdrift ); // 2 00815 ADD_WXNUMINPUT2 (p_loc, sz_loc, wxID_ANY, c_stol , "stol ", stol ); // 3 00816 00817 // fem solution 00818 ADD_WXPANEL (p_fem, sz_fem_t, sz_fem, 18, 2); 00819 ADD_WXCHECKBOX2 (p_fem, sz_fem, wxID_ANY, c_ssout , "ssout ", ssout ); // 4 00820 ADD_WXCHECKBOX2 (p_fem, sz_fem, wxID_ANY, c_ctetg , "ctetg ", ctetg ); // 5 00821 ADD_WXNUMINPUT2 (p_fem, sz_fem, wxID_ANY, c_tf , "tf ", tf ); // 9 00822 ADD_WXNUMINPUT2 (p_fem, sz_fem, wxID_ANY, c_dt , "dt ", dt ); // 10 00823 ADD_WXNUMINPUT2 (p_fem, sz_fem, wxID_ANY, c_dtout , "dtout ", dtout ); // 11 00824 ADD_WXNUMINPUT2 (p_fem, sz_fem, wxID_ANY, c_tsw , "tsw ", tsw ); // 12 00825 ADD_WXNUMINPUT2 (p_fem, sz_fem, wxID_ANY, c_ndiv , "ndiv ", ndiv ); // 13 00826 ADD_WXNUMINPUT2 (p_fem, sz_fem, wxID_ANY, c_nip , "nip ", nip ); // 14 00827 ADD_WXCHECKBOX2 (p_fem, sz_fem, wxID_ANY, c_o2 , "o2 ", o2 ); // 15 00828 ADD_WXCHECKBOX2 (p_fem, sz_fem, wxID_ANY, c_ray , "ray ", ray ); // 16 00829 ADD_WXNUMINPUT2 (p_fem, sz_fem, wxID_ANY, c_am , "am ", am ); // 17 00830 ADD_WXNUMINPUT2 (p_fem, sz_fem, wxID_ANY, c_ak , "ak ", ak ); // 18 00831 ADD_WXCHECKBOX2 (p_fem, sz_fem, wxID_ANY, c_rk , "rk ", rk ); // 19 00832 ADD_WXTEXTCTRL2 (p_fem, sz_fem, wxID_ANY, c_rkscheme , "rkscheme ", rkscheme ); // 20 00833 ADD_WXNUMINPUT2 (p_fem, sz_fem, wxID_ANY, c_rkstol , "rkstol ", rkstol ); // 21 00834 ADD_WXNUMINPUT2 (p_fem, sz_fem, wxID_ANY, c_maxit , "maxit ", maxit ); // 37 00835 ADD_WXNUMINPUT2 (p_fem, sz_fem, wxID_ANY, c_tolr , "tolr ", tolr ); // 38 00836 ADD_WXTEXTCTRL2 (p_fem, sz_fem, wxID_ANY, c_scheme , "scheme ", scheme ); // 41 00837 ADD_WXCHECKBOX2 (p_fem, sz_fem, wxID_ANY, c_vtufile , "vtufile ", vtufile ); // 42 00838 00839 // reference files 00840 ADD_WXPANEL (p_rfi, sz_rfi_t, sz_rfi, 3, 2); 00841 ADD_WXTEXTCTRL2 (p_rfi, sz_rfi, wxID_ANY, c_refdat , "refdat ", refdat ); // 22 00842 ADD_WXTEXTCTRL2 (p_rfi, sz_rfi, wxID_ANY, c_refsim , "refsim ", refsim ); // 23 00843 ADD_WXTEXTCTRL2 (p_rfi, sz_rfi, wxID_ANY, c_refana , "refana ", refana ); // 24 00844 c_refdat->SetMinSize (wxSize(200,20)); 00845 c_refsim->SetMinSize (wxSize(200,20)); 00846 c_refana->SetMinSize (wxSize(200,20)); 00847 00848 // nonlinear steps 00849 ADD_WXPANEL (p_nls, sz_nls_t, sz_nls, 6, 2); 00850 ADD_WXNUMINPUT2 (p_nls, sz_nls, wxID_ANY, c_nldt_nsml , "nldt_nsml", nldt_nsml); // 31 00851 ADD_WXNUMINPUT2 (p_nls, sz_nls, wxID_ANY, c_nldt_nn , "nldt_nn ", nldt_nn ); // 32 00852 ADD_WXNUMINPUT2 (p_nls, sz_nls, wxID_ANY, c_nldt_n , "nldt_n ", nldt_n ); // 33 00853 ADD_WXNUMINPUT2 (p_nls, sz_nls, wxID_ANY, c_nldt_ll , "nldt_ll ", nldt_ll ); // 34 00854 ADD_WXNUMINPUT2 (p_nls, sz_nls, wxID_ANY, c_nldt_sch , "nldt_sch ", nldt_sch ); // 35 00855 ADD_WXNUMINPUT2 (p_nls, sz_nls, wxID_ANY, c_nldt_m , "nldt_m ", nldt_m ); // 36 00856 00857 // others 00858 ADD_WXPANEL (p_oth, sz_oth_t, sz_oth, 6, 2); 00859 ADD_WXNUMINPUT2 (p_oth, sz_oth, wxID_ANY, c_idxvert1 , "idxvert1 ", idxvert1 ); // 25 00860 ADD_WXNUMINPUT2 (p_oth, sz_oth, wxID_ANY, c_idxvert2 , "idxvert2 ", idxvert2 ); // 26 00861 ADD_WXNUMINPUT2 (p_oth, sz_oth, wxID_ANY, c_idxvert3 , "idxvert3 ", idxvert3 ); // 27 00862 ADD_WXNUMINPUT2 (p_oth, sz_oth, wxID_ANY, c_optdbl1 , "optdbl1 ", optdbl1 ); // 28 00863 ADD_WXNUMINPUT2 (p_oth, sz_oth, wxID_ANY, c_optdbl2 , "optdbl2 ", optdbl2 ); // 29 00864 ADD_WXNUMINPUT2 (p_oth, sz_oth, wxID_ANY, c_optdbl3 , "optdbl3 ", optdbl3 ); // 30 00865 00866 // path 00867 Path = new GUI::WxDictTable; Path->Transposed = false; 00868 GPath = new GUI::WxDict (this, Path); GPath->FitCol = true; 00869 00870 // additional data 00871 Prps = new GUI::WxDictTable; 00872 OutNods = new GUI::WxArrayIntTable; 00873 Tag2MatID = new GUI::WxSIPairTable; 00874 GPrps = new GUI::WxDict (this, Prps); 00875 GOutNods = new GUI::WxArrayInt (this, OutNods); 00876 GMatId2Tag = new GUI::WxSIPair (this, Tag2MatID); 00877 Prms = new Dict; 00878 Inis = new Dict; 00879 00880 // notebook 00881 ADD_WXNOTEBOOK (this, nbk0); 00882 ADD_WXNOTEBOOK (this, nbk1); 00883 ADD_WXNOTEBOOK (this, nbk2); 00884 nbk0->AddPage (p_mai, "Main", false); 00885 nbk0->AddPage (p_loc, "Local Integration", false); 00886 nbk0->AddPage (p_oth, "Others", false); 00887 nbk2->AddPage (p_fem, "FEM Solution", false); 00888 nbk2->AddPage (p_nls, "Nonlinear Steps", false); 00889 nbk0->AddPage (p_rfi, "Reference Files", false); 00890 nbk1->AddPage (GPath, "Path", false); 00891 nbk2->AddPage (GPrps, "Elements Properties", false); 00892 nbk2->AddPage (GOutNods, "Output Nodes", false); 00893 nbk2->AddPage (GMatId2Tag, "Material IDs => Tags", false); 00894 00895 // commit all changes to wxAuiManager 00896 Aui.AddPane (pnl, wxAuiPaneInfo().Name("cpnl").Caption("cpnl").Top().MinSize(wxSize(100,50)).DestroyOnClose(false).CaptionVisible(false) .CloseButton(false)); 00897 Aui.AddPane (nbk0, wxAuiPaneInfo().Name("nbk0").Caption("General Input Data").Centre().Position(0).DestroyOnClose(false).CaptionVisible(true).CloseButton(false)); 00898 Aui.AddPane (nbk1, wxAuiPaneInfo().Name("nbk1").Caption("Stress/Strain Path").Centre().Position(1).DestroyOnClose(false).CaptionVisible(true).CloseButton(false)); 00899 Aui.AddPane (nbk2, wxAuiPaneInfo().Name("nbk2").Caption("FEM Input Data") .Centre().Position(2).DestroyOnClose(false).CaptionVisible(true).CloseButton(false)); 00900 Aui.Update (); 00901 } 00902 00903 inline void InpFile::OnLoad (wxCommandEvent & Event) 00904 { 00905 wxFileDialog fd(this, "Load input (.inp) file", LstDir, "", "*.inp"); 00906 if (fd.ShowModal()==wxID_OK) 00907 { 00908 LstDir = fd.GetDirectory (); 00909 try { Read (fd.GetPath().ToStdString().c_str()); } 00910 catch (Fatal * e) { WxError(e->Msg().CStr()); } 00911 } 00912 } 00913 00914 inline void InpFile::OnSave (wxCommandEvent & Event) 00915 { 00916 Sync (); 00917 wxFileDialog fd(this, "Save input (.inp) file", LstDir, "", "*.inp", wxFD_SAVE|wxFD_OVERWRITE_PROMPT); 00918 if (fd.ShowModal()==wxID_OK) 00919 { 00920 std::cout << "fem = " << fem << std::endl; 00921 std::fstream of(fd.GetPath().ToStdString().c_str(), std::ios::out); 00922 of << "ninc = " << ninc << std::endl; // 1 00923 of << "cdrift = " << cdrift << std::endl; // 2 00924 of << "stol = " << stol << std::endl; // 3 00925 of << "ssout = " << ssout << std::endl; // 4 00926 of << "ctetg = " << ctetg << std::endl; // 5 00927 of << "fem = " << fem << std::endl; // 6 00928 of << "dyn = " << dyn << std::endl; // 7 00929 of << "hm = " << hm << std::endl; // 8 00930 of << "tf = " << tf << std::endl; // 9 00931 of << "dt = " << dt << std::endl; // 10 00932 of << "dtout = " << dtout << std::endl; // 11 00933 of << "tsw = " << tsw << std::endl; // 12 00934 of << "ndiv = " << ndiv << std::endl; // 13 00935 of << "nip = " << nip << std::endl; // 14 00936 of << "o2 = " << o2 << std::endl; // 15 00937 of << "ray = " << ray << std::endl; // 16 00938 of << "am = " << am << std::endl; // 17 00939 of << "ak = " << ak << std::endl; // 18 00940 of << "rk = " << rk << std::endl; // 19 00941 of << "rkscheme = " << rkscheme << std::endl; // 20 00942 of << "rkstol = " << rkstol << std::endl; // 21 00943 of << "refdat = " << refdat << std::endl; // 22 00944 of << "refsim = " << refsim << std::endl; // 23 00945 of << "refana = " << refana << std::endl; // 24 00946 of << "idxvert1 = " << idxvert1 << std::endl; // 25 00947 of << "idxvert2 = " << idxvert2 << std::endl; // 26 00948 of << "idxvert3 = " << idxvert3 << std::endl; // 27 00949 of << "optdbl1 = " << optdbl1 << std::endl; // 28 00950 of << "optdbl2 = " << optdbl2 << std::endl; // 29 00951 of << "optdbl3 = " << optdbl3 << std::endl; // 30 00952 of << "nldt_nsml = " << nldt_nsml << std::endl; // 31 00953 of << "nldt_nn = " << nldt_nn << std::endl; // 32 00954 of << "nldt_n = " << nldt_n << std::endl; // 33 00955 of << "nldt_ll = " << nldt_ll << std::endl; // 34 00956 of << "nldt_sch = " << nldt_sch << std::endl; // 35 00957 of << "nldt_m = " << nldt_m << std::endl; // 36 00958 of << "maxit = " << maxit << std::endl; // 37 00959 of << "tolr = " << tolr << std::endl; // 39 00960 of << "pcam0 = " << pcam0 << std::endl; // 40 00961 of << "scheme = " << scheme << std::endl; // 41 00962 of << "vtufile = " << vtufile << std::endl; // 42 00963 of << "suscheme = " << suscheme << std::endl; // 43 00964 of << "sustol = " << sustol << std::endl; // 44 00965 of << "surkscheme = " << surkscheme << std::endl; // 45 00966 of << "dcmaxit = " << dcmaxit << std::endl; // 46 00967 of << "dcftol = " << dcftol << std::endl; // 47 00968 of << "pw0 = " << pw0 << std::endl; // 48 00969 of << "rkdyncte = " << rkdyncte << std::endl; // 49 00970 of << "uwp = " << uwp << std::endl; // 50 00971 of << "npath = " << Path->Keys.Size() << std::endl; 00972 00973 String buf; 00974 for (size_t i=0; i<Path->Keys.Size(); ++i) 00975 { 00976 SDPair const & path = (*Path)(Path->Keys[i]); 00977 of << std::endl; 00978 of << "ndat = " << path.Keys.Size() << std::endl; 00979 for (size_t j=0; j<path.Keys.Size(); ++j) 00980 { 00981 buf.Printf(" %-5s = %g\n", path.Keys[j].CStr(), path(path.Keys[j])); 00982 of << buf; 00983 } 00984 } 00985 of.close(); 00986 } 00987 } 00988 00989 #endif 00990 00991 00993 00994 00995 #define INIT_MAT_INP(argc, argv, inpfn, matfn, verbose, forcegty, MAT, INP) \ 00996 if (argc>1) inpfn = argv[1]; \ 00997 if (argc>2) matfn = argv[2]; \ 00998 if (argc>3) verbose = atoi(argv[3]); \ 00999 MatFile MAT; \ 01000 InpFile INP; \ 01001 MAT.Read (matfn.CStr()); \ 01002 INP.Read (inpfn.CStr()); \ 01003 INP.SetPrmsInis (MAT, forcegty); \ 01004 if (verbose) \ 01005 { \ 01006 printf("\n%s--- Materials data <%s> ----------------------------------------------------%s\n",TERM_CLR1,matfn.CStr(),TERM_RST); \ 01007 std::cout << MAT << std::endl; \ 01008 printf("\n%s--- Input data <%s> --------------------------------------------------------%s\n",TERM_CLR1,inpfn.CStr(),TERM_RST); \ 01009 std::cout << INP << std::endl; \ 01010 } 01011 01012 #define INIT_MAT_INP_(argc, argv, MAT, INP) \ 01013 String inpfn("input.inp"); \ 01014 String matfn("materials.mat"); \ 01015 bool verbose = true; \ 01016 bool forcegty = false; \ 01017 INIT_MAT_INP(argc, argv, inpfn, matfn, verbose, forcegty, MAT, INP); 01018 01019 01020 #endif // MECHSYS_INPFILE_H