From 9a11ffcac7c0cfe9afa6e4bc99caf447c43a01b9 Mon Sep 17 00:00:00 2001 From: Florian Weik Date: Fri, 1 May 2020 20:47:48 +0200 Subject: [PATCH] core: cells: removed cells global --- src/core/cells.cpp | 4 ---- src/core/cells.hpp | 3 --- src/core/domain_decomposition.cpp | 17 +++++++++-------- src/core/domain_decomposition.hpp | 1 + 4 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/core/cells.cpp b/src/core/cells.cpp index cd1ca5a773a..0af5eab78fe 100644 --- a/src/core/cells.cpp +++ b/src/core/cells.cpp @@ -47,9 +47,6 @@ #include -/** list of all cells. */ -std::vector cells; - /** Type of cell structure in use */ CellStructure cell_structure; @@ -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; diff --git a/src/core/cells.hpp b/src/core/cells.hpp index 309cb5d21e1..0ea46761a80 100644 --- a/src/core/cells.hpp +++ b/src/core/cells.hpp @@ -63,9 +63,6 @@ enum { /************************************************************/ /*@{*/ -/** list of all cells. */ -extern std::vector cells; - /** Type of cell structure in use. */ extern CellStructure cell_structure; diff --git a/src/core/domain_decomposition.cpp b/src/core/domain_decomposition.cpp index 28b003fd103..c1c88fd899c 100644 --- a/src/core/domain_decomposition.cpp +++ b/src/core/domain_decomposition.cpp @@ -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); } @@ -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++); } } @@ -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; @@ -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(red_neighbors, black_neighbors); } } @@ -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)); } /************************************************************/ diff --git a/src/core/domain_decomposition.hpp b/src/core/domain_decomposition.hpp index dac821551e8..1775f763560 100644 --- a/src/core/domain_decomposition.hpp +++ b/src/core/domain_decomposition.hpp @@ -87,6 +87,7 @@ struct DomainDecomposition { boost::mpi::communicator comm; BoxGeometry box_geo; LocalBox local_geo; + std::vector cells; }; /** Information about the domain decomposition. */