Skip to content

Commit f9e029f

Browse files
committed
FEAT: restart both grids, clean code
1 parent dc312af commit f9e029f

File tree

1 file changed

+11
-21
lines changed

1 file changed

+11
-21
lines changed

src/main/main.cpp

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ int main() {
2424
try {
2525
// Create inputs (reading the input file):
2626
input = Inputs(time);
27-
2827
if (!input.is_ok())
2928
throw std::string("input initialization failed!");
3029

@@ -37,57 +36,48 @@ int main() {
3736
// cubesphere (6 root)
3837
Quadtree quadtree(input.get_grid_shape("neuGrid"));
3938
Quadtree quadtree_ion(input.get_grid_shape("ionGrid"));
40-
4139
if (!quadtree.is_ok())
4240
throw std::string("quadtree initialization failed!");
4341

4442
// Initialize MPI and parallel aspects of the code:
4543
didWork = init_parallel(quadtree, quadtree_ion);
46-
4744
if (!didWork)
4845
throw std::string("init_parallel failed!");
4946

5047
// Everything should be set for the inputs now, so write a restart file:
5148
didWork = input.write_restart();
52-
5349
if (!didWork)
5450
throw std::string("input.write_restart failed!");
5551

5652
// Initialize the EUV system:
5753
Euv euv;
58-
5954
if (!euv.is_ok())
6055
throw std::string("EUV initialization failed!");
6156

6257
// Initialize the planet:
6358
Planets planet;
64-
MPI_Barrier(aether_comm);
65-
6659
if (!planet.is_ok())
6760
throw std::string("planet initialization failed!");
6861

6962
// Initialize the indices, read the files, and perturb:
7063
Indices indices;
7164
didWork = read_and_store_indices(indices);
72-
MPI_Barrier(aether_comm);
73-
7465
if (!didWork)
7566
throw std::string("read_and_store_indices failed!");
7667

7768
// Perturb the inputs if user has asked for this
7869
indices.perturb();
79-
MPI_Barrier(aether_comm);
8070

8171
// Initialize Geographic grid:
8272
Grid gGrid("neuGrid");
8373
didWork = gGrid.init_geo_grid(quadtree, planet);
84-
MPI_Barrier(aether_comm);
85-
8674
if (!didWork)
8775
throw std::string("init_geo_grid failed!");
8876

8977
// Find interpolation coefs for the ghostcells if cubesphere grid
90-
didWork = find_ghostcell_interpolation_coefs(gGrid);
78+
//didWork = find_ghostcell_interpolation_coefs(gGrid);
79+
//if (!didWork)
80+
// throw std::string("find_ghostcell_interpolation_coefs failed!");
9181

9282
// Calculate centripetal acceleration, since this is a constant
9383
// vector on the grid:
@@ -107,14 +97,13 @@ int main() {
10797
didWork = mGrid.init_geo_grid(quadtree, planet);
10898
mGrid.set_IsGeoGrid(false);
10999
}
110-
// Initialize Neutrals on geographic grid:
100+
101+
// Initialize Neutrals on geographic and magnetic grids:
111102
Neutrals neutrals(gGrid, planet, time, indices);
112-
// Initialize Neutrals on magnetic grid:
113103
Neutrals neutralsMag(mGrid, planet, time, indices);
114104

115-
// Initialize Ions on geographic grid:
105+
// Initialize Ions on geographic and magnetic grids:
116106
Ions ions(gGrid, planet);
117-
// Initialize Ions on magnetic grid:
118107
Ions ionsMag(mGrid, planet);
119108

120109
// -----------------------------------------------------------------
@@ -151,9 +140,8 @@ int main() {
151140
read_collision_file(neutrals, ions);
152141
read_collision_file(neutralsMag, ionsMag);
153142

154-
// Initialize ion temperatures from neutral temperature
143+
// Initialize ion temperatures from neutral temperature (both grids)
155144
ions.init_ion_temperature(neutrals, gGrid);
156-
// Initialize ion temperatures from neutral temperature (on Mag Grid)
157145
ionsMag.init_ion_temperature(neutralsMag, mGrid);
158146

159147
// Initialize electrodynamics and check if electrodynamics times
@@ -239,12 +227,14 @@ int main() {
239227
if (!time.check_time_gate(input.get_dt_write_restarts())) {
240228
report.print(3, "Writing restart files");
241229

242-
didWork = neutrals.restart_file(input.get_restartout_dir(), DoWrite);
230+
didWork = neutrals.restart_file(input.get_restartout_dir(), gGrid.get_gridtype(), DoWrite);
231+
didWork = neutralsMag.restart_file(input.get_restartout_dir(), mGrid.get_gridtype(), DoWrite);
243232

244233
if (!didWork)
245234
throw std::string("Writing Restart for Neutrals Failed!!!\n");
246235

247-
didWork = ions.restart_file(input.get_restartout_dir(), DoWrite);
236+
didWork = ions.restart_file(input.get_restartout_dir(), gGrid.get_gridtype(), DoWrite);
237+
didWork = ionsMag.restart_file(input.get_restartout_dir(), mGrid.get_gridtype(), DoWrite);
248238

249239
if (!didWork)
250240
throw std::string("Writing Restart for Ions Failed!!!\n");

0 commit comments

Comments
 (0)