fixing grid_index for AquiferCarterTracy

adding the mapping from cartisian indices to the actual grid indices.
This commit is contained in:
Kai Bao 2018-12-07 15:55:14 +01:00
parent bec18a5d91
commit 3a55e4aac2
3 changed files with 138 additions and 119 deletions

View File

@ -32,6 +32,7 @@
#include <vector>
#include <algorithm>
#include <unordered_map>
namespace Opm
{
@ -64,9 +65,11 @@ namespace Opm
AquiferCarterTracy( const AquiferCT::AQUCT_data& aquct_data,
const Aquancon::AquanconOutput& connection,
const std::unordered_map<int, int>& cartesian_to_compressed,
const Simulator& ebosSimulator)
: ebos_simulator_ (ebosSimulator)
, aquct_data_ (aquct_data)
, cartesian_to_compressed_(cartesian_to_compressed)
, connection_(connection)
{}
@ -149,6 +152,7 @@ namespace Opm
Eval W_flux_;
const std::unordered_map<int, int>& cartesian_to_compressed_;
Scalar gravity_() const
{ return ebos_simulator_.problem().gravity()[2]; }
@ -213,7 +217,7 @@ namespace Opm
b = beta_ / (Tc_ * ( PItd - td*PItdprime));
}
// This function implements Eq 5.7 of the EclipseTechnicalDescription
// This function implements Eq 5.7 of the EclipseTechnicalDescription
inline void calculateInflowRate(int idx, const Simulator& simulator)
{
Scalar a, b;
@ -230,7 +234,7 @@ namespace Opm
* aquct_data_.r_o * aquct_data_.r_o;
// We calculate the time constant
Tc_ = mu_w_ * aquct_data_.phi_aq
* aquct_data_.C_t
* aquct_data_.C_t
* aquct_data_.r_o * aquct_data_.r_o
/ ( aquct_data_.k_a * aquct_data_.c1 );
}
@ -247,8 +251,8 @@ namespace Opm
const auto cellNeighbour0 = faceCells(faceIdx,0);
const auto cellNeighbour1 = faceCells(faceIdx,1);
const auto defaultFaceArea = Opm::UgGridHelpers::faceArea(ugrid, faceIdx);
const auto calculatedFaceArea = (!connection.influx_coeff.at(idx))?
defaultFaceArea :
const auto calculatedFaceArea = (!connection.influx_coeff.at(idx))?
defaultFaceArea :
*(connection.influx_coeff.at(idx));
faceArea = (cellNeighbour0 * cellNeighbour1 > 0)? 0. : calculatedFaceArea;
if (cellNeighbour1 == 0){
@ -279,7 +283,6 @@ namespace Opm
cell_depth_.resize(cell_idx_.size(), aquct_data_.d0);
alphai_.resize(cell_idx_.size(), 1.0);
faceArea_connected_.resize(cell_idx_.size(),0.0);
Scalar faceArea;
auto cell2Faces = Opm::UgGridHelpers::cell2Faces(ugrid);
auto faceCells = Opm::UgGridHelpers::faceCells(ugrid);
@ -294,7 +297,8 @@ namespace Opm
{
cellToConnectionIdx_[cell_idx_[idx]] = idx;
auto cellFacesRange = cell2Faces[cell_idx_.at(idx)];
const int cell_index = cartesian_to_compressed_.at(cell_idx_[idx]);
auto cellFacesRange = cell2Faces[cell_index];
for(auto cellFaceIter = cellFacesRange.begin(); cellFaceIter != cellFacesRange.end(); ++cellFaceIter)
{
// The index of the face in the compressed grid
@ -344,9 +348,9 @@ namespace Opm
{
int pvttableIdx = aquct_data_.pvttableID - 1;
rhow_.resize(cell_idx_.size(),0.);
if (!aquct_data_.p0)
{
pa0_ = calculateReservoirEquilibrium();

View File

@ -71,6 +71,9 @@ namespace Opm {
Simulator& simulator_;
// map from logically cartesian cell indices to compressed ones
std::unordered_map<int, int> cartesian_to_compressed_;
// This initialization function is used to connect the parser objects with the ones needed by AquiferCarterTracy
void init();

View File

@ -1,111 +1,123 @@
namespace Opm {
template<typename TypeTag>
BlackoilAquiferModel<TypeTag>::
BlackoilAquiferModel(Simulator& simulator)
: simulator_(simulator)
{
init();
}
template<typename TypeTag>
void
BlackoilAquiferModel<TypeTag>::initialSolutionApplied()
{
for (auto aquifer = aquifers_.begin(); aquifer != aquifers_.end(); ++aquifer) {
aquifer->initialSolutionApplied();
}
}
template<typename TypeTag>
void
BlackoilAquiferModel<TypeTag>::beginEpisode()
{ }
template<typename TypeTag>
void
BlackoilAquiferModel<TypeTag>::beginTimeStep()
{
for (auto aquifer = aquifers_.begin(); aquifer != aquifers_.end(); ++aquifer) {
aquifer->beginTimeStep();
}
}
template<typename TypeTag>
void
BlackoilAquiferModel<TypeTag>::beginIteration()
{ }
template<typename TypeTag>
template <class Context>
void
BlackoilAquiferModel<TypeTag>::addToSource(RateVector& rates,
const Context& context,
unsigned spaceIdx,
unsigned timeIdx) const
{
for (auto& aquifer: aquifers_) {
aquifer.addToSource(rates, context, spaceIdx, timeIdx);
}
}
template<typename TypeTag>
void
BlackoilAquiferModel<TypeTag>::endIteration()
{ }
template<typename TypeTag>
void
BlackoilAquiferModel<TypeTag>::endTimeStep()
{
for (auto aquifer = aquifers_.begin(); aquifer != aquifers_.end(); ++aquifer) {
aquifer->endTimeStep();
}
}
template<typename TypeTag>
void
BlackoilAquiferModel<TypeTag>::endEpisode()
{ }
// Initialize the aquifers in the deck
template<typename TypeTag>
void
BlackoilAquiferModel<TypeTag>:: init()
{
const auto& deck = this->simulator_.vanguard().deck();
if ( !deck.hasKeyword("AQUCT") ) {
return ;
}
//updateConnectionIntensiveQuantities();
const auto& eclState = this->simulator_.vanguard().eclState();
// Get all the carter tracy aquifer properties data and put it in aquifers vector
const AquiferCT aquiferct = AquiferCT(eclState,deck);
const Aquancon aquifer_connect = Aquancon(eclState.getInputGrid(), deck);
std::vector<AquiferCT::AQUCT_data> aquifersData = aquiferct.getAquifers();
std::vector<Aquancon::AquanconOutput> aquifer_connection = aquifer_connect.getAquOutput();
assert( aquifersData.size() == aquifer_connection.size() );
for (size_t i = 0; i < aquifersData.size(); ++i)
{
aquifers_.push_back(
AquiferCarterTracy<TypeTag> (aquifersData.at(i), aquifer_connection.at(i), this->simulator_)
);
}
}
template<typename TypeTag>
bool
BlackoilAquiferModel<TypeTag>:: aquiferActive() const
{
return !aquifers_.empty();
}
} // namespace Opm
#include <opm/grid/utility/cartesianToCompressed.hpp>
namespace Opm {
template<typename TypeTag>
BlackoilAquiferModel<TypeTag>::
BlackoilAquiferModel(Simulator& simulator)
: simulator_(simulator)
{
init();
}
template<typename TypeTag>
void
BlackoilAquiferModel<TypeTag>::initialSolutionApplied()
{
for (auto aquifer = aquifers_.begin(); aquifer != aquifers_.end(); ++aquifer) {
aquifer->initialSolutionApplied();
}
}
template<typename TypeTag>
void
BlackoilAquiferModel<TypeTag>::beginEpisode()
{ }
template<typename TypeTag>
void
BlackoilAquiferModel<TypeTag>::beginTimeStep()
{
for (auto aquifer = aquifers_.begin(); aquifer != aquifers_.end(); ++aquifer) {
aquifer->beginTimeStep();
}
}
template<typename TypeTag>
void
BlackoilAquiferModel<TypeTag>::beginIteration()
{ }
template<typename TypeTag>
template <class Context>
void
BlackoilAquiferModel<TypeTag>::addToSource(RateVector& rates,
const Context& context,
unsigned spaceIdx,
unsigned timeIdx) const
{
for (auto& aquifer: aquifers_) {
aquifer.addToSource(rates, context, spaceIdx, timeIdx);
}
}
template<typename TypeTag>
void
BlackoilAquiferModel<TypeTag>::endIteration()
{ }
template<typename TypeTag>
void
BlackoilAquiferModel<TypeTag>::endTimeStep()
{
for (auto aquifer = aquifers_.begin(); aquifer != aquifers_.end(); ++aquifer) {
aquifer->endTimeStep();
}
}
template<typename TypeTag>
void
BlackoilAquiferModel<TypeTag>::endEpisode()
{ }
// Initialize the aquifers in the deck
template<typename TypeTag>
void
BlackoilAquiferModel<TypeTag>:: init()
{
const auto& deck = this->simulator_.vanguard().deck();
if ( !deck.hasKeyword("AQUCT") ) {
return ;
}
//updateConnectionIntensiveQuantities();
const auto& eclState = this->simulator_.vanguard().eclState();
// Get all the carter tracy aquifer properties data and put it in aquifers vector
const AquiferCT aquiferct = AquiferCT(eclState,deck);
const Aquancon aquifer_connect = Aquancon(eclState.getInputGrid(), deck);
std::vector<AquiferCT::AQUCT_data> aquifersData = aquiferct.getAquifers();
std::vector<Aquancon::AquanconOutput> aquifer_connection = aquifer_connect.getAquOutput();
assert( aquifersData.size() == aquifer_connection.size() );
// generate the mapping from Cartesian coordinates to the index in the actual grid
const auto& ugrid = simulator_.vanguard().grid();
const auto& gridView = simulator_.gridView();
const int number_of_cells = gridView.size(0);
cartesian_to_compressed_ = cartesianToCompressed(number_of_cells,
Opm::UgGridHelpers::globalCell(ugrid));
for (size_t i = 0; i < aquifersData.size(); ++i)
{
aquifers_.push_back(
AquiferCarterTracy<TypeTag> (aquifersData.at(i),
aquifer_connection.at(i), cartesian_to_compressed_, this->simulator_)
);
}
}
template<typename TypeTag>
bool
BlackoilAquiferModel<TypeTag>:: aquiferActive() const
{
return !aquifers_.empty();
}
} // namespace Opm