mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Save space for cartesianToCompressed mapping.
For 10 Million cell problems my compute server (with 128 GB Ram) starts to swap, when I use debugging tools in parallel runs. I assume that this might get an issue for others, too. Now we consistently use unordered_map for the mapping.
This commit is contained in:
@@ -297,8 +297,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
int compressedIndex(int cartesianCellIdx) const
|
int compressedIndex(int cartesianCellIdx) const
|
||||||
{
|
{
|
||||||
int index = cartesianToCompressed_[cartesianCellIdx];
|
auto index_pair = cartesianToCompressed_.find(cartesianCellIdx);
|
||||||
return index;
|
if (index_pair!=cartesianToCompressed_.end())
|
||||||
|
return index_pair->second;
|
||||||
|
else
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@@ -399,7 +402,6 @@ protected:
|
|||||||
void updateCartesianToCompressedMapping_()
|
void updateCartesianToCompressedMapping_()
|
||||||
{
|
{
|
||||||
size_t num_cells = asImp_().grid().leafGridView().size(0);
|
size_t num_cells = asImp_().grid().leafGridView().size(0);
|
||||||
cartesianToCompressed_.resize(cartesianSize(), -1);
|
|
||||||
for (unsigned i = 0; i < num_cells; ++i) {
|
for (unsigned i = 0; i < num_cells; ++i) {
|
||||||
unsigned cartesianCellIdx = cartesianIndex(i);
|
unsigned cartesianCellIdx = cartesianIndex(i);
|
||||||
cartesianToCompressed_[cartesianCellIdx] = i;
|
cartesianToCompressed_[cartesianCellIdx] = i;
|
||||||
@@ -482,7 +484,7 @@ protected:
|
|||||||
/*! \brief Mapping between cartesian and compressed cells.
|
/*! \brief Mapping between cartesian and compressed cells.
|
||||||
* It is initialized the first time it is called
|
* It is initialized the first time it is called
|
||||||
*/
|
*/
|
||||||
std::vector<int> cartesianToCompressed_;
|
std::unordered_map<int,int> cartesianToCompressed_;
|
||||||
|
|
||||||
/*! \brief Cell center depths
|
/*! \brief Cell center depths
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -472,9 +472,7 @@ update(bool global)
|
|||||||
updateFromEclState_(global);
|
updateFromEclState_(global);
|
||||||
|
|
||||||
// Create mapping from global to local index
|
// Create mapping from global to local index
|
||||||
const size_t cartesianSize = cartMapper_.cartesianSize();
|
std::unordered_map<std::size_t,int> globalToLocal;
|
||||||
// reserve memory
|
|
||||||
std::vector<int> globalToLocal(cartesianSize, -1);
|
|
||||||
|
|
||||||
// loop over all elements (global grid) and store Cartesian index
|
// loop over all elements (global grid) and store Cartesian index
|
||||||
elemIt = grid_.leafGridView().template begin<0>();
|
elemIt = grid_.leafGridView().template begin<0>();
|
||||||
@@ -813,7 +811,7 @@ computeFaceProperties(const Intersection& intersection,
|
|||||||
template<class Grid, class GridView, class ElementMapper, class Scalar>
|
template<class Grid, class GridView, class ElementMapper, class Scalar>
|
||||||
std::tuple<std::vector<NNCdata>, std::vector<NNCdata>>
|
std::tuple<std::vector<NNCdata>, std::vector<NNCdata>>
|
||||||
EclTransmissibility<Grid,GridView,ElementMapper,Scalar>::
|
EclTransmissibility<Grid,GridView,ElementMapper,Scalar>::
|
||||||
applyNncToGridTrans_(const std::vector<int>& cartesianToCompressed)
|
applyNncToGridTrans_(const std::unordered_map<std::size_t,int>& cartesianToCompressed)
|
||||||
{
|
{
|
||||||
// First scale NNCs with EDITNNC.
|
// First scale NNCs with EDITNNC.
|
||||||
std::vector<NNCdata> unprocessedNnc;
|
std::vector<NNCdata> unprocessedNnc;
|
||||||
@@ -825,8 +823,10 @@ applyNncToGridTrans_(const std::vector<int>& cartesianToCompressed)
|
|||||||
for (const auto& nncEntry : nnc_input) {
|
for (const auto& nncEntry : nnc_input) {
|
||||||
auto c1 = nncEntry.cell1;
|
auto c1 = nncEntry.cell1;
|
||||||
auto c2 = nncEntry.cell2;
|
auto c2 = nncEntry.cell2;
|
||||||
auto low = cartesianToCompressed[c1];
|
auto lowIt = cartesianToCompressed.find(c1);
|
||||||
auto high = cartesianToCompressed[c2];
|
auto highIt = cartesianToCompressed.find(c2);
|
||||||
|
int low = (lowIt == cartesianToCompressed.end())? -1 : lowIt->second;
|
||||||
|
int high = (highIt == cartesianToCompressed.end())? -1 : highIt->second;
|
||||||
|
|
||||||
if (low > high)
|
if (low > high)
|
||||||
std::swap(low, high);
|
std::swap(low, high);
|
||||||
@@ -863,7 +863,7 @@ applyNncToGridTrans_(const std::vector<int>& cartesianToCompressed)
|
|||||||
|
|
||||||
template<class Grid, class GridView, class ElementMapper, class Scalar>
|
template<class Grid, class GridView, class ElementMapper, class Scalar>
|
||||||
void EclTransmissibility<Grid,GridView,ElementMapper,Scalar>::
|
void EclTransmissibility<Grid,GridView,ElementMapper,Scalar>::
|
||||||
applyEditNncToGridTrans_(const std::vector<int>& globalToLocal)
|
applyEditNncToGridTrans_(const std::unordered_map<std::size_t,int>& globalToLocal)
|
||||||
{
|
{
|
||||||
const auto& nnc_input = eclState_.getInputNNC();
|
const auto& nnc_input = eclState_.getInputNNC();
|
||||||
const auto& editNnc = nnc_input.edit();
|
const auto& editNnc = nnc_input.edit();
|
||||||
@@ -879,11 +879,13 @@ applyEditNncToGridTrans_(const std::vector<int>& globalToLocal)
|
|||||||
return fmt::format("({},{},{})", i + 1,j + 1,k + 1);
|
return fmt::format("({},{},{})", i + 1,j + 1,k + 1);
|
||||||
};
|
};
|
||||||
|
|
||||||
auto make_warning = [&format_ijk] (const KeywordLocation& location, const NNCdata& nnc) -> std::string {
|
auto print_warning = [&format_ijk, &nnc_input] (const NNCdata& nnc) {
|
||||||
return fmt::format("Problem with EDITNNC keyword\n"
|
const auto& location = nnc_input.edit_location( nnc );
|
||||||
"In {} line {} \n"
|
auto warning = fmt::format("Problem with EDITNNC keyword\n"
|
||||||
"No NNC defined for connection {} -> {}", location.filename, location.lineno, format_ijk(nnc.cell1), format_ijk(nnc.cell2));
|
"In {} line {} \n"
|
||||||
|
"No NNC defined for connection {} -> {}", location.filename,
|
||||||
|
location.lineno, format_ijk(nnc.cell1), format_ijk(nnc.cell2));
|
||||||
|
OpmLog::warning("EDITNNC", warning);
|
||||||
};
|
};
|
||||||
|
|
||||||
// editNnc is supposed to only reference non-neighboring connections and not
|
// editNnc is supposed to only reference non-neighboring connections and not
|
||||||
@@ -895,16 +897,24 @@ applyEditNncToGridTrans_(const std::vector<int>& globalToLocal)
|
|||||||
while (nnc != end) {
|
while (nnc != end) {
|
||||||
auto c1 = nnc->cell1;
|
auto c1 = nnc->cell1;
|
||||||
auto c2 = nnc->cell2;
|
auto c2 = nnc->cell2;
|
||||||
auto low = globalToLocal[c1];
|
auto lowIt = globalToLocal.find(c1);
|
||||||
auto high = globalToLocal[c2];
|
auto highIt = globalToLocal.find(c2);
|
||||||
|
|
||||||
|
if (lowIt == globalToLocal.end() || highIt == globalToLocal.end()) {
|
||||||
|
print_warning(*nnc);
|
||||||
|
++nnc;
|
||||||
|
warning_count++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto low = lowIt->second, high = highIt->second;
|
||||||
|
|
||||||
if (low > high)
|
if (low > high)
|
||||||
std::swap(low, high);
|
std::swap(low, high);
|
||||||
|
|
||||||
auto candidate = trans_.find(isId(low, high));
|
auto candidate = trans_.find(isId(low, high));
|
||||||
if (candidate == trans_.end()) {
|
if (candidate == trans_.end()) {
|
||||||
const auto& location = nnc_input.edit_location( *nnc );
|
print_warning(*nnc);
|
||||||
auto warning = make_warning(location, *nnc);
|
|
||||||
OpmLog::warning("EDITNNC", warning);
|
|
||||||
++nnc;
|
++nnc;
|
||||||
warning_count++;
|
warning_count++;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -194,10 +194,10 @@ protected:
|
|||||||
* inactive cells are omitted in these vectors.
|
* inactive cells are omitted in these vectors.
|
||||||
*/
|
*/
|
||||||
std::tuple<std::vector<NNCdata>, std::vector<NNCdata>>
|
std::tuple<std::vector<NNCdata>, std::vector<NNCdata>>
|
||||||
applyNncToGridTrans_(const std::vector<int>& cartesianToCompressed);
|
applyNncToGridTrans_(const std::unordered_map<std::size_t,int>& cartesianToCompressed);
|
||||||
|
|
||||||
/// \brief Multiplies the grid transmissibilities according to EDITNNC.
|
/// \brief Multiplies the grid transmissibilities according to EDITNNC.
|
||||||
void applyEditNncToGridTrans_(const std::vector<int>& globalToLocal);
|
void applyEditNncToGridTrans_(const std::unordered_map<std::size_t,int>& globalToLocal);
|
||||||
|
|
||||||
void extractPermeability_();
|
void extractPermeability_();
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user