/usr/include/dune/istl/paamg/galerkin.hh is in libdune-istl-dev 2.2.1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 | // -*- tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set ts=8 sw=2 et sts=2:
// $Id: galerkin.hh 1553 2012-04-26 12:18:19Z mblatt $
#ifndef DUNE_GALERKIN_HH
#define DUNE_GALERKIN_HH
#include"aggregates.hh"
#include"pinfo.hh"
#include<dune/common/poolallocator.hh>
#include<dune/common/enumset.hh>
#include<set>
#include<limits>
#include<algorithm>
namespace Dune
{
namespace Amg
{
/**
* @addtogroup ISTL_PAAMG
*
* @{
*/
/** @file
* @author Markus Blatt
* @brief Provides a class for building the galerkin product
* based on a aggregation scheme.
*/
template<class T>
struct OverlapVertex
{
/**
* @brief The aggregate descriptor.
*/
typedef T Aggregate;
/**
* @brief The vertex descriptor.
*/
typedef T Vertex;
/**
* @brief The aggregate the vertex belongs to.
*/
Aggregate* aggregate;
/**
* @brief The vertex descriptor.
*/
Vertex vertex;
};
/**
* @brief Functor for building the sparsity pattern of the matrix
* using examineConnectivity.
*/
template<class M>
class SparsityBuilder
{
public:
/**
* @brief Constructor.
* @param matrix The matrix whose sparsity pattern we
* should set up.
*/
SparsityBuilder(M& matrix);
void insert(const typename M::size_type& index);
void operator++();
std::size_t minRowSize();
std::size_t maxRowSize();
std::size_t sumRowSize();
std::size_t index()
{
return row_.index();
}
private:
/** @brief Create iterator for the current row. */
typename M::CreateIterator row_;
/** @brief The minim row size. */
std::size_t minRowSize_;
/** @brief The maximum row size. */
std::size_t maxRowSize_;
std::size_t sumRowSize_;
#ifdef DUNE_ISTL_WITH_CHECKING
bool diagonalInserted;
#endif
};
class BaseGalerkinProduct
{
public:
/**
* @brief Calculate the galerkin product.
* @param fine The fine matrix.
* @param aggregates The aggregate mapping.
* @param coarse The coarse Matrix.
* @param pinfo Parallel information about the fine level.
* @param copy The attribute set identifying the copy nodes of the graph.
*/
template<class M, class V, class I, class O>
void calculate(const M& fine, const AggregatesMap<V>& aggregates, M& coarse,
const I& pinfo, const O& copy);
};
template<class T>
class GalerkinProduct
: public BaseGalerkinProduct
{
public:
typedef T ParallelInformation;
/**
* @brief Calculates the coarse matrix via a Galerkin product.
* @param fine The matrix on the fine level.
* @param fineGraph The graph of the fine matrix.
* @param visitedMap Map for marking vertices as visited.
* @param pinfo Parallel information about the fine level.
* @param aggregates The mapping of the fine level unknowns onto aggregates.
* @param size The number of columns and rows of the coarse matrix.
* @param copy The attribute set identifying the copy nodes of the graph.
*/
template<class M, class G, class V, class Set>
M* build(const M& fine, G& fineGraph, V& visitedMap,
const ParallelInformation& pinfo,
AggregatesMap<typename G::VertexDescriptor>& aggregates,
const typename M::size_type& size,
const Set& copy);
private:
/**
* @brief Builds the data structure needed for rebuilding the aggregates int the overlap.
* @param graph The graph of the matrix.
* @param pinfo The parallel information.
* @param aggregates The mapping onto the aggregates.
*/
template<class G, class I, class Set>
const OverlapVertex<typename G::VertexDescriptor>*
buildOverlapVertices(const G& graph, const I& pinfo,
AggregatesMap<typename G::VertexDescriptor>& aggregates,
const Set& overlap,
std::size_t& overlapCount);
template<class A>
struct OVLess
{
bool operator()(const OverlapVertex<A>& o1, const OverlapVertex<A>& o2)
{
return *o1.aggregate < *o2.aggregate;
}
};
};
template<>
class GalerkinProduct<SequentialInformation>
: public BaseGalerkinProduct
{
public:
/**
* @brief Calculates the coarse matrix via a Galerkin product.
* @param fine The matrix on the fine level.
* @param fineGraph The graph of the fine matrix.
* @param visitedMap Map for marking vertices as visited.
* @param pinfo Parallel information about the fine level.
* @param aggregates The mapping of the fine level unknowns onto aggregates.
* @param size The number of columns and rows of the coarse matrix.
* @param copy The attribute set identifying the copy nodes of the graph.
*/
template<class M, class G, class V, class Set>
M* build(const M& fine, G& fineGraph, V& visitedMap,
const SequentialInformation& pinfo,
const AggregatesMap<typename G::VertexDescriptor>& aggregates,
const typename M::size_type& size,
const Set& copy);
};
struct BaseConnectivityConstructor
{
template<class R, class G, class V>
static void constructOverlapConnectivity(R& row, G& graph, V& visitedMap,
const AggregatesMap<typename G::VertexDescriptor>& aggregates,
const OverlapVertex<typename G::VertexDescriptor>*& seed,
const OverlapVertex<typename G::VertexDescriptor>* overlapEnd);
/**
* @brief Construct the connectivity of an aggregate in the overlap.
*/
template<class R, class G, class V>
static void constructNonOverlapConnectivity(R& row, G& graph, V& visitedMap,
const AggregatesMap<typename G::VertexDescriptor>& aggregates,
const typename G::VertexDescriptor& seed);
/**
* @brief Visitor for identifying connected aggregates during a breadthFirstSearch.
*/
template<class G, class S, class V>
class ConnectedBuilder
{
public:
/**
* @brief The type of the graph.
*/
typedef G Graph;
/**
* @brief The constant edge iterator.
*/
typedef typename Graph::ConstEdgeIterator ConstEdgeIterator;
/**
* @brief The type of the connected set.
*/
typedef S Set;
/**
* @brief The type of the map for marking vertices as visited.
*/
typedef V VisitedMap;
/**
* @brief The vertex descriptor of the graph.
*/
typedef typename Graph::VertexDescriptor Vertex;
/**
* @brief Constructor
* @param aggregates The mapping of the vertices onto the aggregates.
* @param graph The graph to work on.
* @param visitedMap The map for marking vertices as visited
* @param connected The set to added the connected aggregates to.
*/
ConnectedBuilder(const AggregatesMap<Vertex>& aggregates, Graph& graph,
VisitedMap& visitedMap, Set& connected);
/**
* @brief Process an edge pointing to another aggregate.
* @param edge The iterator positioned at the edge.
*/
void operator()(const ConstEdgeIterator& edge);
private:
/**
* @brief The mapping of the vertices onto the aggregates.
*/
const AggregatesMap<Vertex>& aggregates_;
Graph& graph_;
/**
* @brief The map for marking vertices as visited.
*/
VisitedMap& visitedMap_;
/**
* @brief The set to add the connected aggregates to.
*/
Set& connected_;
};
};
template<class G, class T>
struct ConnectivityConstructor: public BaseConnectivityConstructor
{
typedef typename G::VertexDescriptor Vertex;
template<class V, class O, class R>
static void examine(G& graph,
V& visitedMap,
const T& pinfo,
const AggregatesMap<Vertex>& aggregates,
const O& overlap,
const OverlapVertex<Vertex>* overlapVertices,
const OverlapVertex<Vertex>* overlapEnd,
R& row);
};
template<class G>
struct ConnectivityConstructor<G,SequentialInformation> : public BaseConnectivityConstructor
{
typedef typename G::VertexDescriptor Vertex;
template<class V, class R>
static void examine(G& graph,
V& visitedMap,
const SequentialInformation& pinfo,
const AggregatesMap<Vertex>& aggregates,
R& row);
};
template<class T>
struct DirichletBoundarySetter
{
template<class M, class O>
static void set(M& coarse, const T& pinfo, const O& copy);
};
template<>
struct DirichletBoundarySetter<SequentialInformation>
{
template<class M, class O>
static void set(M& coarse, const SequentialInformation& pinfo, const O& copy);
};
template<class R, class G, class V>
void BaseConnectivityConstructor::constructNonOverlapConnectivity(R& row, G& graph, V& visitedMap,
const AggregatesMap<typename G::VertexDescriptor>& aggregates,
const typename G::VertexDescriptor& seed)
{
assert(row.index()==aggregates[seed]);
row.insert(aggregates[seed]);
ConnectedBuilder<G,R,V> conBuilder(aggregates, graph, visitedMap, row);
typedef typename G::VertexDescriptor Vertex;
typedef std::allocator<Vertex> Allocator;
typedef SLList<Vertex,Allocator> VertexList;
typedef typename AggregatesMap<Vertex>::DummyEdgeVisitor DummyVisitor;
VertexList vlist;
DummyVisitor dummy;
aggregates.template breadthFirstSearch<true,false>(seed,aggregates[seed], graph, vlist, dummy,
conBuilder, visitedMap);
}
template<class R, class G, class V>
void BaseConnectivityConstructor::constructOverlapConnectivity(R& row, G& graph, V& visitedMap,
const AggregatesMap<typename G::VertexDescriptor>& aggregates,
const OverlapVertex<typename G::VertexDescriptor>*& seed,
const OverlapVertex<typename G::VertexDescriptor>* overlapEnd)
{
ConnectedBuilder<G,R,V> conBuilder(aggregates, graph, visitedMap, row);
const typename G::VertexDescriptor aggregate=*seed->aggregate;
if (row.index()==*seed->aggregate){
while(seed != overlapEnd && aggregate == *seed->aggregate){
row.insert(*seed->aggregate);
// Walk over all neighbours and add them to the connected array.
visitNeighbours(graph, seed->vertex, conBuilder);
// Mark vertex as visited
put(visitedMap, seed->vertex, true);
++seed;
}
}
}
template<class G, class S, class V>
BaseConnectivityConstructor::ConnectedBuilder<G,S,V>::ConnectedBuilder(const AggregatesMap<Vertex>& aggregates,
Graph& graph, VisitedMap& visitedMap,
Set& connected)
: aggregates_(aggregates), graph_(graph), visitedMap_(visitedMap), connected_(connected)
{}
template<class G, class S, class V>
void BaseConnectivityConstructor::ConnectedBuilder<G,S,V>::operator()(const ConstEdgeIterator& edge)
{
typedef typename G::VertexDescriptor Vertex;
const Vertex& vertex = aggregates_[edge.target()];
assert(vertex!= AggregatesMap<Vertex>::UNAGGREGATED);
if(vertex!= AggregatesMap<Vertex>::ISOLATED)
connected_.insert(vertex);
}
template<class T>
template<class G, class I, class Set>
const OverlapVertex<typename G::VertexDescriptor>*
GalerkinProduct<T>::buildOverlapVertices(const G& graph, const I& pinfo,
AggregatesMap<typename G::VertexDescriptor>& aggregates,
const Set& overlap,
std::size_t& overlapCount)
{
// count the overlap vertices.
typedef typename G::ConstVertexIterator ConstIterator;
typedef typename I::GlobalLookupIndexSet GlobalLookup;
typedef typename GlobalLookup::IndexPair IndexPair;
const ConstIterator end = graph.end();
overlapCount = 0;
const GlobalLookup& lookup=pinfo.globalLookup();
for(ConstIterator vertex=graph.begin(); vertex != end; ++vertex){
const IndexPair* pair = lookup.pair(*vertex);
if(pair!=0 && overlap.contains(pair->local().attribute()))
++overlapCount;
}
// Allocate space
typedef typename G::VertexDescriptor Vertex;
OverlapVertex<Vertex>* overlapVertices = new OverlapVertex<Vertex>[overlapCount=0?1:overlapCount];
if(overlapCount==0)
return overlapVertices;
// Initialize them
overlapCount=0;
for(ConstIterator vertex=graph.begin(); vertex != end; ++vertex){
const IndexPair* pair = lookup.pair(*vertex);
if(pair!=0 && overlap.contains(pair->local().attribute())){
overlapVertices[overlapCount].aggregate = &aggregates[pair->local()];
overlapVertices[overlapCount].vertex = pair->local();
++overlapCount;
}
}
dverb << overlapCount<<" overlap vertices"<<std::endl;
std::sort(overlapVertices, overlapVertices+overlapCount, OVLess<Vertex>());
// due to the sorting the isolated aggregates (to be skipped) are at the end.
return overlapVertices;
}
template<class G, class T>
template<class V, class O, class R>
void ConnectivityConstructor<G,T>::examine(G& graph,
V& visitedMap,
const T& pinfo,
const AggregatesMap<Vertex>& aggregates,
const O& overlap,
const OverlapVertex<Vertex>* overlapVertices,
const OverlapVertex<Vertex>* overlapEnd,
R& row)
{
typedef typename T::GlobalLookupIndexSet GlobalLookup;
const GlobalLookup& lookup = pinfo.globalLookup();
typedef typename G::VertexIterator VertexIterator;
VertexIterator vend=graph.end();
#ifdef DUNE_ISTL_WITH_CHECKING
std::set<Vertex> examined;
#endif
// The aggregates owned by the process have lower local indices
// then those not owned. We process them in the first pass.
// They represent the rows 0, 1, ..., n of the coarse matrix
for(VertexIterator vertex = graph.begin(); vertex != vend; ++vertex)
if(!get(visitedMap, *vertex)){
// In the first pass we only process owner nodes
typedef typename GlobalLookup::IndexPair IndexPair;
const IndexPair* pair = lookup.pair(*vertex);
if(pair==0 || !overlap.contains(pair->local().attribute())){
#ifdef DUNE_ISTL_WITH_CHECKING
assert(examined.find(aggregates[*vertex])==examined.end());
examined.insert(aggregates[*vertex]);
#endif
constructNonOverlapConnectivity(row, graph, visitedMap, aggregates, *vertex);
// only needed for ALU
// (ghosts with same global id as owners on the same process)
if (pinfo.getSolverCategory() == static_cast<int>(SolverCategory::nonoverlapping)){
if(overlapVertices != overlapEnd){
if(*overlapVertices->aggregate!=AggregatesMap<Vertex>::ISOLATED){
constructOverlapConnectivity(row, graph, visitedMap, aggregates, overlapVertices, overlapEnd);}
else{
++overlapVertices;
}
}
}
++row;
}
}
dvverb<<"constructed "<<row.index()<<" non-overlapping rows"<<std::endl;
// Now come the aggregates not owned by use.
// They represent the rows n+1, ..., N
while(overlapVertices != overlapEnd)
if(*overlapVertices->aggregate!=AggregatesMap<Vertex>::ISOLATED){
#ifdef DUNE_ISTL_WITH_CHECKING
typedef typename GlobalLookup::IndexPair IndexPair;
const IndexPair* pair = lookup.pair(overlapVertices->vertex);
assert(pair!=0 && overlap.contains(pair->local().attribute()));
assert(examined.find(aggregates[overlapVertices->vertex])==examined.end());
examined.insert(aggregates[overlapVertices->vertex]);
#endif
constructOverlapConnectivity(row, graph, visitedMap, aggregates, overlapVertices, overlapEnd);
++row;
}else{
++overlapVertices;
}
}
template<class G>
template<class V, class R>
void ConnectivityConstructor<G,SequentialInformation>::examine(G& graph,
V& visitedMap,
const SequentialInformation& pinfo,
const AggregatesMap<Vertex>& aggregates,
R& row)
{
typedef typename G::VertexIterator VertexIterator;
VertexIterator vend=graph.end();
for(VertexIterator vertex = graph.begin(); vertex != vend; ++vertex){
if(!get(visitedMap, *vertex)){
constructNonOverlapConnectivity(row, graph, visitedMap, aggregates, *vertex);
++row;
}
}
}
template<class M>
SparsityBuilder<M>::SparsityBuilder(M& matrix)
: row_(matrix.createbegin()),
minRowSize_(std::numeric_limits<std::size_t>::max()),
maxRowSize_(0), sumRowSize_(0)
{
#ifdef DUNE_ISTL_WITH_CHECKING
diagonalInserted = false;
#endif
}
template<class M>
std::size_t SparsityBuilder<M>::maxRowSize()
{
return maxRowSize_;
}
template<class M>
std::size_t SparsityBuilder<M>::minRowSize()
{
return minRowSize_;
}
template<class M>
std::size_t SparsityBuilder<M>::sumRowSize()
{
return sumRowSize_;
}
template<class M>
void SparsityBuilder<M>::operator++()
{
sumRowSize_ += row_.size();
minRowSize_=std::min(minRowSize_, row_.size());
maxRowSize_=std::max(maxRowSize_, row_.size());
++row_;
#ifdef DUNE_ISTL_WITH_CHECKING
assert(diagonalInserted);
diagonalInserted = false;
#endif
}
template<class M>
void SparsityBuilder<M>::insert(const typename M::size_type& index)
{
row_.insert(index);
#ifdef DUNE_ISTL_WITH_CHECKING
diagonalInserted = diagonalInserted || row_.index()==index;
#endif
}
template<class T>
template<class M, class G, class V, class Set>
M* GalerkinProduct<T>::build(const M& fine, G& fineGraph, V& visitedMap,
const ParallelInformation& pinfo,
AggregatesMap<typename G::VertexDescriptor>& aggregates,
const typename M::size_type& size,
const Set& overlap)
{
typedef OverlapVertex<typename G::VertexDescriptor> OverlapVertex;
std::size_t count;
const OverlapVertex* overlapVertices = buildOverlapVertices(fineGraph,
pinfo,
aggregates,
overlap,
count);
M* coarseMatrix = new M(size, size, M::row_wise);
// Reset the visited flags of all vertices.
// As the isolated nodes will be skipped we simply mark them as visited
typedef typename G::VertexIterator Vertex;
Vertex vend = fineGraph.end();
for(Vertex vertex = fineGraph.begin(); vertex != vend; ++vertex){
assert(aggregates[*vertex] != AggregatesMap<typename G::VertexDescriptor>::UNAGGREGATED);
put(visitedMap, *vertex, aggregates[*vertex]==AggregatesMap<typename G::VertexDescriptor>::ISOLATED);
}
SparsityBuilder<M> sparsityBuilder(*coarseMatrix);
ConnectivityConstructor<G,T>::examine(fineGraph, visitedMap, pinfo,
aggregates, overlap,
overlapVertices,
overlapVertices+count,
sparsityBuilder);
dinfo<<pinfo.communicator().rank()<<": Matrix ("<<coarseMatrix->N()<<"x"<<coarseMatrix->M()<<" row: min="<<sparsityBuilder.minRowSize()<<" max="
<<sparsityBuilder.maxRowSize()<<" avg="
<<static_cast<double>(sparsityBuilder.sumRowSize())/coarseMatrix->N()
<<std::endl;
delete[] overlapVertices;
//calculate(fine, aggregates, *coarse, overlap);
return coarseMatrix;
}
template<class M, class G, class V, class Set>
M* GalerkinProduct<SequentialInformation>::build(const M& fine, G& fineGraph, V& visitedMap,
const SequentialInformation& pinfo,
const AggregatesMap<typename G::VertexDescriptor>& aggregates,
const typename M::size_type& size,
const Set& overlap)
{
M* coarseMatrix = new M(size, size, M::row_wise);
// Reset the visited flags of all vertices.
// As the isolated nodes will be skipped we simply mark them as visited
typedef typename G::VertexIterator Vertex;
Vertex vend = fineGraph.end();
for(Vertex vertex = fineGraph.begin(); vertex != vend; ++vertex){
assert(aggregates[*vertex] != AggregatesMap<typename G::VertexDescriptor>::UNAGGREGATED);
put(visitedMap, *vertex, aggregates[*vertex]==AggregatesMap<typename G::VertexDescriptor>::ISOLATED);
}
SparsityBuilder<M> sparsityBuilder(*coarseMatrix);
ConnectivityConstructor<G,SequentialInformation>::examine(fineGraph, visitedMap, pinfo,
aggregates, sparsityBuilder);
dinfo<<"Matrix row: min="<<sparsityBuilder.minRowSize()<<" max="
<<sparsityBuilder.maxRowSize()<<" average="
<<static_cast<double>(sparsityBuilder.sumRowSize())/coarseMatrix->N()<<std::endl;
return coarseMatrix;
}
template<class M, class V, class P, class O>
void BaseGalerkinProduct::calculate(const M& fine, const AggregatesMap<V>& aggregates, M& coarse,
const P& pinfo, const O& copy)
{
coarse = static_cast<typename M::field_type>(0);
typedef typename M::ConstIterator RowIterator;
RowIterator endRow = fine.end();
for(RowIterator row = fine.begin(); row != endRow; ++row)
if(aggregates[row.index()] != AggregatesMap<V>::ISOLATED){
assert(aggregates[row.index()]!=AggregatesMap<V>::UNAGGREGATED);
typedef typename M::ConstColIterator ColIterator;
ColIterator endCol = row->end();
for(ColIterator col = row->begin(); col != endCol; ++col)
if(aggregates[col.index()] != AggregatesMap<V>::ISOLATED){
assert(aggregates[row.index()]!=AggregatesMap<V>::UNAGGREGATED);
coarse[aggregates[row.index()]][aggregates[col.index()]]+=*col;
}
}
// get the right diagonal matrix values on copy lines from owner processes
typedef typename M::block_type BlockType;
std::vector<BlockType> rowsize(coarse.N(),BlockType(0));
for (RowIterator row = coarse.begin(); row != coarse.end(); ++row)
rowsize[row.index()]=coarse[row.index()][row.index()];
pinfo.copyOwnerToAll(rowsize,rowsize);
for (RowIterator row = coarse.begin(); row != coarse.end(); ++row)
coarse[row.index()][row.index()] = rowsize[row.index()];
// don't set dirichlet boundaries for copy lines to make novlp case work,
// the preconditioner yields slightly different results now.
// Set the dirichlet border
//DirichletBoundarySetter<P>::template set<M>(coarse, pinfo, copy);
}
template<class T>
template<class M, class O>
void DirichletBoundarySetter<T>::set(M& coarse, const T& pinfo, const O& copy)
{
typedef typename T::ParallelIndexSet::const_iterator ConstIterator;
ConstIterator end = pinfo.indexSet().end();
typedef typename M::block_type Block;
Block identity=Block(0.0);
for(typename Block::RowIterator b=identity.begin(); b != identity.end(); ++b)
b->operator[](b.index())=1.0;
for(ConstIterator index = pinfo.indexSet().begin();
index != end; ++index){
if(copy.contains(index->local().attribute())){
typedef typename M::ColIterator ColIterator;
typedef typename M::row_type Row;
Row row = coarse[index->local()];
ColIterator cend = row.find(index->local());
ColIterator col = row.begin();
for(; col != cend; ++col)
*col = 0;
cend = row.end();
assert(col != cend); // There should be a diagonal entry
*col = identity;
for(++col; col != cend; ++col)
*col = 0;
}
}
}
template<class M, class O>
void DirichletBoundarySetter<SequentialInformation>::set(M& coarse,
const SequentialInformation& pinfo,
const O& overlap)
{
}
}// namespace Amg
}// namespace Dune
#endif
|