Skip to content

Commit

Permalink
core: cells: removed cells global
Browse files Browse the repository at this point in the history
  • Loading branch information
fweik committed Jun 29, 2020
1 parent 9cc0cd1 commit 9a11ffc
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 15 deletions.
4 changes: 0 additions & 4 deletions src/core/cells.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@

#include <cstdio>

/** list of all cells. */
std::vector<Cell> cells;

/** Type of cell structure in use */
CellStructure cell_structure;

Expand Down Expand Up @@ -197,7 +194,6 @@ void cells_re_init(int new_cs, double range) {

cell_structure.m_local_cells.clear();
cell_structure.m_ghost_cells.clear();
cells.clear();

topology_init(new_cs, range);
cell_structure.min_range = range;
Expand Down
3 changes: 0 additions & 3 deletions src/core/cells.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ enum {
/************************************************************/
/*@{*/

/** list of all cells. */
extern std::vector<Cell> cells;

/** Type of cell structure in use. */
extern CellStructure cell_structure;

Expand Down
17 changes: 9 additions & 8 deletions src/core/domain_decomposition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,8 @@ void dd_create_cell_grid(double range) {
cell_structure.max_range = dd.cell_size;

/* allocate cell array and cell pointer arrays */
cells.resize(new_cells);
dd.cells.clear();
dd.cells.resize(new_cells);
cell_structure.m_local_cells.resize(n_local_cells);
cell_structure.m_ghost_cells.resize(new_cells - n_local_cells);
}
Expand All @@ -185,9 +186,9 @@ void dd_mark_cells() {
if ((m > 0 && m < dd.ghost_cell_grid[0] - 1 && n > 0 &&
n < dd.ghost_cell_grid[1] - 1 && o > 0 &&
o < dd.ghost_cell_grid[2] - 1))
cell_structure.m_local_cells[cnt_l++] = &cells[cnt_c++];
cell_structure.m_local_cells[cnt_l++] = &dd.cells.at(cnt_c++);
else
cell_structure.m_ghost_cells[cnt_g++] = &cells[cnt_c++];
cell_structure.m_ghost_cells[cnt_g++] = &dd.cells.at(cnt_c++);
}
}

Expand Down Expand Up @@ -222,7 +223,7 @@ int dd_fill_comm_cell_lists(ParticleList **part_lists,
{dd.ghost_cell_grid[0], dd.ghost_cell_grid[1],
dd.ghost_cell_grid[2]});

part_lists[c] = &(cells[i].particles());
part_lists[c] = &(dd.cells.at(i).particles());
c++;
}
return c;
Expand Down Expand Up @@ -468,12 +469,12 @@ void dd_init_cell_interactions(const Utils::Vector3i &grid) {
dd.ghost_cell_grid[1],
dd.ghost_cell_grid[2]});
if (ind2 > ind1) {
red_neighbors.push_back(&cells[ind2]);
red_neighbors.push_back(&dd.cells.at(ind2));
} else {
black_neighbors.push_back(&cells[ind2]);
black_neighbors.push_back(&dd.cells.at(ind2));
}
}
cells[ind1].m_neighbors =
dd.cells.at(ind1).m_neighbors =
Neighbors<Cell *>(red_neighbors, black_neighbors);
}
}
Expand Down Expand Up @@ -513,7 +514,7 @@ Cell *dd_save_position_to_cell(const Utils::Vector3d &pos) {
auto const ind = get_linear_index(
cpos[0], cpos[1], cpos[2],
{dd.ghost_cell_grid[0], dd.ghost_cell_grid[1], dd.ghost_cell_grid[2]});
return &(cells[ind]);
return &(dd.cells.at(ind));
}

/************************************************************/
Expand Down
1 change: 1 addition & 0 deletions src/core/domain_decomposition.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ struct DomainDecomposition {
boost::mpi::communicator comm;
BoxGeometry box_geo;
LocalBox<double> local_geo;
std::vector<Cell> cells;
};

/** Information about the domain decomposition. */
Expand Down

0 comments on commit 9a11ffc

Please sign in to comment.