20#ifndef OPM_EXTRACT_MATRIX_HEADER_INCLUDED
21#define OPM_EXTRACT_MATRIX_HEADER_INCLUDED
34 template <
class Matrix>
35 void copySubMatrix(
const Matrix&
A,
const std::vector<int>& indices, Matrix& B)
38 for (
auto row = B.begin();
row != B.end(); ++
row) {
40 *
col =
A[indices[
row.index()]][indices[
col.index()]];
46 template <
class Matrix>
47 Matrix extractMatrix(
const Matrix&
m,
const std::vector<int>& indices)
49 assert(std::is_sorted(indices.begin(), indices.end()));
52 const std::size_t
n = indices.size();
81 Matrix
res(
n,
n, nnz, Matrix::row_wise);
85 while (
static_cast<int>(
from_row.index()) < indices[
row.index()]) {
98 copySubMatrix(
m, indices,
res);
103 template <
class Vector>
104 Vector extractVector(
const Vector& x,
const std::vector<int>& indices)
106 Vector
res(indices.size());
107 for (std::size_t
ii = 0;
ii < indices.size(); ++
ii) {
114 template <
class Vector>
115 void setGlobal(
const Vector& x,
const std::vector<int>& indices, Vector&
global_x)
117 for (std::size_t
ii = 0;
ii < indices.size(); ++
ii) {
124 template <
class Matrix>
125 bool matrixEqual(
const Matrix&
m1,
const Matrix&
m2)
128 if (
m1.N() !=
m2.N())
return false;
129 if (
m1.M() !=
m2.M())
return false;
130 if (
m1.nonzeroes() !=
m2.nonzeroes())
return false;
135 if (
row2 ==
m2.end())
return false;
136 if (
row1.index() !=
row2.index())
return false;
140 if (
col2 ==
row2->end())
return false;
141 if (
col1.index() !=
col2.index())
return false;
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilboundaryratevector.hh:37
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:242