Merge pull request #5006 from akva2/janitoring

Some janitoring
This commit is contained in:
Arne Morten Kvarving 2023-11-20 14:29:45 +01:00 committed by GitHub
commit 4ccc5cddc7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 252 additions and 214 deletions

View File

@ -19,38 +19,34 @@
#ifndef OPM_GRAPHCOLORING_HEADER_INCLUDED
#define OPM_GRAPHCOLORING_HEADER_INCLUDED
#include <vector>
#include <deque>
#include <tuple>
#include <algorithm>
#include <cstddef>
#include <deque>
#include <limits>
#include <numeric>
#include <queue>
#include <cstddef>
#include <limits>
#include <string>
#include <tuple>
#include <vector>
namespace Opm
{
namespace Detail
{
template<class Graph>
namespace Opm {
namespace Detail {
template <class Graph>
std::size_t colorGraphWelshPowell(const Graph& graph,
std::deque<typename Graph::VertexDescriptor>& orderedVertices,
std::vector<int>& colors,
int color, int noVertices)
int color,
int noVertices)
{
std::vector<int> forbidden(noVertices, false);
std::size_t noColored = 0;
for(auto vertex = orderedVertices.begin(),
vertexEnd = orderedVertices.end();
vertex != vertexEnd; ++vertex)
{
for (auto vertex = orderedVertices.begin(),
vertexEnd = orderedVertices.end(); vertex != vertexEnd; ++vertex) {
// Skip forbidden vertices
while(vertex != vertexEnd && forbidden[*vertex])
while (vertex != vertexEnd && forbidden[*vertex])
++vertex;
if ( vertex == vertexEnd )
{
if (vertex == vertexEnd) {
break;
}
@ -58,24 +54,23 @@ std::size_t colorGraphWelshPowell(const Graph& graph,
colors[*vertex] = color;
++noColored;
// Forbid neighors
for(auto edge = graph.beginEdges(*vertex), endEdge = graph.endEdges(*vertex);
edge != endEdge; ++edge)
{
for (auto edge = graph.beginEdges(*vertex),
endEdge = graph.endEdges(*vertex); edge != endEdge; ++edge) {
forbidden[edge.target()] = true;
}
}
// forbidden vertices will be colored next for coloring
using Vertex = typename Graph::VertexDescriptor;
auto newEnd = std::remove_if(orderedVertices.begin(), orderedVertices.end(),
[&forbidden](const Vertex& vertex)
{
return !forbidden[vertex];
});
orderedVertices.resize(newEnd-orderedVertices.begin());
auto newEnd = std::remove_if(orderedVertices.begin(),
orderedVertices.end(),
[&forbidden](const Vertex& vertex) { return !forbidden[vertex]; });
orderedVertices.resize(newEnd - orderedVertices.begin());
return noColored;
}
template<class Graph, class Functor>
std::size_t breadthFirstSearch(const Graph& graph, typename Graph::VertexDescriptor root,
template <class Graph, class Functor>
std::size_t breadthFirstSearch(const Graph& graph,
typename Graph::VertexDescriptor root,
Functor functor)
{
std::vector<int> visited(graph.maxVertex() + 1, false);
@ -85,15 +80,11 @@ std::size_t breadthFirstSearch(const Graph& graph, typename Graph::VertexDescrip
nextVertices.push(root);
visited[root] = true; // We do not visit root.
while( !nextVertices.empty() )
{
while (!nextVertices.empty()) {
auto current = nextVertices.front();
for(auto edge = graph.beginEdges(current),
endEdge = graph.endEdges(current);
edge != endEdge; ++edge)
{
if ( ! visited[edge.target()] )
{
for (auto edge = graph.beginEdges(current),
endEdge = graph.endEdges(current); edge != endEdge; ++edge) {
if (!visited[edge.target()]) {
visited[edge.target()] = true;
nextVertices.push(edge.target());
functor(edge.target());
@ -113,44 +104,36 @@ std::size_t breadthFirstSearch(const Graph& graph, typename Graph::VertexDescrip
/// \param graph The graph to color. Must adhere to the graph interface of dune-istl.
/// \return A pair of a vector with the colors of the vertices and the number of colors
/// assigned
template<class Graph>
std::tuple<std::vector<int>, int, std::vector<std::size_t> >
template <class Graph>
std::tuple<std::vector<int>, int, std::vector<std::size_t>>
colorVerticesWelshPowell(const Graph& graph)
{
using Vertex = typename Graph::VertexDescriptor;
std::deque<Vertex> orderedVertices;
auto noVertices = graph.maxVertex()+1;
auto noVertices = graph.maxVertex() + 1;
std::vector<int> degrees(noVertices, 0);
int maxDegree = 0;
std::ptrdiff_t firstDegreeChange = 0;
// populate deque
for( auto vertex = graph.begin(), endVertex = graph.end();
vertex != endVertex; ++vertex)
{
for (auto vertex = graph.begin(),
endVertex = graph.end(); vertex != endVertex; ++vertex) {
auto currentVertex = *vertex;
auto& degree = degrees[currentVertex];
for(auto edge = graph.beginEdges(currentVertex),
endEdge = graph.endEdges(currentVertex);
edge != endEdge; ++edge)
{
for (auto edge = graph.beginEdges(currentVertex),
endEdge = graph.endEdges(currentVertex); edge != endEdge; ++edge) {
++degree;
}
if( degree >= maxDegree )
{
if (degree >= maxDegree) {
orderedVertices.emplace_front(currentVertex);
++firstDegreeChange;
if(degree > maxDegree)
{
if (degree > maxDegree) {
firstDegreeChange = 1;
maxDegree = degree;
}
}
else
{
} else {
orderedVertices.emplace_back(currentVertex);
}
}
@ -159,9 +142,7 @@ colorVerticesWelshPowell(const Graph& graph)
std::stable_sort(orderedVertices.begin() + firstDegreeChange,
orderedVertices.end(),
[&degrees](const Vertex& v1, const Vertex& v2)
{
return degrees[v1] > degrees[v2];
});
{ return degrees[v1] > degrees[v2]; });
// Overwrite degree with color
auto& colors = degrees;
@ -171,39 +152,38 @@ colorVerticesWelshPowell(const Graph& graph)
std::vector<std::size_t> verticesPerColor;
verticesPerColor.reserve(10);
while(!orderedVertices.empty())
{
verticesPerColor
.push_back(Detail::colorGraphWelshPowell(graph, orderedVertices, colors,
color++, noVertices));
while (!orderedVertices.empty()) {
verticesPerColor.push_back(Detail::colorGraphWelshPowell(graph, orderedVertices,
colors, color++, noVertices));
}
return std::make_tuple(colors, color, verticesPerColor);
}
/// \! Reorder colored graph preserving order of vertices with the same color.
template<class Graph>
template <class Graph>
std::vector<std::size_t>
reorderVerticesPreserving(const std::vector<int>& colors, int noColors,
reorderVerticesPreserving(const std::vector<int>& colors,
int noColors,
const std::vector<std::size_t>& verticesPerColor,
const Graph& graph)
{
std::vector<std::size_t> colorIndex(noColors, 0);
std::vector<std::size_t> indices(graph.maxVertex() + 1);
std::partial_sum(verticesPerColor.begin(),
verticesPerColor.begin()+verticesPerColor.size() - 1,
verticesPerColor.begin() + verticesPerColor.size() - 1,
colorIndex.begin() + 1);
for(const auto& vertex: graph)
{
for (const auto& vertex : graph) {
indices[vertex] = colorIndex[colors[vertex]]++;
}
return indices;
}
/// \! Reorder Vetrices in spheres
template<class Graph>
template <class Graph>
std::vector<std::size_t>
reorderVerticesSpheres(const std::vector<int>& colors, int noColors,
reorderVerticesSpheres(const std::vector<int>& colors,
int noColors,
const std::vector<std::size_t>& verticesPerColor,
const Graph& graph,
typename Graph::VertexDescriptor root)
@ -213,7 +193,7 @@ reorderVerticesSpheres(const std::vector<int>& colors, int noColors,
std::vector<std::size_t> indices(graph.maxVertex() + 1, notVisitedTag);
using Vertex = typename Graph::VertexDescriptor;
std::partial_sum(verticesPerColor.begin(),
verticesPerColor.begin()+verticesPerColor.size() - 1,
verticesPerColor.begin() + verticesPerColor.size() - 1,
colorIndex.begin() + 1);
std::size_t noVisited = 0;
auto numberer = [&colorIndex, &colors, &indices](Vertex vertex)
@ -221,18 +201,14 @@ reorderVerticesSpheres(const std::vector<int>& colors, int noColors,
indices[vertex] = colorIndex[colors[vertex]]++;
};
while ( noVisited < graph.maxVertex() + 1 )
{
while (noVisited < graph.maxVertex() + 1) {
numberer(root);
++noVisited; //root node already visited and not visited in BFS
++noVisited; // root node already visited and not visited in BFS
noVisited += Detail::breadthFirstSearch(graph, root, numberer);
if ( noVisited < graph.maxVertex() + 1 )
{
if (noVisited < graph.maxVertex() + 1) {
// Graph is disconnected search for not yet visited node
for(auto vertex: graph)
{
if ( indices[vertex] == notVisitedTag )
{
for (auto vertex : graph) {
if (indices[vertex] == notVisitedTag) {
// \todo make sure that this is a peripheral node!
root = vertex;
break;

View File

@ -52,27 +52,27 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(SeqDILUDiagIsCorrect2x2NoZeros, T, NumericTypes)
row.insert(1);
}
A[0][0][0][0]=3.0;
A[0][0][0][1]=1.0;
A[0][0][1][0]=2.0;
A[0][0][1][1]=1.0;
A[0][0][0][0] = 3.0;
A[0][0][0][1] = 1.0;
A[0][0][1][0] = 2.0;
A[0][0][1][1] = 1.0;
A[0][1][0][0]=1.0;
A[0][1][1][1]=1.0;
A[0][1][0][0] = 1.0;
A[0][1][1][1] = 1.0;
A[1][0][0][0]=2.0;
A[1][0][1][1]=2.0;
A[1][0][0][0] = 2.0;
A[1][0][1][1] = 2.0;
A[1][1][0][0]=-1.0;
A[1][1][1][1]=-1.0;
A[1][1][0][0] = -1.0;
A[1][1][1][1] = -1.0;
auto D_00 = A[0][0];
auto D_00_inv = D_00;
D_00_inv.invert();
// D_11 = A_11 - L_10 D_00_inv U_01
auto D_11 = A[1][1] - A[1][0]*D_00_inv*A[0][1];
auto D_11 = A[1][1] - A[1][0] * D_00_inv * A[0][1];
Dune::SeqDilu<Matrix, Vector, Vector> seqdilu(A);
@ -122,16 +122,16 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(SeqDILUDiagIsCorrect2x2, T, NumericTypes)
}
}
A[0][0][0][0]=3.0;
A[0][0][0][1]=1.0;
A[0][0][1][0]=2.0;
A[0][0][1][1]=1.0;
A[0][0][0][0] = 3.0;
A[0][0][0][1] = 1.0;
A[0][0][1][0] = 2.0;
A[0][0][1][1] = 1.0;
A[0][1][0][0]=1.0;
A[0][1][1][1]=1.0;
A[0][1][0][0] = 1.0;
A[0][1][1][1] = 1.0;
A[1][1][0][0]=-1.0;
A[1][1][1][1]=-1.0;
A[1][1][0][0] = -1.0;
A[1][1][1][1] = -1.0;
auto D_00 = A[0][0];
@ -188,20 +188,20 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(SeqDILUApplyIsCorrectNoZeros, T, NumericTypes)
row.insert(1);
}
A[0][0][0][0]=3.0;
A[0][0][0][1]=1.0;
A[0][0][1][0]=2.0;
A[0][0][1][1]=1.0;
A[0][0][0][0] = 3.0;
A[0][0][0][1] = 1.0;
A[0][0][1][0] = 2.0;
A[0][0][1][1] = 1.0;
A[0][1][0][0]=1.0;
A[0][1][1][1]=1.0;
A[0][1][0][0] = 1.0;
A[0][1][1][1] = 1.0;
A[1][0][0][0]=2.0;
A[1][0][1][1]=2.0;
A[1][0][0][0] = 2.0;
A[1][0][1][1] = 2.0;
A[1][1][0][0]=-1.0;
A[1][1][1][1]=-1.0;
A[1][1][0][0] = -1.0;
A[1][1][1][1] = -1.0;
Vector x(2);
@ -221,7 +221,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(SeqDILUApplyIsCorrectNoZeros, T, NumericTypes)
auto D_00_inv = D_00;
D_00_inv.invert();
// D_11= A_11 - L_10 D_00_inv U_01
auto D_11 = A[1][1] - A[1][0]*D_00_inv*A[0][1];
auto D_11 = A[1][1] - A[1][0] * D_00_inv * A[0][1];
auto D_11_inv = D_11;
D_11_inv.invert();
@ -251,7 +251,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(SeqDILUApplyIsCorrectNoZeros, T, NumericTypes)
// z_0 = y_0 - D_00_inv*A_01*z_1
z[0] = y[0];
auto temp = D_00_inv*A[0][1];
auto temp = D_00_inv * A[0][1];
temp.mmv(z[1], z[0]);
// x_k+1 = x_k + z
@ -299,16 +299,16 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(SeqDILUApplyIsCorrect1, T, NumericTypes)
}
}
A[0][0][0][0]=3.0;
A[0][0][0][1]=1.0;
A[0][0][1][0]=2.0;
A[0][0][1][1]=1.0;
A[0][0][0][0] = 3.0;
A[0][0][0][1] = 1.0;
A[0][0][1][0] = 2.0;
A[0][0][1][1] = 1.0;
A[0][1][0][0]=1.0;
A[0][1][1][1]=1.0;
A[0][1][0][0] = 1.0;
A[0][1][1][1] = 1.0;
A[1][1][0][0]=-1.0;
A[1][1][1][1]=-1.0;
A[1][1][0][0] = -1.0;
A[1][1][1][1] = -1.0;
Vector x(2);
@ -356,7 +356,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(SeqDILUApplyIsCorrect1, T, NumericTypes)
// z_0 = y_0 - D_00_inv*A_01*z_1
z[0] = y[0];
auto temp = D_00_inv*A[0][1];
auto temp = D_00_inv * A[0][1];
temp.mmv(z[1], z[0]);
// x_k+1 = x_k + z
@ -402,16 +402,16 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(SeqDILUApplyIsCorrect2, T, NumericTypes)
}
}
A[0][0][0][0]=3.0;
A[0][0][0][1]=1.0;
A[0][0][1][0]=2.0;
A[0][0][1][1]=1.0;
A[0][0][0][0] = 3.0;
A[0][0][0][1] = 1.0;
A[0][0][1][0] = 2.0;
A[0][0][1][1] = 1.0;
A[1][1][0][0]=2.0;
A[1][1][1][1]=2.0;
A[1][1][0][0] = 2.0;
A[1][1][1][1] = 2.0;
A[1][1][0][0]=-1.0;
A[1][1][1][1]=-1.0;
A[1][1][0][0] = -1.0;
A[1][1][1][1] = -1.0;
Vector x(2);
x[0][0] = 1.0;
@ -504,36 +504,61 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(SeqDILUDiagIsCorrect3x3, T, NumericTypes)
for (auto row = A.createbegin(); row != A.createend(); ++row) {
if (row.index() == 0) {
row.insert(row.index());
}
else if (row.index() == 1) {
} else if (row.index() == 1) {
row.insert(row.index());
row.insert(row.index() + 1);
}
else if (row.index() == 2) {
} else if (row.index() == 2) {
row.insert(row.index() - 1);
row.insert(row.index());
}
}
A[0][0][0][0]=3.0; A[1][1][0][0]=1.0; A[1][2][0][0]=1.0;
A[0][0][0][1]=1.0; A[1][1][0][1]=0.0; A[1][2][0][1]=0.0;
A[0][0][0][2]=2.0; A[1][1][0][2]=1.0; A[1][2][0][2]=2.0;
A[0][0][1][0]=2.0; A[1][1][1][0]=4.0; A[1][2][1][0]=0.0;
A[0][0][1][1]=3.0; A[1][1][1][1]=1.0; A[1][2][1][1]=1.0;
A[0][0][1][2]=1.0; A[1][1][1][2]=0.0; A[1][2][1][2]=1.0;
A[0][0][2][0]=2.0; A[1][1][2][0]=3.0; A[1][2][2][0]=0.0;
A[0][0][2][1]=1.0; A[1][1][2][1]=1.0; A[1][2][2][1]=1.0;
A[0][0][2][2]=0.0; A[1][1][2][2]=3.0; A[1][2][2][2]=3.0;
A[0][0][0][0] = 3.0;
A[1][1][0][0] = 1.0;
A[1][2][0][0] = 1.0;
A[0][0][0][1] = 1.0;
A[1][1][0][1] = 0.0;
A[1][2][0][1] = 0.0;
A[0][0][0][2] = 2.0;
A[1][1][0][2] = 1.0;
A[1][2][0][2] = 2.0;
A[0][0][1][0] = 2.0;
A[1][1][1][0] = 4.0;
A[1][2][1][0] = 0.0;
A[0][0][1][1] = 3.0;
A[1][1][1][1] = 1.0;
A[1][2][1][1] = 1.0;
A[0][0][1][2] = 1.0;
A[1][1][1][2] = 0.0;
A[1][2][1][2] = 1.0;
A[0][0][2][0] = 2.0;
A[1][1][2][0] = 3.0;
A[1][2][2][0] = 0.0;
A[0][0][2][1] = 1.0;
A[1][1][2][1] = 1.0;
A[1][2][2][1] = 1.0;
A[0][0][2][2] = 0.0;
A[1][1][2][2] = 3.0;
A[1][2][2][2] = 3.0;
A[2][1][0][0]=1.0; A[2][2][0][0]=1.0;
A[2][1][0][1]=0.0; A[2][2][0][1]=3.0;
A[2][1][0][2]=2.0; A[2][2][0][2]=2.0;
A[2][1][1][0]=0.0; A[2][2][1][0]=2.0;
A[2][1][1][1]=1.0; A[2][2][1][1]=1.0;
A[2][1][1][2]=4.0; A[2][2][1][2]=3.0;
A[2][1][2][0]=5.0; A[2][2][2][0]=3.0;
A[2][1][2][1]=1.0; A[2][2][2][1]=1.0;
A[2][1][2][2]=1.0; A[2][2][2][2]=2.0;
A[2][1][0][0] = 1.0;
A[2][2][0][0] = 1.0;
A[2][1][0][1] = 0.0;
A[2][2][0][1] = 3.0;
A[2][1][0][2] = 2.0;
A[2][2][0][2] = 2.0;
A[2][1][1][0] = 0.0;
A[2][2][1][0] = 2.0;
A[2][1][1][1] = 1.0;
A[2][2][1][1] = 1.0;
A[2][1][1][2] = 4.0;
A[2][2][1][2] = 3.0;
A[2][1][2][0] = 5.0;
A[2][2][2][0] = 3.0;
A[2][1][2][1] = 1.0;
A[2][2][2][1] = 1.0;
A[2][1][2][2] = 1.0;
A[2][2][2][2] = 2.0;
auto D_00 = A[0][0];
@ -544,7 +569,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(SeqDILUDiagIsCorrect3x3, T, NumericTypes)
auto D_11_inv = D_11;
D_11_inv.invert();
// D_22 = A_22 - A_20 D_00_inv A_02 - A_21 D_11_inv A_12 = A_22 - A_21 D_11_inv A_12
auto D_22 = A[2][2] - A[2][1]*D_11_inv*A[1][2];
auto D_22 = A[2][2] - A[2][1] * D_11_inv * A[1][2];
auto D_22_inv = D_22;
D_22_inv.invert();
@ -602,46 +627,83 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(SeqDILUApplyIsCorrect3, T, NumericTypes)
for (auto row = A.createbegin(); row != A.createend(); ++row) {
if (row.index() == 0) {
row.insert(row.index());
}
else if (row.index() == 1) {
} else if (row.index() == 1) {
row.insert(row.index());
row.insert(row.index() + 1);
}
else if (row.index() == 2) {
} else if (row.index() == 2) {
row.insert(row.index() - 1);
row.insert(row.index());
}
}
A[0][0][0][0]=3.0; A[1][1][0][0]=1.0; A[1][2][0][0]=1.0;
A[0][0][0][1]=1.0; A[1][1][0][1]=0.0; A[1][2][0][1]=0.0;
A[0][0][0][2]=2.0; A[1][1][0][2]=1.0; A[1][2][0][2]=2.0;
A[0][0][1][0]=2.0; A[1][1][1][0]=4.0; A[1][2][1][0]=0.0;
A[0][0][1][1]=3.0; A[1][1][1][1]=1.0; A[1][2][1][1]=1.0;
A[0][0][1][2]=1.0; A[1][1][1][2]=0.0; A[1][2][1][2]=1.0;
A[0][0][2][0]=2.0; A[1][1][2][0]=3.0; A[1][2][2][0]=0.0;
A[0][0][2][1]=1.0; A[1][1][2][1]=1.0; A[1][2][2][1]=1.0;
A[0][0][2][2]=0.0; A[1][1][2][2]=3.0; A[1][2][2][2]=3.0;
A[0][0][0][0] = 3.0;
A[1][1][0][0] = 1.0;
A[1][2][0][0] = 1.0;
A[0][0][0][1] = 1.0;
A[1][1][0][1] = 0.0;
A[1][2][0][1] = 0.0;
A[0][0][0][2] = 2.0;
A[1][1][0][2] = 1.0;
A[1][2][0][2] = 2.0;
A[0][0][1][0] = 2.0;
A[1][1][1][0] = 4.0;
A[1][2][1][0] = 0.0;
A[0][0][1][1] = 3.0;
A[1][1][1][1] = 1.0;
A[1][2][1][1] = 1.0;
A[0][0][1][2] = 1.0;
A[1][1][1][2] = 0.0;
A[1][2][1][2] = 1.0;
A[0][0][2][0] = 2.0;
A[1][1][2][0] = 3.0;
A[1][2][2][0] = 0.0;
A[0][0][2][1] = 1.0;
A[1][1][2][1] = 1.0;
A[1][2][2][1] = 1.0;
A[0][0][2][2] = 0.0;
A[1][1][2][2] = 3.0;
A[1][2][2][2] = 3.0;
A[2][1][0][0]=1.0; A[2][2][0][0]=1.0;
A[2][1][0][1]=0.0; A[2][2][0][1]=3.0;
A[2][1][0][2]=2.0; A[2][2][0][2]=2.0;
A[2][1][1][0]=0.0; A[2][2][1][0]=2.0;
A[2][1][1][1]=1.0; A[2][2][1][1]=1.0;
A[2][1][1][2]=4.0; A[2][2][1][2]=3.0;
A[2][1][2][0]=5.0; A[2][2][2][0]=3.0;
A[2][1][2][1]=1.0; A[2][2][2][1]=1.0;
A[2][1][2][2]=1.0; A[2][2][2][2]=2.0;
A[2][1][0][0] = 1.0;
A[2][2][0][0] = 1.0;
A[2][1][0][1] = 0.0;
A[2][2][0][1] = 3.0;
A[2][1][0][2] = 2.0;
A[2][2][0][2] = 2.0;
A[2][1][1][0] = 0.0;
A[2][2][1][0] = 2.0;
A[2][1][1][1] = 1.0;
A[2][2][1][1] = 1.0;
A[2][1][1][2] = 4.0;
A[2][2][1][2] = 3.0;
A[2][1][2][0] = 5.0;
A[2][2][2][0] = 3.0;
A[2][1][2][1] = 1.0;
A[2][2][2][1] = 1.0;
A[2][1][2][2] = 1.0;
A[2][2][2][2] = 2.0;
Vector x(3);
x[0][0] = 1.0; x[1][0] = 1.0; x[2][0] = 1.0;
x[0][1] = 2.0; x[1][1] = 3.0; x[2][1] = 0.0;
x[0][2] = 3.0; x[1][2] = 2.0; x[2][2] = 2.0;
x[0][0] = 1.0;
x[1][0] = 1.0;
x[2][0] = 1.0;
x[0][1] = 2.0;
x[1][1] = 3.0;
x[2][1] = 0.0;
x[0][2] = 3.0;
x[1][2] = 2.0;
x[2][2] = 2.0;
Vector b(3);
b[0][0] = 2.0; b[1][0] = 2.0; b[2][0] = 0.0;
b[0][1] = 1.0; b[1][1] = 3.0; b[2][1] = 2.0;
b[0][2] = 2.0; b[1][2] = 2.0; b[2][2] = 1.0;
b[0][0] = 2.0;
b[1][0] = 2.0;
b[2][0] = 0.0;
b[0][1] = 1.0;
b[1][1] = 3.0;
b[2][1] = 2.0;
b[0][2] = 2.0;
b[1][2] = 2.0;
b[2][2] = 1.0;
// D_00 = A_00
@ -655,7 +717,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(SeqDILUApplyIsCorrect3, T, NumericTypes)
D_11_inv.invert();
// D_22 = A_22 - A_20 D_00_inv A_02 - A_21 D_11_inv A_12
// = A_22 - A_21 D_11_inv A_12
auto D_22 = A[2][2] - A[2][1]*D_11_inv*A[1][2];
auto D_22 = A[2][2] - A[2][1] * D_11_inv * A[1][2];
auto D_22_inv = D_22;
D_22_inv.invert();
@ -693,7 +755,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(SeqDILUApplyIsCorrect3, T, NumericTypes)
// z_1 = y_1 - D_11_inv*A_12*z_2
z[1] = y[1];
auto temp = D_11_inv*A[1][2];
auto temp = D_11_inv * A[1][2];
temp.mmv(z[2], z[1]);
// z_0 = y_0 - D_00_inv(A_01*z_1 + A_02*z_2)
@ -741,13 +803,13 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(SeqDILUApplyIsEqualToDuneSeqILUApply, T, NumericTy
row.insert(row.index());
}
A[0][0][0][0]=3.0;
A[0][0][0][1]=1.0;
A[0][0][1][0]=2.0;
A[0][0][1][1]=1.0;
A[0][0][0][0] = 3.0;
A[0][0][0][1] = 1.0;
A[0][0][1][0] = 2.0;
A[0][0][1][1] = 1.0;
A[1][1][0][0]=-1.0;
A[1][1][1][1]=-1.0;
A[1][1][0][0] = -1.0;
A[1][1][1][1] = -1.0;
Dune::SeqDilu<Matrix, Vector, Vector> seqdilu(A);