23 #ifndef OPM_STANDARDWELL_EQUATIONS_HEADER_INCLUDED 24 #define OPM_STANDARDWELL_EQUATIONS_HEADER_INCLUDED 26 #include <opm/simulators/utils/ParallelCommunication.hpp> 27 #include <opm/simulators/wells/WellHelpers.hpp> 28 #include <opm/common/TimingMacros.hpp> 29 #include <dune/common/dynmatrix.hh> 30 #include <dune/common/dynvector.hh> 31 #include <dune/istl/bcrsmatrix.hh> 32 #include <dune/istl/bvector.hh> 37 template<
class Scalar>
class ParallelWellInfo;
38 template<
class Scalar,
typename IndexTraits,
int numEq>
class StandardWellEquationAccess;
39 #if COMPILE_GPU_BRIDGE 40 template<
class Scalar>
class WellContributions;
42 template<
typename Scalar,
typename IndexTraits>
class WellInterfaceGeneric;
43 template<
typename Scalar,
typename IndexTraits>
class WellState;
45 template<
typename Scalar,
typename IndexTraits,
int numEq>
46 class StandardWellEquations
54 using VectorBlockWellType = Dune::DynamicVector<Scalar>;
55 using BVectorWell = Dune::BlockVector<VectorBlockWellType>;
58 using DiagMatrixBlockWellType = Dune::DynamicMatrix<Scalar>;
59 using DiagMatWell = Dune::BCRSMatrix<DiagMatrixBlockWellType>;
62 using OffDiagMatrixBlockWellType = Dune::DynamicMatrix<Scalar>;
63 using OffDiagMatWell = Dune::BCRSMatrix<OffDiagMatrixBlockWellType>;
66 using BVector = Dune::BlockVector<Dune::FieldVector<Scalar,numEq>>;
68 explicit StandardWellEquations(
const ParallelWellInfo<Scalar>& parallel_well_info);
74 void init(
const int numWellEq,
76 const std::vector<int>& cells);
82 void apply(
const BVector& x, BVector& Ax)
const;
85 void apply(BVector& r)
const;
88 void solve(BVectorWell& dx_well)
const;
91 void solve(
const BVectorWell& rhs_well, BVectorWell& x_well)
const;
100 #if COMPILE_GPU_BRIDGE 101 void extract(
const int numStaticWellEq,
103 WellContributions<Scalar>& wellContribs)
const;
107 template<
class SparseMatrixAdapter>
108 void extract(SparseMatrixAdapter& jacobian)
const;
111 template<
class PressureMatrix>
113 const BVector& weights,
114 const int pressureVarIndex,
115 const bool use_well_weights,
116 const WellInterfaceGeneric<Scalar, IndexTraits>& well,
117 const int bhp_var_index,
118 const WellState<Scalar, IndexTraits>& well_state)
const;
132 const OffDiagMatWell& getB()
const {
return duneB_; }
133 const OffDiagMatWell& getC()
const {
return duneC_; }
134 const DiagMatWell& getD()
const {
return duneD_; }
135 const std::vector<int>& cells()
const {
return cells_; }
138 friend class StandardWellEquationAccess<Scalar, IndexTraits, numEq>;
141 OffDiagMatWell duneB_;
142 OffDiagMatWell duneC_;
144 DiagMatWell invDuneD_;
148 wellhelpers::ParallelStandardWellB<Scalar> parallelB_;
151 BVectorWell resWell_;
154 mutable BVectorWell Bx_;
155 mutable BVectorWell invDrw_;
158 std::vector<int> cells_;
163 #endif // OPM_STANDARDWELL_EQUATIONS_HEADER_INCLUDED void invert()
Invert D matrix.
Definition: StandardWellEquations.cpp:162
void extract(SparseMatrixAdapter &jacobian) const
Add the matrices of this well to the sparse matrix adapter.
Definition: StandardWellEquations.cpp:250
Structs needed for tpfalinearizer and its gpuparams struct extracted to be defined in one place that ...
Definition: blackoilbioeffectsmodules.hh:45
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:286
const BVectorWell & residual() const
Returns a const reference to the residual.
Definition: StandardWellEquations.hpp:127
unsigned int getNumBlocks() const
Get the number of blocks of the C and B matrices.
Definition: StandardWellEquations.cpp:278
void apply(const BVector &x, BVector &Ax) const
Apply linear operator to vector.
Definition: StandardWellEquations.cpp:132
void recoverSolutionWell(const BVector &x, BVectorWell &xw) const
Recover well solution.
Definition: StandardWellEquations.cpp:182
void clear()
Set all coefficients to 0.
Definition: StandardWellEquations.cpp:123
void sumDistributed(Parallel::Communication comm)
Sum with off-process contribution.
Definition: StandardWellEquations.cpp:414
void solve(BVectorWell &dx_well) const
Apply inverted D matrix to residual and store in vector.
Definition: StandardWellEquations.cpp:169
void init(const int numWellEq, const int numPerfs, const std::vector< int > &cells)
Setup sparsity pattern for the matrices.
Definition: StandardWellEquations.cpp:55