mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
add: MultisegmentWellEquations
this is a container for the multisegment well equation system
This commit is contained in:
@@ -203,15 +203,16 @@ namespace Opm
|
||||
// Contributions are already in the matrix itself
|
||||
return;
|
||||
}
|
||||
BVectorWell Bx(this->duneB_.N());
|
||||
BVectorWell Bx(this->linSys_.duneB_.N());
|
||||
|
||||
this->duneB_.mv(x, Bx);
|
||||
this->linSys_.duneB_.mv(x, Bx);
|
||||
|
||||
// invDBx = duneD^-1 * Bx_
|
||||
const BVectorWell invDBx = mswellhelpers::applyUMFPack(this->duneD_, this->duneDSolver_, Bx);
|
||||
const BVectorWell invDBx = mswellhelpers::applyUMFPack(this->linSys_.duneD_,
|
||||
this->linSys_.duneDSolver_, Bx);
|
||||
|
||||
// Ax = Ax - duneC_^T * invDBx
|
||||
this->duneC_.mmtv(invDBx,Ax);
|
||||
this->linSys_.duneC_.mmtv(invDBx,Ax);
|
||||
}
|
||||
|
||||
|
||||
@@ -226,9 +227,11 @@ namespace Opm
|
||||
if (!this->isOperableAndSolvable() && !this->wellIsStopped()) return;
|
||||
|
||||
// invDrw_ = duneD^-1 * resWell_
|
||||
const BVectorWell invDrw = mswellhelpers::applyUMFPack(this->duneD_, this->duneDSolver_, this->resWell_);
|
||||
const BVectorWell invDrw = mswellhelpers::applyUMFPack(this->linSys_.duneD_,
|
||||
this->linSys_.duneDSolver_,
|
||||
this->linSys_.resWell_);
|
||||
// r = r - duneC_^T * invDrw
|
||||
this->duneC_.mmtv(invDrw, r);
|
||||
this->linSys_.duneC_.mmtv(invDrw, r);
|
||||
}
|
||||
|
||||
|
||||
@@ -526,7 +529,9 @@ namespace Opm
|
||||
|
||||
// We assemble the well equations, then we check the convergence,
|
||||
// which is why we do not put the assembleWellEq here.
|
||||
const BVectorWell dx_well = mswellhelpers::applyUMFPack(this->duneD_, this->duneDSolver_, this->resWell_);
|
||||
const BVectorWell dx_well = mswellhelpers::applyUMFPack(this->linSys_.duneD_,
|
||||
this->linSys_.duneDSolver_,
|
||||
this->linSys_.resWell_);
|
||||
|
||||
updateWellState(dx_well, well_state, deferred_logger);
|
||||
}
|
||||
@@ -727,7 +732,7 @@ namespace Opm
|
||||
MultisegmentWell<TypeTag>::
|
||||
addWellContributions(SparseMatrixAdapter& jacobian) const
|
||||
{
|
||||
const auto invDuneD = mswellhelpers::invertWithUMFPack<BVectorWell>(this->duneD_, this->duneDSolver_);
|
||||
const auto invDuneD = mswellhelpers::invertWithUMFPack<BVectorWell>(this->linSys_.duneD_, this->linSys_.duneDSolver_);
|
||||
|
||||
// We need to change matrix A as follows
|
||||
// A -= C^T D^-1 B
|
||||
@@ -737,13 +742,15 @@ namespace Opm
|
||||
// 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.
|
||||
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) {
|
||||
for (size_t rowC = 0; rowC < this->linSys_.duneC_.N(); ++rowC) {
|
||||
for (auto colC = this->linSys_.duneC_[rowC].begin(),
|
||||
endC = this->linSys_.duneC_[rowC].end(); colC != endC; ++colC) {
|
||||
const auto row_index = colC.index();
|
||||
for (size_t rowB = 0; rowB < this->duneB_.N(); ++rowB) {
|
||||
for (auto colB = this->duneB_[rowB].begin(), endB = this->duneB_[rowB].end(); colB != endB; ++colB) {
|
||||
for (size_t rowB = 0; rowB < this->linSys_.duneB_.N(); ++rowB) {
|
||||
for (auto colB = this->linSys_.duneB_[rowB].begin(),
|
||||
endB = this->linSys_.duneB_[rowB].end(); colB != endB; ++colB) {
|
||||
const auto col_index = colB.index();
|
||||
OffDiagMatrixBlockWellType tmp1;
|
||||
typename Equations::OffDiagMatrixBlockWellType tmp1;
|
||||
detail::multMatrixImpl(invDuneD[rowC][rowB], (*colB), tmp1, std::true_type());
|
||||
typename SparseMatrixAdapter::MatrixBlock tmp2;
|
||||
detail::multMatrixTransposedImpl((*colC), tmp1, tmp2, std::false_type());
|
||||
@@ -768,10 +775,11 @@ namespace Opm
|
||||
|
||||
// Add for coupling from well to reservoir
|
||||
const auto seg_pressure_var_ind = this->SPres;
|
||||
const int welldof_ind = this->duneC_.M() + this->index_of_well_;
|
||||
const int welldof_ind = this->linSys_.duneC_.M() + this->index_of_well_;
|
||||
if(not(this->isPressureControlled(well_state))){
|
||||
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) {
|
||||
for (size_t rowC = 0; rowC < this->linSys_.duneC_.N(); ++rowC) {
|
||||
for (auto colC = this->linSys_.duneC_[rowC].begin(),
|
||||
endC = this->linSys_.duneC_[rowC].end(); colC != endC; ++colC) {
|
||||
const auto row_index = colC.index();
|
||||
const auto& bw = weights[row_index];
|
||||
double matel = 0.0;
|
||||
@@ -789,8 +797,9 @@ namespace Opm
|
||||
auto well_weight = weights[0];
|
||||
well_weight = 0.0;
|
||||
int num_perfs = 0;
|
||||
for (size_t rowB = 0; rowB < this->duneB_.N(); ++rowB) {
|
||||
for (auto colB = this->duneB_[rowB].begin(), endB = this->duneB_[rowB].end(); colB != endB; ++colB) {
|
||||
for (size_t rowB = 0; rowB < this->linSys_.duneB_.N(); ++rowB) {
|
||||
for (auto colB = this->linSys_.duneB_[rowB].begin(),
|
||||
endB = this->linSys_.duneB_[rowB].end(); colB != endB; ++colB) {
|
||||
const auto col_index = colB.index();
|
||||
const auto& bw = weights[col_index];
|
||||
well_weight += bw;
|
||||
@@ -803,9 +812,10 @@ namespace Opm
|
||||
|
||||
// Add for coupling from reservoir to well and caclulate diag elelement corresping to incompressible standard well
|
||||
double diag_ell = 0.0;
|
||||
for (size_t rowB = 0; rowB < this->duneB_.N(); ++rowB) {
|
||||
for (size_t rowB = 0; rowB < this->linSys_.duneB_.N(); ++rowB) {
|
||||
const auto& bw = well_weight;
|
||||
for (auto colB = this->duneB_[rowB].begin(), endB = this->duneB_[rowB].end(); colB != endB; ++colB) {
|
||||
for (auto colB = this->linSys_.duneB_[rowB].begin(),
|
||||
endB = this->linSys_.duneB_[rowB].end(); colB != endB; ++colB) {
|
||||
const auto col_index = colB.index();
|
||||
double matel = 0.0;
|
||||
for(size_t i = 0; i< bw.size(); ++i){
|
||||
@@ -1494,7 +1504,9 @@ namespace Opm
|
||||
|
||||
assembleWellEqWithoutIteration(ebosSimulator, dt, inj_controls, prod_controls, well_state, group_state, deferred_logger);
|
||||
|
||||
const BVectorWell dx_well = mswellhelpers::applyUMFPack(this->duneD_, this->duneDSolver_, this->resWell_);
|
||||
const BVectorWell dx_well = mswellhelpers::applyUMFPack(this->linSys_.duneD_,
|
||||
this->linSys_.duneDSolver_,
|
||||
this->linSys_.resWell_);
|
||||
|
||||
if (it > this->param_.strict_inner_iter_wells_) {
|
||||
relax_convergence = true;
|
||||
@@ -1622,13 +1634,13 @@ namespace Opm
|
||||
computeSegmentFluidProperties(ebosSimulator, deferred_logger);
|
||||
|
||||
// clear all entries
|
||||
this->duneB_ = 0.0;
|
||||
this->duneC_ = 0.0;
|
||||
this->linSys_.duneB_ = 0.0;
|
||||
this->linSys_.duneC_ = 0.0;
|
||||
|
||||
this->duneD_ = 0.0;
|
||||
this->resWell_ = 0.0;
|
||||
this->linSys_.duneD_ = 0.0;
|
||||
this->linSys_.resWell_ = 0.0;
|
||||
|
||||
this->duneDSolver_.reset();
|
||||
this->linSys_.duneDSolver_.reset();
|
||||
|
||||
auto& ws = well_state.well(this->index_of_well_);
|
||||
ws.dissolved_gas_rate = 0;
|
||||
@@ -1659,9 +1671,9 @@ namespace Opm
|
||||
const EvalWell accumulation_term = regularization_factor * (segment_surface_volume * this->surfaceVolumeFraction(seg, comp_idx)
|
||||
- segment_fluid_initial_[seg][comp_idx]) / dt;
|
||||
|
||||
this->resWell_[seg][comp_idx] += accumulation_term.value();
|
||||
this->linSys_.resWell_[seg][comp_idx] += accumulation_term.value();
|
||||
for (int pv_idx = 0; pv_idx < numWellEq; ++pv_idx) {
|
||||
this->duneD_[seg][seg][comp_idx][pv_idx] += accumulation_term.derivative(pv_idx + Indices::numEq);
|
||||
this->linSys_.duneD_[seg][seg][comp_idx][pv_idx] += accumulation_term.derivative(pv_idx + Indices::numEq);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1673,13 +1685,13 @@ namespace Opm
|
||||
const int seg_upwind = this->upwinding_segments_[seg];
|
||||
// segment_rate contains the derivatives with respect to WQTotal in seg,
|
||||
// and WFrac and GFrac in seg_upwind
|
||||
this->resWell_[seg][comp_idx] -= segment_rate.value();
|
||||
this->duneD_[seg][seg][comp_idx][WQTotal] -= segment_rate.derivative(WQTotal + Indices::numEq);
|
||||
this->linSys_.resWell_[seg][comp_idx] -= segment_rate.value();
|
||||
this->linSys_.duneD_[seg][seg][comp_idx][WQTotal] -= segment_rate.derivative(WQTotal + Indices::numEq);
|
||||
if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) {
|
||||
this->duneD_[seg][seg_upwind][comp_idx][WFrac] -= segment_rate.derivative(WFrac + Indices::numEq);
|
||||
this->linSys_.duneD_[seg][seg_upwind][comp_idx][WFrac] -= segment_rate.derivative(WFrac + Indices::numEq);
|
||||
}
|
||||
if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) {
|
||||
this->duneD_[seg][seg_upwind][comp_idx][GFrac] -= segment_rate.derivative(GFrac + Indices::numEq);
|
||||
this->linSys_.duneD_[seg][seg_upwind][comp_idx][GFrac] -= segment_rate.derivative(GFrac + Indices::numEq);
|
||||
}
|
||||
// pressure derivative should be zero
|
||||
}
|
||||
@@ -1694,13 +1706,13 @@ namespace Opm
|
||||
const int inlet_upwind = this->upwinding_segments_[inlet];
|
||||
// inlet_rate contains the derivatives with respect to WQTotal in inlet,
|
||||
// and WFrac and GFrac in inlet_upwind
|
||||
this->resWell_[seg][comp_idx] += inlet_rate.value();
|
||||
this->duneD_[seg][inlet][comp_idx][WQTotal] += inlet_rate.derivative(WQTotal + Indices::numEq);
|
||||
this->linSys_.resWell_[seg][comp_idx] += inlet_rate.value();
|
||||
this->linSys_.duneD_[seg][inlet][comp_idx][WQTotal] += inlet_rate.derivative(WQTotal + Indices::numEq);
|
||||
if (FluidSystem::phaseIsActive(FluidSystem::waterPhaseIdx)) {
|
||||
this->duneD_[seg][inlet_upwind][comp_idx][WFrac] += inlet_rate.derivative(WFrac + Indices::numEq);
|
||||
this->linSys_.duneD_[seg][inlet_upwind][comp_idx][WFrac] += inlet_rate.derivative(WFrac + Indices::numEq);
|
||||
}
|
||||
if (FluidSystem::phaseIsActive(FluidSystem::gasPhaseIdx)) {
|
||||
this->duneD_[seg][inlet_upwind][comp_idx][GFrac] += inlet_rate.derivative(GFrac + Indices::numEq);
|
||||
this->linSys_.duneD_[seg][inlet_upwind][comp_idx][GFrac] += inlet_rate.derivative(GFrac + Indices::numEq);
|
||||
}
|
||||
// pressure derivative should be zero
|
||||
}
|
||||
@@ -1744,21 +1756,21 @@ namespace Opm
|
||||
this->connectionRates_[perf][comp_idx] = Base::restrictEval(cq_s_effective);
|
||||
|
||||
// subtract sum of phase fluxes in the well equations.
|
||||
this->resWell_[seg][comp_idx] += cq_s_effective.value();
|
||||
this->linSys_.resWell_[seg][comp_idx] += cq_s_effective.value();
|
||||
|
||||
// assemble the jacobians
|
||||
for (int pv_idx = 0; pv_idx < numWellEq; ++pv_idx) {
|
||||
|
||||
// also need to consider the efficiency factor when manipulating the jacobians.
|
||||
this->duneC_[seg][cell_idx][pv_idx][comp_idx] -= cq_s_effective.derivative(pv_idx + Indices::numEq); // intput in transformed matrix
|
||||
this->linSys_.duneC_[seg][cell_idx][pv_idx][comp_idx] -= cq_s_effective.derivative(pv_idx + Indices::numEq); // intput in transformed matrix
|
||||
|
||||
// the index name for the D should be eq_idx / pv_idx
|
||||
this->duneD_[seg][seg][comp_idx][pv_idx] += cq_s_effective.derivative(pv_idx + Indices::numEq);
|
||||
this->linSys_.duneD_[seg][seg][comp_idx][pv_idx] += cq_s_effective.derivative(pv_idx + Indices::numEq);
|
||||
}
|
||||
|
||||
for (int pv_idx = 0; pv_idx < Indices::numEq; ++pv_idx) {
|
||||
// also need to consider the efficiency factor when manipulating the jacobians.
|
||||
this->duneB_[seg][cell_idx][comp_idx][pv_idx] += cq_s_effective.derivative(pv_idx);
|
||||
this->linSys_.duneB_[seg][cell_idx][comp_idx][pv_idx] += cq_s_effective.derivative(pv_idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user