Skip to content

Commit

Permalink
More comments in the test
Browse files Browse the repository at this point in the history
  • Loading branch information
lisajulia committed Feb 12, 2024
1 parent 37c4e9f commit aa72833
Showing 1 changed file with 13 additions and 8 deletions.
21 changes: 13 additions & 8 deletions tests/test_ghostlastmatrixadapter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ M setupAnisotropic2d(int N, Dune::ParallelIndexSet<G,L,s>& indices, const C& p,
int start, end, overlapStart, overlapEnd;

int n = N/procs; // number of unknowns per process
std::cout << "number of unknowns per process " << n << std::endl;
int bigger = N%procs; // number of process with n+1 unknows

// Compute owner region
Expand All @@ -249,12 +250,15 @@ M setupAnisotropic2d(int N, Dune::ParallelIndexSet<G,L,s>& indices, const C& p,

*nout = noKnown;

BCRSMat mat(noKnown*N, noKnown*N, noKnown*N*5, BCRSMat::row_wise);
BCRSMat mat(noKnown*N, noKnown*N, noKnown*N*5, BCRSMat::row_wise); //noKnown*N*5 average columns per row

std::cout << "on rank " << rank << ", noKnown = " << noKnown << ", overlapStart = " << overlapStart << ", overlapEnd = " << overlapEnd << std::endl;

setupPattern(N, mat, indices, overlapStart, overlapEnd, start, end);
fillValues(N, mat, overlapStart, overlapEnd, start, end, eps);

//Dune::printmatrix(std::cout,mat,"aniso 2d","row",9,1); //das hier auf zwei Prozessen ausgeben
std::string title = "rank" + std::to_string(rank);
Dune::printSparseMatrix(std::cout, mat, title,"row");

return mat;
}
Expand All @@ -263,7 +267,7 @@ int main(int argc, char** argv)
{
Dune::MPIHelper::instance(argc, argv);

constexpr int BS=2, N=100;
constexpr int BS=2, N=1000;
using MatrixBlock = Dune::FieldMatrix<double,BS,BS>;
using BCRSMat = Dune::BCRSMatrix<MatrixBlock>;
using VectorBlock = Dune::FieldVector<double,BS>;
Expand All @@ -281,7 +285,7 @@ int main(int argc, char** argv)

Vector b(mat.N()), x(mat.M());

b=10;
b=0;
x=100;
setBoundary(x, b, N, comm.indexSet());

Expand All @@ -290,18 +294,18 @@ int main(int argc, char** argv)

using namespace std::string_literals;
Opm::PropertyTree prm;
prm.put("type", "Jac"s);
prm.put("type", "amg"s);
std::function<Vector()> weights = [&mat]() {
return Opm::Amg::getQuasiImpesWeights<BCRSMat, Vector>(mat, 0, false);
};

auto fullPreconditioner = Opm::PreconditionerFactory<Operator, Communication>::create(op, prm, weights, comm);
Dune::BiCGSTABSolver<Vector> amgBiCGSTAB(op, sp, *fullPreconditioner, 10e-8, 300, (ccomm.rank()==0) ? 2 : 0);
Dune::BiCGSTABSolver<Vector> amgBiCGSTAB(op, sp, *fullPreconditioner, 10e-6, 3000, (ccomm.rank()==0) ? 2 : 0);

using PreconditionerOperatorType = Opm::GhostLastMatrixAdapter<BCRSMat, Vector, Vector, Communication>;
auto ghostOperator = std::make_unique<PreconditionerOperatorType>(mat, comm);
auto ghostPreconditioner = Opm::PreconditionerFactory<PreconditionerOperatorType, Communication>::create(*ghostOperator, prm, weights, comm);
Dune::BiCGSTABSolver<Vector> amgGhostBiCGSTAB(op, sp, *ghostPreconditioner, 10e-8, 300, (ccomm.rank()==0) ? 2 : 0);
Dune::BiCGSTABSolver<Vector> amgGhostBiCGSTAB(op, sp, *ghostPreconditioner, 10e-6, 3000, (ccomm.rank()==0) ? 2 : 0);

auto x2 = x;
auto b2 = b;
Expand All @@ -310,7 +314,7 @@ int main(int argc, char** argv)
Dune::Timer timerFull;
amgBiCGSTAB.apply(x,b,r);
auto timeFull = timerFull.elapsed();

MPI_Barrier(ccomm);
Dune::InverseOperatorResult r2;
Dune::Timer timerGhost;
amgGhostBiCGSTAB.apply(x2,b2,r2);
Expand All @@ -323,6 +327,7 @@ int main(int argc, char** argv)

if (r.iterations != r2.iterations)
return 1;

if (ccomm.rank() == 0) {
std::cout << "Full preconditioner took " << timeFull << std::endl;
std::cout << "Ghost preconditioner took " << timeGhost << std::endl;
Expand Down

0 comments on commit aa72833

Please sign in to comment.