Add deallocation for C++ geometry globals

This commit is contained in:
Sterling Harper 2018-05-27 14:54:51 -04:00
parent 1e867c0749
commit 3d5e9b4dc2
5 changed files with 33 additions and 11 deletions

View file

@ -520,12 +520,5 @@ extern "C" {
}
}
//extern "C" void free_memory_cells_c()
//{
// delete cells_c;
// cells_c = nullptr;
// n_cells = 0;
// cell_dict.clear();
//}
} // namespace openmc

View file

@ -321,4 +321,23 @@ maximum_levels(int32_t univ)
return levels_below;
}
//==============================================================================
void
free_memory_geometry_c()
{
for (Cell *c : cells_c) {delete c;}
cells_c.clear();
cell_dict.clear();
n_cells = 0;
for (Universe *u : universes_c) {delete u;}
universes_c.clear();
universe_dict.clear();
for (Lattice *lat : lattices_c) {delete lat;}
lattices_c.clear();
lattice_dict.clear();
}
} // namespace openmc

View file

@ -102,5 +102,11 @@ distribcell_path(int32_t target_cell, int32_t map, int32_t target_offset,
extern "C" int maximum_levels(int32_t univ);
//==============================================================================
//! Deallocates global vectors and maps for cells, universes, and lattices.
//==============================================================================
extern "C" void free_memory_geometry_c();
} // namespace openmc
#endif // GEOMETRY_AUX_H

View file

@ -516,6 +516,12 @@ contains
!===============================================================================
subroutine free_memory_geometry()
interface
subroutine free_memory_geometry_c() bind(C)
end subroutine free_memory_geometry_c
end interface
call free_memory_geometry_c()
n_cells = 0
n_universes = 0

View file

@ -8,9 +8,7 @@ fi
# Run regression and unit tests
if [[ $MPI == 'y' ]]; then
pytest --cov=openmc -v --mpi tests/regression_tests
pytest --cov=openmc -v --mpi tests/unit_tests
pytest --cov=openmc -v --mpi tests
else
pytest --cov=openmc -v tests/regression_tests
pytest --cov=openmc -v tests/unit_tests
pytest --cov=openmc -v tests
fi