3#ifndef DUNE_ISTL_OWNEROVERLAPCOPY_HH
4#define DUNE_ISTL_OWNEROVERLAPCOPY_HH
21#include <dune/common/tuples.hh>
22#include <dune/common/enumset.hh>
25#include <dune/common/parallel/indexset.hh>
26#include <dune/common/parallel/communicator.hh>
27#include <dune/common/parallel/remoteindices.hh>
28#include <dune/common/parallel/mpicollectivecommunication.hh>
33#include <dune/common/parallel/collectivecommunication.hh>
36template<
int dim,
template<
class,
class>
class Comm>
75 template <
class G,
class L>
111 localindices.insert(x);
125 remoteindices.insert(x);
143 return remoteindices;
151 localindices.clear();
152 remoteindices.clear();
157 std::set<IndexTripel> localindices;
159 std::set<RemoteIndexTripel> remoteindices;
171 template <
class GlobalIdType,
class LocalIdType=
int>
174 template<
typename M,
typename G,
typename L>
182 typedef typename std::set<IndexTripel>::const_iterator localindex_iterator;
183 typedef typename std::set<RemoteIndexTripel>::const_iterator remoteindex_iterator;
190 typedef typename RI::RemoteIndex
RX;
192 typedef Dune::Interface
IF;
234 if (OwnerOverlapToAllInterfaceBuilt)
235 OwnerOverlapToAllInterface.free();
241 OwnerOverlapToAllInterfaceBuilt =
true;
246 if (OwnerToAllInterfaceBuilt)
247 OwnerToAllInterface.free();
251 OwnerToAllInterfaceBuilt =
true;
256 if (OwnerCopyToAllInterfaceBuilt)
257 OwnerCopyToAllInterface.free();
263 OwnerCopyToAllInterfaceBuilt =
true;
268 if (OwnerCopyToOwnerCopyInterfaceBuilt)
269 OwnerCopyToOwnerCopyInterface.free();
274 OwnerCopyToOwnerCopyInterfaceBuilt =
true;
279 if (CopyToAllInterfaceBuilt)
280 CopyToAllInterface.free();
284 CopyToAllInterfaceBuilt =
true;
318 if (!OwnerToAllInterfaceBuilt)
335 if (!CopyToAllInterfaceBuilt)
352 if (!OwnerOverlapToAllInterfaceBuilt)
369 if (!OwnerCopyToAllInterfaceBuilt)
386 if (!OwnerCopyToOwnerCopyInterfaceBuilt)
402 template<
class T1,
class T2>
406 if (mask.size()!=
static_cast<typename std::vector<double>::size_type
>(x.size()))
408 mask.resize(x.size());
409 for (
typename std::vector<double>::size_type i=0; i<mask.size(); i++)
411 for (
typename PIS::const_iterator i=pis.begin(); i!=pis.end(); ++i)
413 mask[i->local().local()] = 0;
417 for (
typename T1::size_type i=0; i<x.size(); i++)
433 if (mask.size()!=
static_cast<typename std::vector<double>::size_type
>(x.size()))
435 mask.resize(x.size());
436 for (
typename std::vector<double>::size_type i=0; i<mask.size(); i++)
438 for (
typename PIS::const_iterator i=pis.begin(); i!=pis.end(); ++i)
440 mask[i->local().local()] = 0;
442 typename T1::field_type
result =
typename T1::field_type(0.0);
443 for (
typename T1::size_type i=0; i<x.size(); i++)
444 result += x[i].two_norm2()*mask[i];
445 return static_cast<double>(
sqrt(cc.sum(
result)));
500 if(pis.seqNo()==oldseqNo)
503 delete globalLookup_;
507 oldseqNo = pis.seqNo();
513 if(pis.seqNo()==oldseqNo)
516 delete globalLookup_;
519 oldseqNo = pis.seqNo();
524 delete globalLookup_;
530 assert(globalLookup_ != 0);
531 return *globalLookup_;
542 for (
typename PIS::const_iterator i=pis.begin(); i!=pis.end(); ++i)
544 x[i->local().local()] = 0;
559 : comm(comm_), cc(comm_), pis(), ri(pis,pis,comm_),
560 OwnerToAllInterfaceBuilt(
false), OwnerOverlapToAllInterfaceBuilt(
false),
561 OwnerCopyToAllInterfaceBuilt(
false), OwnerCopyToOwnerCopyInterfaceBuilt(
false),
562 CopyToAllInterfaceBuilt(
false), globalLookup_(0), category(cat_),
576 OwnerToAllInterfaceBuilt(
false), OwnerOverlapToAllInterfaceBuilt(
false),
577 OwnerCopyToAllInterfaceBuilt(
false), OwnerCopyToOwnerCopyInterfaceBuilt(
false),
578 CopyToAllInterfaceBuilt(
false), globalLookup_(0), category(cat_), freecomm(
false)
592 : comm(comm_), cc(comm_), OwnerToAllInterfaceBuilt(
false),
593 OwnerOverlapToAllInterfaceBuilt(
false), OwnerCopyToAllInterfaceBuilt(
false),
594 OwnerCopyToOwnerCopyInterfaceBuilt(
false), CopyToAllInterfaceBuilt(
false),
595 globalLookup_(0), category(cat_), freecomm(
freecomm_)
599 for (localindex_iterator i=
indexinfo.localIndices().begin(); i!=
indexinfo.localIndices().end(); ++i)
613 ri.setIndexSets(pis,pis,cc);
616 remoteindex_iterator i=
indexinfo.remoteIndices().begin();
619 typename PIS::const_iterator
pi=pis.begin();
620 for ( ; i!=
indexinfo.remoteIndices().end(); ++i)
631 while (
pi->global()!=
get<1>(*i) &&
pi!=pis.end())
655 if (OwnerToAllInterfaceBuilt) OwnerToAllInterface.free();
656 if (OwnerOverlapToAllInterfaceBuilt) OwnerOverlapToAllInterface.free();
657 if (OwnerCopyToAllInterfaceBuilt) OwnerCopyToAllInterface.free();
658 if (OwnerCopyToOwnerCopyInterfaceBuilt) OwnerCopyToOwnerCopyInterface.free();
659 if (CopyToAllInterfaceBuilt) CopyToAllInterface.free();
660 if (globalLookup_)
delete globalLookup_;
680 CollectiveCommunication<MPI_Comm> cc;
683 mutable IF OwnerToAllInterface;
684 mutable bool OwnerToAllInterfaceBuilt;
685 mutable IF OwnerOverlapToAllInterface;
686 mutable bool OwnerOverlapToAllInterfaceBuilt;
687 mutable IF OwnerCopyToAllInterface;
688 mutable bool OwnerCopyToAllInterfaceBuilt;
689 mutable IF OwnerCopyToOwnerCopyInterface;
690 mutable bool OwnerCopyToOwnerCopyInterfaceBuilt;
691 mutable IF CopyToAllInterface;
692 mutable bool CopyToAllInterfaceBuilt;
693 mutable std::vector<double> mask;
void testRedistributed(int s)
Provides classes for reading and writing MatrixMarket Files with an extension for parallel matrices.
Definition basearray.hh:19
Statistics about compression achieved in implicit mode.
Definition bcrsmatrix.hh:81
derive error class from the base class in common
Definition istlexception.hh:16
Attribute set for overlapping schwarz.
Definition owneroverlapcopy.hh:58
AttributeSet
Definition owneroverlapcopy.hh:59
@ owner
Definition owneroverlapcopy.hh:60
@ copy
Definition owneroverlapcopy.hh:60
@ overlap
Definition owneroverlapcopy.hh:60
Information about the index distribution.
Definition owneroverlapcopy.hh:77
tuple< GlobalIdType, LocalIdType, int > IndexTripel
A triple describing a local index.
Definition owneroverlapcopy.hh:91
void addRemoteIndex(const RemoteIndexTripel &x)
Add a new remote index triple to the set of remote indices.
Definition owneroverlapcopy.hh:119
G GlobalIdType
The type of the global index.
Definition owneroverlapcopy.hh:80
const std::set< IndexTripel > & localIndices() const
Get the set of indices local to the process.
Definition owneroverlapcopy.hh:132
const std::set< RemoteIndexTripel > & remoteIndices() const
Get the set of remote indices.
Definition owneroverlapcopy.hh:141
L LocalIdType
The type of the local index.
Definition owneroverlapcopy.hh:83
void clear()
Remove all indices from the sets.
Definition owneroverlapcopy.hh:149
tuple< int, GlobalIdType, int > RemoteIndexTripel
A triple describing a remote index.
Definition owneroverlapcopy.hh:98
void addLocalIndex(const IndexTripel &x)
Add a new index triple to the set of local indices.
Definition owneroverlapcopy.hh:105
A class setting up standard communication for a two-valued attribute set with owner/overlap/copy sema...
Definition owneroverlapcopy.hh:173
EnumItem< AttributeSet, OwnerOverlapCopyAttributeSet::copy > CopySet
Definition owneroverlapcopy.hh:194
const GlobalLookupIndexSet & globalLookup() const
Definition owneroverlapcopy.hh:528
FieldTraits< typenameT1::field_type >::real_type norm(const T1 &x) const
Compute the global euclidian norm of a vector.
Definition owneroverlapcopy.hh:430
void buildOwnerOverlapToAllInterface() const
Definition owneroverlapcopy.hh:232
Dune::ParallelIndexSet< GlobalIdType, LI, 512 > PIS
Definition owneroverlapcopy.hh:187
void buildOwnerCopyToAllInterface() const
Definition owneroverlapcopy.hh:254
void buildOwnerCopyToOwnerCopyInterface() const
Definition owneroverlapcopy.hh:266
OwnerOverlapCopyCommunication(const IndexInfoFromGrid< GlobalIdType, LocalIdType > &indexinfo, MPI_Comm comm_, SolverCategory::Category cat_=SolverCategory::overlapping, bool freecomm_=false)
Constructor.
Definition owneroverlapcopy.hh:588
void addOwnerCopyToOwnerCopy(const T &source, T &dest) const
Communicate values from owner and copy data points to owner and copy data points and add them to thos...
Definition owneroverlapcopy.hh:384
void buildCopyToAllInterface() const
Definition owneroverlapcopy.hh:277
Dune::EnumItem< AttributeSet, OwnerOverlapCopyAttributeSet::copy > CopyFlags
Definition owneroverlapcopy.hh:448
RemoteIndices & remoteIndices()
Get the underlying remote indices.
Definition owneroverlapcopy.hh:492
const ParallelIndexSet & indexSet() const
Get the underlying parallel index set.
Definition owneroverlapcopy.hh:464
Dune::RemoteIndices< PIS > RI
Definition owneroverlapcopy.hh:188
void buildGlobalLookup(std::size_t size)
Definition owneroverlapcopy.hh:510
void addOwnerOverlapToAll(const T &source, T &dest) const
Communicate values from owner data points to all other data points and add them to those values.
Definition owneroverlapcopy.hh:350
Dune::RemoteIndices< PIS > RemoteIndices
The type of the remote indices.
Definition owneroverlapcopy.hh:454
void project(T1 &x) const
Set vector to zero at copy dofs.
Definition owneroverlapcopy.hh:540
Dune::AllSet< AttributeSet > AllSet
Definition owneroverlapcopy.hh:196
Combine< EnumItem< AttributeSet, OwnerOverlapCopyAttributeSet::owner >, EnumItem< AttributeSet, OwnerOverlapCopyAttributeSet::overlap >, AttributeSet > OwnerOverlapSet
Definition owneroverlapcopy.hh:195
void copyCopyToAll(const T &source, T &dest) const
Communicate values from copy data points to all other data points.
Definition owneroverlapcopy.hh:333
Dune::GlobalLookupIndexSet< ParallelIndexSet > GlobalLookupIndexSet
The type of the reverse lookup of indices.
Definition owneroverlapcopy.hh:458
Dune::Interface IF
Definition owneroverlapcopy.hh:192
~OwnerOverlapCopyCommunication()
Definition owneroverlapcopy.hh:652
void buildGlobalLookup()
Definition owneroverlapcopy.hh:497
Dune::BufferedCommunicator BC
Definition owneroverlapcopy.hh:191
OwnerOverlapCopyCommunication(MPI_Comm comm_, SolverCategory::Category cat_=SolverCategory::overlapping, bool freecomm_=false)
Construct the communication without any indices.
Definition owneroverlapcopy.hh:556
ParallelIndexSet & indexSet()
Get the underlying parallel index set.
Definition owneroverlapcopy.hh:482
void dot(const T1 &x, const T1 &y, T2 &result) const
Compute a global dot product of two vectors.
Definition owneroverlapcopy.hh:403
OwnerOverlapCopyCommunication(SolverCategory::Category cat_=SolverCategory::overlapping)
Construct the communication without any indices using MPI_COMM_WORLD.
Definition owneroverlapcopy.hh:574
const CollectiveCommunication< MPI_Comm > & communicator() const
Definition owneroverlapcopy.hh:304
EnumItem< AttributeSet, OwnerOverlapCopyAttributeSet::owner > OwnerSet
Definition owneroverlapcopy.hh:193
void setSolverCategory(SolverCategory set)
Set right Solver Category (default is overlapping).
Definition owneroverlapcopy.hh:292
void copyOwnerToAll(const T &source, T &dest) const
Communicate values from owner data points to all other data points.
Definition owneroverlapcopy.hh:316
const RemoteIndices & remoteIndices() const
Get the underlying remote indices.
Definition owneroverlapcopy.hh:473
friend void loadMatrixMarket(M &, const std::string &, OwnerOverlapCopyCommunication< G, L > &, bool)
Load a parallel matrix/vector stored in matrix market format.
Definition matrixmarket.hh:1031
RI::RemoteIndex RX
Definition owneroverlapcopy.hh:190
void addOwnerCopyToAll(const T &source, T &dest) const
Communicate values from owner and copy data points to all other data points and add them to those val...
Definition owneroverlapcopy.hh:367
void freeGlobalLookup()
Definition owneroverlapcopy.hh:522
SolverCategory::Category getSolverCategory() const
Get Solver Category.
Definition owneroverlapcopy.hh:300
Dune::RemoteIndexListModifier< PIS, typename RI::Allocator, false > RILM
Definition owneroverlapcopy.hh:189
Dune::ParallelIndexSet< GlobalIdType, LI, 512 > ParallelIndexSet
The type of the parallel index set.
Definition owneroverlapcopy.hh:451
void buildOwnerToAllInterface() const
Definition owneroverlapcopy.hh:244
gather/scatter callback for communcation
Definition owneroverlapcopy.hh:203
static V gather(const T &a, std::size_t i)
Definition owneroverlapcopy.hh:206
static void scatter(T &a, V v, std::size_t i)
Definition owneroverlapcopy.hh:211
CommPolicy< T >::IndexedType V
Definition owneroverlapcopy.hh:204
Definition owneroverlapcopy.hh:218
CommPolicy< T >::IndexedType V
Definition owneroverlapcopy.hh:219
static V gather(const T &a, std::size_t i)
Definition owneroverlapcopy.hh:221
static void scatter(T &a, V v, std::size_t i)
Definition owneroverlapcopy.hh:226
Categories for the solvers.
Definition solvercategory.hh:18
Category
Definition solvercategory.hh:19
@ overlapping
Category for overlapping solvers.
Definition solvercategory.hh:25