Loading...
Searching...
No Matches
StandardWellEquations.hpp
/*
Copyright 2017 SINTEF Digital, Mathematics and Cybernetics.
Copyright 2017 Statoil ASA.
Copyright 2016 - 2017 IRIS AS.
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPM_STANDARDWELL_EQUATIONS_HEADER_INCLUDED
#define OPM_STANDARDWELL_EQUATIONS_HEADER_INCLUDED
#include <opm/simulators/utils/ParallelCommunication.hpp>
#include <opm/simulators/wells/WellHelpers.hpp>
#include <opm/common/TimingMacros.hpp>
#include <dune/common/dynmatrix.hh>
#include <dune/common/dynvector.hh>
#include <dune/istl/bcrsmatrix.hh>
#include <dune/istl/bvector.hh>
namespace Opm
{
template<class Scalar> class ParallelWellInfo;
template<class Scalar, typename IndexTraits, int numEq> class StandardWellEquationAccess;
#if COMPILE_GPU_BRIDGE
template<class Scalar> class WellContributions;
#endif
template<typename Scalar, typename IndexTraits> class WellInterfaceGeneric;
template<typename Scalar, typename IndexTraits> class WellState;
template<typename Scalar, typename IndexTraits, int numEq>
class StandardWellEquations
{
public:
// sparsity pattern for the matrices
//[A C^T [x = [ res
// B D ] x_well] res_well]
// the vector type for the res_well and x_well
using VectorBlockWellType = Dune::DynamicVector<Scalar>;
using BVectorWell = Dune::BlockVector<VectorBlockWellType>;
// the matrix type for the diagonal matrix D
using DiagMatrixBlockWellType = Dune::DynamicMatrix<Scalar>;
using DiagMatWell = Dune::BCRSMatrix<DiagMatrixBlockWellType>;
// the matrix type for the non-diagonal matrix B and C^T
using OffDiagMatrixBlockWellType = Dune::DynamicMatrix<Scalar>;
using OffDiagMatWell = Dune::BCRSMatrix<OffDiagMatrixBlockWellType>;
// block vector type
using BVector = Dune::BlockVector<Dune::FieldVector<Scalar,numEq>>;
explicit StandardWellEquations(const ParallelWellInfo<Scalar>& parallel_well_info);
void init(const int numWellEq,
const int numPerfs,
const std::vector<int>& cells);
void clear();
void apply(const BVector& x, BVector& Ax) const;
void apply(BVector& r) const;
void solve(BVectorWell& dx_well) const;
void solve(const BVectorWell& rhs_well, BVectorWell& x_well) const;
void invert();
void recoverSolutionWell(const BVector& x, BVectorWell& xw) const;
#if COMPILE_GPU_BRIDGE
void extract(const int numStaticWellEq,
WellContributions<Scalar>& wellContribs) const;
#endif
template<class SparseMatrixAdapter>
void extract(SparseMatrixAdapter& jacobian) const;
template<class PressureMatrix>
void extractCPRPressureMatrix(PressureMatrix& jacobian,
const BVector& weights,
const int pressureVarIndex,
const bool use_well_weights,
const WellInterfaceGeneric<Scalar, IndexTraits>& well,
const int bhp_var_index,
const WellState<Scalar, IndexTraits>& well_state) const;
unsigned int getNumBlocks() const;
void sumDistributed(Parallel::Communication comm);
const BVectorWell& residual() const
{
return resWell_;
}
private:
friend class StandardWellEquationAccess<Scalar, IndexTraits, numEq>;
// two off-diagonal matrices
OffDiagMatWell duneB_;
OffDiagMatWell duneC_;
// diagonal matrix for the well
DiagMatWell invDuneD_;
DiagMatWell duneD_;
// Wrapper for the parallel application of B for distributed wells
wellhelpers::ParallelStandardWellB<Scalar> parallelB_;
// residuals of the well equations
BVectorWell resWell_;
// several vector used in the matrix calculation
mutable BVectorWell Bx_;
mutable BVectorWell invDrw_;
// Store the global index of well perforated cells
std::vector<int> cells_;
};
}
#endif // OPM_STANDARDWELL_EQUATIONS_HEADER_INCLUDED
Opm::ParallelWellInfo
Class encapsulating some information about parallel wells.
Definition ParallelWellInfo.hpp:198
Opm::StandardWellEquationAccess
Class administering assembler access to equation system.
Definition StandardWellAssemble.cpp:44
Opm::StandardWellEquations::solve
void solve(BVectorWell &dx_well) const
Apply inverted D matrix to residual and store in vector.
Definition StandardWellEquations.cpp:175
Opm::StandardWellEquations::solve
void solve(const BVectorWell &rhs_well, BVectorWell &x_well) const
Apply inverted D matrix to rhs and store in vector.
Definition StandardWellEquations.cpp:181
Opm::StandardWellEquations::recoverSolutionWell
void recoverSolutionWell(const BVector &x, BVectorWell &xw) const
Recover well solution.
Definition StandardWellEquations.cpp:188
Opm::StandardWellEquations::residual
const BVectorWell & residual() const
Returns a const reference to the residual.
Definition StandardWellEquations.hpp:127
Opm::StandardWellEquations::extract
void extract(SparseMatrixAdapter &jacobian) const
Add the matrices of this well to the sparse matrix adapter.
Definition StandardWellEquations.cpp:256
Opm::StandardWellEquations::getNumBlocks
unsigned int getNumBlocks() const
Get the number of blocks of the C and B matrices.
Definition StandardWellEquations.cpp:285
Opm::StandardWellEquations::apply
void apply(BVector &r) const
Apply linear operator to vector.
Definition StandardWellEquations.cpp:149
Opm::StandardWellEquations::sumDistributed
void sumDistributed(Parallel::Communication comm)
Sum with off-process contribution.
Definition StandardWellEquations.cpp:421
Opm::StandardWellEquations::apply
void apply(const BVector &x, BVector &Ax) const
Apply linear operator to vector.
Definition StandardWellEquations.cpp:130
Opm::StandardWellEquations::extractCPRPressureMatrix
void extractCPRPressureMatrix(PressureMatrix &jacobian, const BVector &weights, const int pressureVarIndex, const bool use_well_weights, const WellInterfaceGeneric< Scalar, IndexTraits > &well, const int bhp_var_index, const WellState< Scalar, IndexTraits > &well_state) const
Extract CPR pressure matrix.
Definition StandardWellEquations.cpp:293
Opm::StandardWellEquations::clear
void clear()
Set all coefficients to 0.
Definition StandardWellEquations.cpp:121
Opm::StandardWellEquations::init
void init(const int numWellEq, const int numPerfs, const std::vector< int > &cells)
Setup sparsity pattern for the matrices.
Definition StandardWellEquations.cpp:57
Opm::StandardWellEquations::invert
void invert()
Invert D matrix.
Definition StandardWellEquations.cpp:160
Opm::WellContributions
This class serves to eliminate the need to include the WellContributions into the matrix (with –matri...
Definition WellContributions.hpp:51
Opm::WellInterfaceGeneric
Definition WellInterfaceGeneric.hpp:53
Opm::WellState
The state of a set of wells, tailored for use by the fully implicit blackoil simulator.
Definition WellState.hpp:66
Opm::wellhelpers::ParallelStandardWellB
A wrapper around the B matrix for distributed wells.
Definition WellHelpers.hpp:53
Opm
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilbioeffectsmodules.hh:43