<commit_before>// C++
#include <iostream>

// Libmesh
#include "libmesh/libmesh.h" //for libmeshinit

// FEMuS
#include "FemusDefault.hpp"
#include "Files.hpp"
#include "GeomEl.hpp"
#include "Box.hpp"

#include "GenCase.hpp"

#include "FEElemBase.hpp"
#include "FEQuad4.hpp"
#include "FEQuad9.hpp"
#include "FEHex8.hpp"
#include "FEHex27.hpp"
#include "FETri3.hpp"
#include "FETri6.hpp"
#include "FETet4.hpp"
#include "FETet10.hpp"
#include "FETypeEnum.hpp"
#include "RunTimeMap.hpp"
#include "TimeLoop.hpp"
#include "CmdLine.hpp"


// ==========================================
//         GENCASE
// ==========================================
//The goal of the gencase program is to put some files 
// into the input/ directory of the corresponding Application

//If you want to generate the mesh with libmesh, set libmesh_gen=1

//If you want to read it from an external file: 
// - set libmesh_gen=0,
// - put the external file (e.g. mesh.gam) into the CONFIG directory
// - and set the file name in F_MESH_READ in "param_files.in"
// Only, beware that "dimension" is the same as the mesh dimension in the file
// (anyway we have a check for that)

//This is a special application in the sense all that its configuration
//is dependent on the App that we are considering,
//so it is a sort of "service application"


// Considering instead the configuration of the classes, the classes that are involved 
// are the FE because you must know how the dofs are arranged, the GeomEl which gives you 
// the type of Geometric element of the class. Strangely, Mesh is not involved. This is because
//Mesh only "dialogues" with the output files of gencase. But clearly, Mesh depends on GeomEl,
//so there cannot be TWO DIFFERENT GeomEl for Gencase and for the App, as it happens to be the case of course.

//TODO can we make the gencase output in parallel?!
// The fact of the parallel output is what refrains me from thinking of some alternative 
// to redirecting std output INSIDE C++ instead of FROM SHELL... maybe there is a shell variable
// that holds the MPI Rank... the problem is that it would exist after a command
// of the type "mpiexec  > file$MYPROC.txt" would be launched...


