Skip to content
Snippets Groups Projects
Commit 37311d14 authored by Oliver Sander's avatar Oliver Sander
Browse files

[!278] [bugfix] matrixredistribute for matrices with scalar block_type and add a test

Merge branch 'fix_matrixredistribute_for_scalar_valued_matrices' into 'master'

ref:core/dune-istl This MR adapts matrixredistribute.hh for matrices with
scalar block_type like BCRSMatrix<double> and adapts the
matrixredistributetest.

See merge request [!278]

  [!278]: gitlab.dune-project.org/core/dune-istl/merge_requests/278
parents 24688469 a21fdec3
Branches
Tags
1 merge request!278[bugfix] matrixredistribute for matrices with scalar block_type and add a test
Pipeline #17676 passed
......@@ -446,10 +446,16 @@ namespace Dune
{
*c=0;
if(c.index()==i->local()) {
typedef typename M::block_type::RowIterator RIter;
for(RIter r=c->begin(), rend=c->end();
r != rend; ++r)
(*r)[r.index()]=1;
typedef typename M::block_type Block;
Hybrid::ifElse(IsNumber<Block>(),
[&](auto id){
*c = 1;
},
[&](auto id){
for(auto r=id(c)->begin(), rend=id(c)->end();
r != rend; ++r)
(*r)[r.index()]=1;
});
}
}
}
......
......@@ -34,25 +34,22 @@ void MPI_err_handler(MPI_Comm *, int *err_code, ...){
throw MPIError(s, *err_code);
}
template<int BS>
template<class MatrixBlock>
int testRepart(int N, int coarsenTarget)
{
std::cout<<"==================================================="<<std::endl;
std::cout<<"BS="<<BS<<" N="<<N<<" coarsenTarget="<<coarsenTarget<<std::endl;
std::cout<<" N="<<N<<" coarsenTarget="<<coarsenTarget<<std::endl;
int procs, rank;
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
MPI_Comm_size(MPI_COMM_WORLD, &procs);
typedef Dune::FieldMatrix<double,BS,BS> MatrixBlock;
typedef Dune::BCRSMatrix<MatrixBlock> BCRSMat;
typedef Dune::bigunsignedint<56> GlobalId;
typedef Dune::OwnerOverlapCopyCommunication<GlobalId> Communication;
int n;
N/=BS;
Communication comm(MPI_COMM_WORLD);
BCRSMat mat = setupAnisotropic2d<MatrixBlock>(N, comm.indexSet(), comm.communicator(), &n, 1);
......@@ -138,6 +135,8 @@ int main(int argc, char** argv)
return 1;
}
testRepart<1>(N,coarsenTarget);
testRepart<Dune::FieldMatrix<double, 1, 1>>(N,coarsenTarget);
testRepart<Dune::FieldMatrix<double, 2, 2>>(N/2,coarsenTarget);
testRepart<double>(N,coarsenTarget);
MPI_Finalize();
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment