mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Changes to make ms wells work with cprw
This commit is contained in:
committed by
Atgeirr Flø Rasmussen
parent
141a816e5d
commit
a8acd40f4a
@@ -747,6 +747,103 @@ namespace Opm
|
||||
}
|
||||
|
||||
|
||||
template<typename TypeTag>
|
||||
void
|
||||
MultisegmentWell<TypeTag>::
|
||||
addWellPressureEquations(PressureMatrix& jacobian,
|
||||
const BVector& weights,
|
||||
const int pressureVarIndex,
|
||||
const bool use_well_weights,
|
||||
const WellState& well_state) const
|
||||
{
|
||||
// We need to change matrix A as follows
|
||||
// A -= C^T D^-1 B
|
||||
// D is a (nseg x nseg) block matrix with (4 x 4) blocks.
|
||||
// B and C are (nseg x ncells) block matrices with (4 x 4 blocks).
|
||||
// They have nonzeros at (i, j) only if this well has a
|
||||
// perforation at cell j connected to segment i. The code
|
||||
// assumes that no cell is connected to more than one segment,
|
||||
// i.e. the columns of B/C have no more than one nonzero.
|
||||
const auto seg_pressure_var_ind = this->SPres;
|
||||
const int welldof_ind = this->duneC_.M() + this->index_of_well_;
|
||||
for (size_t rowC = 0; rowC < this->duneC_.N(); ++rowC) {
|
||||
for (auto colC = this->duneC_[rowC].begin(), endC = this->duneC_[rowC].end(); colC != endC; ++colC) {
|
||||
const auto row_index = colC.index();
|
||||
const auto& bw = weights[row_index];
|
||||
double matel = 0.0;
|
||||
//if(this->isPressureControlled(well_state)){
|
||||
// jacobian[row_index][welldof_ind] = 0.0;
|
||||
if(not(this->isPressureControlled(well_state))){
|
||||
for(int i = 0; i< bw.size(); ++i){
|
||||
matel += bw[i]*(*colC)[seg_pressure_var_ind][i];
|
||||
}
|
||||
jacobian[row_index][welldof_ind] += matel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//BVector segment_weights(this->duneB_.N());
|
||||
auto well_weight = weights[0]*0.0;
|
||||
int num_perfs = 0;
|
||||
//segment_weights = 0.0;
|
||||
for (size_t rowB = 0; rowB < this->duneB_.N(); ++rowB) {
|
||||
//segment_weights[rowB] = 0.0;
|
||||
//int num_perfs = 0;
|
||||
for (auto colB = this->duneB_[rowB].begin(), endB = this->duneB_[rowB].end(); colB != endB; ++colB) {
|
||||
const auto col_index = colB.index();
|
||||
const auto& bw = weights[col_index];
|
||||
//segment_weights[rowB] += bw;
|
||||
well_weight += bw;
|
||||
num_perfs += 1;
|
||||
}
|
||||
//segment_weights[rowB] /= num_perfs;
|
||||
}
|
||||
well_weight /= num_perfs;
|
||||
assert(num_perfs>0);
|
||||
|
||||
|
||||
for (size_t rowB = 0; rowB < this->duneB_.N(); ++rowB) {
|
||||
//const auto& bw = segment_weights[rowB];
|
||||
const auto& bw = well_weight;
|
||||
for (auto colB = this->duneB_[rowB].begin(), endB = this->duneB_[rowB].end(); colB != endB; ++colB) {
|
||||
const auto col_index = colB.index();
|
||||
double matel = 0.0;
|
||||
//if(this->isPressureControlled(well_state)){
|
||||
// jacobian[welldof_ind][col_index] = 0.0;
|
||||
if(not(this->isPressureControlled(well_state))){
|
||||
for(int i = 0; i< bw.size(); ++i){
|
||||
matel += bw[i] *(*colB)[i][pressureVarIndex];
|
||||
}
|
||||
jacobian[welldof_ind][col_index] += matel;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(this->isPressureControlled(well_state)){
|
||||
jacobian[welldof_ind][welldof_ind] = 1.0;
|
||||
}else{
|
||||
for (size_t rowD = 0; rowD < this->duneD_.N(); ++rowD) {
|
||||
//const auto& bw = segment_weights[rowD];
|
||||
const auto& bw = well_weight;
|
||||
//const auto row_index = rowD.index();
|
||||
for (auto colD = this->duneD_[rowD].begin(), endD = this->duneD_[rowD].end(); colD != endD; ++colD) {
|
||||
const auto col_index = colD.index();
|
||||
if(rowD == col_index){//need?
|
||||
double matel = 0.0;
|
||||
for(int i = 0; i< bw.size(); ++i){
|
||||
matel += bw[i]*(*colD)[i][seg_pressure_var_ind];
|
||||
}
|
||||
jacobian[welldof_ind][welldof_ind] += matel;
|
||||
}
|
||||
}
|
||||
}
|
||||
assert(jacobian[welldof_ind][welldof_ind] != 0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
template<typename TypeTag>
|
||||
template<class Value>
|
||||
|
||||
Reference in New Issue
Block a user