Skip to content
Snippets Groups Projects
Commit b012a4dc authored by Oliver Sander's avatar Oliver Sander Committed by sander
Browse files

[bugfix] The matrix communicator actually needs to different GridView objects

Normally, the two different level grid views.  Previously we used the same one
to compute the localToGlobal renumbering for boths rows and columns.  Of course
that screws up the numbering.

I am not quite sure when that got introduced.  I may have gotten in fairly recently,
after the upstreaming of the GlobalIndexSet classs.

[[Imported from SVN: r9962]]
parent 9fcf189d
No related branches found
No related tags found
No related merge requests found
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
#include <dune/gfe/parallel/mpifunctions.hh> #include <dune/gfe/parallel/mpifunctions.hh>
template<typename RowGlobalMapper, typename GridView, typename MatrixType, typename LocalMapper1, typename LocalMapper2, typename ColumnGlobalMapper=RowGlobalMapper> template<typename RowGlobalMapper, typename GridView1, typename GridView2, typename MatrixType, typename LocalMapper1, typename LocalMapper2, typename ColumnGlobalMapper=RowGlobalMapper>
class MatrixCommunicator { class MatrixCommunicator {
struct TransferMatrixTuple { struct TransferMatrixTuple {
...@@ -45,7 +45,7 @@ class MatrixCommunicator { ...@@ -45,7 +45,7 @@ class MatrixCommunicator {
} }
public: public:
MatrixCommunicator(const RowGlobalMapper& rowGlobalMapper, const GridView& gridView, const LocalMapper1& localMapper1, const LocalMapper2& localMapper2, const int& root) MatrixCommunicator(const RowGlobalMapper& rowGlobalMapper, const GridView1& gridView, const LocalMapper1& localMapper1, const LocalMapper2& localMapper2, const int& root)
: rowGlobalMapper_(rowGlobalMapper), : rowGlobalMapper_(rowGlobalMapper),
columnGlobalMapper_(rowGlobalMapper), columnGlobalMapper_(rowGlobalMapper),
localMapper1_(localMapper1), localMapper1_(localMapper1),
...@@ -53,18 +53,22 @@ public: ...@@ -53,18 +53,22 @@ public:
communicator_(gridView.comm()), communicator_(gridView.comm()),
root_rank(root) root_rank(root)
{ {
setLocalToGlobal(gridView); setLocalToGlobalRows(gridView);
setLocalToGlobalColumns(gridView);
} }
MatrixCommunicator(const RowGlobalMapper& rowGlobalMapper, const ColumnGlobalMapper& columnGlobalMapper, const GridView& gridView, const LocalMapper1& localMapper1, const LocalMapper2& localMapper2, const int& root) MatrixCommunicator(const RowGlobalMapper& rowGlobalMapper, const ColumnGlobalMapper& columnGlobalMapper,
const GridView1& gridView1, const GridView2& gridView2,
const LocalMapper1& localMapper1, const LocalMapper2& localMapper2, const int& root)
: rowGlobalMapper_(rowGlobalMapper), : rowGlobalMapper_(rowGlobalMapper),
columnGlobalMapper_(columnGlobalMapper), columnGlobalMapper_(columnGlobalMapper),
localMapper1_(localMapper1), localMapper1_(localMapper1),
localMapper2_(localMapper2), localMapper2_(localMapper2),
communicator_(gridView.comm()), communicator_(gridView1.comm()),
root_rank(root) root_rank(root)
{ {
setLocalToGlobal(gridView); setLocalToGlobalRows(gridView1);
setLocalToGlobalColumns(gridView2);
} }
MatrixType reduceAdd(const MatrixType& local) MatrixType reduceAdd(const MatrixType& local)
...@@ -119,27 +123,38 @@ public: ...@@ -119,27 +123,38 @@ public:
private: private:
void setLocalToGlobal(const GridView& gridView) void setLocalToGlobalRows(const GridView1& gridView)
{ {
localToGlobal1_.resize(localMapper1_.size()); localToGlobal1_.resize(localMapper1_.size());
localToGlobal2_.resize(localMapper2_.size());
for (auto it = gridView.template begin<0>(); it != gridView.template end<0>(); ++it) for (auto it = gridView.template begin<0>(); it != gridView.template end<0>(); ++it)
for (int codim = 0; codim <= GridView::dimension; codim++) for (int codim = 0; codim <= GridView1::dimension; codim++)
for (size_t i=0; i<it->subEntities(codim); i++) for (size_t i=0; i<it->subEntities(codim); i++)
{ {
typename RowGlobalMapper::Index localIdx; typename LocalMapper1::Index localIdx;
typename RowGlobalMapper::Index globalIdx; typename RowGlobalMapper::Index globalIdx;
if (localMapper1_.contains(*it,i,codim,localIdx) if (localMapper1_.contains(*it,i,codim,localIdx)
and rowGlobalMapper_.contains(*it,i,codim,globalIdx)) and rowGlobalMapper_.contains(*it,i,codim,globalIdx))
localToGlobal1_[localIdx] = globalIdx; localToGlobal1_[localIdx] = globalIdx;
}
}
void setLocalToGlobalColumns(const GridView2& gridView)
{
localToGlobal2_.resize(localMapper2_.size());
for (auto it = gridView.template begin<0>(); it != gridView.template end<0>(); ++it)
for (int codim = 0; codim <= GridView2::dimension; codim++)
for (size_t i=0; i<it->subEntities(codim); i++)
{
typename LocalMapper2::Index localIdx;
typename ColumnGlobalMapper::Index globalIdx;
if (localMapper2_.contains(*it,i,codim,localIdx) if (localMapper2_.contains(*it,i,codim,localIdx)
and columnGlobalMapper_.contains(*it,i,codim,globalIdx)) and columnGlobalMapper_.contains(*it,i,codim,globalIdx))
localToGlobal2_[localIdx] = globalIdx; localToGlobal2_[localIdx] = globalIdx;
} }
} }
// Mappers for the global numbering // Mappers for the global numbering
...@@ -150,7 +165,7 @@ private: ...@@ -150,7 +165,7 @@ private:
const LocalMapper1& localMapper1_; const LocalMapper1& localMapper1_;
const LocalMapper2& localMapper2_; const LocalMapper2& localMapper2_;
const typename GridView::CollectiveCommunication& communicator_; const typename GridView1::CollectiveCommunication& communicator_;
int root_rank; int root_rank;
std::vector<typename RowGlobalMapper::Index> localToGlobal1_; std::vector<typename RowGlobalMapper::Index> localToGlobal1_;
......
...@@ -131,6 +131,7 @@ setup(const GridType& grid, ...@@ -131,6 +131,7 @@ setup(const GridType& grid,
LocalMapper localMapper(grid_->leafGridView()); LocalMapper localMapper(grid_->leafGridView());
MatrixCommunicator<GlobalMapper, MatrixCommunicator<GlobalMapper,
typename GridType::LeafGridView,
typename GridType::LeafGridView, typename GridType::LeafGridView,
ScalarMatrixType, ScalarMatrixType,
LocalMapper, LocalMapper,
...@@ -199,11 +200,12 @@ setup(const GridType& grid, ...@@ -199,11 +200,12 @@ setup(const GridType& grid,
typedef typename TruncatedCompressedMGTransfer<CorrectionType>::TransferOperatorType TransferOperatorType; typedef typename TruncatedCompressedMGTransfer<CorrectionType>::TransferOperatorType TransferOperatorType;
MatrixCommunicator<GlobalMapper, MatrixCommunicator<GlobalMapper,
typename GridType::LeafGridView,
typename GridType::LeafGridView, typename GridType::LeafGridView,
TransferOperatorType, TransferOperatorType,
LocalMapper, LocalMapper,
LeafP1LocalMapper, LeafP1LocalMapper,
GlobalLeafP1Mapper> matrixComm(*globalMapper_, p1Index, grid_->leafGridView(), localMapper, leafP1LocalMapper, 0); GlobalLeafP1Mapper> matrixComm(*globalMapper_, p1Index, grid_->leafGridView(), grid_->leafGridView(), localMapper, leafP1LocalMapper, 0);
mmgStep->mgTransfer_.back() = new PKtoP1MGTransfer<CorrectionType>; mmgStep->mgTransfer_.back() = new PKtoP1MGTransfer<CorrectionType>;
Dune::shared_ptr<TransferOperatorType> topTransferOperator = Dune::make_shared<TransferOperatorType>(matrixComm.reduceCopy(topTransferOp->getMatrix())); Dune::shared_ptr<TransferOperatorType> topTransferOperator = Dune::make_shared<TransferOperatorType>(matrixComm.reduceCopy(topTransferOp->getMatrix()));
...@@ -226,10 +228,11 @@ setup(const GridType& grid, ...@@ -226,10 +228,11 @@ setup(const GridType& grid,
typedef typename TruncatedCompressedMGTransfer<CorrectionType>::TransferOperatorType TransferOperatorType; typedef typename TruncatedCompressedMGTransfer<CorrectionType>::TransferOperatorType TransferOperatorType;
MatrixCommunicator<GlobalLevelP1Mapper, MatrixCommunicator<GlobalLevelP1Mapper,
typename GridType::LevelGridView,
typename GridType::LevelGridView, typename GridType::LevelGridView,
TransferOperatorType, TransferOperatorType,
LevelLocalMapper, LevelLocalMapper,
LevelLocalMapper> matrixComm(fineGUIndex, coarseGUIndex, grid_->levelGridView(i+1), fineLevelLocalMapper, coarseLevelLocalMapper, 0); LevelLocalMapper> matrixComm(fineGUIndex, coarseGUIndex, grid_->levelGridView(i+2), grid_->levelGridView(i+1), fineLevelLocalMapper, coarseLevelLocalMapper, 0);
mmgStep->mgTransfer_[i] = new TruncatedCompressedMGTransfer<CorrectionType>; mmgStep->mgTransfer_[i] = new TruncatedCompressedMGTransfer<CorrectionType>;
Dune::shared_ptr<TransferOperatorType> transferOperatorMatrix = Dune::make_shared<TransferOperatorType>(matrixComm.reduceCopy(newTransferOp->getMatrix())); Dune::shared_ptr<TransferOperatorType> transferOperatorMatrix = Dune::make_shared<TransferOperatorType>(matrixComm.reduceCopy(newTransferOp->getMatrix()));
...@@ -337,6 +340,7 @@ void RiemannianTrustRegionSolver<GridType,TargetSpace>::solve() ...@@ -337,6 +340,7 @@ void RiemannianTrustRegionSolver<GridType,TargetSpace>::solve()
LocalMapper localMapper(grid_->leafGridView()); LocalMapper localMapper(grid_->leafGridView());
MatrixCommunicator<GlobalMapper, MatrixCommunicator<GlobalMapper,
typename GridType::LeafGridView,
typename GridType::LeafGridView, typename GridType::LeafGridView,
MatrixType, MatrixType,
LocalMapper, LocalMapper,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment