2 #include <athena/mesh/mesh.hpp>
3 #include <athena/outputs/io_wrapper.hpp>
4 #include <athena/parameter_input.hpp>
7 #include <application/command_line.hpp>
8 #include <application/exceptions.hpp>
11 #include <configure.hpp>
28 IOWrapper infile, restartfile;
29 auto cli = CommandLine::GetInstance();
32 pinput =
new ParameterInput;
34 if (cli->res_flag == 1) {
35 restartfile.Open(cli->restart_filename, IOWrapper::FileMode::read);
36 pinput->LoadFromFile(restartfile);
40 if (cli->iarg_flag == 1) pinput->RollbackNextTime();
44 if (cli->iarg_flag == 1) {
47 infile.Open(cli->input_filename, IOWrapper::FileMode::read);
48 pinput->LoadFromFile(infile);
51 pinput->ModifyFromCmdline(cli->argc, cli->argv);
52 }
catch (std::bad_alloc& ba) {
53 if (cli->res_flag == 1) restartfile.Close();
55 "main",
"memory allocation failed initializing class ParameterInput:");
56 }
catch (std::exception
const& ex) {
57 if (cli->res_flag == 1) restartfile.Close();
58 throw RuntimeError(
"main", ex.what());
71 if (cli->res_flag == 0) {
72 pmesh =
new Mesh(pinput, cli->mesh_flag);
74 pmesh =
new Mesh(pinput, restartfile, cli->mesh_flag);
76 }
catch (std::bad_alloc& ba) {
77 if (cli->res_flag == 1) restartfile.Close();
78 throw RuntimeError(
"main",
79 "memory allocation failed initializing class Mesh:");
80 }
catch (std::exception
const& ex) {
81 if (cli->res_flag == 1) restartfile.Close();
82 throw RuntimeError(
"main", ex.what());
87 if (cli->iarg_flag == 1 && cli->res_flag == 1) {
89 pinput->ForwardNextTime(pmesh->time);
94 if (Globals::my_rank == 0) pinput->ParameterDump(std::cout);
95 if (cli->res_flag == 1) restartfile.Close();
103 if (cli->res_flag == 1) restartfile.Close();
106 if (cli->mesh_flag > 0) {
114 for (
int b = 0;
b < pmesh->nblocal; ++
b) {
115 MeshBlock* pmb = pmesh->my_blocks(
b);
116 pmb->pimpl = std::make_shared<MeshBlock::Impl>(pmb, pinput);
120 pmesh->Initialize(cli->res_flag, pinput);
static IndexMap const * InitFromAthenaInput(ParameterInput *pin)
static Thermodynamics const * InitFromAthenaInput(ParameterInput *pin)
void mesh_setup(ParameterInput *&pinput, Mesh *&pmesh)
void commit_mpi_particle_data()