int main(int argc, char** argv) {

  LibMeshInit init(argc, argv);   // Initialize libMesh

  CmdLine::parse(argc,argv);
  std::string chosen_app = CmdLine::get("--app"); 
  std::cout << "**************************************************************" << std::endl;
  std::cout << "***** The application I will generate the case for is  ****** " << chosen_app << std::endl;
  std::cout << "**************************************************************" << std::endl;

  // ======= Files =====
  Files::CheckDirOrAbort("../",chosen_app);
  std::string basepath = "../" + chosen_app + "/";
  Files files(basepath);
   std::cout << "******The basepath starting from the gencase directory is ***** " << files.get_basepath() << std::endl;
//   files.CheckDirOrAbort(files.get_basepath(),DEFAULT_CONFIGDIR); 
//   files.get_frtmap_ptr()->read(); // THE ERROR IS IN HERE.. BUT NOT IN THE APPS... WHAT IS DIFFERENT WRT THEM ?!? ... LIBMESH...! but... ONLY IN DEBUG MODE!!!!
  files.get_frtmap().read();
  files.get_frtmap().print();
  files.CheckDir(files.get_basepath(),DEFAULT_CASEDIR); //here, we must check if the input directory where gencase writes is there  //if not, we make it

//======== first of all, check for restart ======      
//======== don't rerun gencase in that case, to avoid spending time on rebuilding the operators and so on ======      
//======== actually we will change the logic, we will read EVERYTHING from THE PREVIOUS RUN ======      
     RunTimeMap<double> timemap("TimeLoop",files.get_basepath());  //here you don't need to instantiate a TimeLoop object, but only to read its RUNTIME MAP
     timemap.read();
     timemap.print();
     TimeLoop::check_time_par(timemap);
     const uint restart      = (uint) timemap.get("restart");    // restart param
     if (restart)  {std::cout << "No GenCase because of restart flag !=0 " << std::endl; abort();}

  
  // ======= Mesh =====
     RunTimeMap<double> mesh_map("Mesh",files.get_basepath());
     mesh_map.read();
     mesh_map.print();
<commit_msg>Greatly simplified restart check on gencase<commit_after>// C++
#include <iostream>

// Libmesh
#include "libmesh/libmesh.h" //for libmeshinit

// FEMuS
#include "FemusDefault.hpp"
#include "Files.hpp"
#include "GeomEl.hpp"
#include "Box.hpp"

#include "GenCase.hpp"

#include "FEElemBase.hpp"
#include "FEQuad4.hpp"
#include "FEQuad9.hpp"
#include "FEHex8.hpp"
#include "FEHex27.hpp"
#include "FETri3.hpp"
#include "FETri6.hpp"
#include "FETet4.hpp"
#include "FETet10.hpp"
#include "FETypeEnum.hpp"
#include "RunTimeMap.hpp"
#include "TimeLoop.hpp"
#include "CmdLine.hpp"


// ==========================================
//         GENCASE
// ==========================================
//The goal of the gencase program is to put some files 
// into the input/ directory of the corresponding Application

//If you want to generate the mesh with libmesh, set libmesh_gen=1

//If you want to read it from an external file: 
// - set libmesh_gen=0,
// - put the external file (e.g. mesh.gam) into the CONFIG directory
// - and set the file name in F_MESH_READ in "param_files.in"
// Only, beware that "dimension" is the same as the mesh dimension in the file
// (anyway we have a check for that)

//This is a special application in the sense all that its configuration
//is dependent on the App that we are considering,
//so it is a sort of "service application"


// Considering instead the configuration of the classes, the classes that are involved 
// are the FE because you must know how the dofs are arranged, the GeomEl which gives you 
// the type of Geometric element of the class. Strangely, Mesh is not involved. This is because
//Mesh only "dialogues" with the output files of gencase. But clearly, Mesh depends on GeomEl,
//so there cannot be TWO DIFFERENT GeomEl for Gencase and for the App, as it happens to be the case of course.

//TODO can we make the gencase output in parallel?!
// The fact of the parallel output is what refrains me from thinking of some alternative 
// to redirecting std output INSIDE C++ instead of FROM SHELL... maybe there is a shell variable
// that holds the MPI Rank... the problem is that it would exist after a command
// of the type "mpiexec  > file$MYPROC.txt" would be launched...
//TODO see what happens with libmesh in debug mode

int main(int argc, char** argv) {

  LibMeshInit init(argc, argv);   // Initialize libMesh

  CmdLine::parse(argc,argv);
  std::string chosen_app = CmdLine::get("--app"); 
  std::cout << "**************************************************************" << std::endl;
  std::cout << "***** The application I will generate the case for is  ****** " << chosen_app << std::endl;
  std::cout << "**************************************************************" << std::endl;

  // ======= Files =====
  Files::CheckDirOrAbort("../",chosen_app);
  std::string basepath = "../" + chosen_app + "/";
  Files files(basepath);
   std::cout << "******The basepath starting from the gencase directory is ***** " << files.get_basepath() << std::endl;

//======== first of all, check for restart ======      
//======== don't rerun gencase in that case, to avoid spending time on rebuilding the operators and so on ======      
  files.ConfigureRestart();
  if (files._restart_flag == true) { std::cout << "Do not rerun gencase in case of restart" << std::endl; abort(); }
  files.get_frtmap().read();
  files.get_frtmap().print();
  files.CheckDir(files.get_basepath(),DEFAULT_CASEDIR); //here, we must check if the input directory where gencase writes is there  //if not, we make it

  // ======= Mesh =====
     RunTimeMap<double> mesh_map("Mesh",files.get_basepath());
     mesh_map.read();
     mesh_map.print();

{'fraction_non_alphanumeric': 0.1824281554627168, 'fraction_numerical': 0.0031649575895683, 'mean_word_length': 3.9529780564263324, 'pattern_counts': {'":': 0, '<': 56, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5804939', 'n_tokens_mistral': 2425, 'n_tokens_neox': 2333, 'n_words': 908}