63 "\nUsage: exe inputfile [options values]\n"
65 " -v Level of verbosity. Default 0.\n"
66 " Can be either 0, 1 or 2.\n"
67 " a=b Executes argument as a lua string. "
68 "i.e. x=2 or y=[[\"string\"]]\n"
69 " --allow_petsc_error_handler Allow petsc error handler.\n"
70 " --supress_beg_end_timelog Suppress time logs at the \n"
71 " beginning and end of execution.\n"
72 " --suppress_color Suppresses the printing of color.\n"
73 " useful for unit tests requiring a diff.\n"
74 " --dump-object-registry Dumps the object registry.\n"
84 bool input_file_found =
false;
85 for (
int i = 1; i < argc; i++)
87 std::string argument(argv[i]);
89 Chi::log.
Log() <<
"Parsing argument " << i <<
" " << argument;
91 if (argument.find(
"-h") != std::string::npos or
92 argument.find(
"--help") != std::string::npos)
97 else if (argument.find(
"--supress_beg_end_timelog") != std::string::npos)
101 else if (argument.find(
"--allow_petsc_error_handler") != std::string::npos)
105 else if (argument.find(
"--suppress_color") != std::string::npos)
109 else if (argument.find(
"--dump-object-registry") != std::string::npos)
115 else if (argument.find(
"-b") != std::string::npos)
120 else if (argument.find(
"-v") != std::string::npos)
124 std::cerr <<
"Invalid option used with command line argument "
125 "-v. Options are 0,1 or 2."
131 std::string v_option(argv[i + 1]);
134 int level = std::stoi(v_option);
137 catch (
const std::invalid_argument& e)
139 std::cerr <<
"Invalid option used with command line argument "
140 "-v. Options are 0,1 or 2."
147 else if ((argument.find(
'=') == std::string::npos) and (!input_file_found))
150 input_file_found =
true;
153 else if (argument.find(
'=') != std::string::npos)
175 int location_id = 0, number_processes = 1;
177 MPI_Init(&argc, &argv);
178 MPI_Comm_rank(communicator, &location_id);
179 MPI_Comm_size(communicator, &number_processes);
204 PetscOptionsInsertString(
nullptr,
"-error_output_stderr");
206 PetscOptionsInsertString(
nullptr,
"-no_signal_handler");
208 PetscCall(PetscInitialize(&argc, &argv,
nullptr,
nullptr));
244 <<
" Running ChiTech in interactive-mode with "
250 Chi::log.
Log() <<
"ChiTech number of arguments supplied: " << argc - 1;
258 if (not input_fname.empty())
264 catch (
const std::exception& excp)
277 <<
" ChiTech finished execution.";
290 <<
" Running ChiTech in batch-mode with "
296 Chi::log.
Log() <<
"ChiTech number of arguments supplied: " << argc - 1;
304 for (
int k = 0; k < 2; ++k)
322 catch (
const std::exception& excp)
333 <<
" ChiTech finished execution of "
355 for (
const auto& [key, _] : object_factory.Registry())
static bool termination_posted_
static void ParseArguments(int argc, char **argv)
static bool supress_beg_end_timelog_
static bool sim_option_interactive_
static bool dump_registry_
static const std::string command_line_help_string_
static bool allow_petsc_error_handler_
static int InitPetSc(int argc, char **argv)
static std::string input_file_name_
static bool suppress_color_
static int RunBatch(int argc, char **argv)
static std::vector< chi_mesh::FFInterpPtr > field_func_interpolation_stack
static std::vector< chi_physics::MaterialPtr > material_stack
static std::vector< chi_physics::FieldFunctionPtr > field_function_stack
static chi::Timer program_timer
static std::vector< chi_physics::MultiGroupXSPtr > multigroup_xs_stack
static std::vector< chi_mesh::MeshHandlerPtr > meshhandler_stack
static std::vector< chi_math::AngularQuadraturePtr > angular_quadrature_stack
static std::vector< chi_mesh::UnpartMeshPtr > unpartitionedmesh_stack
static void Exit(int error_code)
static std::vector< ChiObjectPtr > object_stack
static int RunInteractive(int argc, char **argv)
static chi::RegistryStatuses GetStatusOfRegistries()
static std::vector< chi_mesh::SurfaceMeshPtr > surface_mesh_stack
static std::string GetVersionStr()
static int Initialize(int argc, char **argv, MPI_Comm communicator)
static int current_mesh_handler
static std::vector< chi_math::SpatialDiscretizationPtr > sdm_stack
static chi::MPI_Info & mpi
static chi::Console & console
static std::vector< chi::PostProcessorPtr > postprocessor_stack
void DumpRegister() const
Dumps the object registry to stdout.
static ChiObjectFactory & GetInstance() noexcept
void SetVerbosity(int int_level)
static ChiLog & GetInstance() noexcept
LogStream Log(LOG_LVL level=LOG_0)
int ExecuteFile(const std::string &fileName, int argc, char **argv) const
void LoadRegisteredLuaItems()
std::vector< std::string > & GetCommandBuffer()
void PostMPIInfo(int location_id, int number_of_processes) const
static Console & GetInstance() noexcept
void FlushConsole()
Flushes any commands in the command buffer.
const std::map< std::string, LuaFunctionRegistryEntry > & GetLuaFunctionRegistry() const
void DumpRegister() const
Dumps the object registry to stdout.
void RunConsoleLoop(char *fileName=nullptr) const
const std::map< std::string, LuaFunctionRegistryEntry > & GetFunctionWrapperRegistry() const
const MPI_Comm & comm
MPI communicator.
static MPI_Info & GetInstance() noexcept
void SetProcessCount(int in_process_count)
void SetLocationID(int in_location_id)
void SetCommunicator(MPI_Comm new_communicator)
const int & process_count
Total number of processes.
static SystemWideEventPublisher & GetInstance()
void PublishEvent(const chi::Event &event) override
static std::string GetLocalDateTimeString()
std::string GetTimeString() const
TimingBlock & CreateTimingBlock(const std::string &name, const std::string &parent_name="")
TimingBlock & GetTimingBlock(const std::string &name)
int GetStandardEventCode(const std::string &event_name)
std::vector< std::string > console_lua_func_keys_
std::vector< std::string > objfactory_keys_
std::vector< std::string > console_lua_wrapper_keys_