dune-istl 3.0-git
transfer.hh
Go to the documentation of this file.
1// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
2// vi: set et ts=4 sw=2 sts=2:
3#ifndef DUNE_AMGTRANSFER_HH
4#define DUNE_AMGTRANSFER_HH
5
11#include <dune/common/exceptions.hh>
12#include <dune/common/unused.hh>
13
14namespace Dune
15{
16 namespace Amg
17 {
18
29 template<class V1, class V2, class T>
31 {
32
33 public:
34 typedef V1 Vertex;
35 typedef V2 Vector;
36
37 template<typename T1, typename R>
40
41 template<typename T1, typename R>
43 T1 damp);
44
45 static void restrictVector(const AggregatesMap<Vertex>& aggregates, Vector& coarse, const Vector& fine,
46 T& comm);
47 };
48
49 template<class V,class V1>
51 {
52 public:
53 typedef V Vertex;
54 typedef V1 Vector;
56 template<typename T1>
60 const Redist& redist=Redist());
61 template<typename T1>
63 T1 damp,
65
66
67 static void restrictVector(const AggregatesMap<Vertex>& aggregates, Vector& coarse, const Vector& fine,
68 const SequentialInformation& comm);
69 };
70
71#if HAVE_MPI
72
73 template<class V,class V1, class T1, class T2>
75 {
76 public:
77 typedef V Vertex;
78 typedef V1 Vector;
80 template<typename T3>
81 static void prolongateVector(const AggregatesMap<Vertex>& aggregates, Vector& coarse, Vector& fine,
83 const Redist& redist);
84 template<typename T3>
85 static void prolongateVector(const AggregatesMap<Vertex>& aggregates, Vector& coarse, Vector& fine,
87
88 static void restrictVector(const AggregatesMap<Vertex>& aggregates, Vector& coarse, const Vector& fine,
90 };
91
92#endif
93
94 template<class V, class V1>
95 template<typename T>
96 inline void
99 T damp,
100 const SequentialInformation& comm,
101 const Redist& redist)
102 {
105 DUNE_UNUSED_PARAMETER(redist);
106 prolongateVector(aggregates, coarse, fine, damp);
107 }
108 template<class V, class V1>
109 template<typename T>
110 inline void
113 T damp,
114 const SequentialInformation& comm)
115 {
117 typedef typename Vector::iterator Iterator;
118
119 Iterator end = coarse.end();
120 Iterator begin= coarse.begin();
121 for(; begin!=end; ++begin)
122 *begin*=damp;
123 end=fine.end();
124 begin=fine.begin();
125
126 for(Iterator block=begin; block != end; ++block) {
127 std::ptrdiff_t index=block-begin;
128 const Vertex& vertex = aggregates[index];
130 *block += coarse[aggregates[index]];
131 }
132 }
133
134 template<class V, class V1>
135 inline void
137 Vector& coarse,
138 const Vector& fine,
139 const SequentialInformation& comm)
140 {
142 // Set coarse vector to zero
143 coarse=0;
144
145 typedef typename Vector::const_iterator Iterator;
146 Iterator end = fine.end();
147 Iterator begin=fine.begin();
148
149 for(Iterator block=begin; block != end; ++block) {
150 const Vertex& vertex = aggregates[block-begin];
152 coarse[vertex] += *block;
153 }
154 }
155
156#if HAVE_MPI
157 template<class V, class V1, class T1, class T2>
158 template<typename T3>
159 inline void Transfer<V,V1,OwnerOverlapCopyCommunication<T1,T2> >::prolongateVector(const AggregatesMap<Vertex>& aggregates,
163 const Redist& redist)
164 {
165 if(fineRedist.size()>0)
166 // we operated on the coarse level
168
169 // TODO This could be accomplished with one communication, too!
171 comm.copyOwnerToAll(fine,fine);
172 }
173
174 template<class V, class V1, class T1, class T2>
175 template<typename T3>
184 template<class V, class V1, class T1, class T2>
185 inline void Transfer<V,V1,OwnerOverlapCopyCommunication<T1,T2> >::restrictVector(const AggregatesMap<Vertex>& aggregates,
186 Vector& coarse, const Vector& fine,
188 {
190 // We need this here to avoid it in the smoothers on the coarse level.
191 // There (in the preconditioner d is const.
192 comm.project(coarse);
193 }
194#endif
196 } // namspace Amg
197} // namspace Dune
198#endif
Provides classes for the Coloring process of AMG.
This file implements a vector space as a tensor product of a given vector space. The number of compon...
Functionality for redistributing a sparse matrix.
Classes providing communication interfaces for overlapping Schwarz methods.
Definition basearray.hh:19
Statistics about compression achieved in implicit mode.
Definition bcrsmatrix.hh:81
Definition matrixredistribute.hh:21
void redistributeBackward(D &from, const D &to) const
Definition matrixredistribute.hh:34
A class setting up standard communication for a two-valued attribute set with owner/overlap/copy sema...
Definition owneroverlapcopy.hh:173
Class providing information about the mapping of the vertices onto aggregates.
Definition aggregates.hh:543
Definition pinfo.hh:26
Definition transfer.hh:31
static void restrictVector(const AggregatesMap< Vertex > &aggregates, Vector &coarse, const Vector &fine, T &comm)
static void prolongateVector(const AggregatesMap< Vertex > &aggregates, Vector &coarse, Vector &fine, T1 damp)
static void prolongateVector(const AggregatesMap< Vertex > &aggregates, Vector &coarse, Vector &fine, Vector &fineRedist, T1 damp, R &redistributor=R())
V1 Vertex
Definition transfer.hh:34
V2 Vector
Definition transfer.hh:35
RedistributeInformation< SequentialInformation > Redist
Definition transfer.hh:55
static void prolongateVector(const AggregatesMap< Vertex > &aggregates, Vector &coarse, Vector &fine, Vector &fineRedist, T1 damp, const SequentialInformation &comm=SequentialInformation(), const Redist &redist=Redist())
static void prolongateVector(const AggregatesMap< Vertex > &aggregates, Vector &coarse, Vector &fine, T1 damp, const SequentialInformation &comm=SequentialInformation())
RedistributeInformation< OwnerOverlapCopyCommunication< T1, T2 > > Redist
Definition transfer.hh:79