Operators.hpp
Go to the documentation of this file.
1#ifndef OPM_MIXED_OPERATORS_HEADER_INCLUDED
2#define OPM_MIXED_OPERATORS_HEADER_INCLUDED
3
4
5namespace Opm
6{
7
16template<class M, class V, class C>
17class MixedGhostLastMatrixAdapter : public Dune::AssembledLinearOperator<M,V,V>
18{
19public:
21 MixedGhostLastMatrixAdapter (const M& A, const C& comm) : A_( A ), comm_(comm) {}
22
23 // y = A * x
24 void apply( const V& x, V& y ) const override
25 {
26 A_.mv(x,y);
27 ghostLast_project(y);
28 }
29
30 // y += \alpha * A * x
31 void applyscaleadd (double alpha, const V& x, V& y) const override
32 {
33 A_.usmv(alpha,x,y);
34 ghostLast_project(y);
35 }
36
37 // accessor to matix object
38 const M& getmat() const override { return A_; }
39
40 // solver category
41 Dune::SolverCategory::Category category() const override
42 {
43 return Dune::SolverCategory::overlapping;
44 }
45
46private:
47 // extract block size
48 static constexpr auto block_size = V::block_type::dimension;
49
50 void ghostLast_project( V& y ) const
51 {
52 double *yy = &y[0][0];
53 int n = block_size*A_.nrows();
54 int N = block_size*y.N();
55 for (int i=n;i<N;i++) yy[i] = 0;
56 }
57
58 const M& A_;
59 const C& comm_;
60};
61
62
72template<class M, class V, class C>
73class WellModelMixedGhostLastMatrixAdapter : public Dune::AssembledLinearOperator<M,V,V>
74{
75public:
76 using field_type = typename V::field_type;
77 using PressureMatrix = Dune::BCRSMatrix<MatrixBlock<field_type, 1, 1>>;
78
79 // extract block size
80 static constexpr auto block_size = V::block_type::dimension;
81
84 const LinearOperatorExtra<V, V>& wellOper,
85 const C& comm
86 )
87 : A_( A ), wellOper_( wellOper ), comm_ ( comm )
88 {}
89
90 // y = A * x
91 void apply( const V& x, V& y ) const override
92 {
93 A_.mv(x,y);
94 wellOper_.apply(x, y);
95 //comm_.project(y);
96 ghostLast_project(y);
97 }
98
99 // y += \alpha * A * x
100 void applyscaleadd (double alpha, const V& x, V& y) const override
101 {
102 A_.usmv(alpha,x,y);
103 wellOper_.applyscaleadd(alpha, x, y);
104 //comm_.project(y);
105 ghostLast_project(y);
106 }
107
108 // accessor to matix object
109 const M& getmat() const override { return A_; }
110
112 const V& weights,
113 const bool use_well_weights) const
114 {
115 OPM_TIMEBLOCK(addWellPressureEquations);
116 wellOper_.addWellPressureEquations(jacobian, weights, use_well_weights);
117 }
118
120 {
121 OPM_TIMEBLOCK(addWellPressureEquationsStruct);
123 }
124
126 {
128 }
129
130 // solver category
131 Dune::SolverCategory::Category category() const override
132 {
133 return Dune::SolverCategory::overlapping;
134 }
135
136
137protected:
138
139 const M& A_ ;
141 const C& comm_ ;
142
143private:
144
145 void ghostLast_project( V& y ) const
146 {
147 double *yy = &y[0][0];
148 int n = block_size*A_.nrows();
149 int N = block_size*y.N();
150 for (int i=n;i<N;i++) yy[i] = 0;
151 }
152
153};
154
155} // namespace Opm
156#endif // OPM_MIXED_OPERATORS_HEADER_INCLUDED
virtual void addWellPressureEquationsStruct(PressureMatrix &jacobian) const =0
virtual void addWellPressureEquations(PressureMatrix &jacobian, const X &weights, const bool use_well_weights) const =0
virtual int getNumberOfExtraEquations() const =0
Adapter to take advantage of the fact that all matrix rows associated with ghost cells are located at...
Definition: Operators.hpp:18
Dune::SolverCategory::Category category() const override
Definition: Operators.hpp:41
const M & getmat() const override
Definition: Operators.hpp:38
void apply(const V &x, V &y) const override
Definition: Operators.hpp:24
MixedGhostLastMatrixAdapter(const M &A, const C &comm)
constructor: just store a reference to matrix and communicator
Definition: Operators.hpp:21
void applyscaleadd(double alpha, const V &x, V &y) const override
Definition: Operators.hpp:31
Adapter to combine a matrix with another linear operator while taking advantage of the fact that all ...
Definition: Operators.hpp:74
int getNumberOfExtraEquations() const
Definition: Operators.hpp:125
const LinearOperatorExtra< V, V > & wellOper_
Definition: Operators.hpp:140
static constexpr auto block_size
Definition: Operators.hpp:80
void addWellPressureEquations(PressureMatrix &jacobian, const V &weights, const bool use_well_weights) const
Definition: Operators.hpp:111
void addWellPressureEquationsStruct(PressureMatrix &jacobian) const
Definition: Operators.hpp:119
Dune::SolverCategory::Category category() const override
Definition: Operators.hpp:131
const M & A_
Definition: Operators.hpp:139
const C & comm_
Definition: Operators.hpp:141
void applyscaleadd(double alpha, const V &x, V &y) const override
Definition: Operators.hpp:100
void apply(const V &x, V &y) const override
Definition: Operators.hpp:91
WellModelMixedGhostLastMatrixAdapter(const M &A, const LinearOperatorExtra< V, V > &wellOper, const C &comm)
constructor: just store a reference to a matrix
Definition: Operators.hpp:83
typename V::field_type field_type
Definition: Operators.hpp:76
Dune::BCRSMatrix< MatrixBlock< field_type, 1, 1 > > PressureMatrix
Definition: Operators.hpp:77
const M & getmat() const override
Definition: Operators.hpp:109
Definition: blackoilbioeffectsmodules.hh:45