simplifying the constructor for AquiferNumerical

removing the unused global_cell and avoid the unnecessary construction of cartesianToCompressed
This commit is contained in:
Kai Bao 2022-08-18 14:59:17 +02:00
parent 6afb386070
commit d69c80b84a
2 changed files with 5 additions and 18 deletions

View File

@ -61,13 +61,10 @@ public:
// Constructor
AquiferNumerical(const SingleNumericalAquifer& aquifer,
const std::unordered_map<int, int>& cartesian_to_compressed,
const Simulator& ebos_simulator,
const int* global_cell)
const Simulator& ebos_simulator)
: AquiferInterface<TypeTag>(aquifer.id(), ebos_simulator)
, flux_rate_ (0.0)
, cumulative_flux_(0.0)
, global_cell_ (global_cell)
, init_pressure_ (aquifer.numCells(), 0.0)
{
this->cell_to_aquifer_cell_idx_.resize(this->ebos_simulator_.gridView().size(/*codim=*/0), -1);
@ -77,9 +74,9 @@ public:
const auto* cell = aquifer.getCellPrt(idx);
// Due to parallelisation, the cell might not exist in the current process
auto search = cartesian_to_compressed.find(cell->global_index);
if (search != cartesian_to_compressed.end()) {
this->cell_to_aquifer_cell_idx_[search->second] = idx;
const int compressed_idx = ebos_simulator.vanguard().compressedIndexForInterior(cell->global_index);
if (compressed_idx >= 0) {
this->cell_to_aquifer_cell_idx_[compressed_idx] = idx;
aquifer_on_process = true;
}
}
@ -301,7 +298,6 @@ private:
double flux_rate_; // aquifer influx rate
double cumulative_flux_; // cumulative aquifer influx
const int* global_cell_; // mapping to global index
std::vector<double> init_pressure_{};
double pressure_; // aquifer pressure
bool solution_set_from_restart_ {false};

View File

@ -18,8 +18,6 @@
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#include <opm/grid/utility/cartesianToCompressed.hpp>
namespace Opm
{
@ -157,15 +155,8 @@ BlackoilAquiferModel<TypeTag>::init()
if (aquifer.hasNumericalAquifer()) {
const auto& num_aquifers = aquifer.numericalAquifers().aquifers();
const int number_of_cells = simulator_.gridView().size(0);
const int* global_cell = this->simulator_.vanguard().globalCell().data();
const std::unordered_map<int, int> cartesian_to_compressed = cartesianToCompressed(number_of_cells,
global_cell);
for ([[maybe_unused]]const auto& [id, aqu] : num_aquifers) {
auto aqf = std::make_unique<AquiferNumerical<TypeTag>>(aqu,
cartesian_to_compressed,
this->simulator_,
global_cell);
auto aqf = std::make_unique<AquiferNumerical<TypeTag>>(aqu, this->simulator_);
aquifers.push_back(std::move(aqf));
}
}