@@ -191,7 +191,17 @@ namespace config
191191 }
192192
193193 std::string physName;
194- gmsh::open (config.meshFileName );
194+ std::ifstream mFile (config.meshFileName );
195+ if (mFile .is_open ())
196+ {
197+ gmsh::open (config.meshFileName );
198+ }
199+ else
200+ {
201+ std::string message = " Mesh file '" +config.meshFileName +" ' not found or corrupted" ;
202+ Fatal_Error (message.c_str ())
203+ }
204+ mFile .close ();
195205 gmsh::vectorpair m_physicalDimTags;
196206 int bcDim = gmsh::model::getDimension () - 1 ;
197207 gmsh::model::getPhysicalGroups (m_physicalDimTags, bcDim);
@@ -217,13 +227,14 @@ namespace config
217227 throw ;
218228 }
219229 gmsh::logger::write (" ==================================================" );
220- gmsh::logger::write (" Simulation parameters : " );
221- gmsh::logger::write (" Time step : " + std::to_string (config.timeStep ));
222- gmsh::logger::write (" Final time : " + std::to_string (config.timeEnd ));
223- gmsh::logger::write (" Mean flow velocity : (" + std::to_string (config.v0 [0 ]) + " ," + std::to_string (config.v0 [1 ]) + " ," + std::to_string (config.v0 [2 ]) + " )" );
224- gmsh::logger::write (" Mean density : " + std::to_string (config.rho0 ));
225- gmsh::logger::write (" Speed of sound : " + std::to_string (config.c0 ));
226- gmsh::logger::write (" Solver : " + config.timeIntMethod );
230+ gmsh::logger::write (" Simulation parameters: " );
231+ gmsh::logger::write (" Time step: " + std::to_string (config.timeStep ));
232+ gmsh::logger::write (" Final time: " + std::to_string (config.timeEnd ));
233+ gmsh::logger::write (" Mean flow velocity: (" + std::to_string (config.v0 [0 ]) + " ," + std::to_string (config.v0 [1 ]) + " ," + std::to_string (config.v0 [2 ]) + " )" );
234+ gmsh::logger::write (" Mean density: " + std::to_string (config.rho0 ));
235+ gmsh::logger::write (" Speed of sound: " + std::to_string (config.c0 ));
236+ gmsh::logger::write (" Mesh file: " + config.meshFileName );
237+ gmsh::logger::write (" Solver: " + config.timeIntMethod );
227238
228239 return config;
229240 }
@@ -241,7 +252,17 @@ namespace config
241252 config.meshFileName = config.jsonData [" mesh" ][" File" ];
242253 int nbBC = config.jsonData [" mesh" ][" BC" ][" number" ];
243254 std::string physName;
244- gmsh::open (config.meshFileName );
255+ std::ifstream mFile (config.meshFileName );
256+ if (mFile .is_open ())
257+ {
258+ gmsh::open (config.meshFileName );
259+ }
260+ else
261+ {
262+ std::string message = " Mesh file '" +config.meshFileName +" ' not found or corrupted" ;
263+ Fatal_Error (message.c_str ())
264+ }
265+ mFile .close ();
245266 gmsh::vectorpair m_physicalDimTags;
246267 int bcDim = gmsh::model::getDimension () - 1 ;
247268 gmsh::model::getPhysicalGroups (m_physicalDimTags, bcDim);
@@ -264,7 +285,7 @@ namespace config
264285 gmsh::logger::write (" Not specified or supported boundary conditions." );
265286 }
266287 }
267- screen_display::write_string (" Mesh loaded" ,GREEN );
288+ screen_display::write_string (" Mesh loaded" , GREEN );
268289 // solver
269290
270291 config.timeStart = config.jsonData [" solver" ][" time" ][" start" ];
@@ -275,7 +296,7 @@ namespace config
275296 config.timeIntMethod = config.jsonData [" solver" ][" timeIntMethod" ];
276297 config.numThreads = config.jsonData [" solver" ][" numThreads" ];
277298 config.numThreads = (config.numThreads == 1 ) ? 0 : config.numThreads ;
278- screen_display::write_string (" Solver parameters loaded" ,GREEN );
299+ screen_display::write_string (" Solver parameters loaded" , GREEN );
279300 // initial conditions
280301 config.v0 [0 ] = config.jsonData [" initialization" ][" meanFlow" ][" vx" ];
281302 config.v0 [1 ] = config.jsonData [" initialization" ][" meanFlow" ][" vy" ];
@@ -299,7 +320,7 @@ namespace config
299320 std::vector<double > init1 = {double (index), x, y, z, size, amp};
300321 config.initConditions .push_back (init1);
301322 }
302- screen_display::write_string (" Initial conditions loaded" ,GREEN );
323+ screen_display::write_string (" Initial conditions loaded" , GREEN );
303324 // observers
304325 int nbObs = config.jsonData [" observers" ][" number" ];
305326 for (int i = 0 ; i < nbObs; i++)
@@ -311,14 +332,14 @@ namespace config
311332 std::vector<double > obs = {x, y, z, size};
312333 config.observers .push_back (obs);
313334 }
314- screen_display::write_string (" Observers coordinates loaded" ,GREEN );
315-
335+ screen_display::write_string (" Observers coordinates loaded" , GREEN );
336+
316337 // sources
317338 int nbSrc = config.jsonData [" sources" ][" number" ];
318339 for (int i = 0 ; i < nbSrc; i++)
319340 {
320341 std::string type = config.jsonData [" sources" ][" source" + std::to_string (i + 1 )][" type" ];
321- std::string fct = config.jsonData [" sources" ][" source" + std::to_string (i + 1 )][" fct" ];
342+ std::string fct = config.jsonData [" sources" ][" source" + std::to_string (i + 1 )][" fct" ];
322343 double x = config.jsonData [" sources" ][" source" + std::to_string (i + 1 )][" x" ];
323344 double y = config.jsonData [" sources" ][" source" + std::to_string (i + 1 )][" y" ];
324345 double z = config.jsonData [" sources" ][" source" + std::to_string (i + 1 )][" z" ];
@@ -367,13 +388,13 @@ namespace config
367388 if (type == " formula" )
368389 {
369390 std::string expr = fct;
370- expr.erase (std::remove_if (expr.begin (), expr.end (), isspace),expr.end ());
391+ expr.erase (std::remove_if (expr.begin (), expr.end (), isspace), expr.end ());
371392
372393 if (expr.front () == ' "' )
373394 expr.erase (0 , 1 );
374395 if (expr.back () == ' "' )
375396 expr.pop_back ();
376-
397+
377398 Sources S (expr, {-1 , x, y, z, size, duration});
378399 config.sources .push_back (S);
379400 }
@@ -405,21 +426,21 @@ namespace config
405426 }
406427 }
407428 }
408- screen_display::write_string (" Sources loaded" ,GREEN );
409-
429+ screen_display::write_string (" Sources loaded" , GREEN );
410430 }
411431 else
412432 {
413433 throw ;
414434 }
415435 gmsh::logger::write (" ==================================================" );
416- gmsh::logger::write (" Simulation parameters : " );
417- gmsh::logger::write (" Time step : " + std::to_string (config.timeStep ));
418- gmsh::logger::write (" Final time : " + std::to_string (config.timeEnd ));
419- gmsh::logger::write (" Mean flow velocity : (" + std::to_string (config.v0 [0 ]) + " ," + std::to_string (config.v0 [1 ]) + " ," + std::to_string (config.v0 [2 ]) + " )" );
420- gmsh::logger::write (" Mean density : " + std::to_string (config.rho0 ));
421- gmsh::logger::write (" Speed of sound : " + std::to_string (config.c0 ));
422- gmsh::logger::write (" Solver : " + config.timeIntMethod );
436+ gmsh::logger::write (" Simulation parameters: " );
437+ gmsh::logger::write (" Time step: " + std::to_string (config.timeStep ));
438+ gmsh::logger::write (" Final time: " + std::to_string (config.timeEnd ));
439+ gmsh::logger::write (" Mean flow velocity: (" + std::to_string (config.v0 [0 ]) + " ," + std::to_string (config.v0 [1 ]) + " ," + std::to_string (config.v0 [2 ]) + " )" );
440+ gmsh::logger::write (" Mean density: " + std::to_string (config.rho0 ));
441+ gmsh::logger::write (" Speed of sound: " + std::to_string (config.c0 ));
442+ gmsh::logger::write (" Mesh file: " + config.meshFileName );
443+ gmsh::logger::write (" Solver: " + config.timeIntMethod );
423444
424445 return config;
425446 }
0 commit comments