DUNE PDELab (2.8)

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
8#include <dune/istl/paamg/pinfo.hh>
12
13namespace Dune
14{
15 namespace Amg
16 {
17
28 template<class V1, class V2, class T>
29 class Transfer
30 {
31
32 public:
33 typedef V1 Vertex;
34 typedef V2 Vector;
35
36 template<typename T1, typename R>
37 static void prolongateVector(const AggregatesMap<Vertex>& aggregates, Vector& coarse, Vector& fine,
38 Vector& fineRedist,T1 damp, R& redistributor=R());
39
40 template<typename T1, typename R>
41 static void prolongateVector(const AggregatesMap<Vertex>& aggregates, Vector& coarse, Vector& fine,
42 T1 damp);
43
44 static void restrictVector(const AggregatesMap<Vertex>& aggregates, Vector& coarse, const Vector& fine,
45 T& comm);
46 };
47
48 template<class V,class V1>
49 class Transfer<V,V1, SequentialInformation>
50 {
51 public:
52 typedef V Vertex;
53 typedef V1 Vector;
54 typedef RedistributeInformation<SequentialInformation> Redist;
55 template<typename T1>
56 static void prolongateVector(const AggregatesMap<Vertex>& aggregates, Vector& coarse, Vector& fine,
57 Vector& fineRedist, T1 damp,
58 const SequentialInformation& comm=SequentialInformation(),
59 const Redist& redist=Redist());
60 template<typename T1>
61 static void prolongateVector(const AggregatesMap<Vertex>& aggregates, Vector& coarse, Vector& fine,
62 T1 damp,
63 const SequentialInformation& comm=SequentialInformation());
64
65
66 static void restrictVector(const AggregatesMap<Vertex>& aggregates, Vector& coarse, const Vector& fine,
67 const SequentialInformation& comm);
68 };
69
70#if HAVE_MPI
71
72 template<class V,class V1, class T1, class T2>
73 class Transfer<V,V1,OwnerOverlapCopyCommunication<T1,T2> >
74 {
75 public:
76 typedef V Vertex;
77 typedef V1 Vector;
78 typedef RedistributeInformation<OwnerOverlapCopyCommunication<T1,T2> > Redist;
79 template<typename T3>
80 static void prolongateVector(const AggregatesMap<Vertex>& aggregates, Vector& coarse, Vector& fine,
81 Vector& fineRedist, T3 damp, OwnerOverlapCopyCommunication<T1,T2>& comm,
82 const Redist& redist);
83 template<typename T3>
84 static void prolongateVector(const AggregatesMap<Vertex>& aggregates, Vector& coarse, Vector& fine,
85 T3 damp, OwnerOverlapCopyCommunication<T1,T2>& comm);
86
87 static void restrictVector(const AggregatesMap<Vertex>& aggregates, Vector& coarse, const Vector& fine,
88 OwnerOverlapCopyCommunication<T1,T2>& comm);
89 };
90
91#endif
92
93 template<class V, class V1>
94 template<typename T>
95 inline void
96 Transfer<V,V1,SequentialInformation>::prolongateVector(const AggregatesMap<Vertex>& aggregates,
97 Vector& coarse, Vector& fine,
98 [[maybe_unused]] Vector& fineRedist,
99 T damp,
100 [[maybe_unused]] const SequentialInformation& comm,
101 [[maybe_unused]] const Redist& redist)
102 {
103 prolongateVector(aggregates, coarse, fine, damp);
104 }
105 template<class V, class V1>
106 template<typename T>
107 inline void
108 Transfer<V,V1,SequentialInformation>::prolongateVector(const AggregatesMap<Vertex>& aggregates,
109 Vector& coarse, Vector& fine,
110 T damp,
111 [[maybe_unused]] const SequentialInformation& comm)
112 {
113 typedef typename Vector::iterator Iterator;
114
115 Iterator end = coarse.end();
116 Iterator begin= coarse.begin();
117 for(; begin!=end; ++begin)
118 *begin*=damp;
119 end=fine.end();
120 begin=fine.begin();
121
122 for(Iterator block=begin; block != end; ++block) {
123 std::ptrdiff_t index=block-begin;
124 const Vertex& vertex = aggregates[index];
126 *block += coarse[aggregates[index]];
127 }
128 }
129
130 template<class V, class V1>
131 inline void
132 Transfer<V,V1,SequentialInformation>::restrictVector(const AggregatesMap<Vertex>& aggregates,
133 Vector& coarse,
134 const Vector& fine,
135 [[maybe_unused]] const SequentialInformation& comm)
136 {
137 // Set coarse vector to zero
138 coarse=0;
139
140 typedef typename Vector::const_iterator Iterator;
141 Iterator end = fine.end();
142 Iterator begin=fine.begin();
143
144 for(Iterator block=begin; block != end; ++block) {
145 const Vertex& vertex = aggregates[block-begin];
147 coarse[vertex] += *block;
148 }
149 }
150
151#if HAVE_MPI
152 template<class V, class V1, class T1, class T2>
153 template<typename T3>
154 inline void Transfer<V,V1,OwnerOverlapCopyCommunication<T1,T2> >::prolongateVector(const AggregatesMap<Vertex>& aggregates,
155 Vector& coarse, Vector& fine,
156 Vector& fineRedist, T3 damp,
157 OwnerOverlapCopyCommunication<T1,T2>& comm,
158 const Redist& redist)
159 {
160 if(fineRedist.size()>0)
161 // we operated on the coarse level
162 Transfer<V,V1,SequentialInformation>::prolongateVector(aggregates, coarse, fineRedist, damp);
163
164 // TODO This could be accomplished with one communication, too!
165 redist.redistributeBackward(fine, fineRedist);
166 comm.copyOwnerToAll(fine,fine);
167 }
168
169 template<class V, class V1, class T1, class T2>
170 template<typename T3>
171 inline void Transfer<V,V1,OwnerOverlapCopyCommunication<T1,T2> >::prolongateVector(
172 const AggregatesMap<Vertex>& aggregates,
173 Vector& coarse, Vector& fine, T3 damp,
174 [[maybe_unused]] OwnerOverlapCopyCommunication<T1,T2>& comm)
175 {
176 Transfer<V,V1,SequentialInformation>::prolongateVector(aggregates, coarse, fine, damp);
177 }
178 template<class V, class V1, class T1, class T2>
179 inline void Transfer<V,V1,OwnerOverlapCopyCommunication<T1,T2> >::restrictVector(const AggregatesMap<Vertex>& aggregates,
180 Vector& coarse, const Vector& fine,
181 OwnerOverlapCopyCommunication<T1,T2>& comm)
182 {
183 Transfer<V,V1,SequentialInformation>::restrictVector(aggregates, coarse, fine, SequentialInformation());
184 // We need this here to avoid it in the smoothers on the coarse level.
185 // There (in the preconditioner d is const.
186 comm.project(coarse);
187 }
188#endif
190 } // namspace Amg
191} // namspace Dune
192#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...
A few common exception classes.
constexpr GeometryType vertex
GeometryType representing a vertex.
Definition: type.hh:504
static const Vertex ISOLATED
Identifier of isolated vertices.
Definition: aggregates.hh:569
Functionality for redistributing a sparse matrix.
Dune namespace.
Definition: alignedallocator.hh:11
Classes providing communication interfaces for overlapping Schwarz methods.
Creative Commons License   |  Legal Statements / Impressum  |  Hosted by TU Dresden  |  generated with Hugo v0.111.3 (Jul 27, 22:29, 2024)