remove cartesian to compressed vector

This commit is contained in:
Tor Harald Sandve 2021-09-27 11:28:27 +02:00 committed by Markus Blatt
parent 5717a95cb4
commit 1cfe3e0aad
6 changed files with 39 additions and 69 deletions

View File

@ -370,8 +370,6 @@ namespace Opm {
// setting the well_solutions_ based on well_state.
void updatePrimaryVariables(DeferredLogger& deferred_logger);
void setupCartesianToCompressed_(const int* global_cell, int local_num__cells);
void updateAverageFormationFactor();
void computePotentials(const std::size_t widx,
@ -421,6 +419,10 @@ namespace Opm {
void assignWellTracerRates(data::Wells& wsrpt) const;
int compressedIndex(int cartesian_cell_idx) const override {
return ebosSimulator_.vanguard().compressedIndex(cartesian_cell_idx);
}
private:
BlackoilWellModel(Simulator& ebosSimulator, const PhaseUsage& pu);
};

View File

@ -349,8 +349,7 @@ initializeWellPerfData()
parallelWellInfo.beginReset();
for (const auto& completion : well.getConnections()) {
const int active_index =
cartesian_to_compressed_[completion.global_index()];
const int active_index = compressedIndex(completion.global_index());
if (completion.state() == Connection::State::OPEN) {
if (active_index >= 0) {
if (firstOpenCompletion)
@ -1706,7 +1705,7 @@ BlackoilWellModelGeneric::
setRepRadiusPerfLength()
{
for (const auto& well : well_container_generic_) {
well->setRepRadiusPerfLength(cartesian_to_compressed_);
well->setRepRadiusPerfLength();
}
}

View File

@ -374,6 +374,9 @@ protected:
void runWellPIScaling(const int timeStepIdx,
DeferredLogger& local_deferredLogger);
virtual int compressedIndex(int cartesian_cell_idx) const = 0;
Schedule& schedule_;
const SummaryState& summaryState_;
const EclipseState& eclState_;
@ -401,11 +404,6 @@ protected:
std::vector<WellProdIndexCalculator> prod_index_calc_;
// Map from logically cartesian cell indices to compressed ones.
// Cells not in the interior are not mapped. This deactivates
// these for distributed wells and makes the distribution non-overlapping.
std::vector<int> cartesian_to_compressed_;
std::vector<int> pvt_region_idx_;
mutable std::unordered_set<std::string> closed_this_step_;

View File

@ -51,18 +51,11 @@ namespace Opm {
// Number of cells the global grid view
global_num_cells_ = ebosSimulator_.vanguard().globalNumCells();
// Set up cartesian mapping.
// Set up parallel wells
{
const auto& grid = this->ebosSimulator_.vanguard().grid();
const auto& cartDims = UgGridHelpers::cartDims(grid);
setupCartesianToCompressed_(UgGridHelpers::globalCell(grid),
cartDims[0] * cartDims[1] * cartDims[2]);
auto& parallel_wells = ebosSimulator.vanguard().parallelWells();
for (const auto& wellinfo : parallel_wells) {
this->parallel_well_info_.emplace_back(wellinfo, grid.comm());
}
this->parallel_well_info_.assign(parallel_wells.begin(),
parallel_wells.end());
}
this->alternative_well_rate_init_ =
@ -129,8 +122,7 @@ namespace Opm {
for ( size_t c=0; c < connectionSet.size(); c++ )
{
const auto& connection = connectionSet.get(c);
int compressed_idx = cartesian_to_compressed_
.at(connection.global_index());
int compressed_idx = compressedIndex(connection.global_index());
if ( compressed_idx >= 0 ) { // Ignore connections in inactive/remote cells.
wellCells.push_back(compressed_idx);
@ -1431,31 +1423,6 @@ namespace Opm {
template<typename TypeTag>
void
BlackoilWellModel<TypeTag>::
setupCartesianToCompressed_(const int* global_cell, int number_of_cartesian_cells)
{
cartesian_to_compressed_.resize(number_of_cartesian_cells, -1);
if (global_cell) {
auto elemIt = ebosSimulator_.gridView().template begin</*codim=*/ 0>();
for (unsigned i = 0; i < local_num_cells_; ++i) {
// Skip perforations in the overlap/ghost for distributed wells.
if (elemIt->partitionType() == Dune::InteriorEntity)
{
assert(ebosSimulator_.gridView().indexSet().index(*elemIt) == static_cast<int>(i));
cartesian_to_compressed_[global_cell[i]] = i;
}
++elemIt;
}
}
else {
for (unsigned i = 0; i < local_num_cells_; ++i) {
cartesian_to_compressed_[i] = i;
}
}
}
template<typename TypeTag>
void

View File

@ -263,7 +263,7 @@ void WellInterfaceGeneric::setWellEfficiencyFactor(const double efficiency_facto
well_efficiency_factor_ = efficiency_factor;
}
void WellInterfaceGeneric::setRepRadiusPerfLength(const std::vector<int>& cartesian_to_compressed)
void WellInterfaceGeneric::setRepRadiusPerfLength()
{
const int nperf = number_of_perforations_;
@ -275,31 +275,35 @@ void WellInterfaceGeneric::setRepRadiusPerfLength(const std::vector<int>& cartes
perf_length_.reserve(nperf);
bore_diameters_.reserve(nperf);
// COMPDAT handling
const auto& connectionSet = well_ecl_.getConnections();
CheckDistributedWellConnections checker(well_ecl_, parallel_well_info_);
for (size_t c=0; c<connectionSet.size(); c++) {
const auto& connection = connectionSet.get(c);
const int cell =
cartesian_to_compressed[connection.global_index()];
if (connection.state() != Connection::State::OPEN || cell >= 0)
const WellConnections& connections = well_ecl_.getConnections();
const std::size_t num_conns = connections.size();
int num_active_connections = 0;
auto my_next_perf = perf_data_->begin();
for (std::size_t c = 0; c < num_conns; ++c) {
if (my_next_perf == perf_data_->end())
{
checker.connectionFound(c);
break;
}
if (my_next_perf->ecl_index > c)
{
continue;
}
assert(my_next_perf->ecl_index == c);
const auto& connection = connections[c];
if (connection.state() == Connection::State::OPEN) {
if (cell >= 0) {
double radius = connection.rw();
double re = connection.re(); // area equivalent radius of the grid block
double perf_length = connection.connectionLength(); // the length of the well perforation
const double repR = std::sqrt(re * radius);
perf_rep_radius_.push_back(repR);
perf_length_.push_back(perf_length);
bore_diameters_.push_back(2. * radius);
}
double radius = connection.rw();
double re = connection.re(); // area equivalent radius of the grid block
double perf_length = connection.connectionLength(); // the length of the well perforation
const double repR = std::sqrt(re * radius);
perf_rep_radius_.push_back(repR);
perf_length_.push_back(perf_length);
bore_diameters_.push_back(2. * radius);
num_active_connections++;
}
++my_next_perf;
}
checker.checkAllConnectionsFound();
assert(my_next_perf == perf_data_->end());
assert(num_active_connections == nperf);
}
void WellInterfaceGeneric::setWsolvent(const double wsolvent)

View File

@ -93,7 +93,7 @@ public:
void setVFPProperties(const VFPProperties* vfp_properties_arg);
void setGuideRate(const GuideRate* guide_rate_arg);
void setWellEfficiencyFactor(const double efficiency_factor);
void setRepRadiusPerfLength(const std::vector<int>& cartesian_to_compressed);
void setRepRadiusPerfLength();
void setWsolvent(const double wsolvent);
void setDynamicThpLimit(const double thp_limit);
void updatePerforatedCell(std::vector<bool>& is_cell_perforated);